commit 023391edfe3ea0185712b703b248e39e7f6189a0 Author: lijh Date: Wed Mar 11 17:13:32 2026 +0800 first commit diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..70b14cf --- /dev/null +++ b/.classpath @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..9bfe1cc --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + com.connor.renben.process.plm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..7941f4d --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//src/com/connor/renben/process/plm/util/CheckListCellRenderer.java=UTF-8 +encoding//src/com/connor/renben/process/plm/util/MyComboBox.java=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ccfa15d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,117 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullable.secondary= +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +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.APILeak=warning +org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning +org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled +org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=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..bcfe785 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,793 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: com.connor.renben.process.plm;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.connor.renben.process.plm.Activator +Bundle-Vendor: CONNOR +Bundle-Localization: plugin +Eclipse-ExtensibleAPI: true +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.activity;bundle-version="12000.4.0", + com.teamcenter.rac.aifrcp;bundle-version="12000.4.0", + com.teamcenter.rac.external;bundle-version="12000.4.0", + com.teamcenter.rac.kernel;bundle-version="12000.4.0", + TcSoaCoreRac;bundle-version="12000.4.0", + com.teamcenter.rac.tcapps;bundle-version="12000.4.0", + TcSoaCommon;bundle-version="12000.4.0", + TcSoaStructureManagementRac;bundle-version="12000.4.0", + com.teamcenter.rac.common;bundle-version="12000.4.0", + com.teamcenter.rac.util;bundle-version="12000.4.0", + com.teamcenter.rac.workflow.processdesigner;bundle-version="12000.4.0", + com.teamcenter.rac.workflow.processviewer;bundle-version="12000.4.0", + com.teamcenter.rac.workflow;bundle-version="12000.4.0", + com.teamcenter.rac.ui.commands;bundle-version="12000.4.0", + com.teamcenter.rac.processhistory;bundle-version="12000.4.0", + com.teamcenter.rac.viewer;bundle-version="12000.4.0", + com.teamcenter.rac.schedule;bundle-version="12000.4.0", + com.teamcenter.rac.cme.bvr.connect;bundle-version="12000.4.0", + com.teamcenter.rac.vns;bundle-version="12000.4.0", + com.teamcenter.rac.ui.views;bundle-version="12000.4.0", + com.teamcenter.rac.ui;bundle-version="12000.4.0", + TcSoaCoreLoose, + TcSoaCoreTypes;bundle-version="12000.4.0", + TcSoaCadRac;bundle-version="12000.4.0", + TcSoaCadBomAlignmentLoose;bundle-version="12000.4.0", + TcSoaBomLoose;bundle-version="12000.4.0", + TcSoaBomRac;bundle-version="12000.4.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8, + JavaSE-1.7 +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: ., + poilib/commons-codec-1.10.jar, + poilib/commons-logging-1.1.jar, + poilib/dom4j-1.6.1.jar, + poilib/jsr173_1.0_api.jar, + poilib/jxl_1.0.0.jar, + poilib/poi-3.9-20121203.jar, + poilib/poi-examples-3.9-20121203.jar, + poilib/poi-excelant-3.9-20121203.jar, + poilib/poi-ooxml-3.9-20121203.jar, + poilib/poi-ooxml-schemas-3.9-20121203.jar, + poilib/poi-scratchpad-3.9-20121203.jar, + poilib/xmlbeans-2.5.0.jar, + poilib/commons-dbutils-1.5.jar, + poilib/commons-beanutils-1.9.2.jar, + poilib/commons-collections-3.2.1.jar, + poilib/commons-lang-2.6.jar, + poilib/commons-logging-1.1.3.jar, + poilib/ezmorph-1.0.6.jar, + poilib/json-lib-2.4-jdk15.jar, + poilib/Spire.Xls.jar, + poilib/aspose-cells-18.9.jar, + poilib/hutool-all-5.0.7.jar, + poilib/datepicker.jar, + lib/fastjson-1.2.66.jar, + poilib/orai18n.jar, + poilib/ojdbc7-12.1.0.1.jar, + lib/saveAsTest.jar +Export-Package: cn.hutool, + cn.hutool.aop, + cn.hutool.aop.aspects, + cn.hutool.aop.interceptor, + cn.hutool.aop.proxy, + cn.hutool.bloomfilter, + cn.hutool.bloomfilter.bitMap, + cn.hutool.bloomfilter.filter, + cn.hutool.cache, + cn.hutool.cache.file, + cn.hutool.cache.impl, + cn.hutool.captcha, + cn.hutool.captcha.generator, + cn.hutool.core.annotation, + cn.hutool.core.bean, + cn.hutool.core.bean.copier, + cn.hutool.core.bean.copier.provider, + cn.hutool.core.builder, + cn.hutool.core.clone, + cn.hutool.core.codec, + cn.hutool.core.collection, + cn.hutool.core.comparator, + cn.hutool.core.convert, + cn.hutool.core.convert.impl, + cn.hutool.core.date, + cn.hutool.core.date.format, + cn.hutool.core.exceptions, + cn.hutool.core.getter, + cn.hutool.core.img, + cn.hutool.core.io, + cn.hutool.core.io.checksum, + cn.hutool.core.io.file, + cn.hutool.core.io.resource, + cn.hutool.core.io.watch, + cn.hutool.core.io.watch.watchers, + cn.hutool.core.lang, + cn.hutool.core.lang.caller, + cn.hutool.core.lang.copier, + cn.hutool.core.lang.func, + cn.hutool.core.lang.loader, + cn.hutool.core.lang.mutable, + cn.hutool.core.map, + cn.hutool.core.map.multi, + cn.hutool.core.math, + cn.hutool.core.net, + cn.hutool.core.swing, + cn.hutool.core.swing.clipboard, + cn.hutool.core.text, + cn.hutool.core.text.csv, + cn.hutool.core.text.escape, + cn.hutool.core.text.replacer, + cn.hutool.core.thread, + cn.hutool.core.thread.lock, + cn.hutool.core.thread.threadlocal, + cn.hutool.core.util, + cn.hutool.cron, + cn.hutool.cron.listener, + cn.hutool.cron.pattern, + cn.hutool.cron.pattern.matcher, + cn.hutool.cron.pattern.parser, + cn.hutool.cron.task, + cn.hutool.crypto, + cn.hutool.crypto.asymmetric, + cn.hutool.crypto.digest, + cn.hutool.crypto.digest.mac, + cn.hutool.crypto.symmetric, + cn.hutool.db, + cn.hutool.db.dialect, + cn.hutool.db.dialect.impl, + cn.hutool.db.ds, + cn.hutool.db.ds.c3p0, + cn.hutool.db.ds.dbcp, + cn.hutool.db.ds.druid, + cn.hutool.db.ds.hikari, + cn.hutool.db.ds.jndi, + cn.hutool.db.ds.pooled, + cn.hutool.db.ds.simple, + cn.hutool.db.ds.tomcat, + cn.hutool.db.handler, + cn.hutool.db.meta, + cn.hutool.db.nosql.mongo, + cn.hutool.db.nosql.redis, + cn.hutool.db.sql, + cn.hutool.db.transaction, + cn.hutool.dfa, + cn.hutool.extra.emoji, + cn.hutool.extra.ftp, + cn.hutool.extra.mail, + cn.hutool.extra.qrcode, + cn.hutool.extra.servlet, + cn.hutool.extra.servlet.multipart, + cn.hutool.extra.ssh, + cn.hutool.extra.template, + cn.hutool.extra.template.engine, + cn.hutool.extra.template.engine.beetl, + cn.hutool.extra.template.engine.enjoy, + cn.hutool.extra.template.engine.freemarker, + cn.hutool.extra.template.engine.rythm, + cn.hutool.extra.template.engine.thymeleaf, + cn.hutool.extra.template.engine.velocity, + cn.hutool.extra.tokenizer, + cn.hutool.extra.tokenizer.engine, + cn.hutool.extra.tokenizer.engine.analysis, + cn.hutool.extra.tokenizer.engine.ansj, + cn.hutool.extra.tokenizer.engine.hanlp, + cn.hutool.extra.tokenizer.engine.ikanalyzer, + cn.hutool.extra.tokenizer.engine.jcseg, + cn.hutool.extra.tokenizer.engine.jieba, + cn.hutool.extra.tokenizer.engine.mmseg, + cn.hutool.extra.tokenizer.engine.mynlp, + cn.hutool.extra.tokenizer.engine.word, + cn.hutool.http, + cn.hutool.http.cookie, + cn.hutool.http.ssl, + cn.hutool.http.useragent, + cn.hutool.http.webservice, + cn.hutool.json, + cn.hutool.json.serialize, + cn.hutool.log, + cn.hutool.log.dialect.commons, + cn.hutool.log.dialect.console, + cn.hutool.log.dialect.jboss, + cn.hutool.log.dialect.jdk, + cn.hutool.log.dialect.log4j, + cn.hutool.log.dialect.log4j2, + cn.hutool.log.dialect.slf4j, + cn.hutool.log.dialect.tinylog, + cn.hutool.log.level, + cn.hutool.poi, + cn.hutool.poi.excel, + cn.hutool.poi.excel.cell, + cn.hutool.poi.excel.editors, + cn.hutool.poi.excel.sax, + cn.hutool.poi.excel.sax.handler, + cn.hutool.poi.excel.style, + cn.hutool.poi.exceptions, + cn.hutool.poi.word, + cn.hutool.script, + cn.hutool.setting, + cn.hutool.setting.dialect, + cn.hutool.setting.profile, + cn.hutool.socket, + cn.hutool.socket.aio, + cn.hutool.socket.nio, + cn.hutool.socket.protocol, + cn.hutool.system, + cn.hutool.system.oshi, + com.alibaba.fastjson, + com.alibaba.fastjson.annotation, + com.alibaba.fastjson.asm, + com.alibaba.fastjson.parser, + com.alibaba.fastjson.parser.deserializer, + com.alibaba.fastjson.serializer, + com.alibaba.fastjson.spi, + com.alibaba.fastjson.support.config, + com.alibaba.fastjson.support.hsf, + com.alibaba.fastjson.support.jaxrs, + com.alibaba.fastjson.support.moneta, + com.alibaba.fastjson.support.retrofit, + com.alibaba.fastjson.support.spring, + com.alibaba.fastjson.support.spring.annotation, + com.alibaba.fastjson.support.spring.messaging, + com.alibaba.fastjson.support.springfox, + com.alibaba.fastjson.util, + com.aspose.cells, + com.aspose.cells.a, + com.aspose.cells.a.a, + com.aspose.cells.a.b.a, + com.aspose.cells.a.c, + com.aspose.cells.a.d, + com.aspose.cells.a.d.a, + com.aspose.cells.a.d.a.a, + com.aspose.cells.a.d.a.b, + com.aspose.cells.a.d.b, + com.aspose.cells.a.e, + com.aspose.cells.a.f, + com.aspose.cells.b.a, + com.aspose.cells.b.a.a, + com.aspose.cells.b.a.b, + com.aspose.cells.b.a.b.a, + com.aspose.cells.b.a.b.a.a, + com.aspose.cells.b.a.b.b, + com.aspose.cells.b.a.b.c, + com.aspose.cells.b.a.b.d, + com.aspose.cells.b.a.b.d.a, + com.aspose.cells.b.a.b.e, + com.aspose.cells.b.a.c, + com.aspose.cells.b.a.d, + com.aspose.cells.b.a.e, + com.aspose.cells.b.a.f, + com.aspose.cells.b.a.f.a, + com.aspose.cells.b.a.f.a.a, + com.aspose.cells.b.b, + com.aspose.cells.b.c.a, + com.connor.renben.process.plm, + com.connor.renben.process.plm.bean, + com.connor.renben.process.plm.bean.packageProcess, + com.connor.renben.process.plm.sql.util, + com.connor.renben.process.plm.test, + com.connor.renben.process.plm.tmom001, + com.connor.renben.process.plm.tmom002, + com.connor.renben.process.plm.tmom003, + com.connor.renben.process.plm.tmom004, + com.connor.renben.process.plm.tmom005, + com.connor.renben.process.plm.tmom006, + com.connor.renben.process.plm.tmom007, + com.connor.renben.process.plm.tmom008, + com.connor.renben.process.plm.tmom009, + com.connor.renben.process.plm.tmom010, + com.connor.renben.process.plm.tmom011, + com.connor.renben.process.plm.tmom012, + com.connor.renben.process.plm.tmom013, + com.connor.renben.process.plm.tmom014, + com.connor.renben.process.plm.tmom015, + com.connor.renben.process.plm.tmom016, + com.connor.renben.process.plm.tmom017, + com.connor.renben.process.plm.tmom018, + com.connor.renben.process.plm.tmom019, + com.connor.renben.process.plm.tmom020, + com.connor.renben.process.plm.tmom021, + com.connor.renben.process.plm.tmom022, + com.connor.renben.process.plm.tmom023, + com.connor.renben.process.plm.tmom024, + com.connor.renben.process.plm.tmom025, + com.connor.renben.process.plm.tmom026, + com.connor.renben.process.plm.tmom027, + com.connor.renben.process.plm.tmom028, + com.connor.renben.process.plm.tmom028._new, + com.connor.renben.process.plm.tmom028.copy, + com.connor.renben.process.plm.tmom029, + com.connor.renben.process.plm.tmom029._new, + com.connor.renben.process.plm.tmom030, + com.connor.renben.process.plm.tmom031, + com.connor.renben.process.plm.tmom031.copy, + com.connor.renben.process.plm.tmom031.hzzc, + com.connor.renben.process.plm.tmom032, + com.connor.renben.process.plm.tmom032.copy, + com.connor.renben.process.plm.tmom033, + com.connor.renben.process.plm.tmom033.copy, + com.connor.renben.process.plm.tmom034, + com.connor.renben.process.plm.tmom035, + com.connor.renben.process.plm.tmom036, + com.connor.renben.process.plm.tmom037, + com.connor.renben.process.plm.tmom038, + com.connor.renben.process.plm.tmom039, + com.connor.renben.process.plm.tmom0392, + com.connor.renben.process.plm.tmom040, + com.connor.renben.process.plm.tmom041, + com.connor.renben.process.plm.tmom042, + com.connor.renben.process.plm.updataBOM, + com.connor.renben.process.plm.util, + com.connor.renben.process.plm.worklist, + com.eltima.components.ui, + com.nbtm.customization.project.N01, + com.proya.savebomcheck, + 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.jna, + com.sun.jna.platform, + com.sun.jna.platform.dnd, + com.sun.jna.platform.mac, + com.sun.jna.platform.unix, + com.sun.jna.platform.unix.solaris, + com.sun.jna.platform.win32, + com.sun.jna.platform.win32.COM, + com.sun.jna.platform.win32.COM.tlb, + com.sun.jna.platform.win32.COM.tlb.imp, + com.sun.jna.platform.win32.COM.util, + com.sun.jna.platform.win32.COM.util.annotation, + com.sun.jna.platform.wince, + com.sun.jna.ptr, + com.sun.jna.win32, + javax.xml.stream, + javax.xml.stream.events, + javax.xml.stream.util, + jxl, + jxl.biff, + jxl.biff.drawing, + jxl.biff.formula, + jxl.common, + jxl.common.log, + 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.i18n.text, + oracle.i18n.text.converter, + oracle.i18n.util, + oracle.i18n.util.builder, + 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.commons.beanutils, + org.apache.commons.beanutils.converters, + org.apache.commons.beanutils.expression, + org.apache.commons.beanutils.locale, + org.apache.commons.beanutils.locale.converters, + org.apache.commons.codec, + org.apache.commons.codec.binary, + org.apache.commons.codec.digest, + org.apache.commons.codec.language, + org.apache.commons.codec.language.bm, + 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.dbutils, + org.apache.commons.dbutils.handlers, + org.apache.commons.dbutils.wrappers, + 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.reflect, + org.apache.commons.lang.text, + org.apache.commons.lang.time, + org.apache.commons.logging, + org.apache.commons.logging.impl, + org.apache.poi, + org.apache.poi.common.usermodel, + org.apache.poi.ddf, + org.apache.poi.dev, + org.apache.poi.extractor, + org.apache.poi.hdf.event, + org.apache.poi.hdf.extractor, + org.apache.poi.hdf.extractor.data, + org.apache.poi.hdf.extractor.util, + org.apache.poi.hdf.model, + org.apache.poi.hdf.model.hdftypes, + org.apache.poi.hdf.model.hdftypes.definitions, + org.apache.poi.hdf.model.util, + org.apache.poi.hdgf, + org.apache.poi.hdgf.chunks, + org.apache.poi.hdgf.dev, + org.apache.poi.hdgf.exceptions, + org.apache.poi.hdgf.extractor, + org.apache.poi.hdgf.pointers, + org.apache.poi.hdgf.streams, + org.apache.poi.hmef, + org.apache.poi.hmef.attribute, + org.apache.poi.hmef.dev, + org.apache.poi.hmef.extractor, + org.apache.poi.hpbf, + org.apache.poi.hpbf.dev, + org.apache.poi.hpbf.extractor, + org.apache.poi.hpbf.model, + org.apache.poi.hpbf.model.qcbits, + org.apache.poi.hpsf, + org.apache.poi.hpsf.examples, + org.apache.poi.hpsf.extractor, + org.apache.poi.hpsf.wellknown, + org.apache.poi.hslf, + org.apache.poi.hslf.blip, + org.apache.poi.hslf.dev, + org.apache.poi.hslf.examples, + org.apache.poi.hslf.exceptions, + org.apache.poi.hslf.extractor, + org.apache.poi.hslf.model, + org.apache.poi.hslf.model.textproperties, + org.apache.poi.hslf.record, + org.apache.poi.hslf.usermodel, + org.apache.poi.hslf.util, + org.apache.poi.hsmf, + org.apache.poi.hsmf.datatypes, + org.apache.poi.hsmf.dev, + org.apache.poi.hsmf.examples, + org.apache.poi.hsmf.exceptions, + org.apache.poi.hsmf.extractor, + org.apache.poi.hsmf.parsers, + org.apache.poi.hssf, + org.apache.poi.hssf.converter, + org.apache.poi.hssf.dev, + org.apache.poi.hssf.eventmodel, + org.apache.poi.hssf.eventusermodel, + org.apache.poi.hssf.eventusermodel.dummyrecord, + org.apache.poi.hssf.eventusermodel.examples, + org.apache.poi.hssf.extractor, + org.apache.poi.hssf.model, + org.apache.poi.hssf.record, + org.apache.poi.hssf.record.aggregates, + org.apache.poi.hssf.record.cf, + org.apache.poi.hssf.record.chart, + org.apache.poi.hssf.record.common, + org.apache.poi.hssf.record.cont, + org.apache.poi.hssf.record.crypto, + org.apache.poi.hssf.record.pivottable, + org.apache.poi.hssf.usermodel, + org.apache.poi.hssf.usermodel.examples, + org.apache.poi.hssf.util, + org.apache.poi.hssf.view, + org.apache.poi.hssf.view.brush, + org.apache.poi.hwpf, + org.apache.poi.hwpf.converter, + org.apache.poi.hwpf.dev, + org.apache.poi.hwpf.extractor, + org.apache.poi.hwpf.model, + org.apache.poi.hwpf.model.io, + org.apache.poi.hwpf.model.types, + org.apache.poi.hwpf.sprm, + org.apache.poi.hwpf.usermodel, + org.apache.poi.openxml4j.exceptions, + org.apache.poi.openxml4j.opc, + org.apache.poi.openxml4j.opc.internal, + org.apache.poi.openxml4j.opc.internal.marshallers, + org.apache.poi.openxml4j.opc.internal.signature, + org.apache.poi.openxml4j.opc.internal.unmarshallers, + org.apache.poi.openxml4j.opc.signature, + org.apache.poi.openxml4j.util, + org.apache.poi.poifs.common, + org.apache.poi.poifs.crypt, + org.apache.poi.poifs.dev, + org.apache.poi.poifs.eventfilesystem, + org.apache.poi.poifs.filesystem, + org.apache.poi.poifs.nio, + org.apache.poi.poifs.poibrowser, + org.apache.poi.poifs.property, + org.apache.poi.poifs.storage, + org.apache.poi.sl.usermodel, + org.apache.poi.ss, + org.apache.poi.ss.examples, + org.apache.poi.ss.examples.formula, + org.apache.poi.ss.examples.html, + org.apache.poi.ss.excelant, + org.apache.poi.ss.excelant.util, + org.apache.poi.ss.extractor, + org.apache.poi.ss.format, + org.apache.poi.ss.formula, + org.apache.poi.ss.formula.atp, + org.apache.poi.ss.formula.constant, + org.apache.poi.ss.formula.eval, + org.apache.poi.ss.formula.eval.forked, + org.apache.poi.ss.formula.function, + org.apache.poi.ss.formula.functions, + org.apache.poi.ss.formula.ptg, + org.apache.poi.ss.formula.udf, + org.apache.poi.ss.usermodel, + org.apache.poi.ss.usermodel.charts, + org.apache.poi.ss.util, + org.apache.poi.ss.util.cellwalk, + org.apache.poi.util, + org.apache.poi.xslf, + org.apache.poi.xslf.extractor, + org.apache.poi.xslf.model, + org.apache.poi.xslf.model.geom, + org.apache.poi.xslf.usermodel, + org.apache.poi.xslf.usermodel.tutorial, + org.apache.poi.xslf.util, + org.apache.poi.xssf.dev, + org.apache.poi.xssf.eventusermodel, + org.apache.poi.xssf.eventusermodel.examples, + org.apache.poi.xssf.extractor, + org.apache.poi.xssf.model, + org.apache.poi.xssf.streaming, + org.apache.poi.xssf.usermodel, + org.apache.poi.xssf.usermodel.charts, + org.apache.poi.xssf.usermodel.examples, + org.apache.poi.xssf.usermodel.extensions, + org.apache.poi.xssf.usermodel.helpers, + org.apache.poi.xssf.util, + org.apache.poi.xwpf.extractor, + org.apache.poi.xwpf.model, + org.apache.poi.xwpf.usermodel, + org.apache.xmlbeans, + org.apache.xmlbeans.impl.common, + org.apache.xmlbeans.impl.config, + org.apache.xmlbeans.impl.inst2xsd, + org.apache.xmlbeans.impl.inst2xsd.util, + org.apache.xmlbeans.impl.jam, + org.apache.xmlbeans.impl.jam.annotation, + org.apache.xmlbeans.impl.jam.internal, + org.apache.xmlbeans.impl.jam.internal.classrefs, + org.apache.xmlbeans.impl.jam.internal.elements, + org.apache.xmlbeans.impl.jam.internal.javadoc, + org.apache.xmlbeans.impl.jam.internal.parser, + org.apache.xmlbeans.impl.jam.internal.reflect, + org.apache.xmlbeans.impl.jam.mutable, + org.apache.xmlbeans.impl.jam.provider, + org.apache.xmlbeans.impl.jam.visitor, + org.apache.xmlbeans.impl.jam.xml, + org.apache.xmlbeans.impl.piccolo.io, + org.apache.xmlbeans.impl.piccolo.util, + org.apache.xmlbeans.impl.piccolo.xml, + org.apache.xmlbeans.impl.regex, + org.apache.xmlbeans.impl.richParser, + org.apache.xmlbeans.impl.schema, + org.apache.xmlbeans.impl.soap, + org.apache.xmlbeans.impl.store, + org.apache.xmlbeans.impl.tool, + org.apache.xmlbeans.impl.util, + org.apache.xmlbeans.impl.validator, + org.apache.xmlbeans.impl.values, + org.apache.xmlbeans.impl.xb.ltgfmt, + org.apache.xmlbeans.impl.xb.ltgfmt.impl, + org.apache.xmlbeans.impl.xb.substwsdl, + org.apache.xmlbeans.impl.xb.substwsdl.impl, + org.apache.xmlbeans.impl.xb.xmlconfig, + org.apache.xmlbeans.impl.xb.xmlconfig.impl, + org.apache.xmlbeans.impl.xb.xmlschema, + org.apache.xmlbeans.impl.xb.xmlschema.impl, + org.apache.xmlbeans.impl.xb.xsdownload, + org.apache.xmlbeans.impl.xb.xsdownload.impl, + org.apache.xmlbeans.impl.xb.xsdschema, + org.apache.xmlbeans.impl.xb.xsdschema.impl, + org.apache.xmlbeans.impl.xpathgen, + org.apache.xmlbeans.impl.xsd2inst, + org.apache.xmlbeans.soap, + org.apache.xmlbeans.xml.stream, + org.apache.xmlbeans.xml.stream.events, + org.apache.xmlbeans.xml.stream.utils, + org.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.openxmlformats.schemas.drawingml.x2006.chart, + org.openxmlformats.schemas.drawingml.x2006.chart.impl, + org.openxmlformats.schemas.drawingml.x2006.main, + org.openxmlformats.schemas.drawingml.x2006.main.impl, + org.openxmlformats.schemas.drawingml.x2006.picture, + org.openxmlformats.schemas.drawingml.x2006.picture.impl, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.impl, + org.openxmlformats.schemas.officeDocument.x2006.customProperties, + org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.impl, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.relationships, + org.openxmlformats.schemas.officeDocument.x2006.relationships.impl, + org.openxmlformats.schemas.presentationml.x2006.main, + org.openxmlformats.schemas.presentationml.x2006.main.impl, + org.openxmlformats.schemas.spreadsheetml.x2006.main, + org.openxmlformats.schemas.spreadsheetml.x2006.main.impl, + org.openxmlformats.schemas.wordprocessingml.x2006.main, + org.openxmlformats.schemas.wordprocessingml.x2006.main.impl, + org.w3c.dom, + repackage, + schemaorg_apache_xmlbeans.system.sE130CAA0A01A7CDE5A2B4FEB8B311707, + schemaorg_apache_xmlbeans.system.sXMLCONFIG, + schemaorg_apache_xmlbeans.system.sXMLLANG, + schemaorg_apache_xmlbeans.system.sXMLSCHEMA, + schemaorg_apache_xmlbeans.system.sXMLTOOLS, + schemasMicrosoftComOfficeExcel, + schemasMicrosoftComOfficeExcel.impl, + schemasMicrosoftComOfficeOffice, + schemasMicrosoftComOfficeOffice.impl, + schemasMicrosoftComVml, + schemasMicrosoftComVml.impl +Import-Package: com.teamcenter.rac.cm.ui, + org.osgi.service.event diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..c2d9872 --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..4041489 --- /dev/null +++ b/build.properties @@ -0,0 +1,38 @@ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + icons/,\ + poilib/commons-codec-1.10.jar,\ + poilib/commons-logging-1.1.jar,\ + poilib/dom4j-1.6.1.jar,\ + poilib/jsr173_1.0_api.jar,\ + poilib/jxl_1.0.0.jar,\ + poilib/poi-3.9-20121203.jar,\ + poilib/poi-examples-3.9-20121203.jar,\ + poilib/poi-excelant-3.9-20121203.jar,\ + poilib/poi-ooxml-3.9-20121203.jar,\ + poilib/poi-ooxml-schemas-3.9-20121203.jar,\ + poilib/poi-scratchpad-3.9-20121203.jar,\ + poilib/xmlbeans-2.5.0.jar,\ + sql.properties,\ + src/com/teamcenter/rac/pse/pse_user.properties,\ + poilib/commons-beanutils-1.9.2.jar,\ + poilib/commons-collections-3.2.1.jar,\ + poilib/commons-lang-2.6.jar,\ + poilib/commons-logging-1.1.3.jar,\ + poilib/ezmorph-1.0.6.jar,\ + poilib/json-lib-2.4-jdk15.jar,\ + poilib/Spire.Xls.jar,\ + .,\ + plugin_zh_CN.properties,\ + plugin.properties,\ + lib/fastjson-1.2.66.jar,\ + poilib/orai18n.jar,\ + poilib/ojdbc7-12.1.0.1.jar,\ + lib/TcSoaCommon_12000.4.0.jar,\ + lib/TcSoaCoreRac_12000.4.0.jar,\ + lib/TcSoaCoreTypes_12000.4.0.jar,\ + lib/TcSoaStructureManagementRac_12000.4.0.jar,\ + lib/saveAsTest.jar +source.. = src/ +jars.compile.order = . diff --git a/icons/group_16.png b/icons/group_16.png new file mode 100644 index 0000000..71a4bfb Binary files /dev/null and b/icons/group_16.png differ diff --git a/icons/organization_16.png b/icons/organization_16.png new file mode 100644 index 0000000..88d3093 Binary files /dev/null and b/icons/organization_16.png differ diff --git a/icons/person_16.png b/icons/person_16.png new file mode 100644 index 0000000..fa412c8 Binary files /dev/null and b/icons/person_16.png differ diff --git a/icons/role_16.png b/icons/role_16.png new file mode 100644 index 0000000..78c754d Binary files /dev/null and b/icons/role_16.png differ diff --git a/icons/sample.gif b/icons/sample.gif new file mode 100644 index 0000000..34fb3c9 Binary files /dev/null and b/icons/sample.gif differ diff --git a/lib/fastjson-1.2.66.jar b/lib/fastjson-1.2.66.jar new file mode 100644 index 0000000..048bdc8 Binary files /dev/null and b/lib/fastjson-1.2.66.jar differ diff --git a/lib/saveAsTest.jar b/lib/saveAsTest.jar new file mode 100644 index 0000000..9fdf448 Binary files /dev/null and b/lib/saveAsTest.jar differ diff --git a/plugin.properties b/plugin.properties new file mode 100644 index 0000000..fdc5098 --- /dev/null +++ b/plugin.properties @@ -0,0 +1,82 @@ +cjgy_display.TITLE=Create Process +cjlsgy_display.TITLE=Creating historical crafts +cjgx_display.TITLE=Create process +cjgclct_display.TITLE=Create process flow chart +cjsscgzjh_display.TITLE=Create pilot production control plan +cjsckzjh_display.TITLE=Create production control plan +cjyjkzjh_display.TITLE=Create sample control plan +cjPFMEA_display.TITLE=Create PFMEA +cjsb_display.TITLE=Create device +cjgz_display.TITLE=Create tooling +cjgzqy_display.TITLE=Create workspace +cjgytz_display.TITLE=Create process drawings +cjzyzds_display.TITLE=Create work instruction +pldctz_display.TITLE=Batch export drawings +txkzjh_display.TITLE=Fill in control plan +drkzjh_display.TITLE=Import control plan +shkzjh_display.TITLE=Audit control plan +gjmbcjgx_display.TITLE=Create an operation from a template +gjmbcjgy_display.TITLE=Create process based on template +gjgycjgy_display.TITLE=Create process based on process +zyzp_display.TITLE=resource assignment +gyfg_display.TITLE=Process division +kzjhrwff_display.TITLE=Control plan task distribution +PFMEAsj_display.TITLE=PFMEA design +cxplBOM_display.TITLE=Rearrange BOM +glkzjhk_display.TITLE=Management control plan library +glPFMEAk_display.TITLE=Manage PFMEA Library +glck_display.TITLE=Manage lexicon +ggkzjhfzr_display.TITLE=Person in charge of change control plan +bzgysj_display.TITLE=Packaging process design +qcwcbj_display.TITLE=Clear completion flag +qckzjhsysj_display.TITLE=Clear all data of control plan +xzgytz_display.TITLE=Select process drawings +gjkzjhlc_display.TITLE=Save as per control plan +gjPFMEAlc_display.TITLE=Save as per PFMEA +PFMEAyqtj_display.TITLE=Overdue statistics of PFMEA +zlrjyl_display.TITLE=Quality software Preview +bjwtd_display.TITLE=Edit order +zygyk_display.TITLE=Operation process card +zpgyk_display.TITLE=Assembly process card +zyjzs_display.TITLE=Task standard +hbgyk_display.TITLE=Horizontal plate process card +sbgyk_display.TITLE=Vertical process card +zpgyk_display.TITLE=Assembly process card +bzsq_display.TITLE=Packaging application +bzzyzds_display.TITLE=Packing operation instruction +bzgysj_display.TITLE=Packaging process design +bzfa_display.TITLE=Package plan +jclcjc_display.TITLE=Inspection process monitoring +cs_display.TITLE=test +rbgy_display.TITLE=Process +gydx_display.TITLE=Process object +gxdx_display.TITLE=working procedure object +PFMEAzz_display.TITLE=PFMEA making +kzjhzz_display.TITLE=Control plan making +gywjgl_display.TITLE=Process document management +xjkzjh_display.TITLE=newly build control plan +xtfg_display.TITLE=Collaborative division of labor +dcgyk_display.TITLE=Export process card +dcgykx_display.TITLE=Export process card (New) +bzgy_display.TITLE=Packaging process +zykwh_display.TITLE=Resource library maintenance +lssjwh_display.TITLE=Historical data maintenance +syjcwt_display.TITLE=Test / Inspection Commission +cjbzgx_display.TITLE=Create standard operation +jcfxwtd_display.TITLE=Inspection and Analysis Order +jsfxwtd_display.TITLE=Calculation Analysis Order +gzlcfl_display.TITLE=Workflow classification +sywtd_display.TITLE=Test Order +xcpgzmjqd_display.TITLE=List of new product tooling and mould +sbgykx_display.TITLE=Vertical version process card (new) +hbgykx_display.TITLE=Horizontal process card (new) +zpgykx_display.TITLE=Assembly Process Card (New) +hzzcgyk_display.TITLE=Rotary Bearing Process Card +TITLE= +TITLE= +TITLE= +TITLE= +TITLE= +TITLE= +TITLE= + diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..ed7c22c --- /dev/null +++ b/plugin.xml @@ -0,0 +1,2357 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + label="%zykwh_display.TITLE" + mnemonic="M" + id="com.connor.renben.plm.menus.OtherMenu"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +- + + + diff --git a/plugin_zh_CN.properties b/plugin_zh_CN.properties new file mode 100644 index 0000000..4a07fdd --- /dev/null +++ b/plugin_zh_CN.properties @@ -0,0 +1,82 @@ +cjgy_display.TITLE=\u521b\u5efa\u5de5\u827a +cjlsgy_display.TITLE=\u521b\u5efa\u5386\u53f2\u5de5\u827a +cjgx_display.TITLE=\u521b\u5efa\u5de5\u5e8f +cjgclct_display.TITLE=\u521b\u5efa\u8fc7\u7a0b\u6d41\u7a0b\u56fe\u000d\u000a +cjsscgzjh_display.TITLE=\u521b\u5efa\u8bd5\u751f\u4ea7\u63a7\u5236\u8ba1\u5212\u000d\u000a +cjsckzjh_display.TITLE=\u521b\u5efa\u751f\u4ea7\u63a7\u5236\u8ba1\u5212 +cjyjkzjh_display.TITLE=\u521b\u5efa\u6837\u4ef6\u63a7\u5236\u8ba1\u5212 +cjPFMEA_display.TITLE=\u521b\u5efa\u0050\u0046\u004d\u0045\u0041 +cjsb_display.TITLE=\u521b\u5efa\u8bbe\u5907 +cjgz_display.TITLE=\u521b\u5efa\u5de5\u88c5 +cjgzqy_display.TITLE=\u521b\u5efa\u5de5\u4f5c\u533a\u57df +cjgytz_display.TITLE=\u521b\u5efa\u5de5\u827a\u56fe\u7eb8 +cjzyzds_display.TITLE=\u521b\u5efa\u4f5c\u4e1a\u6307\u5bfc\u4e66 +pldctz_display.TITLE=\u6279\u91cf\u5bfc\u51fa\u56fe\u7eb8 +txkzjh_display.TITLE=\u586b\u5199\u63a7\u5236\u8ba1\u5212 +drkzjh_display.TITLE=\u5bfc\u5165\u63a7\u5236\u8ba1\u5212 +shkzjh_display.TITLE=\u5ba1\u6838\u63a7\u5236\u8ba1\u5212 +gjmbcjgx_display.TITLE=\u6839\u636e\u6a21\u677f\u521b\u5efa\u5de5\u5e8f +gjmbcjgy_display.TITLE=\u6839\u636e\u6a21\u677f\u521b\u5efa\u5de5\u827a +gjgycjgy_display.TITLE=\u6839\u636e\u5de5\u827a\u521b\u5efa\u5de5\u827a +zyzp_display.TITLE=\u8d44\u6e90\u6307\u6d3e +gyfg_display.TITLE=\u5de5\u827a\u5206\u5de5 +kzjhrwff_display.TITLE=\u63a7\u5236\u8ba1\u5212\u4efb\u52a1\u5206\u53d1 +PFMEAsj_display.TITLE=\u0050\u0046\u004d\u0045\u0041\u8bbe\u8ba1 +cxplBOM_display.TITLE=\u91cd\u65b0\u6392\u5217\u0042\u004f\u004d +glkzjhk_display.TITLE=\u7ba1\u7406\u63a7\u5236\u8ba1\u5212\u5e93 +glPFMEAk_display.TITLE=\u7ba1\u7406\u0050\u0046\u004d\u0045\u0041\u5e93 +glck_display.TITLE=\u7ba1\u7406\u8bcd\u5e93 +ggkzjhfzr_display.TITLE=\u66f4\u6539\u63a7\u5236\u8ba1\u5212\u8d1f\u8d23\u4eba +bzgysj_display.TITLE=\u5305\u88c5\u5de5\u827a\u8bbe\u8ba1 +qcwcbj_display.TITLE=\u6e05\u9664\u5b8c\u6210\u6807\u8bb0 +qckzjhsysj_display.TITLE=\u6e05\u9664\u63a7\u5236\u8ba1\u5212\u6240\u6709\u6570\u636e +xzgytz_display.TITLE=\u9009\u62e9\u5de5\u827a\u56fe\u7eb8 +gjkzjhlc_display.TITLE=\u6839\u636e\u63a7\u5236\u8ba1\u5212\u53e6\u5b58 +gjPFMEAlc_display.TITLE=\u6839\u636e\u0050\u0046\u004d\u0045\u0041\u53e6\u5b58 +PFMEAyqtj_display.TITLE=\u0050\u0046\u004d\u0045\u0041\u903e\u671f\u7edf\u8ba1 +zlrjyl_display.TITLE=\u8d28\u91cf\u8f6f\u4ef6\u9884\u89c8 +bjwtd_display.TITLE=\u7f16\u8f91\u59d4\u6258\u5355 +zygyk_display.TITLE=\u4f5c\u4e1a\u5de5\u827a\u5361 +zygyk_new_display.TITLE=\u4F5C\u4E1A\u5DE5\u827A\u5361\uff08\u65b0\uff09 +zpgyk_display.TITLE=\u88c5\u914d\u5de5\u827a\u5361 +zyjzs_display.TITLE=\u4f5c\u4e1a\u57fa\u51c6\u4e66 +hbgyk_display.TITLE=\u6a2a\u677f\u5de5\u827a\u5361 +sbgyk_display.TITLE=\u7ad6\u7248\u5de5\u827a\u5361 +zpgyk_display.TITLE=\u88c5\u914d\u5de5\u827a\u5361 +zpgyk_new_display.TITLE=\u88c5\u914d\u5de5\u827a\u5361\uff08\u65b0\uff09 +bzsq_display.TITLE=\u5305\u88c5\u7533\u8bf7 +bzzyzds_display.TITLE=\u5305\u88c5\u4f5c\u4e1a\u6307\u5bfc\u4e66 +bzgysj_display.TITLE=\u5305\u88c5\u5de5\u827a\u8bbe\u8ba1 +bzfa_display.TITLE=\u5305\u88c5\u65b9\u6848 +jclcjc_display.TITLE=\u68c0\u6d4b\u6d41\u7a0b\u76d1\u6d4b +cs_display.TITLE=\u6d4b\u8bd5 +rbgy_display.TITLE=\u5de5\u827a +gydx_display.TITLE=\u5de5\u827a\u5bf9\u8c61 +gxdx_display.TITLE=\u5de5\u5e8f\u5bf9\u8c61 +PFMEAzz_display.TITLE=\u0050\u0046\u004d\u0045\u0041\u5236\u4f5c +kzjhzz_display.TITLE=\u63a7\u5236\u8ba1\u5212\u5236\u4f5c +gywjgl_display.TITLE=\u5de5\u827a\u6587\u4ef6\u7ba1\u7406 +xjkzjh_display.TITLE=\u65b0\u5efa\u63a7\u5236\u8ba1\u5212 +xtfg_display.TITLE=\u534f\u540c\u5206\u5de5 +dcgyk_display.TITLE=\u5bfc\u51fa\u5de5\u827a\u5361 +dcgykx_display.TITLE=\u5bfc\u51fa\u5de5\u827a\u5361\uff08\u65b0\uff09 +bzgy_display.TITLE=\u5305\u88c5\u5de5\u827a +zykwh_display.TITLE=\u8d44\u6e90\u5e93\u7ef4\u62a4 +lssjwh_display.TITLE=\u5386\u53f2\u6570\u636e\u7ef4\u62a4 +syjcwt_display.TITLE=\u8bd5\u9a8c\u002f\u68c0\u6d4b\u59d4\u6258 +cjbzgx_display.TITLE=\u521B\u5EFA\u6807\u51C6\u5DE5\u5E8F +jcfxwtd_display.TITLE=\u68C0\u6D4B\u5206\u6790\u59D4\u6258\u5355 +jsfxwtd_display.TITLE=\u8BA1\u7B97\u5206\u6790\u59D4\u6258\u5355 +sywtd_display.TITLE=\u8BD5\u9A8C\u59D4\u6258\u5355 +gzlcfl_display.TITLE=\u5DE5\u4F5C\u6D41\u7A0B\u5206\u7C7B +xcpgzmjqd_display.TITLE=\u65B0\u4EA7\u54C1\u5DE5\u88C5\u6A21\u5177\u6E05\u5355 +sbgykx_display.TITLE=\u7ad6\u7248\u5de5\u827a\u5361\uff08\u65b0\uff09 +hbgykx_display.TITLE=\u6a2a\u7248\u5de5\u827a\u5361\uff08\u65b0\uff09 +zpgykx_display.TITLE=\u88c5\u914d\u5de5\u827a\u5361\uff08\u65b0\uff09 +hzzcgyk_display.TITLE=\u56de\u8f6c\u652f\u627f\u5de5\u827a\u5361 +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= +_display.TITLE= diff --git a/poilib/Spire.Xls.jar b/poilib/Spire.Xls.jar new file mode 100644 index 0000000..2d1af62 Binary files /dev/null and b/poilib/Spire.Xls.jar differ diff --git a/poilib/aspose-cells-18.9.jar b/poilib/aspose-cells-18.9.jar new file mode 100644 index 0000000..2cefe55 Binary files /dev/null and b/poilib/aspose-cells-18.9.jar differ diff --git a/poilib/classes12.jar b/poilib/classes12.jar new file mode 100644 index 0000000..9eaf0b4 Binary files /dev/null and b/poilib/classes12.jar differ diff --git a/poilib/com.sun.jna.platform-4.5.1.v20190425-1842.jar b/poilib/com.sun.jna.platform-4.5.1.v20190425-1842.jar new file mode 100644 index 0000000..c531461 Binary files /dev/null and b/poilib/com.sun.jna.platform-4.5.1.v20190425-1842.jar differ diff --git a/poilib/commons-beanutils-1.9.2.jar b/poilib/commons-beanutils-1.9.2.jar new file mode 100644 index 0000000..289461d Binary files /dev/null and b/poilib/commons-beanutils-1.9.2.jar differ diff --git a/poilib/commons-codec-1.10.jar b/poilib/commons-codec-1.10.jar new file mode 100644 index 0000000..1d7417c Binary files /dev/null and b/poilib/commons-codec-1.10.jar differ diff --git a/poilib/commons-collections-3.2.1.jar b/poilib/commons-collections-3.2.1.jar new file mode 100644 index 0000000..c35fa1f Binary files /dev/null and b/poilib/commons-collections-3.2.1.jar differ diff --git a/poilib/commons-dbutils-1.5.jar b/poilib/commons-dbutils-1.5.jar new file mode 100644 index 0000000..b0c0e12 Binary files /dev/null and b/poilib/commons-dbutils-1.5.jar differ diff --git a/poilib/commons-lang-2.6.jar b/poilib/commons-lang-2.6.jar new file mode 100644 index 0000000..98467d3 Binary files /dev/null and b/poilib/commons-lang-2.6.jar differ diff --git a/poilib/commons-logging-1.1.3.jar b/poilib/commons-logging-1.1.3.jar new file mode 100644 index 0000000..ab51254 Binary files /dev/null and b/poilib/commons-logging-1.1.3.jar differ diff --git a/poilib/commons-logging-1.1.jar b/poilib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/poilib/commons-logging-1.1.jar differ diff --git a/poilib/datepicker.jar b/poilib/datepicker.jar new file mode 100644 index 0000000..8304d36 Binary files /dev/null and b/poilib/datepicker.jar differ diff --git a/poilib/dom4j-1.6.1.jar b/poilib/dom4j-1.6.1.jar new file mode 100644 index 0000000..c8c4dbb Binary files /dev/null and b/poilib/dom4j-1.6.1.jar differ diff --git a/poilib/ezmorph-1.0.6.jar b/poilib/ezmorph-1.0.6.jar new file mode 100644 index 0000000..30fad12 Binary files /dev/null and b/poilib/ezmorph-1.0.6.jar differ diff --git a/poilib/hutool-all-5.0.7.jar b/poilib/hutool-all-5.0.7.jar new file mode 100644 index 0000000..0ed0b10 Binary files /dev/null and b/poilib/hutool-all-5.0.7.jar differ diff --git a/poilib/jna-3.0.9.jar b/poilib/jna-3.0.9.jar new file mode 100644 index 0000000..33461ec Binary files /dev/null and b/poilib/jna-3.0.9.jar differ diff --git a/poilib/json-lib-2.4-jdk15.jar b/poilib/json-lib-2.4-jdk15.jar new file mode 100644 index 0000000..68d4f3b Binary files /dev/null and b/poilib/json-lib-2.4-jdk15.jar differ diff --git a/poilib/jsr173_1.0_api.jar b/poilib/jsr173_1.0_api.jar new file mode 100644 index 0000000..fef9a9c Binary files /dev/null and b/poilib/jsr173_1.0_api.jar differ diff --git a/poilib/jxl_1.0.0.jar b/poilib/jxl_1.0.0.jar new file mode 100644 index 0000000..cb144e4 Binary files /dev/null and b/poilib/jxl_1.0.0.jar differ diff --git a/poilib/ojdbc5.jar b/poilib/ojdbc5.jar new file mode 100644 index 0000000..13d7feb Binary files /dev/null and b/poilib/ojdbc5.jar differ diff --git a/poilib/ojdbc6.jar b/poilib/ojdbc6.jar new file mode 100644 index 0000000..aacbd97 Binary files /dev/null and b/poilib/ojdbc6.jar differ diff --git a/poilib/ojdbc7-12.1.0.1.jar b/poilib/ojdbc7-12.1.0.1.jar new file mode 100644 index 0000000..fd38a6c Binary files /dev/null and b/poilib/ojdbc7-12.1.0.1.jar differ diff --git a/poilib/ojdbc8.jar b/poilib/ojdbc8.jar new file mode 100644 index 0000000..98a1a31 Binary files /dev/null and b/poilib/ojdbc8.jar differ diff --git a/poilib/orai18n.jar b/poilib/orai18n.jar new file mode 100644 index 0000000..6b26160 Binary files /dev/null and b/poilib/orai18n.jar differ diff --git a/poilib/poi-3.9-20121203.jar b/poilib/poi-3.9-20121203.jar new file mode 100644 index 0000000..0f46288 Binary files /dev/null and b/poilib/poi-3.9-20121203.jar differ diff --git a/poilib/poi-examples-3.9-20121203.jar b/poilib/poi-examples-3.9-20121203.jar new file mode 100644 index 0000000..a364cc2 Binary files /dev/null and b/poilib/poi-examples-3.9-20121203.jar differ diff --git a/poilib/poi-excelant-3.9-20121203.jar b/poilib/poi-excelant-3.9-20121203.jar new file mode 100644 index 0000000..cb403fa Binary files /dev/null and b/poilib/poi-excelant-3.9-20121203.jar differ diff --git a/poilib/poi-ooxml-3.9-20121203.jar b/poilib/poi-ooxml-3.9-20121203.jar new file mode 100644 index 0000000..8792d46 Binary files /dev/null and b/poilib/poi-ooxml-3.9-20121203.jar differ diff --git a/poilib/poi-ooxml-schemas-3.9-20121203.jar b/poilib/poi-ooxml-schemas-3.9-20121203.jar new file mode 100644 index 0000000..eda4ef4 Binary files /dev/null and b/poilib/poi-ooxml-schemas-3.9-20121203.jar differ diff --git a/poilib/poi-scratchpad-3.9-20121203.jar b/poilib/poi-scratchpad-3.9-20121203.jar new file mode 100644 index 0000000..1520855 Binary files /dev/null and b/poilib/poi-scratchpad-3.9-20121203.jar differ diff --git a/poilib/sqljdbc4.jar b/poilib/sqljdbc4.jar new file mode 100644 index 0000000..b26b1ec Binary files /dev/null and b/poilib/sqljdbc4.jar differ diff --git a/poilib/xmlbeans-2.5.0.jar b/poilib/xmlbeans-2.5.0.jar new file mode 100644 index 0000000..c368fb2 Binary files /dev/null and b/poilib/xmlbeans-2.5.0.jar differ diff --git a/sql.properties b/sql.properties new file mode 100644 index 0000000..e06d1e6 --- /dev/null +++ b/sql.properties @@ -0,0 +1,113 @@ +INSERTSQL=insert into RB3_CONTROLPLAN values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +DELETE=delete from RB3_CONTROLPLAN where RB3_MEOPID = \'%s\' and PROCESSPUID = \'%s\' +INSERTPFMEA=INSERT INTO RB3_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +BOMCHECKSAVESELECT=select RB3_MEOPID,RB3_GYBH,RB3_GCMC,RB3_JQSB from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and rb3_gcmc not like (\'%s\') AND REVISIONUID=\'%s\' group by RB3_MEOPID,rb3_gybh,RB3_GCMC,RB3_JQSB +BOMCHECKSAVESELECTPERMISSIONS=select RB3_MEOPID,rb3_gybh,RB3_GCMC,RB3_GXH from RB3_PERMISSIONS where PROCESSPUID = \'%s\' group by RB3_MEOPID,rb3_gybh,RB3_GCMC,RB3_GXH ORDER BY rb3_gybh +BOMCHECKSAVESELECTPFMEA=select RB3_MEOPID,rb3_station,rb3_gybh,RB3_GCMC from RB3_PFMEA where PROCESSPUID = \'%s\' +BOMCHECKSAVESELECT2=select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVESELECTPERMISSIONS2 = select * from RB3_PERMISSIONS where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVESELECTPFMEA2=select * from RB3_PFMEA where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVESELECT3=select * from RB3_PFMEA where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVEUPDATE=update RB3_CONTROLPLAN set RB3_GYBH = ?,RB3_GCMC = ?,RB3_JQSB = ? where PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' and rb3_gcmc not like (\'%s\') +BOMCHECKSAVEUPDATE2=update RB3_CONTROLPLAN set RB3_GYBH = ?,RB3_GCMC = ?,RB3_JQSB = ? where PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' and rb3_gcmc like (\'%s\') + +DELETEPFMEA=delete from RB3_PFMEA where RB3_MEOPID = \'%s\' and PROCESSPUID = \'%s\' +UPDATEPFMEA=update RB3_PFMEA set RB3_STATION = ? where PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' + +INSERTPERMISSIONS=INSERT INTO RB3_PERMISSIONS VALUES(?,?,?,?,?,?,?,?,?,?) +UPDATEPERMISSIONS=UPDATE RB3_PERMISSIONS SET RB3_GYBH = ?,RB3_GCMC = ? ,RB3_GXH=? WHERE PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' +DELETEPERMISSIONS=DELETE FROM RB3_PERMISSIONS WHERE RB3_MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +CONTROLPLANSELECT=select t1.*,t2.rb3_user,t2.rb3_inspectionuser from rb3_controlplan t1 left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid where t1.PROCESSPUID = \'%s\' and t1.type = \'%s\' and t1.revisionuid=\'%s\' order by TO_NUMBER(t1.NO),to_number(t1.RB3_HH) +CONTROLPLANUPDATE=update RB3_CONTROLPLAN set RB3_GYBH = ?,RB3_GCMC = ?,RB3_JQSB = ?,RB3_QPTBH = ?,RB3_CP = ?,RB3_GC = ?,RB3_TSTX = ?,RB3_CPGC = ?,RB3_CLFF = ?,RB3_RL = ?,RB3_PL = ?,RB3_KZFF = ?,RB3_FYJH = ?,RB3_HH = ?,RB3_HBDYG = ? where plmeid = \'%s\' and revisionuid=\'%s\' +CONTROLPLANOPERATIONSELECT=select RB3_MEOPID,rb3_gybh from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and RB3_MEOPID is not null group by RB3_MEOPID,rb3_gybh +CONTROLPLANOPERATIONSELECT2=select RB3_MEOPID,NO from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and RB3_MEOPID is not null group by RB3_MEOPID,NO +CONTROLPLANDELETE=delete from RB3_CONTROLPLAN where PLMEID = \'%s\' + +OPDIVISIONDIALOGSELECT=select processpuid,rb3_meopid,rb3_gybh,rb3_gcmc,rb3_user,rb3_inspectionuser,RB3_USER_NAME,RB3_INSPECTIONUSER_NAME from RB3_PERMISSIONS where PROCESSPUID = \'%s\' group by processpuid, rb3_meopid,rb3_gybh,rb3_gcmc,rb3_user,rb3_inspectionuser,RB3_USER_NAME,RB3_INSPECTIONUSER_NAME ORDER BY to_number(RB3_GYBH) +OPDIVISIONDIALOGUPDATE=UPDATE RB3_PERMISSIONS SET RB3_USER = ?,RB3_INSPECTIONUSER = ?,RB3_USER_NAME = ?,RB3_INSPECTIONUSER_NAME = ? WHERE PROCESSPUID = \'%s\' AND RB3_MEOPID = \'%s\' + +CONTROLSYNERGYSELECT=select wm_concat(rb3_meopid) as rb3_meopid,RB3_USER_ID from RB3_CONTROLSYNERGY_VIEW where PROCESSPUID = '\%s\' group by RB3_USER_ID +CONTROLSYNERGYUPDATE=UPDATE RB3_PERMISSIONS SET RB3_CONTROLPLANUSER = ? WHERE PLMEID = \'%s\' + +SETPFMEASELECT=SELECT * FROM RB3_PFMEA WHERE PROCESSPUID = \'%s\' AND REVISIONID=\'%s\' ORDER BY to_number(NO),to_number(RB3_HH) +SETPFMEADELETE=delete from RB3_PFMEA where PLMEID = \'%s\' +SETPFMEASELECT2=SELECT RB3_MEOPID,RB3_REQUIREMENT from RB3_PFMEA where PROCESSPUID = \'%s\' group by RB3_MEOPID,RB3_REQUIREMENT +SETPFMEAUPDATE=update RB3_PFMEA set RB3_GYBH = ?,RB3_GCMC = ?,RB3_STATION = ?,RB3_REQUIREMENT = ?,RB3_QZSXMS = ?,RB3_QZSXHG = ?,RB3_YZD = ?,RB3_JB = ?,RB3_QZSXQY = ?,RB3_XXGCKZYF = ?,RB3_PDS = ?,RB3_XXGCKZTC = ?,RB3_TCD = ?,RB3_RPN = ?,RB3_JYCS = ?,RB3_ZZR = ?,RB3_JHWCRQ = ?,RB3_CQDCS = ?,RB3_NEW_SEV = ?,RB3_NEW_OCC = ?,RB3_NEW_DET = ?,RB3_NEW_RPN = ?,RB3_IDEAL_STATE = ?,RB3_SPECIAL = ?,RB3_HH = ?,RB3_HBDYG = ? ,OCCURRRENCE = ?,DETECTION = ?,PRIORITY = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ? where plmeid = \'%s\' AND revisionid=\'%s\' + +PFMEALIBRARYSELECT2=SELECT * FROM RB3_PFMEALIBRARY WHERE PUID = \'%s\' order by NUM + + + +TM2CONTROLPLANTREESELECT=select * from RB3_CONTROLPLAN_TREE ORDER BY PARENT_ID,ID +CONTROLPLANLIBRARYSELECT=SELECT * FROM RB3_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY ID +CONTROLPLANLIBRARYDELETE=delete from RB3_CONTROLPLAN_NODE where PLMEID = \'%s\' +CONTROLPLANLIBRARYUPDATE=update RB3_CONTROLPLAN_NODE set ID = ?,RB3_JQSB = ?,RB3_SMJY = ?, RB3_QPTBH = ?,RB3_CC = ?,RB3_NO = ?,RB3_CP = ?,RB3_GC = ?,RB3_TSTX = ?,RB3_CPGC = ?,RB3_CLFF = ?,RB3_RL = ?,RB3_PL = ?,RB3_FZR = ?,RB3_KZFF = ?,RB3_CZGF = ?,RB3_FYJH = ?,RB3_SJSJ = ?,RB3_GCSJ = ?,RB3_MJSJ = ?,RB3_SPECIAL = ? where plmeid = \'%s\' +CONTROLPLANLIBRARYINSERT=INSERT INTO RB3_CONTROLPLAN_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +!++++++++++++++++++++++++++++++ +RB3_TESTFORMSELECT=select * from RB3_TESTFORM WHERE PUID = \'%s\' order by P1 +RB3_TESTFORMUPDATE=update RB3_TESTFORM set P1 = ?, P2 = ?, P3 = ?, P4 = ?, P5 = ?WHERE PLMID = \'%s\' +RB3_TESTFORMINSERT=INSERT INTO RB3_TESTFORM VALUES(?,?,?,?,?,?,?) +RB3_TESTFORMDELETE=DELETE FROM RB3_TESTFORM WHERE PLMID = \'%s\' +!+++++++++++++++++++++++++++++++ +RB3_TESTDATASELECT=select * from RB3_TESTDATA WHERE PUID = \'%s\' order by P1 +RB3_TESTDATAUPDATE=update RB3_TESTDATA set PLMEID = ?, PUID = ?,TYPE = ?, P1 = ? ,P2 = ?,P3 = ?,P4 = ? ,P5 = ?,P6 = ? WHERE PUID = \'%s\' +RB3_TESTDATAINSERT=INSERT INTO RB3_TESTDATA VALUES(?,?,?,?,?,?,?,?,?,?) +RB3_TESTDATADELETE=DELETE FROM RB3_TESTDATA WHERE TYPE = \'%s\' AND PUID = \'%s\' AND NODE = \'%s\' +!++++++++++++++++++++++++++++++ +TM2PFMEATREESELECT=select * from RB3_PFMEA_TREE ORDER BY PARENT_ID,ID +PFMEALIBRARYSELECT=SELECT * FROM RB3_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY ID +PFMEALIBRARYDELETE=delete from RB3_PFMEA_NODE where PLMEID = \'%s\' +PFMEALIBRARYUPDATE=update RB3_PFMEA_NODE set ID = ?, RB3_STATION = ?,RB3_REQUIREMENT = ?,RB3_QZSXMS = ?,RB3_QZSXHG = ?,RB3_YZD = ?,RB3_JB = ?,RB3_QZSXQY = ?,RB3_XXGCKZYF = ?,RB3_PDS = ?,RB3_XXGCKZTC = ?,RB3_TCD = ?,RB3_RPN = ?,RB3_JYCS = ?,RB3_ZZR = ?,RB3_JHWCRQ = ?,RB3_CQDCS = ?,RB3_NEW_SEV = ?,RB3_NEW_OCC = ?,RB3_NEW_DET = ?,RB3_NEW_RPN = ?,RB3_IDEAL_STATE = ?,RB3_SPECIAL = ?,P1 = ?,P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ?,P8 = ? where plmeid = \'%s\' +PFMEALIBRARYINSERT=INSERT INTO RB3_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +CONTROLPLANOUTPUTSELECT =select t1.*,t2.rb3_user,t2.rb3_inspectionuser from rb3_controlplan t1 left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid where t1.RB3_MEOPID = \'%s\' and t1.type = \'%s\' order by to_number(t1.RB3_GYBH),to_number(t1.RB3_HH) + +!==============================================TMOM022================================================! +TM2THESAURUSTREESELECT=select * from RB3_THESAURUS_TREE ORDER BY PARENT_ID,ID +TM2THESAURUSNODESELECT=SELECT * FROM RB3_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY ID +TM2THESAURUSNODEDELETE=delete from RB3_THESAURUS_NODE where PLMEID = \'%s\' +TM2THESAURUSNODEDUPDATE=update RB3_THESAURUS_NODE set ID = ?, RB3_VALUE = ?, RB3_VALUE2 = ?, RB3_EXAMPLE = ? where plmeid = \'%s\' +TM2THESAURUSNODEDINSERT=INSERT INTO RB3_THESAURUS_NODE VALUES(?,?,?,?,?,?) + +!==============================================TMOM027================================================! +RB3_ENTRUSTMENTFORMSELECT=select * from RB3_ENTRUSTMENTFORM WHERE PUID = \'%s\' +RB3_ENTRUSTMENTFORMUPDATE=update RB3_ENTRUSTMENTFORM set P1 = ?, P2 = ?, P3 = ?, P4 = ?, P5 = ?, P6 = ?, P7 = ?, P8 = ?, P9 = ?, P10 = ?, P11 = ?, P12 = ?, P13 = ?, P14 = ?, P15 = ?, P16 = ?, P17 = ?, P18 = ?, P19 = ?, P20 = ?, P21 = ?, P22 = ?, P23 = ?, P24 = ?, P25 = ?, P26 = ?, P27 = ?, P28 = ?, P29 = ?, P30 = ?, P31 = ?, P32 = ?, P33 = ?, P34 = ?, P35 = ?, P36 = ?, P37 = ?, P38 = ?, P39 = ?, P40 = ?, P41 = ?, P42 = ?, P43 = ?, P44 = ?, P45 = ?, P46 = ?, P47 = ?, P48 = ?, P49 = ?, P50 = ?, P51 = ?, P52 = ?, P53 = ?, P54 = ?, P55 = ?, P56 = ?, P57 = ?, P58 = ?, P59 = ?, P60 = ?, P61 = ?, P62 = ?, P63 = ?, P64 = ?, P65 = ?, P66 = ?, P67 = ?, P68 = ? , P69 = ?, P70 = ?, P71 = ?,P72 = ?WHERE PUID = \'%s\' +RB3_ENTRUSTMENTFORMINSERT=INSERT INTO RB3_ENTRUSTMENTFORM VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +RB3_ENTRUSTMENTFORMSELECTA=select * from RB3_ENTRUSTMENTFORM WHERE PUID = \'%s\' AND P72 =\'%s\' +RB3_ENTRUSTMENTFORMUPDATEA=update RB3_ENTRUSTMENTFORM set P1 = ?, P2 = ?, P3 = ?, P4 = ?, P5 = ?, P6 = ?, P7 = ?, P8 = ?, P9 = ?, P10 = ?, P11 = ?, P12 = ?, P13 = ?, P14 = ?, P15 = ?, P16 = ?, P17 = ?, P18 = ?, P19 = ?, P20 = ?, P21 = ?, P22 = ?, P23 = ?, P24 = ?, P25 = ?, P26 = ?, P27 = ?, P28 = ?, P29 = ?, P30 = ?, P31 = ?, P32 = ?, P33 = ?, P34 = ?, P35 = ?, P36 = ?, P37 = ?, P38 = ?, P39 = ?, P40 = ?, P41 = ?, P42 = ?, P43 = ?, P44 = ?, P45 = ?, P46 = ?, P47 = ?, P48 = ?, P49 = ?, P50 = ?, P51 = ?, P52 = ?, P53 = ?, P54 = ?, P55 = ?, P56 = ?, P57 = ?, P58 = ?, P59 = ?, P60 = ?, P61 = ?, P62 = ?, P63 = ?, P64 = ?, P65 = ?, P66 = ?, P67 = ?, P68 = ? , P69 = ?, P70 = ?, P71 = ?WHERE PUID = \'%s\' AND P72 = \'%s\' +RB3_ENTRUSTMENTFORMINSERTA=INSERT INTO RB3_ENTRUSTMENTFORM VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +RB3_ENTRUSTMENTSELECT=select * from RB3_ENTRUSTMENT WHERE PUID = \'%s\' +RB3_ENTRUSTMENTSELECTTYPE=select * from RB3_ENTRUSTMENT WHERE TYPE=\'%s\' AND PUID = \'%s\' +RB3_ENTRUSTMENTUPDATE=update RB3_ENTRUSTMENT set PLMEID = ?, PUID = ?,P1 = ?, P2 = ?,TYPE = ? WHERE PUID = \'%s\' +RB3_ENTRUSTMENTINSERT=INSERT INTO RB3_ENTRUSTMENT VALUES(?,?,?,?,?) +RB3_ENTRUSTMENTDELETE=DELETE FROM RB3_ENTRUSTMENT WHERE TYPE = \'%s\' AND PUID = \'%s\' + +!==============================================TMOM028================================================! +RB3_CONTROLPLANDATASELECT=SELECT RB3_QPTBH,RB3_CP, RB3_GC,RB3_TSTX,RB3_CPGC,RB3_KZFF,RB3_HH,RB3_CLFF,CASE WHEN RB3_KZFF LIKE '%%\u9996\u68C0%%' THEN RB3_RL END AS SJ,CASE WHEN RB3_KZFF LIKE '%%\u81EA\u68C0%%' THEN RB3_RL || '/' || RB3_PL END AS ZJ,CASE WHEN RB3_KZFF LIKE '%%\u5DE1\u68C0%%' THEN RB3_RL || '/' || RB3_PL END AS XJ,RB3_PL,RB3_RL,RB3_FYJH FROM RB3_CONTROLPLAN WHERE PROCESSPUID = \'%s\' AND RB3_MEOPID = \'%s\' AND TYPE = \'%s\' AND REVISIONUID= \'%s\' ORDER BY RB3_QPTBH+0,RB3_HH+0 +RB3_TOOLINGDETAILSELECT=select * from RB3_TOOLINGDETAIL WHERE PUID = \'%s\' ORDER BY ID+0 +RB3_TOOLINGDETAILUPDATE=update RB3_TOOLINGDETAIL set ID = ?, NAME = ?, SPECIFICATION = ?, SPECIALITY = ?, P1 = ? WHERE PLMEID = \'%s\' +RB3_TOOLINGDETAILINSERT=INSERT INTO RB3_TOOLINGDETAIL VALUES(?,?,?,?,?,?,?) +RB3_TOOLINGDETAILDELETE=DELETE FROM RB3_TOOLINGDETAIL WHERE PLMEID = \'%s\' + +RB3_MACHININGPARAMETERSELECT=select * from RB3_MACHININGPARAMETER WHERE PUID = \'%s\' ORDER BY ID+0 +RB3_MACHININGPARAMETERUPDATE=update RB3_MACHININGPARAMETER set ID = ?, NAME = ?, SPECIALITY = ?,VALUE = ?, P1 = ? WHERE PLMEID = \'%s\' +RB3_MACHININGPARAMETERINSERT=INSERT INTO RB3_MACHININGPARAMETER VALUES(?,?,?,?,?,?,?) +RB3_MACHININGPARAMETERDELETE=DELETE FROM RB3_MACHININGPARAMETER WHERE PLMEID = \'%s\' + +RB3_CONTROLREQUIREMENTSELECT=select * from RB3_CONTROLREQUIREMENT WHERE PUID = \'%s\' ORDER BY ID+0 +RB3_CONTROLREQUIREMENTUPDATE=update RB3_CONTROLREQUIREMENT set ID = ?, PROJECT = ?, SPECIALITY = ?,MANAGEMENT_REQUIREMENTS = ?, CHECK_METHOD = ?, FIRST_INSPECTION = ?, SELF_INSPECTION = ?, ROUTING_INSPECTION = ?, REACTION_PLAN = ?,REMARKS=? WHERE PLMEID = \'%s\' +RB3_CONTROLREQUIREMENTINSERT=INSERT INTO RB3_CONTROLREQUIREMENT (PLMEID,PUID,ID,PROJECT,SPECIALITY,MANAGEMENT_REQUIREMENTS,CHECK_METHOD,FIRST_INSPECTION,SELF_INSPECTION,ROUTING_INSPECTION,REACTION_PLAN,REMARKS) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) +RB3_CONTROLREQUIREMENTUPDATE2=update RB3_CONTROLREQUIREMENT set ID = ?, PROJECT = ?, SPECIALITY = ?,MANAGEMENT_REQUIREMENTS = ?, CHECK_METHOD = ?, FIRST_INSPECTION = ?, SELF_INSPECTION = ?, ROUTING_INSPECTION = ?, REACTION_PLAN = ?,REMARKS=?,PROCESS_SPECIFICATIONS=?,MANAGEMENT_POINTS=?,STEP_CONTENT=? WHERE PLMEID = \'%s\' +RB3_CONTROLREQUIREMENTINSERT2=INSERT INTO RB3_CONTROLREQUIREMENT VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +RB3_CONTROLREQUIREMENTDELETE=DELETE FROM RB3_CONTROLREQUIREMENT WHERE PLMEID = \'%s\' + +!==============================================TMOM034================================================! +RB3_PACKAGINGPROJECTSELECT=select * from RB3_PACKAGINGPROJECT WHERE PUID = \'%s\' +RB3_PACKAGINGPROJECTUPDATE=update RB3_PACKAGINGPROJECT set P1 = ?, P2 = ?, P3 = ?, P4 = ? WHERE PLMEID = \'%s\' +RB3_PACKAGINGPROJECTINSERT=INSERT INTO RB3_PACKAGINGPROJECT VALUES(?,?,?,?,?,?) +RB3_PACKAGINGPROJECTDELETE=DELETE FROM RB3_PACKAGINGPROJECT WHERE PLMEID = \'%s\' diff --git a/src/com/connor/renben/process/plm/Activator.java b/src/com/connor/renben/process/plm/Activator.java new file mode 100644 index 0000000..7608699 --- /dev/null +++ b/src/com/connor/renben/process/plm/Activator.java @@ -0,0 +1,50 @@ +package com.connor.renben.process.plm; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.connor.renben.process.plm"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/CXBean.java b/src/com/connor/renben/process/plm/bean/CXBean.java new file mode 100644 index 0000000..72eac62 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/CXBean.java @@ -0,0 +1,74 @@ +package com.connor.renben.process.plm.bean; + +public class CXBean { + private int no; + private String jcxm; + private String jsyq; + private String clqj; + private String zjpc; + private String xjpc; + private String tstx; + private boolean sj; + private boolean mj; + + + public int getNo() { + return no; + } + public void setNo(int no) { + this.no = no; + } + public String getJcxm() { + return jcxm; + } + public void setJcxm(String jcxm) { + this.jcxm = jcxm; + } + public String getJsyq() { + return jsyq; + } + public void setJsyq(String jsyq) { + this.jsyq = jsyq; + } + public String getClqj() { + return clqj; + } + public void setClqj(String clqj) { + this.clqj = clqj; + } + public String getZjpc() { + return zjpc; + } + public void setZjpc(String zjpc) { + this.zjpc = zjpc; + } + public String getXjpc() { + return xjpc; + } + public void setXjpc(String xjpc) { + this.xjpc = xjpc; + } + public String getTstx() { + return tstx; + } + public void setTstx(String tstx) { + this.tstx = tstx; + } + public boolean isSj() { + return sj; + } + public void setSj(boolean sj) { + this.sj = sj; + } + public boolean isMj() { + return mj; + } + public void setMj(boolean mj) { + this.mj = mj; + } + + public void print() + { + System.out.println("no:"+no+",jcxm:"+jcxm+",jsyq:"+jsyq+",clqj:"+clqj+",zjpc:"+zjpc+",xjpc:"+xjpc+",tstx:"+tstx+",sj:"+sj+",mj:"+mj); + } +} diff --git a/src/com/connor/renben/process/plm/bean/CXListBean.java b/src/com/connor/renben/process/plm/bean/CXListBean.java new file mode 100644 index 0000000..c7b189d --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/CXListBean.java @@ -0,0 +1,43 @@ +package com.connor.renben.process.plm.bean; + +import java.util.List; + +public class CXListBean { + private List cxBeans; + private String cpmc; + private String cpdh; + private String khmc; + private String khth; + + public List getCxBeans() { + return cxBeans; + } + public void setCxBeans(List cxBeans) { + this.cxBeans = cxBeans; + } + public String getCpmc() { + return cpmc; + } + public void setCpmc(String cpmc) { + this.cpmc = cpmc; + } + public String getCpdh() { + return cpdh; + } + public void setCpdh(String cpdh) { + this.cpdh = cpdh; + } + public String getKhmc() { + return khmc; + } + public void setKhmc(String khmc) { + this.khmc = khmc; + } + public String getKhth() { + return khth; + } + public void setKhth(String khth) { + this.khth = khth; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/CheckTable.java b/src/com/connor/renben/process/plm/bean/CheckTable.java new file mode 100644 index 0000000..af30722 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/CheckTable.java @@ -0,0 +1,181 @@ +package com.connor.renben.process.plm.bean; + +public class CheckTable implements Cloneable{ + private String processPuid; + private String productId; + private String productName; + private String meopId; + private String meopName; + private String serialNo; + private String cp; + private String cpgc; + private String max; + private String min; + private String afterMax;//ռǰֵ + private String afterMin;//ռǰСֵ + private String percentage;//ռٷֱ + private String afterGcgc;//ռĹ̹ + private String clff; + private String rl; + private String pl; + private String tstx; + private String type;// + private String version;//ڲ汾 + private String fzr;// + private String meopNo;//ձ + private String hh;//к + public String getHh() { + return hh; + } + public void setHh(String hh) { + this.hh = hh; + } + public String getProcessPuid() { + return processPuid; + } + public void setProcessPuid(String processPuid) { + this.processPuid = processPuid; + } + public String getProductId() { + return productId; + } + public void setProductId(String productId) { + this.productId = productId; + } + public String getProductName() { + return productName; + } + public void setProductName(String productName) { + this.productName = productName; + } + public String getMeopName() { + return meopName; + } + public void setMeopName(String meopName) { + this.meopName = meopName; + } + public String getMeopId() { + return meopId; + } + public void setMeopId(String meopId) { + this.meopId = meopId; + } + public String getSerialNo() { + return serialNo; + } + public void setSerialNo(String serialNo) { + this.serialNo = serialNo; + } + public String getCp() { + return cp; + } + public void setCp(String cp) { + this.cp = cp; + } + public String getCpgc() { + return cpgc; + } + public void setCpgc(String cpgc) { + this.cpgc = cpgc; + } + public String getMax() { + return max; + } + public void setMax(String max) { + this.max = max; + } + public String getMin() { + return min; + } + public void setMin(String min) { + this.min = min; + } + public String getAfterMax() { + return afterMax; + } + public void setAfterMax(String afterMax) { + this.afterMax = afterMax; + } + public String getAfterMin() { + return afterMin; + } + public void setAfterMin(String afterMin) { + this.afterMin = afterMin; + } + public String getPercentage() { + return percentage; + } + public void setPercentage(String percentage) { + this.percentage = percentage; + } + public String getAfterGcgc() { + return afterGcgc; + } + public void setAfterGcgc(String afterGcgc) { + this.afterGcgc = afterGcgc; + } + public String getClff() { + return clff; + } + public void setClff(String clff) { + this.clff = clff; + } + public String getRl() { + return rl; + } + public void setRl(String rl) { + this.rl = rl; + } + public String getPl() { + return pl; + } + public void setPl(String pl) { + this.pl = pl; + } + public String getTstx() { + return tstx; + } + public void setTstx(String tstx) { + this.tstx = tstx; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getVersion() { + return version; + } + public void setVersion(String version) { + this.version = version; + } + public String getFzr() { + return fzr; + } + public void setFzr(String fzr) { + this.fzr = fzr; + } + public String getMeopNo() { + return meopNo; + } + public void setMeopNo(String meopNo) { + this.meopNo = meopNo; + } + @Override + public CheckTable clone() throws CloneNotSupportedException { + return (CheckTable) super.clone(); + } + @Override + public String toString() { + return "CheckTable [processPuid=" + processPuid + ", productId=" + + productId + ", productName=" + productName + ", meopId=" + + meopId + ", meopName=" + meopName + ", serialNo=" + serialNo + + ", cp=" + cp + ", cpgc=" + cpgc + ", max=" + max + ", min=" + + min + ", clff=" + clff + ", rl=" + rl + ", pl=" + pl + + ", tstx=" + tstx + ", type=" + type + ", version=" + version + + ", fzr=" + fzr + ", meopNo=" + meopNo + ", hh=" + hh + "]"; + } + + +} diff --git a/src/com/connor/renben/process/plm/bean/ControlPlanBean.java b/src/com/connor/renben/process/plm/bean/ControlPlanBean.java new file mode 100644 index 0000000..a691deb --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/ControlPlanBean.java @@ -0,0 +1,233 @@ +package com.connor.renben.process.plm.bean; + +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +public class ControlPlanBean { + private boolean sc;// + private boolean ssc;// + private boolean yj;// + + private String kzjhbh;//Ƽƻ + private String zylxr;//Ҫϵ + private String zylxrdh;//Ҫϵ˵绰 + private String bzriq;//ڣƣ + private String xdrq;//ڣ޶ + + private String sorhm;//SOR + private String ljh;// + private String hxxz;//С + private String gkgcpz;//˿͹׼/ + + private String khtzbh;//ͻͼֽ + private String ljmc;/// + private String gfpzrq;///׼/ + private String gkzlpz;//˿׼/ + + private String gfgc;/// + private String gfdh;// + private String xgdj;//޸ĵȼ + private String cx;/// + private String gkpz;//˿׼/ + private String qtpz;//׼/ + private String qtpzrq;//׼ + + private List processList; + + public boolean isSc() { + return sc; + } + + public void setSc(boolean sc) { + this.sc = sc; + } + + public boolean isSsc() { + return ssc; + } + + public void setSsc(boolean ssc) { + this.ssc = ssc; + } + + public boolean isYj() { + return yj; + } + + public void setYj(boolean yj) { + this.yj = yj; + } + + public String getKzjhbh() { + return kzjhbh; + } + + public void setKzjhbh(String kzjhbh) { + this.kzjhbh = kzjhbh; + } + + public String getZylxr() { + return zylxr; + } + + public void setZylxr(String zylxr) { + this.zylxr = zylxr; + } + + public String getZylxrdh() { + return zylxrdh; + } + + public void setZylxrdh(String zylxrdh) { + this.zylxrdh = zylxrdh; + } + + public String getBzriq() { + return bzriq; + } + + public void setBzriq(String bzriq) { + this.bzriq = bzriq; + } + + public String getXdrq() { + return xdrq; + } + + public void setXdrq(String xdrq) { + this.xdrq = xdrq; + } + + public String getSorhm() { + return sorhm; + } + + public void setSorhm(String sorhm) { + this.sorhm = sorhm; + } + + public String getLjh() { + return ljh; + } + + public void setLjh(String ljh) { + this.ljh = ljh; + } + + public String getHxxz() { + return hxxz; + } + + public void setHxxz(String hxxz) { + this.hxxz = hxxz; + } + + public String getGkgcpz() { + return gkgcpz; + } + + public void setGkgcpz(String gkgcpz) { + this.gkgcpz = gkgcpz; + } + + public String getKhtzbh() { + return khtzbh; + } + + public void setKhtzbh(String khtzbh) { + this.khtzbh = khtzbh; + } + + public String getLjmc() { + return ljmc; + } + + public void setLjmc(String ljmc) { + this.ljmc = ljmc; + } + + public String getGfpzrq() { + return gfpzrq; + } + + public void setGfpzrq(String gfpzrq) { + this.gfpzrq = gfpzrq; + } + + public String getGkzlpz() { + return gkzlpz; + } + + public void setGkzlpz(String gkzlpz) { + this.gkzlpz = gkzlpz; + } + + public String getGfgc() { + return gfgc; + } + + public void setGfgc(String gfgc) { + this.gfgc = gfgc; + } + + public String getGfdh() { + return gfdh; + } + + public void setGfdh(String gfdh) { + this.gfdh = gfdh; + } + + public String getXgdj() { + return xgdj; + } + + public void setXgdj(String xgdj) { + this.xgdj = xgdj; + } + + public String getCx() { + return cx; + } + + public void setCx(String cx) { + this.cx = cx; + } + + public String getGkpz() { + return gkpz; + } + + public void setGkpz(String gkpz) { + this.gkpz = gkpz; + } + + public String getQtpz() { + return qtpz; + } + + public void setQtpz(String qtpz) { + this.qtpz = qtpz; + } + + public String getQtpzrq() { + return qtpzrq; + } + + public void setQtpzrq(String qtpzrq) { + this.qtpzrq = qtpzrq; + } + + public List getProcessList() { + return processList; + } + + public void setProcessList(List processList) { + this.processList = processList; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/ControlPlanComboBoxBean.java b/src/com/connor/renben/process/plm/bean/ControlPlanComboBoxBean.java new file mode 100644 index 0000000..c16b1d5 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/ControlPlanComboBoxBean.java @@ -0,0 +1,26 @@ +package com.connor.renben.process.plm.bean; + +public class ControlPlanComboBoxBean { + + private String itemId; + private String itemName; + public String getItemId() { + return itemId; + } + public void setItemId(String itemId) { + this.itemId = itemId; + } + public String getItemName() { + return itemName; + } + public void setItemName(String itemName) { + this.itemName = itemName; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.itemName; + //return super.toString(); + } +} diff --git a/src/com/connor/renben/process/plm/bean/EntrustmentFormBean.java b/src/com/connor/renben/process/plm/bean/EntrustmentFormBean.java new file mode 100644 index 0000000..43dc334 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/EntrustmentFormBean.java @@ -0,0 +1,524 @@ +package com.connor.renben.process.plm.bean; + +public class EntrustmentFormBean { + private String puid; + private String itemId; + private String p1 = ""; + private String p2 = ""; + private String p3 = ""; + private String p4 = ""; + private String p5 = ""; + private String p6 = ""; + private String p7 = ""; + private String p8 = ""; + private String p9 = ""; + private String p10 = ""; + private String p11 = ""; + private String p12 = ""; + private String p13 = ""; + private String p14 = ""; + private String p15 = ""; + private String p16 = ""; + private String p17 = ""; + private String p18 = ""; + private String p19 = ""; + private String p20 = ""; + private String p21 = ""; + private String p22 = ""; + private String p23 = ""; + private String p24 = ""; + private String p25 = ""; + private String p26 = ""; + private String p27 = ""; + private String p28 = ""; + private String p29 = ""; + private String p30 = ""; + private String p31 = ""; + private String p32 = ""; + private String p33 = ""; + private String p34 = ""; + private String p35 = ""; + private String p36 = ""; + private String p37 = ""; + private String p38 = ""; + private String p39 = ""; + private String p40 = ""; + private String p41 = ""; + private String p42 = ""; + private String p43 = ""; + private String p44 = ""; + private String p45 = ""; + private String p46 = ""; + private String p47 = ""; + private String p48 = ""; + private String p49 = ""; + private String p50 = ""; + private String p51 = ""; + private String p52 = ""; + private String p53 = ""; + private String p54 = ""; + private String p55 = ""; + private String p56 = ""; + private String p57 = ""; + private String p58 = ""; + private String p59 = ""; + private String p60 = ""; + private String p61 = ""; + private String p62 = ""; + private String p63 = ""; + private String p64 = ""; + private String p65 = ""; + private String p66 = ""; + private String p67 = ""; + private String p68 = ""; + private String p69 = ""; + private String p70 = ""; + private String p71 = ""; + private String p72 = ""; + public String getPuid() { + return puid; + } + public void setPuid(String puid) { + this.puid = puid; + } + public String getItemId() { + return itemId; + } + public void setItemId(String itemId) { + this.itemId = itemId; + } + 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 getP6() { + return p6; + } + public void setP6(String p6) { + this.p6 = p6; + } + public String getP7() { + return p7; + } + public void setP7(String p7) { + this.p7 = p7; + } + public String getP8() { + return p8; + } + public void setP8(String p8) { + this.p8 = p8; + } + public String getP9() { + return p9; + } + public void setP9(String p9) { + this.p9 = p9; + } + public String getP10() { + return p10; + } + public void setP10(String p10) { + this.p10 = p10; + } + public String getP11() { + return p11; + } + public void setP11(String p11) { + this.p11 = p11; + } + public String getP12() { + return p12; + } + public void setP12(String p12) { + this.p12 = p12; + } + public String getP13() { + return p13; + } + public void setP13(String p13) { + this.p13 = p13; + } + public String getP14() { + return p14; + } + public void setP14(String p14) { + this.p14 = p14; + } + public String getP15() { + return p15; + } + public void setP15(String p15) { + this.p15 = p15; + } + public String getP16() { + return p16; + } + public void setP16(String p16) { + this.p16 = p16; + } + public String getP17() { + return p17; + } + public void setP17(String p17) { + this.p17 = p17; + } + public String getP18() { + return p18; + } + public void setP18(String p18) { + this.p18 = p18; + } + public String getP19() { + return p19; + } + public void setP19(String p19) { + this.p19 = p19; + } + public String getP20() { + return p20; + } + public void setP20(String p20) { + this.p20 = p20; + } + public String getP21() { + return p21; + } + public void setP21(String p21) { + this.p21 = p21; + } + public String getP22() { + return p22; + } + public void setP22(String p22) { + this.p22 = p22; + } + public String getP23() { + return p23; + } + public void setP23(String p23) { + this.p23 = p23; + } + public String getP24() { + return p24; + } + public void setP24(String p24) { + this.p24 = p24; + } + public String getP25() { + return p25; + } + public void setP25(String p25) { + this.p25 = p25; + } + public String getP26() { + return p26; + } + public void setP26(String p26) { + this.p26 = p26; + } + public String getP27() { + return p27; + } + public void setP27(String p27) { + this.p27 = p27; + } + public String getP28() { + return p28; + } + public void setP28(String p28) { + this.p28 = p28; + } + public String getP29() { + return p29; + } + public void setP29(String p29) { + this.p29 = p29; + } + public String getP30() { + return p30; + } + public void setP30(String p30) { + this.p30 = p30; + } + public String getP31() { + return p31; + } + public void setP31(String p31) { + this.p31 = p31; + } + public String getP32() { + return p32; + } + public void setP32(String p32) { + this.p32 = p32; + } + public String getP33() { + return p33; + } + public void setP33(String p33) { + this.p33 = p33; + } + public String getP34() { + return p34; + } + public void setP34(String p34) { + this.p34 = p34; + } + public String getP35() { + return p35; + } + public void setP35(String p35) { + this.p35 = p35; + } + public String getP36() { + return p36; + } + public void setP36(String p36) { + this.p36 = p36; + } + public String getP37() { + return p37; + } + public void setP37(String p37) { + this.p37 = p37; + } + public String getP38() { + return p38; + } + public void setP38(String p38) { + this.p38 = p38; + } + public String getP39() { + return p39; + } + public void setP39(String p39) { + this.p39 = p39; + } + public String getP40() { + return p40; + } + public void setP40(String p40) { + this.p40 = p40; + } + public String getP41() { + return p41; + } + public void setP41(String p41) { + this.p41 = p41; + } + public String getP42() { + return p42; + } + public void setP42(String p42) { + this.p42 = p42; + } + public String getP43() { + return p43; + } + public void setP43(String p43) { + this.p43 = p43; + } + public String getP44() { + return p44; + } + public void setP44(String p44) { + this.p44 = p44; + } + public String getP45() { + return p45; + } + public void setP45(String p45) { + this.p45 = p45; + } + public String getP46() { + return p46; + } + public void setP46(String p46) { + this.p46 = p46; + } + public String getP47() { + return p47; + } + public void setP47(String p47) { + this.p47 = p47; + } + public String getP48() { + return p48; + } + public void setP48(String p48) { + this.p48 = p48; + } + public String getP49() { + return p49; + } + public void setP49(String p49) { + this.p49 = p49; + } + public String getP50() { + return p50; + } + public void setP50(String p50) { + this.p50 = p50; + } + public String getP51() { + return p51; + } + public void setP51(String p51) { + this.p51 = p51; + } + public String getP52() { + return p52; + } + public void setP52(String p52) { + this.p52 = p52; + } + public String getP53() { + return p53; + } + public void setP53(String p53) { + this.p53 = p53; + } + public String getP54() { + return p54; + } + public void setP54(String p54) { + this.p54 = p54; + } + public String getP55() { + return p55; + } + public void setP55(String p55) { + this.p55 = p55; + } + public String getP56() { + return p56; + } + public void setP56(String p56) { + this.p56 = p56; + } + public String getP57() { + return p57; + } + public void setP57(String p57) { + this.p57 = p57; + } + public String getP58() { + return p58; + } + public void setP58(String p58) { + this.p58 = p58; + } + public String getP59() { + return p59; + } + public void setP59(String p59) { + this.p59 = p59; + } + public String getP60() { + return p60; + } + public void setP60(String p60) { + this.p60 = p60; + } + public String getP61() { + return p61; + } + public void setP61(String p61) { + this.p61 = p61; + } + public String getP62() { + return p62; + } + public void setP62(String p62) { + this.p62 = p62; + } + public String getP63() { + return p63; + } + public void setP63(String p63) { + this.p63 = p63; + } + public String getP64() { + return p64; + } + public void setP64(String p64) { + this.p64 = p64; + } + public String getP65() { + return p65; + } + public void setP65(String p65) { + this.p65 = p65; + } + public String getP66() { + return p66; + } + public void setP66(String p66) { + this.p66 = p66; + } + public String getP67() { + return p67; + } + public void setP67(String p67) { + this.p67 = p67; + } + public String getP68() { + return p68; + } + public void setP68(String p68) { + this.p68 = p68; + } + public String getP69() { + return p69; + } + public void setP69(String p69) { + this.p69 = p69; + } + public String getP70() { + return p70; + } + public void setP70(String p70) { + this.p70 = p70; + } + public String getP71() { + return p71; + } + public void setP71(String p71) { + this.p71 = p71; + } + public String getP72() { + return p72; + } + public void setP72(String p72) { + this.p72 = p72; + } + + +} diff --git a/src/com/connor/renben/process/plm/bean/JobProcessFormBean.java b/src/com/connor/renben/process/plm/bean/JobProcessFormBean.java new file mode 100644 index 0000000..91316a9 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/JobProcessFormBean.java @@ -0,0 +1,124 @@ +package com.connor.renben.process.plm.bean; + +import java.util.List; + +public class JobProcessFormBean { + + private String gsmc; + private String ljdh; + private String sbxh; + private String bgx; + private String sbmc; + + private String xdgx; + private String wjbh; + private String bbh; + private String cxqy; + private String bz; + private String sh; + private String pz; + private String fbrq; + + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + public String getGsmc() { + return gsmc; + } + public void setGsmc(String gsmc) { + this.gsmc = gsmc; + } + public String getLjdh() { + return ljdh; + } + public void setLjdh(String ljdh) { + this.ljdh = ljdh; + } + public String getSbxh() { + return sbxh; + } + public void setSbxh(String sbxh) { + this.sbxh = sbxh; + } + public String getBgx() { + return bgx; + } + public void setBgx(String bgx) { + this.bgx = bgx; + } + public String getSbmc() { + return sbmc; + } + public void setSbmc(String sbmc) { + this.sbmc = sbmc; + } + + public String getXdgx() { + return xdgx; + } + public void setXdgx(String xdgx) { + this.xdgx = xdgx; + } + public String getWjbh() { + return wjbh; + } + public void setWjbh(String wjbh) { + this.wjbh = wjbh; + } + public String getBbh() { + return bbh; + } + public void setBbh(String bbh) { + this.bbh = bbh; + } + public String getCxqy() { + return cxqy; + } + public void setCxqy(String cxqy) { + this.cxqy = cxqy; + } + public String getBz() { + return bz; + } + public void setBz(String bz) { + this.bz = bz; + } + public String getSh() { + return sh; + } + public void setSh(String sh) { + this.sh = sh; + } + public String getPz() { + return pz; + } + public void setPz(String pz) { + this.pz = pz; + } + public String getFbrq() { + return fbrq; + } + public void setFbrq(String fbrq) { + this.fbrq = fbrq; + } + + public List> getToolingDetailData() { + return toolingDetailData; + } + public void setToolingDetailData(List> toolingDetailData) { + this.toolingDetailData = toolingDetailData; + } + public List> getMachiningParameterData() { + return machiningParameterData; + } + public void setMachiningParameterData(List> machiningParameterData) { + this.machiningParameterData = machiningParameterData; + } + public List> getControlRequirementData() { + return controlRequirementData; + } + public void setControlRequirementData(List> controlRequirementData) { + this.controlRequirementData = controlRequirementData; + } +} diff --git a/src/com/connor/renben/process/plm/bean/PFMEABean.java b/src/com/connor/renben/process/plm/bean/PFMEABean.java new file mode 100644 index 0000000..7b36cc7 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/PFMEABean.java @@ -0,0 +1,144 @@ +package com.connor.renben.process.plm.bean; + +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[] 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/renben/process/plm/bean/PFMEADataBean.java b/src/com/connor/renben/process/plm/bean/PFMEADataBean.java new file mode 100644 index 0000000..2470ba0 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/PFMEADataBean.java @@ -0,0 +1,286 @@ +package com.connor.renben.process.plm.bean; + +public class PFMEADataBean { + + private String meopId;//ItemID + private String gybh;// + private String gcmc;//̹ + private String station;//station + private String requirement;//Ҫ + private String qzsxms;//DZʧЧģʽ + private String qzsxhg;//DZʧЧ + private String yzd;//ض + private String jb;// + private String qzsxqy;//DZʧЧ/ + private String xxgckzyf;//й̿Ԥ + private String pds;//ƵO + private String xxgckztc;//й̿̽ + private String tcd;//̽D + private String tm2Rpn;//RPN + private String jycs;//ʩ + private String zrr;// + private String jhwcrq;//ƻ + private String cqdcs;//ȡĴʩ + private String newSev;//S + private String newOcc;//O + private String newDel;//D + private String newRpn;//RPN + private String idealState;//IDEAL_STATE + private String hh;//к + private String hbdyg;//ϲԪ + private String hhc;//кŲ + private String special;//ַ + private String type;//s + private String bak;//Ԥ + private String P1;//Ԥ + private String P2;//Ԥ + private String P3;//Ԥ + private String P4;//Ԥ + private String P5;//Ԥ + private String revisionid;//Ԥ + private String NO;//ұ + private String occurrence;//Ƶ + private String detection;//Ƶ + private String priority;//ȼ + + public String getMeopId() { + return meopId; + } + public void setMeopId(String meopId) { + this.meopId = meopId; + } + public String getNO() { + return NO; + } + public void setNO(String NO) { + this.NO = NO; + } + public String getRevisionid() { + return revisionid; + } + public void setRevisionid(String revisionid) { + this.revisionid = revisionid; + } + public String getGybh() { + return gybh; + } + public void setGybh(String gybh) { + this.gybh = gybh; + } + public String getGcmc() { + return gcmc; + } + public void setGcmc(String gcmc) { + this.gcmc = gcmc; + } + public String getQzsxms() { + return qzsxms; + } + public void setQzsxms(String qzsxms) { + this.qzsxms = qzsxms; + } + public String getQzsxhg() { + return qzsxhg; + } + public void setQzsxhg(String qzsxhg) { + this.qzsxhg = qzsxhg; + } + public String getYzd() { + return yzd; + } + public void setYzd(String yzd) { + this.yzd = yzd; + } + public String getJb() { + return jb; + } + public void setJb(String jb) { + this.jb = jb; + } + public String getQzsxqy() { + return qzsxqy; + } + public void setQzsxqy(String qzsxqy) { + this.qzsxqy = qzsxqy; + } + public String getXxgckzyf() { + return xxgckzyf; + } + public void setXxgckzyf(String xxgckzyf) { + this.xxgckzyf = xxgckzyf; + } + public String getPds() { + return pds; + } + public void setPds(String pds) { + this.pds = pds; + } + public String getXxgckztc() { + return xxgckztc; + } + public void setXxgckztc(String xxgckztc) { + this.xxgckztc = xxgckztc; + } + public String getTcd() { + return tcd; + } + public void setTcd(String tcd) { + this.tcd = tcd; + } + public String getTm2Rpn() { + return tm2Rpn; + } + public void setTm2Rpn(String tm2Rpn) { + this.tm2Rpn = tm2Rpn; + } + public String getJycs() { + return jycs; + } + public void setJycs(String jycs) { + this.jycs = jycs; + } + public String getCqdcs() { + return cqdcs; + } + public void setCqdcs(String cqdcs) { + this.cqdcs = cqdcs; + } + public String getHh() { + return hh; + } + public void setHh(String hh) { + this.hh = hh; + } + public String getHbdyg() { + return hbdyg; + } + public void setHbdyg(String hbdyg) { + this.hbdyg = hbdyg; + } + public String getHhc() { + return hhc; + } + public void setHhc(String hhc) { + this.hhc = hhc; + } + public String getSpecial() { + return special; + } + public void setSpecial(String special) { + this.special = special; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getBak() { + return bak; + } + public void setBak(String bak) { + this.bak = bak; + } + public String getP1() { + return P1; + } + public void setP1(String p1) { + P1 = p1; + } + public String getP2() { + return P2; + } + public void setP2(String p2) { + P2 = p2; + } + public String getP3() { + return P3; + } + public void setP3(String p3) { + P3 = p3; + } + public String getP4() { + return P4; + } + public void setP4(String p4) { + P4 = p4; + } + public String getP5() { + return P5; + } + public void setP5(String p5) { + P5 = p5; + } + public String getStation() { + return station; + } + public void setStation(String station) { + this.station = station; + } + public String getRequirement() { + return requirement; + } + public void setRequirement(String requirement) { + this.requirement = requirement; + } + public String getZrr() { + return zrr; + } + public void setZrr(String zrr) { + this.zrr = zrr; + } + public String getJhwcrq() { + return jhwcrq; + } + public void setJhwcrq(String jhwcrq) { + this.jhwcrq = jhwcrq; + } + public String getNewSev() { + return newSev; + } + public void setNewSev(String newSev) { + this.newSev = newSev; + } + public String getNewOcc() { + return newOcc; + } + public void setNewOcc(String newOcc) { + this.newOcc = newOcc; + } + public String getNewDel() { + return newDel; + } + public void setNewDel(String newDel) { + this.newDel = newDel; + } + public String getNewRpn() { + return newRpn; + } + public void setNewRpn(String newRpn) { + this.newRpn = newRpn; + } + public String getIdealState() { + return idealState; + } + public void setIdealState(String idealState) { + this.idealState = idealState; + } + public String getOccurrence() { + return occurrence; + } + public void setOccurrence(String occurrence) { + this.occurrence = occurrence; + } + public String getDetection() { + return detection; + } + public void setDetection(String detection) { + this.detection = detection; + } + public String getPriority() { + return priority; + } + public void setPriority(String priority) { + this.priority = priority; + } +} diff --git a/src/com/connor/renben/process/plm/bean/ProcessBean.java b/src/com/connor/renben/process/plm/bean/ProcessBean.java new file mode 100644 index 0000000..4ba4a3e --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/ProcessBean.java @@ -0,0 +1,222 @@ +package com.connor.renben.process.plm.bean; + +public class ProcessBean { + private String processPuid;//յPUID + private String meopId;//ItemID + private String gybh;//ձ + private String gcmc;// + private String jqsb;//豸װо + private String smjy;//ĩ + private String qptbh;//ͼ + private String cc;//ߴ + private String no;// + private String cp;//Ʒ + private String gc;// + private String tstx;// + private String cpgc;//Ʒ/// + private String pgclff;// + private String rl;// + private String pl;//Ƶ + private String sjsj;//׼ + private String gcsj;// + private String mjsj;//ĩ + private String fzr;// + private String kzff;//Ʒ + private String czgf;//淶 + private String fyjh;//Ӧƻ + private String hh;//к + private String hbdyg;//ϲԪ + private String sfwc;//Ƿ + private String hhc;//кŲ + private String special;//ַ + private String type;//s + private String revisionuid;//Ƽƻuid汾 + private String NO;//ұ + + public String getGybh() { + return gybh; + } + public void setGybh(String gybh) { + this.gybh = gybh; + } + public String getRevisionuid() { + return revisionuid; + } + public void setRevisionuid(String revisionuid) { + this.revisionuid = revisionuid; + } + public String getGcmc() { + return gcmc; + } + public void setGcmc(String gcmc) { + this.gcmc = gcmc; + } + public String getJqsb() { + return jqsb; + } + public void setJqsb(String jqsb) { + this.jqsb = jqsb; + } + public String getQptbh() { + return qptbh; + } + public void setQptbh(String qptbh) { + this.qptbh = qptbh; + } + public String getCc() { + return cc; + } + public void setCc(String cc) { + this.cc = cc; + } + public String getCp() { + return cp; + } + public void setCp(String cp) { + this.cp = cp; + } + public String getGc() { + return gc; + } + public void setGc(String gc) { + this.gc = gc; + } + public String getTstx() { + return tstx; + } + public void setTstx(String tstx) { + this.tstx = tstx; + } + public String getCpgc() { + return cpgc; + } + public void setCpgc(String cpgc) { + this.cpgc = cpgc; + } + public String getPgclff() { + return pgclff; + } + public void setPgclff(String pgclff) { + this.pgclff = pgclff; + } + public String getRl() { + return rl; + } + public void setRl(String rl) { + this.rl = rl; + } + public String getPl() { + return pl; + } + public void setPl(String pl) { + this.pl = pl; + } + public String getFzr() { + return fzr; + } + public void setFzr(String fzr) { + this.fzr = fzr; + } + public String getKzff() { + return kzff; + } + public void setKzff(String kzff) { + this.kzff = kzff; + } + public String getCzgf() { + return czgf; + } + public void setCzgf(String czgf) { + this.czgf = czgf; + } + public String getFyjh() { + return fyjh; + } + public void setFyjh(String fyjh) { + this.fyjh = fyjh; + } + public String getProcessPuid() { + return processPuid; + } + public void setProcessPuid(String processPuid) { + this.processPuid = processPuid; + } + public String getMeopId() { + return meopId; + } + public void setMeopId(String meopId) { + this.meopId = meopId; + } + public String getSmjy() { + return smjy; + } + public void setSmjy(String smjy) { + this.smjy = smjy; + } + public String getSjsj() { + return sjsj; + } + public void setSjsj(String sjsj) { + this.sjsj = sjsj; + } + public String getGcsj() { + return gcsj; + } + public void setGcsj(String gcsj) { + this.gcsj = gcsj; + } + public String getMjsj() { + return mjsj; + } + public void setMjsj(String mjsj) { + this.mjsj = mjsj; + } + public String getHh() { + return hh; + } + public void setHh(String hh) { + this.hh = hh; + } + public String getHbdyg() { + return hbdyg; + } + public void setHbdyg(String hbdyg) { + this.hbdyg = hbdyg; + } + public String getSfwc() { + return sfwc; + } + public void setSfwc(String sfwc) { + this.sfwc = sfwc; + } + public String getHhc() { + return hhc; + } + public void setHhc(String hhc) { + this.hhc = hhc; + } + public String getSpecial() { + return special; + } + public void setSpecial(String special) { + this.special = special; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getNo() { + return no; + } + public void setNo(String no) { + this.no = no; + } + public String getNO() { + return NO; + } + public void setNO(String NO) { + this.NO = NO; + } +} diff --git a/src/com/connor/renben/process/plm/bean/TMomControlPlanBean.java b/src/com/connor/renben/process/plm/bean/TMomControlPlanBean.java new file mode 100644 index 0000000..cc5a3e0 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/TMomControlPlanBean.java @@ -0,0 +1,244 @@ +package com.connor.renben.process.plm.bean; + +import java.util.List; + +public class TMomControlPlanBean { + + public static final int PROP_COUNT = 40; + public static final int PROP_COUNT_T = 37; + private String controlType = "";// Ƽƻ rb3_cpjd + private String controlPlanNo = "";// Ƽƻ + private String keyPersion = "";// Ҫϵ + private String custromApprovalDateStr = "";// ͻ׼ + private String keyPhone = "";// Ҫϵ˵绰 + private String createDateStr = "";// + private String updateDateStr = "";// ޸ + private String sorName = "";// SOR + private String partNumber = "";// հ汾 + private String coreTeam = "";// С + private String custromEngineeringApprovalDateStr = "";// ͻʦ׼ + private String custromDrawingNumber = "";// ͻͼֽ + private String custromPartNumber = "";// ͻ + private String partNameDesc = "";// + private String supplierApprovalDateStr = "";// ׼ + private String custromQuantyApprovalDateStr = "";// ͻ׼ + private String supplier = "";// + private String supplierCode = "";// + private String changeLev = "";// ޸ĵȼ + private String mode = "";// + private String otherApprovalDateStr = "";// ׼ + private String otherApprovalIfDateStr = "";// Ƿ׼ + private List simpleBeanList;// + + // -------------------------------------------------- + + public String getControlType() { + return controlType; + } + + public String getChangeLev() { + return changeLev; + } + + public void setChangeLev(String changeLev) { + this.changeLev = changeLev; + } + + public static int getPropCount() { + return PROP_COUNT; + } + + public String getCustromDrawingNumber() { + return custromDrawingNumber; + } + + public void setCustromDrawingNumber(String custromDrawingNumber) { + this.custromDrawingNumber = custromDrawingNumber; + } + + public String getKeyPersion() { + return keyPersion; + } + + public void setKeyPersion(String keyPersion) { + this.keyPersion = keyPersion; + } + + public String getCustromApprovalDateStr() { + return custromApprovalDateStr; + } + + public void setCustromApprovalDateStr(String custromApprovalDateStr) { + this.custromApprovalDateStr = custromApprovalDateStr; + } + + public void setControlType(String controlType) { + this.controlType = controlType; + } + + public String getControlPlanNo() { + return controlPlanNo; + } + + public void setControlPlanNo(String controlPlanNo) { + this.controlPlanNo = controlPlanNo; + } + + public String getKeyPhone() { + return keyPhone; + } + + public void setKeyPhone(String keyPhone) { + this.keyPhone = keyPhone; + } + + public String getCreateDateStr() { + return createDateStr; + } + + public void setCreateDateStr(String createDateStr) { + this.createDateStr = createDateStr; + } + + public String getUpdateDateStr() { + return updateDateStr; + } + + public void setUpdateDateStr(String updateDateStr) { + this.updateDateStr = updateDateStr; + } + + public String getSorName() { + return sorName; + } + + public void setSorName(String sorName) { + this.sorName = sorName; + } + + public String getPartNumber() { + return partNumber; + } + + public void setPartNumber(String partNumber) { + this.partNumber = partNumber; + } + + public String getCoreTeam() { + return coreTeam; + } + + public void setCoreTeam(String coreTeam) { + this.coreTeam = coreTeam; + } + + public String getCustromEngineeringApprovalDateStr() { + return custromEngineeringApprovalDateStr; + } + + public void setCustromEngineeringApprovalDateStr( + String custromEngineeringApprovalDateStr) { + this.custromEngineeringApprovalDateStr = custromEngineeringApprovalDateStr; + } + + public String getCustromPartNumber() { + return custromPartNumber; + } + + public void setCustromPartNumber(String custromPartNumber) { + this.custromPartNumber = custromPartNumber; + } + + public String getPartNameDesc() { + return partNameDesc; + } + + public void setPartNameDesc(String partNameDesc) { + this.partNameDesc = partNameDesc; + } + + public String getSupplierApprovalDateStr() { + return supplierApprovalDateStr; + } + + public void setSupplierApprovalDateStr(String supplierApprovalDateStr) { + this.supplierApprovalDateStr = supplierApprovalDateStr; + } + + public String getCustromQuantyApprovalDateStr() { + return custromQuantyApprovalDateStr; + } + + public void setCustromQuantyApprovalDateStr( + String custromQuantyApprovalDateStr) { + this.custromQuantyApprovalDateStr = custromQuantyApprovalDateStr; + } + + public String getSupplier() { + return supplier; + } + + public void setSupplier(String supplier) { + this.supplier = supplier; + } + + public String getSupplierCode() { + return supplierCode; + } + + public void setSupplierCode(String supplierCode) { + this.supplierCode = supplierCode; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getOtherApprovalDateStr() { + return otherApprovalDateStr; + } + + public void setOtherApprovalDateStr(String otherApprovalDateStr) { + this.otherApprovalDateStr = otherApprovalDateStr; + } + + public String getOtherApprovalIfDateStr() { + return otherApprovalIfDateStr; + } + + public void setOtherApprovalIfDateStr(String otherApprovalIfDateStr) { + this.otherApprovalIfDateStr = otherApprovalIfDateStr; + } + + public List getSimpleBeanList() { + return simpleBeanList; + } + + public void setSimpleBeanList(List simpleBeanList) { + this.simpleBeanList = simpleBeanList; + } + + @Override + public String toString() { + return "TMomControlPlanBean [controlType=" + controlType + + ", controlPlanNo=" + controlPlanNo + ", keyPhone=" + keyPhone + + ", createDateStr=" + createDateStr + ", updateDateStr=" + + updateDateStr + ", sorName=" + sorName + ", partNumber=" + + partNumber + ", coreTeam=" + coreTeam + + ", custromEngineeringApprovalDateStr=" + + custromEngineeringApprovalDateStr + ", custromPartNumber=" + + custromPartNumber + ", partNameDesc=" + partNameDesc + + ", supplierApprovalDateStr=" + supplierApprovalDateStr + + ", custromQuantyApprovalDateStr=" + + custromQuantyApprovalDateStr + ", supplier=" + supplier + + ", supplierCode=" + supplierCode + ", mode=" + mode + + ", otherApprovalDateStr=" + otherApprovalDateStr + + ", otherApprovalIfDateStr=" + otherApprovalIfDateStr + + ", simpleBeanList=" + simpleBeanList + "]"; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/TMomControlPlanSimpleBean.java b/src/com/connor/renben/process/plm/bean/TMomControlPlanSimpleBean.java new file mode 100644 index 0000000..2b34f90 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/TMomControlPlanSimpleBean.java @@ -0,0 +1,253 @@ +package com.connor.renben.process.plm.bean; + +public class TMomControlPlanSimpleBean { + + public static final int PROP_COUNT = 19;// Եĸ + private String meopId = "";//ID + private String partProcessNumber = "";// ձ + private String processName = "";// + private String machineDevice = "";// 豸 + private String smjy = "";//ĩ + private String bubbledPrintNo = "";// ͼ + private String size = "";// 5 ߴ + private String No = "";// + private String product = "";// Ʒ + private String process = "";// + private String specialClass = "";// + private String productProcessSpecificationTolerance = "";// 10 Ʒ๫ + + private String upProductProcessSpecificationTolerance = "";// Ʒ๫(ƫ) + private String downProductProcessSpecificationTolerance = "";// Ʒ๫ƫ + private String evaluationMeasurementTechnique = "";// + private String sampleSize = "";// Ʒ + private String sampleFreq = "";// 15 ƷƵ + private String resp = "";// + private String controlMethod = "";// Ʒ + private String operationCriteria = "";// 淶 + private String reactionPlan = "";// Ӧƻ + + private String hbdyg = ""; + private String special = ""; + + private String conceal = "0";//Ƿ + + // --------------------------- + + public String getProductProcessSpecificationTolerance() { + return productProcessSpecificationTolerance; + } + + public void setProductProcessSpecificationTolerance( + String productProcessSpecificationTolerance) { + this.productProcessSpecificationTolerance = productProcessSpecificationTolerance; + } + + public String getPartProcessNumber() { + return partProcessNumber; + } + + public void setPartProcessNumber(String partProcessNumber) { + this.partProcessNumber = partProcessNumber; + } + + public String getProcessName() { + return processName; + } + + public void setProcessName(String processName) { + this.processName = processName; + } + + public String getMachineDevice() { + return machineDevice; + } + + public void setMachineDevice(String machineDevice) { + this.machineDevice = machineDevice; + } + + public String getBubbledPrintNo() { + return bubbledPrintNo; + } + + public void setBubbledPrintNo(String bubbledPrintNo) { + this.bubbledPrintNo = bubbledPrintNo; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + public String getNo() { + return No; + } + + public void setNo(String no) { + No = no; + } + + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public String getProcess() { + return process; + } + + public void setProcess(String process) { + this.process = process; + } + + public String getSpecialClass() { + return specialClass; + } + + public void setSpecialClass(String specialClass) { + this.specialClass = specialClass; + } + + public String getUpProductProcessSpecificationTolerance() { + return upProductProcessSpecificationTolerance; + } + + public void setUpProductProcessSpecificationTolerance( + String upProductProcessSpecificationTolerance) { + this.upProductProcessSpecificationTolerance = upProductProcessSpecificationTolerance; + } + + public String getDownProductProcessSpecificationTolerance() { + return downProductProcessSpecificationTolerance; + } + + public void setDownProductProcessSpecificationTolerance( + String downProductProcessSpecificationTolerance) { + this.downProductProcessSpecificationTolerance = downProductProcessSpecificationTolerance; + } + + public String getEvaluationMeasurementTechnique() { + return evaluationMeasurementTechnique; + } + + public void setEvaluationMeasurementTechnique( + String evaluationMeasurementTechnique) { + this.evaluationMeasurementTechnique = evaluationMeasurementTechnique; + } + + public String getSampleSize() { + return sampleSize; + } + + public void setSampleSize(String sampleSize) { + this.sampleSize = sampleSize; + } + + public String getSampleFreq() { + return sampleFreq; + } + + public void setSampleFreq(String sampleFreq) { + this.sampleFreq = sampleFreq; + } + + public String getResp() { + return resp; + } + + public void setResp(String resp) { + this.resp = resp; + } + + public String getControlMethod() { + return controlMethod; + } + + public void setControlMethod(String controlMethod) { + this.controlMethod = controlMethod; + } + + public String getOperationCriteria() { + return operationCriteria; + } + + public void setOperationCriteria(String operationCriteria) { + this.operationCriteria = operationCriteria; + } + + public String getReactionPlan() { + return reactionPlan; + } + + public void setReactionPlan(String reactionPlan) { + this.reactionPlan = reactionPlan; + } + + public String getHbdyg() { + return hbdyg; + } + + public void setHbdyg(String hbdyg) { + this.hbdyg = hbdyg; + } + + public String getSpecial() { + return special; + } + + public void setSpecial(String special) { + this.special = special; + } + + public String getConceal() { + return conceal; + } + + public void setConceal(String conceal) { + this.conceal = conceal; + } + + public String getSmjy() { + return smjy; + } + + public void setSmjy(String smjy) { + this.smjy = smjy; + } + + @Override + public String toString() { + return "TMomControlPlanSimpleBean [partProcessNumber=" + + partProcessNumber + ", processName=" + processName + + ", machineDevice=" + machineDevice + ", bubbledPrintNo=" + + bubbledPrintNo + ", size=" + size + ", No=" + No + + ", product=" + product + ", process=" + process + + ", specialClass=" + specialClass + + ", productProcessSpecificationTolerance=" + + productProcessSpecificationTolerance + + ", upProductProcessSpecificationTolerance=" + + upProductProcessSpecificationTolerance + + ", downProductProcessSpecificationTolerance=" + + downProductProcessSpecificationTolerance + + ", evaluationMeasurementTechnique=" + + evaluationMeasurementTechnique + ", sampleSize=" + sampleSize + + ", sampleFreq=" + sampleFreq + ", resp=" + resp + + ", controlMethod=" + controlMethod + ", operationCriteria=" + + operationCriteria + ", reactionPlan=" + reactionPlan + "]"; + } + + public String getMeopId() { + return meopId; + } + + public void setMeopId(String meopId) { + this.meopId = meopId; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/TMomCreatePropBean.java b/src/com/connor/renben/process/plm/bean/TMomCreatePropBean.java new file mode 100644 index 0000000..61ab4f7 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/TMomCreatePropBean.java @@ -0,0 +1,44 @@ +package com.connor.renben.process.plm.bean; + +import com.teamcenter.rac.kernel.TCPropertyDescriptor; + +public class TMomCreatePropBean { + + private String displayName; + private String name; + private String value; + private TCPropertyDescriptor descriptor; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public TCPropertyDescriptor getDescriptor() { + return descriptor; + } + + public void setDescriptor(TCPropertyDescriptor descriptor) { + this.descriptor = descriptor; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/TMomItemBean.java b/src/com/connor/renben/process/plm/bean/TMomItemBean.java new file mode 100644 index 0000000..ba2f5c0 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/TMomItemBean.java @@ -0,0 +1,130 @@ +package com.connor.renben.process.plm.bean; + +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; + +public class TMomItemBean { + private TCComponentItem item; + private String itemID;// ID + private String revID;// 汾ID + private String name;// + private String unitDis;// λʾ + private String unit;// λ + private String typeDis;// ʾ + private String type;// + private Map itemProps;// + private Map revProps;// 汾 + private Map formProps;// 汾 + private TCComponentFolder folder; + + public TCComponentFolder getFolder() { + return folder; + } + + public void setFolder(TCComponentFolder folder) { + this.folder = folder; + } + + public String getTypeDis() { + return typeDis; + } + + public void setTypeDis(String typeDis) { + this.typeDis = typeDis; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnitDis() { + return unitDis; + } + + public void setUnitDis(String unitDis) { + this.unitDis = unitDis; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public TCComponentItem getItem() { + return item; + } + + public void setItem(TCComponentItem item) { + this.item = item; + } + + // ---------------------------------------------------- + public String getItemID() { + return itemID; + } + + public void setItemID(String itemID) { + this.itemID = itemID; + } + + public String getRevID() { + return revID; + } + + public void setRevID(String revID) { + this.revID = revID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getItemProps() { + return itemProps; + } + + public void setItemProps(Map itemProps) { + this.itemProps = itemProps; + } + + public Map getRevProps() { + return revProps; + } + + public void setRevProps(Map revProps) { + this.revProps = revProps; + } + + public Map getFormProps() { + return formProps; + } + + public void setFormProps(Map formProps) { + + this.formProps = formProps; + } + + @Override + public String toString() { + return "TMom001DeriveItemBean [itemID=" + itemID + ", revID=" + revID + + ", name=" + name + ", itemProps=" + itemProps + ", revProps=" + + revProps + ", formProps=" + formProps + "]"; + + } + + // ------------------------------ + +} diff --git a/src/com/connor/renben/process/plm/bean/TMomPropExplictBean.java b/src/com/connor/renben/process/plm/bean/TMomPropExplictBean.java new file mode 100644 index 0000000..b4bbbf9 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/TMomPropExplictBean.java @@ -0,0 +1,25 @@ +package com.connor.renben.process.plm.bean; + +import java.util.List; + +public class TMomPropExplictBean { + private String Type = ""; + private List PropList; + + public String getType() { + return Type; + } + + public void setType(String type) { + Type = type; + } + + public List getPropList() { + return PropList; + } + + public void setPropList(List propList) { + PropList = propList; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/TMomUserBean.java b/src/com/connor/renben/process/plm/bean/TMomUserBean.java new file mode 100644 index 0000000..8d00afe --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/TMomUserBean.java @@ -0,0 +1,69 @@ +package com.connor.renben.process.plm.bean; + +import javax.swing.ImageIcon; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentPerson; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; + +public class TMomUserBean { + private TCComponent User; + private TCComponent Parent; + private ImageIcon ImageIcon; + private String UserName; + + public TCComponent getParent() { + return Parent; + } + + public void setParent(TCComponent Parent) { + this.Parent = Parent; + } + + public TCComponent getUser() { + return User; + } + + public void setUser(TCComponent user) { + User = user; + } + + public TMomUserBean() { + + } + + public TMomUserBean(TCComponent user, TCComponent Parent) { + this.Parent = Parent; + this.User = user; + if (user != null) { + + try { + if (user instanceof TCComponentRole) { + this.ImageIcon = new ImageIcon("icons\\role_16.png"); + + } else if (user instanceof TCComponentPerson) { + this.ImageIcon = new ImageIcon("icons\\persons_16.png"); + + } else if (user instanceof TCComponentGroup) { + this.ImageIcon = new ImageIcon("icons\\group_16.png"); + + } else if (user instanceof TCComponentUser) { + this.ImageIcon = new ImageIcon("icons\\persons_16.png"); + } + this.UserName = user.getStringProperty("object_string"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @Override + public String toString() { + return UserName; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/TreeBean.java b/src/com/connor/renben/process/plm/bean/TreeBean.java new file mode 100644 index 0000000..c3d1c4a --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/TreeBean.java @@ -0,0 +1,77 @@ +package com.connor.renben.process.plm.bean; +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/renben/process/plm/bean/Workflow_InfoBean.java b/src/com/connor/renben/process/plm/bean/Workflow_InfoBean.java new file mode 100644 index 0000000..8706dd4 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/Workflow_InfoBean.java @@ -0,0 +1,81 @@ +package com.connor.renben.process.plm.bean; + +import java.util.Date; + +import com.teamcenter.rac.kernel.TCComponent; + +public class Workflow_InfoBean { + private String puid; + private int wf_type; + private String userId; + private String timeinfo; + private String logTime; + private TCComponent comp; + private Date date; + + public String getLogTime() { + return logTime; + } + + public void setLogTime(String logTime) { + this.logTime = logTime; + } + + public String getPuid() { + return puid; + } + + public void setPuid(String puid) { + this.puid = puid; + } + + public int getWf_type() { + return wf_type; + } + + public void setWf_type(int wf_type) { + this.wf_type = wf_type; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getTimeinfo() { + return timeinfo; + } + + public void setTimeinfo(String timeinfo) { + this.timeinfo = timeinfo; + } + + + public TCComponent getComp() { + return comp; + } + + public void setComp(TCComponent comp) { + this.comp = comp; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + @Override + public String toString() { + return "Workflow_InfoBean [puid=" + puid + ", wf_type=" + wf_type + ", userId=" + userId + ", timeinfo=" + + timeinfo + ", logTime=" + logTime + ", comp=" + comp + ", date=" + date + "]"; + } + + + +} diff --git a/src/com/connor/renben/process/plm/bean/packageProcess/Electronforms.java b/src/com/connor/renben/process/plm/bean/packageProcess/Electronforms.java new file mode 100644 index 0000000..d898828 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/packageProcess/Electronforms.java @@ -0,0 +1,194 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2017.11.29 at 12:34:01 PM CST +// + + +package com.connor.renben.process.plm.bean.packageProcess; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice maxOccurs="unbounded" minOccurs="0">
+ *         <element name="Electronform">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="table" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="prt4MaterialCode" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </choice>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "electronform" +}) +@XmlRootElement(name = "Electronforms") +public class Electronforms { + + @XmlElement(name = "Electronform") + protected List electronform; + + /** + * Gets the value of the electronform property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the electronform property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getElectronform().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Electronforms.Electronform } + * + * + */ + public List getElectronform() { + if (electronform == null) { + electronform = new ArrayList(); + } + return this.electronform; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *       <attribute name="table" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *       <attribute name="prt4MaterialCode" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class Electronform { + + @XmlAttribute(name = "type") + protected String type; + @XmlAttribute(name = "table") + protected String table; + @XmlAttribute(name = "prt4MaterialCode") + protected String prt4MaterialCode; + + /** + * Gets the value of the type property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getType() { + return type; + } + + /** + * Sets the value of the type property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setType(String value) { + this.type = value; + } + + /** + * Gets the value of the table property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getTable() { + return table; + } + + /** + * Sets the value of the table property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setTable(String value) { + this.table = value; + } + + /** + * Gets the value of the prt4MaterialCode property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getPrt4MaterialCode() { + return prt4MaterialCode; + } + + /** + * Sets the value of the prt4MaterialCode property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPrt4MaterialCode(String value) { + this.prt4MaterialCode = value; + } + + } + +} diff --git a/src/com/connor/renben/process/plm/bean/packageProcess/NewDataSet.java b/src/com/connor/renben/process/plm/bean/packageProcess/NewDataSet.java new file mode 100644 index 0000000..3c6070d --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/packageProcess/NewDataSet.java @@ -0,0 +1,76 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2018.04.10 at 02:42:15 PM CST +// + + +package com.connor.renben.process.plm.bean.packageProcess; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <choice maxOccurs="unbounded" minOccurs="0">
+ *         <element ref="{}preferences"/>
+ *       </choice>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "preferences" +}) +@XmlRootElement(name = "NewDataSet") +public class NewDataSet { + + protected List preferences; + + /** + * Gets the value of the preferences property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the preferences property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getPreferences().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Preferences } + * + * + */ + public List getPreferences() { + if (preferences == null) { + preferences = new ArrayList(); + } + return this.preferences; + } + +} diff --git a/src/com/connor/renben/process/plm/bean/packageProcess/ObjectFactory.java b/src/com/connor/renben/process/plm/bean/packageProcess/ObjectFactory.java new file mode 100644 index 0000000..6452e55 --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/packageProcess/ObjectFactory.java @@ -0,0 +1,79 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2018.04.10 at 02:42:15 PM CST +// + + +package com.connor.renben.process.plm.bean.packageProcess; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the PackageProcess.bean package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: PackageProcess.bean + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Preferences } + * + */ + public Preferences createPreferences() { + return new Preferences(); + } + + /** + * Create an instance of {@link Preferences.PackageProcess } + * + */ + public Preferences.PackageProcess createPreferencesPackageProcess() { + return new Preferences.PackageProcess(); + } + + /** + * Create an instance of {@link Preferences.PackageProcess.TextFieldButton } + * + */ + public Preferences.PackageProcess.TextFieldButton createPreferencesPackageProcessTextFieldButton() { + return new Preferences.PackageProcess.TextFieldButton(); + } + + /** + * Create an instance of {@link NewDataSet } + * + */ + public NewDataSet createNewDataSet() { + return new NewDataSet(); + } + + /** + * Create an instance of {@link Preferences.PackageProcess.TextFieldButton.Value } + * + */ + public Preferences.PackageProcess.TextFieldButton.Value createPreferencesPackageProcessTextFieldButtonValue() { + return new Preferences.PackageProcess.TextFieldButton.Value(); + } + +} diff --git a/src/com/connor/renben/process/plm/bean/packageProcess/Preferences.java b/src/com/connor/renben/process/plm/bean/packageProcess/Preferences.java new file mode 100644 index 0000000..3c7d7db --- /dev/null +++ b/src/com/connor/renben/process/plm/bean/packageProcess/Preferences.java @@ -0,0 +1,534 @@ +// +// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 +// See http://java.sun.com/xml/jaxb +// Any modifications to this file will be lost upon recompilation of the source schema. +// Generated on: 2018.04.10 at 02:42:15 PM CST +// + + +package com.connor.renben.process.plm.bean.packageProcess; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="packageProcess" maxOccurs="unbounded" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="textFieldButton" maxOccurs="unbounded" minOccurs="0">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <sequence>
+ *                             <element name="value" maxOccurs="unbounded" minOccurs="0">
+ *                               <complexType>
+ *                                 <complexContent>
+ *                                   <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                                     <attribute name="property1" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                     <attribute name="property2" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                     <attribute name="property3" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                     <attribute name="property4" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                     <attribute name="property5" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                     <attribute name="property6" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                   </restriction>
+ *                                 </complexContent>
+ *                               </complexType>
+ *                             </element>
+ *                           </sequence>
+ *                           <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *                 <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *       <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "packageProcess" +}) +@XmlRootElement(name = "preferences") +public class Preferences { + + protected List packageProcess; + @XmlAttribute(name = "version") + protected String version; + + /** + * Gets the value of the packageProcess property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the packageProcess property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getPackageProcess().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Preferences.PackageProcess } + * + * + */ + public List getPackageProcess() { + if (packageProcess == null) { + packageProcess = new ArrayList(); + } + return this.packageProcess; + } + + /** + * Gets the value of the version property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVersion() { + return version; + } + + /** + * Sets the value of the version property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVersion(String value) { + this.version = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="textFieldButton" maxOccurs="unbounded" minOccurs="0">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <sequence>
+     *                   <element name="value" maxOccurs="unbounded" minOccurs="0">
+     *                     <complexType>
+     *                       <complexContent>
+     *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                           <attribute name="property1" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                           <attribute name="property2" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                           <attribute name="property3" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                           <attribute name="property4" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                           <attribute name="property5" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                           <attribute name="property6" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                         </restriction>
+     *                       </complexContent>
+     *                     </complexType>
+     *                   </element>
+     *                 </sequence>
+     *                 <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "textFieldButton" + }) + public static class PackageProcess { + + protected List textFieldButton; + @XmlAttribute(name = "name") + protected String name; + + /** + * Gets the value of the textFieldButton property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the textFieldButton property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getTextFieldButton().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Preferences.PackageProcess.TextFieldButton } + * + * + */ + public List getTextFieldButton() { + if (textFieldButton == null) { + textFieldButton = new ArrayList(); + } + return this.textFieldButton; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <sequence>
+         *         <element name="value" maxOccurs="unbounded" minOccurs="0">
+         *           <complexType>
+         *             <complexContent>
+         *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *                 <attribute name="property1" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *                 <attribute name="property2" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *                 <attribute name="property3" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *                 <attribute name="property4" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *                 <attribute name="property5" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *                 <attribute name="property6" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *               </restriction>
+         *             </complexContent>
+         *           </complexType>
+         *         </element>
+         *       </sequence>
+         *       <attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "value" + }) + public static class TextFieldButton { + + protected List value; + @XmlAttribute(name = "name") + protected String name; + + /** + * Gets the value of the value property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the value property. + * + *

+ * For example, to add a new item, do as follows: + *

+             *    getValue().add(newItem);
+             * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link Preferences.PackageProcess.TextFieldButton.Value } + * + * + */ + public List getValue() { + if (value == null) { + value = new ArrayList(); + } + return this.value; + } + + /** + * Gets the value of the name property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getName() { + return name; + } + + /** + * Sets the value of the name property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setName(String value) { + this.name = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+             * <complexType>
+             *   <complexContent>
+             *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+             *       <attribute name="property1" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *       <attribute name="property2" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *       <attribute name="property3" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *       <attribute name="property4" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *       <attribute name="property5" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *       <attribute name="property6" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *     </restriction>
+             *   </complexContent>
+             * </complexType>
+             * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class Value { + + @XmlAttribute(name = "property1") + protected String property1; + @XmlAttribute(name = "property2") + protected String property2; + @XmlAttribute(name = "property3") + protected String property3; + @XmlAttribute(name = "property4") + protected String property4; + @XmlAttribute(name = "property5") + protected String property5; + @XmlAttribute(name = "property6") + protected String property6; + + /** + * Gets the value of the property1 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProperty1() { + return property1; + } + + /** + * Sets the value of the property1 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProperty1(String value) { + this.property1 = value; + } + + /** + * Gets the value of the property2 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProperty2() { + return property2; + } + + /** + * Sets the value of the property2 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProperty2(String value) { + this.property2 = value; + } + + /** + * Gets the value of the property3 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProperty3() { + return property3; + } + + /** + * Sets the value of the property3 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProperty3(String value) { + this.property3 = value; + } + + /** + * Gets the value of the property4 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProperty4() { + return property4; + } + + /** + * Sets the value of the property4 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProperty4(String value) { + this.property4 = value; + } + + /** + * Gets the value of the property5 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProperty5() { + return property5; + } + + /** + * Sets the value of the property5 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProperty5(String value) { + this.property5 = value; + } + + /** + * Gets the value of the property6 property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getProperty6() { + return property6; + } + + /** + * Sets the value of the property6 property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setProperty6(String value) { + this.property6 = value; + } + + } + + } + + } + +} diff --git a/src/com/connor/renben/process/plm/message/DelReferenceDialog.java b/src/com/connor/renben/process/plm/message/DelReferenceDialog.java new file mode 100644 index 0000000..b55ebbf --- /dev/null +++ b/src/com/connor/renben/process/plm/message/DelReferenceDialog.java @@ -0,0 +1,622 @@ +package com.connor.renben.process.plm.message; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.awt.BorderLayout; +import java.awt.Window; +import java.io.File; +import java.io.FileInputStream; +import java.util.Locale; +import java.util.ResourceBundle; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.filechooser.FileSystemView; + +import org.apache.commons.collections.map.LinkedMap; +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 java.util.ArrayList; + +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.connor.renben.process.plm.util.TMomMethodUtil; +//import com.connor.rb.plm.util.SoaServerUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTask; +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.soa.client.model.ErrorStack; +import com.teamcenter.soa.client.model.ModelObject; + +import com.teamcenter.services.rac.core.DataManagementService; + +public class DelReferenceDialog extends AbstractAIFDialog { + StringBuilder logContent = new StringBuilder(); + + private String lineSeparator = System.lineSeparator();// з + private JButton importButton; + private JButton okButton; + private JButton celButton; + private JLabel selectUploadLabel; + private JComponent uploadInput; + private String[] RB3_Delete_Relation; + private TCSession session; + private AbstractAIFApplication app; + + public DelReferenceDialog(AbstractAIFApplication app, TCSession session, String[] RB3_Delete_Relation) + throws Exception { + this.session = session; + this.app = app; + this.RB3_Delete_Relation = RB3_Delete_Relation; + initUi(); + } + + public void initializationComponent() { + selectUploadLabel = new JLabel("ѡexcel:"); + uploadInput = new JTextField(14); + + importButton = new JButton("ѡ"); + okButton = new JButton("ȷ"); + celButton = new JButton("ȡ"); + + SwingUtilities.getWindowAncestor(importButton); + } + + /** + * ʼ + */ + public void initUi() { + initializationComponent(); + + JDialog dialog = new JDialog((JFrame) SwingUtilities.getWindowAncestor(importButton), "ϵ", true); + dialog.setLayout(null); + + // ǩ + selectUploadLabel.setBounds(30, 40, 150, 25); + dialog.add(selectUploadLabel); + + // + uploadInput.setBounds(180, 40, 220, 25); + dialog.add(uploadInput); + + // ѡť + importButton.setBounds(450, 40, 90, 25); + + importButton.addActionListener(e -> { + JFileChooser fileChooser = new JFileChooser(); + // ΪѡļĿ¼ + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setAcceptAllFileFilterUsed(false); // ʾ "ļ" ѡ + + // Ĭϴ򿪵ļΪ + File desktopDir = new File(System.getProperty("user.home"), "Desktop"); + fileChooser.setCurrentDirectory(desktopDir); + + int result = fileChooser.showOpenDialog(dialog); + if (result == JFileChooser.APPROVE_OPTION) { + ((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath()); + } + }); + dialog.add(importButton, BorderLayout.EAST); + + okButton.addActionListener(e -> { + Locale defaultLocale = Locale.getDefault(); + // ResourceBundle + // rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + String path = ((JTextField) uploadInput).getText(); + if (path.isEmpty()) { + JOptionPane.showMessageDialog(dialog, "ѡļϴ·"); + } else { + // ļǷΪĿ¼ + try { + File file = new File(path); + if (file.isFile() && file.getName().endsWith(".xlsx")) { + // ѡļ + System.out.println("ѡļǣ" + file.getAbsolutePath()); + // ȡEXCEL + FileInputStream fis = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(fis); + // ȡexcelĵ + // ҵһҳ + XSSFSheet sheet = wb.getSheetAt(0); + int rowIndex = 1;// ӵڶпʼ + + XSSFRow firstRow = sheet.getRow(0); + System.out.println("firstRow===========" + firstRow); + System.out.println("firstRow.getCell(0)===========" + firstRow.getCell(0)); + System.out.println("firstRow.getCell(1)===========" + firstRow.getCell(1)); + // if (firstRow == null || firstRow.getCell(0)==null || + // firstRow.getCell(1)==null || !firstRow.getCell(0).equals("ID") || + // !firstRow.getCell(1).equals("汾")) { + if (firstRow == null || firstRow.getCell(0) == null || firstRow.getCell(1) == null) { + + MessageBox.post("ѡȷexcel", "ʾ", MessageBox.INFORMATION); + return; + } + TMomMethodUtil.setByPass(session, true); + // SoaServerUtil.openByPass(session); + while (true) { + XSSFRow nextRow = sheet.getRow(rowIndex); + + // ѭж + if (nextRow == null || nextRow.getCell(0) == null + || nextRow.getCell(0).getCellType() == XSSFCell.CELL_TYPE_BLANK + || nextRow.getCell(1) == null + || nextRow.getCell(1).getCellType() == XSSFCell.CELL_TYPE_BLANK) { + break; + } + String id = nextRow.getCell(0).toString(); + String version = nextRow.getCell(1).toString(); + System.out.println(id + "->" + version); + logContent.append("==================:" + id + "->" + version + lineSeparator); + // Ӧ޸ID + try { + + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem item = itemType.find(id);// ͨidȡitem + String objectType = item.getStringProperty("object_type"); + TCComponentItemRevision itemRevisionFromItem = getItemRevisionFromItem(item, version); + if (itemRevisionFromItem == null) { + System.out.println("δҵӦ汾!"); + logContent.append("ID" + id + "δҵӦ汾" + version + lineSeparator); + } else { + TCComponent[] relatedComponents = itemRevisionFromItem.getRelatedComponents("release_status_list"); + if(relatedComponents.length > 0 && (relatedComponents[0].getProperty("name").equalsIgnoreCase("TCM Released") || relatedComponents[0].getProperty("name").equals("TCM ѷ"))) { + logContent.append("ID" + id + "Ӧ汾" + version +"ѷ"+ lineSeparator); + rowIndex++; + continue; + } + //rev.getRelatedComponents("release_status_list")[0].getProperty("name").equalsIgnoreCase("TCM Released") || rev.getRelatedComponents("release_status_list")[0].getProperty("name").equals("TCM ѷ") + //ѭbomɾ ʹ + TCComponent[] whereUsed = itemRevisionFromItem.whereUsed((short)0); + for (int j = 0; j < whereUsed.length; j++) { + + TCComponentType type = whereUsed[j].getTypeComponent(); + if(type instanceof TCComponentItemType) { + //жǷ񸸼 + TCComponentItem userItem = (TCComponentItem)whereUsed[j]; + String itemId = userItem.getStringProperty("item_id"); + if(itemId.equals(id)) { + continue; + } + }else if(type instanceof TCComponentItemRevisionType) { + TCComponentItemRevision userRevision = (TCComponentItemRevision)whereUsed[j]; + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine topLine = view.setWindowTopLine(userRevision.getItem(), userRevision, null, null); + String parentId = userRevision.getStringProperty("item_id"); + topLine.lock(); + AIFComponentContext[] childrens = topLine.getChildren(); + for (int k = 0; k < childrens.length; k++) { + InterfaceAIFComponent comp = childrens[k].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; + String bomItemId = line.getStringProperty("bl_item_item_id"); + if(bomItemId != null && bomItemId.equals(id)) { + topLine.remove("", line); + logContent.append("ID:"+id+"Ӧ汾"+version+""+parentId+"ʹùϵ"+ lineSeparator); + } + } + } + topLine.save(); + topLine.unlock(); + view.save(); + view.close(); + } + + } + + + System.out.println("objectType==="+objectType); + //߼ ȥ + if(objectType.equals("RB3_SSCKZJH") || objectType.equals("RB3_SCKZJH") || objectType.equals("RB3_ZYJZS") || objectType.equals("RB3_ZPGYK") || objectType.equals("RB3_ZYGYK") || objectType.equals("RB3_HZZCGYK") || objectType.equals("RB3_PFMEA")) { + + AIFComponentContext[] whereReferenced = item.whereReferenced(); + System.out.println("whereReferenced=============" + whereReferenced.length); + for (int z = 0; z < whereReferenced.length; z++) { + + InterfaceAIFComponent component = whereReferenced[z].getComponent(); + + // жǷ񸸼 ǰ汾 + if (component instanceof TCComponentItemRevision) { + TCComponentItemRevision referenceItemrevision = (TCComponentItemRevision) component; + + try { + TCComponent[] relationComponent = referenceItemrevision + .getTCProperty("IMAN_reference") + .getReferenceValueArray(); + System.out.println( + "relationComponent2==========" + relationComponent.length); + String refId = referenceItemrevision.getStringProperty("item_id"); + if (relationComponent != null && relationComponent.length > 0) { + referenceItemrevision.remove("IMAN_reference", + item); + logContent.append("ID:" + id + "Ӧ汾" + version + "" + + "ID:"+refId+"֮ IMAN_reference ϵ" + lineSeparator); + } + + } catch (Exception e2) { + // TODO: handle exception + + System.out.println("111111"); + } + + } + + + } + + } + + + + + AIFComponentContext[] whereReferenced = itemRevisionFromItem.whereReferenced(); + System.out.println("whereReferenced=============" + whereReferenced.length); + String revisionId = itemRevisionFromItem.getStringProperty("item_id"); + for (int z = 0; z < whereReferenced.length; z++) { + + InterfaceAIFComponent component = whereReferenced[z].getComponent(); + // жǷ񸸼 ǰ汾 + if (component instanceof TCComponentItem) { + System.out.println("----------TCComponentItem-----------"); + TCComponentItem referenceItem = (TCComponentItem) component; + String itemId = referenceItem.getStringProperty("item_id"); + if (itemId.equals(revisionId)) { + continue; + } + + for (int i = 0; i < RB3_Delete_Relation.length; i++) { + + System.out.println( + "RB3_Delete_Relation[i]=====" + RB3_Delete_Relation[i]); + + try { + TCComponent[] relationComponent = referenceItem + .getTCProperty(RB3_Delete_Relation[i]) + .getReferenceValueArray(); + System.out.println( + "relationComponent1==========" + relationComponent.length); + if (relationComponent != null && relationComponent.length > 0) { + referenceItem.remove(RB3_Delete_Relation[i], + itemRevisionFromItem); + logContent.append("ID:" + id + "Ӧ汾" + version + "" + + RB3_Delete_Relation[i] + "ϵ" + lineSeparator); + } + } catch (Exception e2) { + // TODO: handle exception + + System.out.println("111111"); + } + } + } + + // жǷ񸸼 ǰ汾 + if (component instanceof TCComponentItemRevision) { + TCComponentItemRevision referenceItemrevision = (TCComponentItemRevision) component; + System.out.println("----------TCComponentItemRevision-----------"); + for (int i = 0; i < RB3_Delete_Relation.length; i++) { + System.out.println( + "RB3_Delete_Relation[i]=====" + RB3_Delete_Relation[i]); + try { + TCComponent[] relationComponent = referenceItemrevision + .getTCProperty(RB3_Delete_Relation[i]) + .getReferenceValueArray(); + System.out.println( + "relationComponent2==========" + relationComponent.length); + if (relationComponent != null && relationComponent.length > 0) { + referenceItemrevision.remove(RB3_Delete_Relation[i], + itemRevisionFromItem); + logContent.append("ID:" + id + "Ӧ汾" + version + "" + + RB3_Delete_Relation[i] + "ϵ" + lineSeparator); + } + + } catch (Exception e2) { + // TODO: handle exception + + System.out.println("111111"); + } + } + } + + // жǷ񸸼 ǰ汾 + if (component instanceof TCComponentFolder) { + TCComponentFolder referenceFolder = (TCComponentFolder) component; + System.out.println("----------TCComponentFolder-----------"); + for (int i = 0; i < RB3_Delete_Relation.length; i++) { + + System.out.println( + "RB3_Delete_Relation[i]=====" + RB3_Delete_Relation[i]); + try { + TCComponent[] relationComponent = referenceFolder + .getTCProperty(RB3_Delete_Relation[i]) + .getReferenceValueArray(); + System.out.println( + "relationComponent3==========" + relationComponent.length); + if (relationComponent != null && relationComponent.length > 0) { + referenceFolder.remove(RB3_Delete_Relation[i], + itemRevisionFromItem); + logContent.append("ID:" + id + "Ӧ汾" + version + "" + + RB3_Delete_Relation[i] + "ϵ" + lineSeparator); + } + } catch (Exception e2) { + // TODO: handle exception + + System.out.println("111111"); + } + + } + } + + if (component instanceof TCComponentTask + || component.getType().equals("EPMTask")) { + TCComponentTask referenceTask = (TCComponentTask) component; + System.out.println("----------TCComponentTask-----------"); + + AIFComponentContext[] taskReferenced = referenceTask.whereReferenced(); + System.out.println("taskReferenced.length=============="+taskReferenced.length); + if(taskReferenced.length > 0) { + if(taskReferenced[0].getComponent().getType().equals("Job") || taskReferenced[0].getComponent().getType().equals("EPMJob")) { + ArrayList delList = new ArrayList(); + delList.add((TCComponentProcess)taskReferenced[0].getComponent()); + + DataManagementService service = DataManagementService.getService(session); + + TCComponent[] components = delList.toArray(new TCComponent[0]); + System.out.println("components============"+components.length); + + + ServiceData serviceData = service.deleteObjects(components); + if(serviceData.sizeOfPartialErrors() > 0){ + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + logContent.append("ʧ------------------->ID:"+id+"Ӧ汾"+version+""+referenceTask.getStringProperty("object_name")+"ʧ,鿴"+errInfo.toString()+ lineSeparator); + }else { + logContent.append("ID:"+id+"Ӧ汾"+version+""+referenceTask.getStringProperty("object_name")+""+ lineSeparator); + } + + + } + } + + + /* + * for (int i = 0; i < RB3_Delete_Relation.length; i++) { + * + * System.out.println("RB3_Delete_Relation[i]====="+RB3_Delete_Relation[i]); + * try { TCComponent[] relationComponent = + * referenceTask.getTCProperty(RB3_Delete_Relation[i]). + * getReferenceValueArray(); + * System.out.println("relationComponent4=========="+relationComponent. + * length); if(relationComponent != null && relationComponent.length > 0) { + * referenceTask.remove(RB3_Delete_Relation[i], itemRevisionFromItem); + * logContent.append("ID:"+id+"Ӧ汾"+version+""+RB3_Delete_Relation[i]+ + * "ϵ"+lineSeparator); } } catch (Exception e2) { // TODO: handle exception + * System.out.println("----------"+RB3_Delete_Relation[i]); + * e2.printStackTrace(); + * + * } + * + * + * ArrayList list = new ArrayList(); + * list.add(itemRevisionFromItem); + * referenceTask.removeAttachments(list.toArray(new TCComponent[0])); + * + * + * } + */ + } + } + String findType = itemRevisionFromItem.getType(); + if(findType.equals("MEProcessRevision")) { + TCComponent[] relationComponent = itemRevisionFromItem + .getTCProperty("IMAN_METarget") + .getReferenceValueArray(); + System.out.println( + "IMAN_METarget==========" + relationComponent.length); + if (relationComponent != null && relationComponent.length > 0) { + itemRevisionFromItem.remove("IMAN_METarget", + relationComponent); + logContent.append("ID:" + id + "Ӧ汾" + version + "IMAN_METarget ϵ" + lineSeparator); + } + + + + AIFComponentContext[] itemWhereReferenced = item.whereReferenced(); + System.out.println("itemWhereReferenced=============" + itemWhereReferenced.length); + for (int z = 0; z < itemWhereReferenced.length; z++) { + + InterfaceAIFComponent component = itemWhereReferenced[z].getComponent(); + // жǷ񸸼 ǰ汾 + if (component instanceof TCComponentItem) { + System.out.println("----------TCComponentItem-2----------"); + TCComponentItem referenceItem = (TCComponentItem) component; + String refId = referenceItem.getStringProperty("item_id"); + String refType = referenceItem.getType(); + System.out.println("refType========="+refType); + if (refType.equals("RB3_ZC")) { + referenceItem.remove("IMAN_reference", + item); + logContent.append("ID:"+refId+"" + id +"IMAN_reference ϵ" + lineSeparator); + } + + } + } + + } + + + /* + * if (serviceData.sizeOfPartialErrors() > 0) { for (int j = 0; j < + * serviceData.sizeOfPartialErrors(); j++) { ErrorStack partialError = + * serviceData.getPartialError(j); ModelObject associatedObject = + * partialError.getAssociatedObject(); } } + */ + } + } catch (Exception e1) { + e1.printStackTrace(); + // MessageBox.post("ID:"+version.toString()+rb.getString("zxtzbcz.TITLE"), "ʾ", + // MessageBox.INFORMATION); + /* + * MessageBox.post("ID:" + version.toString() + e1.getMessage(), "ʾ", + * MessageBox.INFORMATION); + */ + logContent.append("ʧ------------------->ID:" + version.toString() + e1.getMessage() + lineSeparator); + + } + + rowIndex++; + } + // SoaServerUtil.closeByPass(session); + // MessageBox.post(rb.getString("idxgcg.TITLE"), "ʾ", MessageBox.INFORMATION); + log(); + MessageBox.post("!", "ʾ", MessageBox.INFORMATION); + dialog.dispose(); + TMomMethodUtil.setByPass(session, false); + } else { + // MessageBox.post(rb.getString("qxzexcel.TITLE"), "ʾ", + // MessageBox.INFORMATION); + MessageBox.post("ѡȷļ!", "ʾ", MessageBox.INFORMATION); + } + + } catch (Exception e2) { + e2.printStackTrace(); + } + } + }); + celButton.addActionListener(e -> { + dialog.dispose(); + }); + + // ȷȡť + okButton.setBounds(180, 90, 100, 25); + celButton.setBounds(300, 90, 100, 25); + dialog.add(okButton); + dialog.add(celButton); + + // öԻСλ + dialog.pack(); + dialog.setSize(600, 190); + + // ȡ importButton ȴ + Window ancestor = SwingUtilities.getWindowAncestor(importButton); + if (ancestor instanceof JFrame) { + dialog.setLocationRelativeTo((JFrame) ancestor); + } else { + // Ȳ JFrameѡʾĻ + dialog.setLocationRelativeTo(null); + } + + dialog.setVisible(true); + } + + public TCComponentItemRevision getItemRevisionFromItem(TCComponentItem item, String rev) throws TCException { + if (item != null) { +// System.out.println("rev-----" + rev); + AIFComponentContext[] contexts = item.getChildren("revision_list"); + if (contexts != null && contexts.length > 0) { + for (int i = 0; i < contexts.length; i++) { + InterfaceAIFComponent component = contexts[i].getComponent(); + if (component instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) component; + if (revision.getProperty("item_revision_id").equals(rev)) { + return (TCComponentItemRevision) revision; + } + } + } + } + } + return null; + } + + public void log() { + // ļ·ļ + + File tempPath = FileSystemView.getFileSystemView().getHomeDirectory(); + String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); + String fileName = "DelRelation_" + timeStamp + ".txt"; + + + // ļж + File folder = new File("S:\\l\\tcLog"); + if (!folder.exists()) { + folder.mkdirs(); // ༶Ŀ¼ + } + + // ļ· + File logFile = new File(folder, fileName); + + // д־ļ + System.out.println("logContent.toString()1=="+logContent.toString()); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(logFile))) { + writer.write(logContent.toString()); + System.out.println("־ѳɹд뵽ļ1" + logFile.getAbsolutePath()); + } catch (IOException e) { + System.err.println("д־ļʱ"); + + // TODO: handle exception + // ļж + File folder2 = new File(tempPath.toString()+"\\tcLog"); + if (!folder2.exists()) { + folder2.mkdirs(); // ༶Ŀ¼ + } + + // ļ· + File logFile2 = new File(folder2, fileName); + System.out.println("logContent.toString()2=="+logContent.toString()); + // д־ļ + try (BufferedWriter writer = new BufferedWriter(new FileWriter(logFile2))) { + writer.write(logContent.toString()); + System.out.println("־ѳɹд뵽ļ2" + logFile2.getAbsolutePath()); + } catch (IOException e2) { + System.err.println("д־ļʱ"); + e2.printStackTrace(); + + + + + } + + } + } + +} diff --git a/src/com/connor/renben/process/plm/message/DelReferenceHandler.java b/src/com/connor/renben/process/plm/message/DelReferenceHandler.java new file mode 100644 index 0000000..685a0cb --- /dev/null +++ b/src/com/connor/renben/process/plm/message/DelReferenceHandler.java @@ -0,0 +1,44 @@ +package com.connor.renben.process.plm.message; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class DelReferenceHandler extends AbstractHandler{ + + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + final AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + final TCSession session = (TCSession) app.getSession(); + final String[] RB3_Delete_Relation = session.getPreferenceService().getStringValues("RB3_Delete_Relation"); + + if (RB3_Delete_Relation.length <= 0) { + MessageBox.post("ѡRB3_Delete_Relation", "ʾ", MessageBox.INFORMATION); + return null; + } + + try { + new Thread() { + @Override + public void run() { + try { + new DelReferenceDialog(app, session, RB3_Delete_Relation); + } catch (Exception e) { + e.printStackTrace(); + } + } + }.start(); + + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } +} \ No newline at end of file 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..79f928e --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message.properties @@ -0,0 +1,635 @@ +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 +wjbh_display.TITLE=Document Number +fbrq_display.TITLE=Release Date +pz_display.TITLE=Approve +sh_display.TITLE=Examine +bz_display.TITLE=Establishment +xgx_display.TITLE=Next process +cxqy_display.TITLE=Production line/area +bbh_display.TITLE=Version + +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! +qxzzcdxhcj021_display.TITLE=Please select the preferred RB3_CreatProcessTypes configuration type for creation +gy02_display.TITLE=Technology +qjcsjksxxutil_display.TITLE=Please check whether the database preferences are configured correctly +qxzgxbbhcd01_display.TITLE=Please select an operation version and transfer it! +wzdyfbdkzjh01_display.TITLE=No published control plan found! +myxqITEMdx02_display.TITLE=No ITEM object is selected. Please select it and perform this operation +qxzgxdxhcd02_display.TITLE=Please select an operation object and transfer it +qxzzcdxhcj02_display.TITLE=Please select the assembly object to create +dqzhwqxtjgx02_display.TITLE=The current account has no permission to add an operation! +qzjgglqz02_display.TITLE=Please select the process BOM in the structure management area and create it +qxzwjjhcj02_display.TITLE=Please select a folder to create +xzdxzmyyfbd03_display.TITLE=There are no latest released drawings in the selected objects! +nmyqxzxccz03_display.TITLE=You have no permission to perform this operation! Please contact the administrator +pldctzsb03_display.TITLE=Failed to batch export drawings! +qxzkzjhbbdx04_display.TITLE=Please select control plan version object! +wzdsxx04_display.TITLE=No preferences found! +kzjhzzbj04_display.TITLE=The control plan is being edited! (Checked Out) +wqxtjh04_display.TITLE=No permission to add rows! +sfscxzh04_display.TITLE=Delete the selected row? +wqxtjgx04_display.TITLE=No permission to add operation! +wqxsch04_display.TITLE=No permission to delete rows! +wqxhbdyg04_display.TITLE=No permission to merge cells! +wqxcfdyg04_display.TITLE=No permission to split cells! +yfb04_display.TITLE=Published, unable to save! +wzdkzjhmb04_display.TITLE=Control plan template not found! +kzjhbbyqc04_display.TITLE=Control plan version checked out +gxyqc04_display=Operation checked out +czsw04_display.TITLE=Operation error, please exit and re operate +qxzyhbddyg04_display.TITLE=Please select the cells to be merged! +qxzycfddyg04_display.TITLE=Please select the cell to split! +dcexcelcg04_display.TITLE=Excel export succeeded! +qsrzqdsz04_display.TITLE=Please enter the correct number! +qsrgcmc04_display.TITLE=Please enter the process name! +wxzdx05_display.TITLE=No object selected! +xzgyBOM05_display.TITLE=Please select the process BOM in the structure management area and create it +qxzgyBOMhcj05_display.TITLE=Please select the process BOM to create +znxzyggx05_display.TITLE=Only one operation can be selected! Please delete "Content in Component ID" and select again. +qxzgxdx05_display.TITLE=Please select an operation object! +gjmbcjgxcg05_display.TITLE=Successfully created an operation according to the template! +qxzgydx06_display.TITLE=Please select process object! +gjmbcjgycg06_display.TITLE=Successfully created the process according to the template! +gjmbcjgysb06_display.TITLE=Failed to create process according to template! +qxzgydx06_display.TITLE=Please select process object! +gjgycjgycg06_display.TITLE=Create process successfully according to process! +qxzcpdx06_display.TITLE=Please select a Assembly,Part,Roller,Steel ball,Standard Parts,Roller parts,Steel ball parts,Standard components object! +wzdzcdx06_display.TITLE=Assembly object not found! +cxdxcc06_display.TITLE=Error querying object! Please contact the system administrator! +qxzh06_display.TITLE=Please select a row! +qxzzqdgy06_display.TITLE=Please select the correct process! +gjgycjgysb06_display.TITLE=Failed to create process according to process! +xzgxBOM_display.TITLE=Please select the operation BOM in the structure management area and create it +qxzgxbomhcj07_display.TITLE=Please select an operation BOM and create it +zyzpcg07_display.TITLE=Resource assignment succeeded! +qxzPFMEAbbdx10_display.TITLE=Please select PFMEA version object! +PFMEAzzbj10_display.TITLE=PFMEA is editing! (Checked Out) +wqxsch10_display.TITLE=No permission to delete rows! +wqxtjh10_display.TITLE=No permission to add rows! +wqxhbh10_display.TITLE=No permission to merge rows! +wqxczh10_display.TITLE=No permission to operate rows! +wqxbc10_display.TITLE=No permission to save! +wqx10_display.TITLE=No permission! +wqxck10_display.TITLE=No permission to view! +wzdPFMEAmb10_display.TITLE=PFMEA template not found! +qxzyhbddyg10_display.TITLE=Please select the cells to be merged! +wqxhbdyg10_display.TITLE=No permission to merge cells +qxzycfddyg10_display.TITLE=Please select the cell to split! +qxzbbdx10_display.TITLE=Please select PFMEA version object, please re select! +txPFMEAsb10_display.TITLE=Failed to fill in PFNEA! +qxzdc11_display.TITLE=Please select the top BOM! +cxplcg11_display.TITLE=BOM rearrangement succeeded! +cxplczbhsb11_display.TITLE=Failed to rearrange BOM search number! +wglqx12_display.TITLE=No management permission! Please contact the system administrator. +txkzjhksb12_display.TITLE=Failed to fill in control plan library! +txPFMEAksb13_display.TITLE=Failed to fill in PFMEA library! +qxzbzgyzyzds17_display.TITLE=Please select the version object of the packaging process operation instruction! +wzdsxx17_display.TITLE=No preferences found! +bccg17_display.TITLE=Save successfully! +dccg17_display.TITLE=Export succeeded! +txbzgycw17_display.TITLE=Filling in packaging process error! +glcksb22_display.TITLE=Failed to manage thesaurus! +gwtdzzbbj27_display.TITLE=This order is being edited! +btxbnwk27_display.TITLE=Required item cannot be blank! +txwtdsb27_display.TITLE=Failed to fill in the entrustment form! +qxzwtdbb27_display.TITLE=Please select the order version! +zygykzzbj28_display.TITLE=Operation process card is being edited! (Checked Out) +wzdgy28_display.TITLE=Process not found! +qwskzjh28_display.TITLE=Please improve the number of the corresponding operation in the control plan, or the process card will not survive. +wfbj28_display.TITLE=The object has been published and cannot be edited! +wfbjbc28_display.TITLE=Object has been published, unable to edit and save! +wfcxdr28_display.TITLE=Object has been published, unable to re import! +cxdrhscxysj28_display.TITLE=Re import will delete the existing data and reload the control plan data. Please confirm whether to re import. +qxzljdc28_display.TITLE=The object has been published, please select a path to export! +wfxz28_display.TITLE=Object has been published and cannot be selected +yczdct28_display.TITLE=Export picture already exists, do you want to select again? +wftjh28_display.TITLE=The object has been published, unable to add rows! +wfych28_display.TITLE=Object has been published, row cannot be removed! +qxxzdct_display.TITLE=Please select the export picture first! +dzt28_display.TITLE=There are multiple export maps under this job card. +dcexcelcg28_display.TITLE=Excel export succeeded! +qsrzqdsz28_display.TITLE=Please enter the correct number! +srhs28_display.TITLE=The number of input lines cannot be less than 0 +wpzxydsxx28_display.TITLE=No preferences configured +wzdtk28_display.TITLE=No gallery found +wxzzygykbbdx28_display.TITLE=ZYGYKRevision object is not selected, please select again! +txzygyksb28_display.TITLE=Failed to fill in the operation process card! +qxzzygykbb28_display.TITLE=Please select the version of operation process card! +zzbj29_display.TITLE=Editing! (Checked Out) +wzdgy29_display.TITLE=Process not found +wxzzpgyk29_display.TITLE=ZPGYKRevision object is not selected, please select again! +txsb29_display.TITLE=Failed to fill in the assembly process card! +qxzbb29_display.TITLE=Please select the assembly process card version! +wzdgx30_display.TITLE=Operation not found! +wxzzyjzs30_display.TITLE=ZYJZSRevision object is not selected, please select again! +txzyjzssb30_display.TITLE=Failed to fill in the operation benchmark book! +bb30_display.TITLE=Please select the version of the Operation Benchmark! +dcsb33_display.TITLE=Failed to export job benchmark! +sb32_display.TITLE=Failed to export assembly process card! +sb31_display.TITLE=Failed to export job process card! +dclj34_display.TITLE=Please select the export path first +qxzbzbb34_display.TITLE=Please select the packaging version object, please re select! +bjsb34_display.TITLE=Failed to edit packaging scheme! +bb34_display.TITLE=Please select the packaging scheme version! +zzbj40_display.TITLE=This order is being edited! +btxbnwk40_display.TITLE=Required item cannot be blank! +sb40_display.TITLE=Failed to fill in the entrustment form! +bb40_display.TITLE=Please select the calculation and analysis commission document version! +wdsc41_display.TITLE=Please select Word, PDF, Excel and Text documents to upload! +sccg41_display.TITLE=Upload succeeded! +dclj42_display.TITLE=Please select the export path +dycg42_display.TITLE=Printing succeeded! +qxzdx42_display.TITLE=Please select an object +dcqdsb42_display.TITLE=Failed to export the list! +bb42_display.TITLE=Please select the process version! +sjjutil_display.TITLE=Dataset has no named and referenced files or there are too many files, please check! +drexcel_display.TITLE=ImportExcel +pmidnotsame.TITLE=PFMEA ID number is inconsistent +excel_display.TITLE=Excel import failed, please check if the format meets the requirements +_display.TITLE= +tmommethod01=Export Template Selection +tmommethod02=Chinese +tmommethod03=English +tmommethod04=Please choose to export Chinese/English templates: +tmommethod05=Operation cancelled + +issue=Issue +historyChangeAuthorization=History/Change Authorization (if applicable) +processItemSystem=1. Process Item System, Subsystem, Component Element or Process Name +processStepWorkstation=2. Process Step Workstation Number and Focus Element Name +processWorkElement4M=3. Process Work Element 4M Method +processItemFunction=1. Function of Process Item System, Subsystem, Component Element or Process +processStepFunction=2. Function of Process Step and Product Characteristics (optional) +processWorkElementFunction=3. Function of Process Work Element and Process Characteristics +failureEffectHigherLevel=1. Failure Effect (FE) on Higher-level or End User +severityFailureEffect=Severity (S) of Failure Effect +failureModeFocusElement=2. Failure Mode (FM) of Focus Element +failureCauseWorkElement=3. Failure Cause (FC) of Work Element +preventiveControlFailureCause=Current Preventive Control (PC) for Failure Cause +occurrenceFailureCause=Occurrence (O) of Failure Cause +detectionControlFailureCause=Current Detection Control (DC) for Failure Cause or Failure Mode +detectabilityFailureCause=Detection (D) of Failure Cause/Failure Mode +pfmeaActionPriority=PFMEA Action Priority +productCharacteristics=Product Characteristics +filterCode=Filter Code (optional) +preventiveMeasures=Preventive Measures +detectionMeasures=Detection Measures +responsiblePersonName=Responsible Person Name +targetCompletionDate=Target Completion Date +status=Status +evidenceBasedActionsTaken=Evidence-based Actions Taken +completionDate=Completion Date +severityValue=Severity (S) +occurrenceValue=Occurrence (O) +detectabilityValue=Detection (D) +parentNodeID=Parent Node ID +lookupNumber=Lookup Number +plmid=PLMID +serialNumber=Serial Number +date=Date +chapter=Chapter +revisionReason=Revision Reason +revisionContent=Revision Content +revisedVersion=Revised Version +revisedBy=Revised By +approvedBy=Approved By +name=Name +remark=notes + 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..93524b1 --- /dev/null +++ b/src/com/connor/renben/process/plm/message/Message_zh_CN.properties @@ -0,0 +1,644 @@ +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 +hzzcgykdc_display.TITLE=\u56DE\u8F6C\u652F\u627F\u5DE5\u827A\u5361\u5BFC\u51FA +hzzcgyk_display.TITLE=\u56DE\u8F6C\u652F\u627F\u5DE5\u827A\u5361 +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=\u4FDD\u5BC6\u7EA7\u522B +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 +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=\u4ea7\u54c1\u578b\u53f7 +sbxh28_display.TITLE=\u8bbe\u5907\u578b\u53f7 +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=\u4ea7\u54c1\u578b\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 +wjbh_display.TITLE=\u6587\u4ef6\u7f16\u53f7 +bbh_display.TITLE=\u7248\u672c\u53f7 +cxqy_display.TITLE=\u4ea7\u7ebf/\u533a\u57df +xgx_display.TITLE=\u4e0b\u5de5\u5e8f +bz_display.TITLE=\u7F16\u5236 +sh_display.TITLE=\u5BA1\u6838 +pz_display.TITLE=\u6279\u51C6 +fbrq_display.TITLE=\u53D1\u5E03\u65E5\u671F + + + + +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 + + +excel_display.TITLE = excel\u5bfc\u5165\u5931\u8d25\uff0c\u6e05\u67e5\u770b\u683c\u5f0f\u662f\u5426\u7b26\u5408\u8981\u6c42 +wxzcpdxqcxxz02_display.TITLE=\u672A\u9009\u4E2D\u4EA7\u54C1\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +qxzzcdxhcj021_display.TITLE=\u8bf7\u9009\u62e9\u9996\u9009\u9879RB3_CreateProcessTypes\u914d\u7f6e\u7684\u7c7b\u578b\u8fdb\u884c\u521b\u5efa +gy02_display.TITLE=\u5DE5\u827A +qjcsjksxxutil_display.TITLE=\u8BF7\u68C0\u67E5\u6570\u636E\u5E93\u9996\u9009\u9879\u662F\u5426\u914D\u7F6E\u6B63\u786E +qxzgxbbhcd01_display.TITLE=\u8BF7\u9009\u62E9\u5DE5\u5E8F\u7248\u672C\u540E\u4F20\u9012\uFF01 +wzdyfbdkzjh01_display.TITLE=\u672A\u627E\u5230\u5DF2\u53D1\u5E03\u7684\u63A7\u5236\u8BA1\u5212\uFF01 +myxqITEMdx02_display.TITLE=\u6CA1\u6709\u9009\u53D6ITEM\u5BF9\u8C61\uFF0C\u8BF7\u9009\u62E9\u540E\u6267\u884C\u6B64\u64CD\u4F5C +qxzgxdxhcd02_display.TITLE=\u8BF7\u9009\u62E9\u5DE5\u5E8F\u5BF9\u8C61\u540E\u4F20\u9012 +qxzzcdxhcj02_display.TITLE=\u8BF7\u9009\u62E9\u603B\u6210\u5BF9\u8C61\u540E\u521B\u5EFA +dqzhwqxtjgx02_display.TITLE=\u5F53\u524D\u8D26\u6237\u65E0\u6743\u9650\u6DFB\u52A0\u5DE5\u5E8F\uFF01 +qzjgglqz02_display.TITLE=\u8BF7\u5728\u7ED3\u6784\u7BA1\u7406\u533A\u4E2D\u9009\u4E2D\u5DE5\u827ABOM\u540E\u521B\u5EFA +qxzwjjhcj02_display.TITLE=\u8BF7\u9009\u4E2D\u6587\u4EF6\u5939\u540E\u521B\u5EFA +xzdxzmyyfbd03_display.TITLE=\u9009\u4E2D\u5BF9\u8C61\u4E2D\u6CA1\u6709\u5DF2\u53D1\u5E03\u7684\u6700\u65B0\u7248\u672C\u7684\u56FE\u7EB8\uFF01 +nmyqxzxccz03_display.TITLE=\u4F60\u6CA1\u6709\u6743\u9650\u6267\u884C\u6B64\u64CD\u4F5C\uFF01\u8BF7\u8054\u7CFB\u7BA1\u7406\u5458 +pldctzsb03_display.TITLE=\u6279\u91CF\u5BFC\u51FA\u56FE\u7EB8\u5931\u8D25\uFF01 +qxzkzjhbbdx04_display.TITLE=\u8BF7\u9009\u62E9\u63A7\u5236\u8BA1\u5212\u7248\u672C\u5BF9\u8C61\uFF01 +wzdsxx04_display.TITLE=\u672A\u627E\u9996\u9009\u9879\uFF01 +kzjhzzbj04_display.TITLE=\u63A7\u5236\u8BA1\u5212\u6B63\u5728\u7F16\u8F91\uFF01(\u5DF2\u7B7E\u51FA) +wqxtjh04_display.TITLE=\u65E0\u6743\u9650\u6DFB\u52A0\u884C\uFF01 +sfscxzh04_display.TITLE=\u662F\u5426\u5220\u9664\u9009\u4E2D\u884C\uFF1F +wqxtjgx04_display.TITLE=\u65E0\u6743\u9650\u6DFB\u52A0\u5DE5\u5E8F\uFF01 +wqxsch04_display.TITLE=\u65E0\u6743\u9650\u5220\u9664\u884C\uFF01 +wqxhbdyg04_display.TITLE=\u65E0\u6743\u9650\u5408\u5E76\u5355\u5143\u683C\uFF01 +wqxcfdyg04_display.TITLE=\u65E0\u6743\u9650\u62C6\u5206\u5355\u5143\u683C\uFF01 +yfb04_display.TITLE=\u5DF2\u53D1\u5E03\uFF0C\u65E0\u6CD5\u4FDD\u5B58\uFF01 +wzdkzjhmb04_display.TITLE=\u672A\u627E\u5230\u63A7\u5236\u8BA1\u5212\u6A21\u677F\uFF01 +kzjhbbyqc04_display.TITLE=\u63A7\u5236\u8BA1\u5212\u7248\u672C\u5DF2\u7B7E\u51FA +gxyqc04_display.TITLE=\u5DE5\u5E8F\u5DF2\u7B7E\u51FA +czsw04_display.TITLE=\u64CD\u4F5C\u5931\u8BEF\uFF0C\u8BF7\u9000\u51FA\u91CD\u65B0\u64CD\u4F5C +qxzyhbddyg04_display.TITLE=\u8BF7\u9009\u62E9\u8981\u5408\u5E76\u7684\u5355\u5143\u683C\uFF01 +qxzycfddyg04_display.TITLE=\u8BF7\u9009\u62E9\u8981\u62C6\u5206\u7684\u5355\u5143\u683C\uFF01 +dcexcelcg04_display.TITLE=\u5BFC\u51FAExcel\u6210\u529F\uFF01 +qsrzqdsz04_display.TITLE=\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u6570\u5B57! +qsrgcmc04_display.TITLE=\u8BF7\u8F93\u5165\u8FC7\u7A0B\u540D\u79F0! +wxzdx05_display.TITLE=\u672A\u9009\u4E2D\u5BF9\u8C61! +xzgyBOM05_display.TITLE=\u8BF7\u5728\u7ED3\u6784\u7BA1\u7406\u533A\u4E2D\u9009\u4E2D\u5DE5\u827ABOM\u540E\u521B\u5EFA +qxzgyBOMhcj05_display.TITLE=\u8BF7\u9009\u4E2D\u5DE5\u827ABOM\u540E\u521B\u5EFA +znxzyggx05_display.TITLE=\u53EA\u80FD\u9009\u62E9\u4E00\u4E2A\u5DE5\u5E8F\uFF01\u8BF7\u5220\u9664\u201C\u7EC4\u4EF6ID\u4E2D\u5185\u5BB9\u201D\u91CD\u65B0\u9009\u62E9\u3002 +qxzgxdx05_display.TITLE=\u8BF7\u9009\u62E9\u5DE5\u5E8F\u5BF9\u8C61\uFF01 +gjmbcjgxcg05_display.TITLE=\u6839\u636E\u6A21\u677F\u521B\u5EFA\u5DE5\u5E8F\u6210\u529F\uFF01 +qxzgydx06_display.TITLE=\u8BF7\u9009\u62E9\u5DE5\u827A\u5BF9\u8C61\uFF01 +gjmbcjgycg06_display.TITLE=\u6839\u636E\u6A21\u677F\u521B\u5EFA\u5DE5\u827A\u6210\u529F\uFF01 +gjmbcjgysb06_display.TITLE=\u6839\u636E\u6A21\u677F\u521B\u5EFA\u5DE5\u827A\u5931\u8D25\uFF01 +qxzgydx06_display.TITLE=\u8BF7\u9009\u62E9\u5DE5\u827A\u5BF9\u8C61\uFF01 +gjgycjgycg06_display.TITLE=\u6839\u636E\u5DE5\u827A\u521B\u5EFA\u5DE5\u827A\u6210\u529F\uFF01 +qxzcpdx06_display.TITLE=\u8bf7\u9009\u62e9\u603b\u6210,\u96f6\u90e8\u4ef6,\u6eda\u5b50,\u94a2\u7403,\u6807\u51c6\u4ef6,\u6eda\u5b50\u90e8\u4ef6,\u94a2\u7403\u90e8\u4ef6,\u6807\u51c6\u4ef6\u90e8\u4ef6\u5bf9\u8c61\uff01 +wzdzcdx06_display.TITLE=\u672A\u627E\u5230\u603B\u6210\u5BF9\u8C61\uFF01 +cxdxcc06_display.TITLE=\u67E5\u8BE2\u5BF9\u8C61\u51FA\u9519\uFF01\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\uFF01 +qxzh06_display.TITLE=\u8BF7\u9009\u62E9\u884C\uFF01 +qxzzqdgy06_display.TITLE=\u8BF7\u9009\u62E9\u6B63\u786E\u7684\u5DE5\u827A\uFF01 +gjgycjgysb06_display.TITLE=\u6839\u636E\u5DE5\u827A\u521B\u5EFA\u5DE5\u827A\u5931\u8D25\uFF01 +xzgxBOM_display.TITLE=\u8BF7\u5728\u7ED3\u6784\u7BA1\u7406\u533A\u4E2D\u9009\u4E2D\u5DE5\u5E8FBOM\u540E\u521B\u5EFA +qxzgxbomhcj07_display.TITLE=\u8BF7\u9009\u4E2D\u5DE5\u5E8FBOM\u540E\u521B\u5EFA +zyzpcg07_display.TITLE=\u8D44\u6E90\u6307\u6D3E\u6210\u529F\uFF01 +qxzPFMEAbbdx10_display.TITLE=\u8BF7\u9009\u62E9PFMEA\u7248\u672C\u5BF9\u8C61\uFF01 +PFMEAzzbj10_display.TITLE=PFMEA\u6B63\u5728\u7F16\u8F91\uFF01(\u5DF2\u7B7E\u51FA) +wqxsch10_display.TITLE=\u65E0\u6743\u9650\u5220\u9664\u884C\uFF01 +wqxtjh10_display.TITLE=\u65E0\u6743\u9650\u6DFB\u52A0\u884C\uFF01 +wqxhbh10_display.TITLE=\u65E0\u6743\u9650\u5408\u5E76\u884C\uFF01 +wqxczh10_display.TITLE=\u65E0\u6743\u9650\u64CD\u4F5C\u884C\uFF01 +wqxbc10_display.TITLE=\u65E0\u6743\u9650\u4FDD\u5B58\uFF01 +wqx10_display.TITLE=\u65E0\u6743\u9650\uFF01 +wqxck10_display.TITLE=\u65E0\u6743\u9650\u67E5\u770B\uFF01 +wzdPFMEAmb10_display.TITLE=\u672A\u627E\u5230PFMEA\u6A21\u677F\uFF01 +qxzyhbddyg10_display.TITLE=\u8BF7\u9009\u62E9\u8981\u5408\u5E76\u7684\u5355\u5143\u683C\uFF01 +wqxhbdyg10_display.TITLE=\u65E0\u6743\u9650\u5408\u5E76\u5355\u5143\u683C +qxzycfddyg10_display.TITLE=\u8BF7\u9009\u62E9\u8981\u62C6\u5206\u7684\u5355\u5143\u683C\uFF01 +qxzbbdx10_display.TITLE=\u8BF7\u9009\u4E2DPFMEA\u7248\u672C\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +txPFMEAsb10_display.TITLE=\u586B\u5199PFNEA\u5931\u8D25\uFF01 +qxzdc11_display.TITLE=\u8BF7\u9009\u62E9\u9876\u5C42BOM\uFF01 +cxplcg11_display.TITLE=\u91CD\u65B0\u6392\u5217BOM\u6210\u529F\uFF01 +cxplczbhsb11_display.TITLE=\u91CD\u65B0\u6392\u5217BOM\u67E5\u627E\u7F16\u53F7\u5931\u8D25\uFF01 +wglqx12_display.TITLE=\u65E0\u7BA1\u7406\u6743\u9650\uFF01\u8BF7\u8054\u7CFB\u7CFB\u7EDF\u7BA1\u7406\u5458\u3002 +txkzjhksb12_display.TITLE=\u586B\u5199\u63A7\u5236\u8BA1\u5212\u5E93\u5931\u8D25\uFF01 +txPFMEAksb13_display.TITLE=\u586B\u5199PFMEA\u5E93\u5931\u8D25\uFF01 +qxzbzgyzyzds17_display.TITLE=\u8BF7\u9009\u62E9\u5305\u88C5\u5DE5\u827A\u4F5C\u4E1A\u6307\u5BFC\u4E66\u7248\u672C\u5BF9\u8C61! +wzdsxx17_display.TITLE=\u672A\u627E\u9996\u9009\u9879\uFF01 +bccg17_display.TITLE=\u4FDD\u5B58\u6210\u529F\uFF01 +dccg17_display.TITLE=\u5BFC\u51FA\u6210\u529F\uFF01 +txbzgycw17_display.TITLE=\u586B\u5199\u5305\u88C5\u5DE5\u827A\u9519\u8BEF\uFF01 +glcksb22_display.TITLE=\u7BA1\u7406\u8BCD\u5E93\u5931\u8D25\uFF01 +gwtdzzbbj27_display.TITLE=\u8BE5\u59D4\u6258\u5355\u6B63\u5728\u88AB\u7F16\u8F91\uFF01 +btxbnwk27_display.TITLE=\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A\uFF01 +txwtdsb27_display.TITLE=\u586B\u5199\u59D4\u6258\u5355\u5931\u8D25\uFF01 +qxzwtdbb27_display.TITLE=\u8BF7\u9009\u4E2D\u59D4\u6258\u5355\u7248\u672C\uFF01 +zygykzzbj28_display.TITLE=\u4F5C\u4E1A\u5DE5\u827A\u5361\u6B63\u5728\u7F16\u8F91\uFF01(\u5DF2\u7B7E\u51FA) +wzdgy28_display.TITLE=\u672A\u627E\u5230\u5DE5\u827A\uFF01 +qwskzjh28_display.TITLE=\u8BF7\u5B8C\u5584\u63A7\u5236\u8BA1\u5212\u4E2D\u76F8\u5E94\u5DE5\u5E8F\u7684\u7F16\u53F7\uFF0C\u5426\u5219\u65E0\u6CD5\u751F\u6210\u5DE5\u827A\u5361\u3002 +wfbj28_display.TITLE=\u5BF9\u8C61\u5DF2\u53D1\u5E03\uFF0C\u65E0\u6CD5\u7F16\u8F91\uFF01 +wfbjbc28_display.TITLE=\u5BF9\u8C61\u5DF2\u53D1\u5E03\uFF0C\u65E0\u6CD5\u7F16\u8F91\u4FDD\u5B58\uFF01 +wfcxdr28_display.TITLE=\u5BF9\u8C61\u5DF2\u53D1\u5E03\uFF0C\u65E0\u6CD5\u91CD\u65B0\u5BFC\u5165\uFF01 +cxdrhscxysj28_display.TITLE=\u91CD\u65B0\u5BFC\u5165\u4F1A\u5220\u9664\u73B0\u6709\u6570\u636E\uFF0C\u91CD\u65B0\u52A0\u8F7D\u63A7\u5236\u8BA1\u5212\u6570\u636E\uFF0C\u8BF7\u786E\u5B9A\u662F\u5426\u91CD\u65B0\u5BFC\u5165\u3002 +qxzljdc28_display.TITLE=\u5BF9\u8C61\u5DF2\u53D1\u5E03\uFF0C\u8BF7\u9009\u62E9\u8DEF\u5F84\u5BFC\u51FA\uFF01 +wfxz28_display.TITLE=\u5BF9\u8C61\u5DF2\u53D1\u5E03\uFF0C\u65E0\u6CD5\u9009\u62E9 +yczdct28_display.TITLE=\u5DF2\u5B58\u5728\u5BFC\u51FA\u56FE\uFF0C\u662F\u5426\u91CD\u65B0\u9009\u62E9\uFF1F +wftjh28_display.TITLE=\u5BF9\u8C61\u5DF2\u53D1\u5E03\uFF0C\u65E0\u6CD5\u6DFB\u52A0\u884C\uFF01 +wfych28_display.TITLE=\u5BF9\u8C61\u5DF2\u53D1\u5E03\uFF0C\u65E0\u6CD5\u79FB\u9664\u884C\uFF01 +qxxzdct_display.TITLE=\u8BF7\u5148\u9009\u62E9\u5BFC\u51FA\u56FE\uFF01 +dzt28_display.TITLE=\u8BE5\u5DE5\u4F5C\u5361\u4E0B\u5B58\u5728\u591A\u5F20\u5BFC\u51FA\u56FE\u3002 +dcexcelcg28_display.TITLE=\u5BFC\u51FAExcel\u6210\u529F\uFF01 +qsrzqdsz28_display.TITLE=\u8BF7\u8F93\u5165\u6B63\u786E\u7684\u6570\u5B57! +srhs28_display.TITLE=\u8F93\u5165\u884C\u6570\u4E0D\u80FD\u5C0F\u4E8E0 +wpzxydsxx28_display.TITLE=\u672A\u914D\u7F6E\u76F8\u5E94\u9996\u9009\u9879 +wzdtk28_display.TITLE=\u672A\u627E\u5230\u56FE\u5E93 +wxzzygykbbdx28_display.TITLE=\u672A\u9009\u4E2D\u4F5C\u4E1A\u5DE5\u827A\u5361\u7248\u672C\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +wxzzcgykbbdx28_display.TITLE=\u672A\u9009\u4E2D\u56DE\u8F6C\u652F\u627F\u5DE5\u827A\u5361\u7248\u672C\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +txzygyksb28_display.TITLE=\u586B\u5199\u4F5C\u4E1A\u5DE5\u827A\u5361\u5931\u8D25\uFF01 +txhzzcgyksb28_display.TITLE=\u586B\u5199\u56DE\u8F6C\u652F\u627F\u5DE5\u827A\u5361\u5931\u8D25\uFF01 +qxzzygykbb28_display.TITLE=\u8BF7\u9009\u4E2D\u4F5C\u4E1A\u5DE5\u827A\u5361\u7248\u672C\uFF01 +qxzhzzcgykbb28_display.TITLE=\u8BF7\u9009\u4E2D\u56DE\u8F6C\u652F\u627F\u5DE5\u827A\u5361\u7248\u672C\uFF01 +zzbj29_display.TITLE=\u6B63\u5728\u7F16\u8F91\uFF01(\u5DF2\u7B7E\u51FA) +wzdgy29_display.TITLE=\u672A\u627E\u5230\u5DE5\u827A\uFF01 +wxzzpgyk29_display.TITLE=\u672A\u9009\u4E2D\u88C5\u914D\u5DE5\u827A\u5361\u7248\u672C\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +txsb29_display.TITLE=\u586B\u5199\u88C5\u914D\u5DE5\u827A\u5361\u5931\u8D25\uFF01 +qxzbb29_display.TITLE=\u8BF7\u9009\u4E2D\u88C5\u914D\u5DE5\u827A\u5361\u7248\u672C\uFF01 +wzdgx30_display.TITLE=\u672A\u627E\u5230\u5DE5\u5E8F\uFF01 +wxzzyjzs30_display.TITLE=\u672A\u9009\u4E2D\u4F5C\u4E1A\u57FA\u51C6\u4E66\u7248\u672C\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +txzyjzssb30_display.TITLE=\u586B\u5199\u4F5C\u4E1A\u57FA\u51C6\u4E66\u5931\u8D25\uFF01 +bb30_display.TITLE=\u8BF7\u9009\u4E2D\u4F5C\u4E1A\u57FA\u51C6\u4E66\u7248\u672C\uFF01 +dcsb33_display.TITLE=\u5BFC\u51FA\u4F5C\u4E1A\u57FA\u51C6\u4E66\u5931\u8D25\uFF01 +sb32_display.TITLE=\u5BFC\u51FA\u88C5\u914D\u5DE5\u827A\u5361\u5931\u8D25\uFF01 +sb31_display.TITLE=\u5BFC\u51FA\u4F5C\u4E1A\u5DE5\u827A\u5361\u5931\u8D25\uFF01 +dclj34_display.TITLE=\u8BF7\u5148\u9009\u62E9\u5BFC\u51FA\u8DEF\u5F84 +qxzbzbb34_display.TITLE=\u8BF7\u9009\u4E2D\u5305\u88C5\u7248\u672C\u5BF9\u8C61\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\uFF01 +bjsb34_display.TITLE=\u7F16\u8F91\u5305\u88C5\u65B9\u6848\u5931\u8D25\uFF01 +bb34_display.TITLE=\u8BF7\u9009\u4E2D\u5305\u88C5\u65B9\u6848\u7248\u672C\uFF01 +zzbj40_display.TITLE=\u8BE5\u59D4\u6258\u5355\u6B63\u5728\u88AB\u7F16\u8F91\uFF01 +btxbnwk40_display.TITLE=\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A\uFF01 +sb40_display.TITLE=\u586B\u5199\u59D4\u6258\u5355\u5931\u8D25\uFF01 +bb40_display.TITLE=\u8BF7\u9009\u4E2D\u8BA1\u7B97\u5206\u6790\u59D4\u6258\u5355\u7248\u672C\uFF01 +wdsc41_display.TITLE=\u8BF7\u9009\u62E9Word\u3001PDF\u3001Excel\u3001Text\u7C7B\u578B\u7684\u6587\u6863\u4E0A\u4F20\uFF01 +sccg41_display.TITLE=\u4E0A\u4F20\u6210\u529F! +dclj42_display.TITLE=\u8BF7\u9009\u62E9\u5BFC\u51FA\u8DEF\u5F84 +dycg42_display.TITLE=\u6253\u5370\u6210\u529F! +qxzdx42_display.TITLE=\u8BF7\u9009\u4E2D\u5BF9\u8C61 +dcqdsb42_display.TITLE=\u5BFC\u51FA\u6E05\u5355\u5931\u8D25\uFF01 +bb42_display.TITLE=\u8BF7\u9009\u4E2D\u5DE5\u827A\u7248\u672C\uFF01 +sjjutil_display.TITLE=\u6570\u636E\u96C6\u6CA1\u6709\u547D\u540D\u5F15\u7528\u7684\u6587\u4EF6\u6216\u6587\u4EF6\u8FC7\u591A\uFF0C\u8BF7\u68C0\u67E5\uFF01 +drexcel_display.TITLE=\u5bfc\u5165\u0065\u0078\u0063\u0065\u006c +pmidnotsame.TITLE=\u0050\u0046\u004d\u0045\u0041\u0020\u0049\u0044\u7f16\u53f7\u4e0d\u4e00\u81f4 +_display.TITLE= +tmommethod01=\u5bfc\u51fa\u6a21\u677f\u9009\u62e9 +tmommethod02=\u4e2d\u6587 +tmommethod03=\u82f1\u6587 +tmommethod04=\u8bf7\u9009\u62e9\u5bfc\u51fa\u4e2d\u6587/\u82f1\u6587\u6a21\u677f: +tmommethod05=\u64cd\u4f5c\u5df2\u53d6\u6d88 + +issue=\u95ee\u9898 +historyChangeAuthorization=\u5386\u53f2/\u53d8\u66f4\u6388\u6743(\u9002\u7528\u65f6) +processItemSystem=1. \u8fc7\u7a0b\u9879\u7cfb\u7edf\u3001\u5b50\u7cfb\u7edf\u3001\u96f6\u4ef6\u8981\u7d20\u6216\u8fc7\u7a0b\u540d\u79f0 +processStepWorkstation=2. \u8fc7\u7a0b\u6b65\u9aa4\u5de5\u4f4d\u7f16\u53f7\u548c\u5173\u6ce8\u8981\u7d20\u540d\u79f0 +processWorkElement4M=3. \u8fc7\u7a0b\u5de5\u4f5c\u8981\u7d204M\u6cd5 +processItemFunction=1.\u8fc7\u7a0b\u9879\u7684\u529f\u80fd\u7cfb\u7edf\u3001\u5b50\u7cfb\u7edf\u3001\u7ec4\u4ef6\u8981\u7d20\u6216\u8fc7\u7a0b\u7684\u529f\u80fd +processStepFunction=2.\u8fc7\u7a0b\u6b65\u9aa4\u7684\u529f\u80fd\u548c\u4ea7\u54c1\u7279\u6027(\u91cf\u503c\u4e3a\u53ef\u9009\u9879) +processWorkElementFunction=3.\u8fc7\u7a0b\u5de5\u4f5c\u8981\u7d20\u7684\u529f\u80fd\u548c\u8fc7\u7a0b\u7279\u6027 +failureEffectHigherLevel=1.\u5bf9\u4e0a\u4e00\u8f83\u9ad8\u7ea7\u522b\u8981\u548c/\u6216\u7ec8\u7aef\u7528\u6237\u5931\u6548\u5f71\u54cd(FE) +severityFailureEffect=\u5931\u6548\u5f71\u54cd\u7684\u4e25\u91cd\u5ea6(S) +failureModeFocusElement=2.\u5173\u6ce8\u8981\u7d20\u7684\u5931\u6548\u6a21\u5f0f(FM) +failureCauseWorkElement=3.\u5de5\u4f5c\u8981\u7d20\u7684\u5931\u6548\u8d77\u56e0(FC) +preventiveControlFailureCause=\u5bf9\u5931\u6548\u8d77\u56e0\u7684\u5f53\u524d\u9884\u9632\u63a7\u5236(PC) +occurrenceFailureCause=\u5931\u6548\u8d77\u56e0\u7684\u9891\u5ea6(O) +detectionControlFailureCause=\u5bf9\u5931\u6548\u8d77\u56e0\u6216\u5931\u6548\u6a21\u5f0f\u7684\u5f53\u524d\u63a2\u6d4b\u63a7\u5236(DC) +detectabilityFailureCause=\u5931\u6548\u8d77\u56e0/\u5931\u6548\u6a21\u5f0f\u7684\u53ef\u63a2\u6d4b\u5ea6(D) +pfmeaActionPriority=PFMEA\u63aa\u65bd\u4f18\u5148\u7ea7 +productCharacteristics=\u4ea7\u54c1\u7279\u6027 +filterCode=\u7b5b\u9009\u5668\u4ee3\u7801(\u53ef\u9009) +preventiveMeasures=\u9884\u9632\u63aa\u65bd +detectionMeasures=\u63a2\u6d4b\u63aa\u65bd +responsiblePersonName=\u8d1f\u8d23\u4eba\u59d3\u540d +targetCompletionDate=\u76ee\u6807\u5b8c\u6210\u65e5\u671f +status=\u72b6\u6001 +evidenceBasedActionsTaken=\u91c7\u53d6\u57fa\u4e8e\u8bc1\u636e\u7684\u63aa\u65bd +completionDate=\u5b8c\u6210\u65e5\u671f +severityValue=\u4e25\u91cd\u5ea6(S) +occurrenceValue=\u9891\u5ea6(O) +detectabilityValue=\u53ef\u63a2\u6d4b\u5ea6(D) +parentNodeID=\u7236\u8282\u70b9ID +lookupNumber=\u67e5\u627e\u7f16\u53f7 +plmid=PLMID +serialNumber=\u5e8f\u53f7 +date=\u65e5\u671f +chapter=\u7ae0\u8282 +revisionReason=\u4fee\u8ba2\u539f\u56e0 +revisionContent=\u4fee\u8ba2\u5185\u5bb9 +revisedVersion=\u4fee\u8ba2\u540e\u7248\u672c +revisedBy=\u5236/\u4fee\u8ba2\u4eba +approvedBy=\u6838\u51c6\u4eba +name=\u540d\u79f0 +remark=\u5907\u6ce8 diff --git a/src/com/connor/renben/process/plm/sql/util/SqlUtil.java b/src/com/connor/renben/process/plm/sql/util/SqlUtil.java new file mode 100644 index 0000000..14c6538 --- /dev/null +++ b/src/com/connor/renben/process/plm/sql/util/SqlUtil.java @@ -0,0 +1,568 @@ +package com.connor.renben.process.plm.sql.util; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Locale; +import java.util.ResourceBundle; + +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; +import com.teamcenter.rac.util.Registry; + +/** + * ֹ̳final,ֹ󽨶˽й췽,ΪʹС PreparedStatementResultSetС + * + * @author hub 2015-02-06 + */ +public final class SqlUtil { + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + private static Registry reg = Registry.getRegistry(SqlUtil.class); + + /** + * ˽йnew󣬷ֹö + */ + private SqlUtil() { + + } + + static { + String driver = reg.getString("ORACEL_DRIVER"); // 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 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) { + 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) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qjcsjksxxutil_display.TITLE"), "ʾ", 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 = 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) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qjcsjksxxutil_display.TITLE"), "ʾ", 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(String url, String dbName, + String dbPassword) { + try { + String driver_temp = reg.getString("ORACEL_DRIVER"); + + 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(); + // 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("OPERATE_TIME") + || 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(); + } + + /** + * ƴSQLinsert + * + * @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("COMMIT_TIME") + || args[i].toUpperCase().equals("CREATE_DATE") + || args[i].toUpperCase().equals("INVALID_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 { + SqlUtil.ps = SqlUtil.connection.prepareStatement(sql); + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtil.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtil.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 write(String sql, Object[] argments) { + + return update(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 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 update(String sql, Object[] argments) { + int i = -1; + try { + i = SqlUtil.getPs(argments, sql).executeUpdate(); + // 2015-11-19 + // SqlUtil.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtil.rs, SqlUtil.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 SqlUtil.rs = SqlUtil.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 = SqlUtil.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtil.rs, SqlUtil.ps); + } + if (flag) { + try { + SqlUtil.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(SqlUtil.rs, SqlUtil.ps); + } + + /** + * ͷԴ(ȫͷ) + */ + public final static void freeAll() { + free(SqlUtil.rs, SqlUtil.ps, SqlUtil.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/renben/process/plm/sql/util/SqlUtilT.java b/src/com/connor/renben/process/plm/sql/util/SqlUtilT.java new file mode 100644 index 0000000..d33e4f9 --- /dev/null +++ b/src/com/connor/renben/process/plm/sql/util/SqlUtilT.java @@ -0,0 +1,749 @@ +package com.connor.renben.process.plm.sql.util; + +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Locale; +import java.util.Properties; +import java.util.ResourceBundle; +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; +import com.teamcenter.soaictstubs.commitDatasetFileInfo_s; + +/** + * ֹ̳final,ֹ󽨶˽й췽,ΪʹС PreparedStatementResultSetС + * + * @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() { +// connection = com.connor.rb.DBTest.GetConn.getConnAction(); + 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) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qjcsjksxxutil_display.TITLE"), "ʾ", 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) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qjcsjksxxutil_display.TITLE"), "ʾ", 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(); + } + + /** + * ƴSQLinsert + * + * @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 forWrite(Object[] argments, String sql) { + return forWrite(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 forWrite(String sql, Object[] argments) { + + return forUpdate(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 int forUpdate(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(); + } + 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 { + System.out.println("sql:"+sql); + 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/renben/process/plm/sql/util/sqlconn.properties b/src/com/connor/renben/process/plm/sql/util/sqlconn.properties new file mode 100644 index 0000000..fa3899c --- /dev/null +++ b/src/com/connor/renben/process/plm/sql/util/sqlconn.properties @@ -0,0 +1,4 @@ +driverClassName=oracle.jdbc.driver.OracleDriver +url=jdbc:oracle:thin:@192.168.211.239:1521:tc121 +username=infodba +password=infodba \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/test/BZGY.java b/src/com/connor/renben/process/plm/test/BZGY.java new file mode 100644 index 0000000..dd4a89b --- /dev/null +++ b/src/com/connor/renben/process/plm/test/BZGY.java @@ -0,0 +1,428 @@ +package com.connor.renben.process.plm.test; +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.GridLayout; +import java.awt.Image; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Vector; + +import javax.imageio.ImageIO; +import javax.swing.DefaultListSelectionModel; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.util.CTextFieldButton; +import com.connor.renben.process.plm.util.ImageFilter; +import com.teamcenter.rac.util.PropertyLayout; + +public class BZGY { + private static String imagePath; + // ҳؼ + private static JFileChooser jfc;// ļѡ + + private static JPanel titlePanel;// + private static JLabel titleLabel; + + private static JPanel mainPanel;// д + + private static JPanel panel1;// һ + private static JLabel bzfsLabel;// װʽ + private static JComboBox bzfsComboBox; + private static JLabel qyfsLabel;// ?ͷʽ + private static JComboBox qyfsComboBox; + private static JLabel numberLabel;// ÿ + private static JTextField numberTextField; + private static JLabel label;// / + + private static JPanel panel2;// ڶ + private static JLabel cartonNameLabel;// ֽ + private static CTextFieldButton cartonNameField; + private static JLabel packageQuotaLabel;// װ + private static JTextField packageQuotaField; + private static JLabel label1;// /ʱ + + private static JPanel panel3;// + private static JLabel nylonBagNameLabel;// + private static CTextFieldButton nylonBagNameField; + private static JLabel finishedProductWeightLabel;// Ʒ + private static JTextField finishedProductWeightField; + private static JLabel label2;// g + + private static JPanel panel4;// + private static JLabel plasticUptakeNameLabel;// + private static CTextFieldButton plasticUptakeNameField; + private static JTextField plasticUptakeName2Field; + private static JLabel roughWeightLabel;// ë + private static JTextField roughWeightField; + private static JLabel label3;// kg + private static JPanel panel5;// + private static JLabel outerBoxLabel;// ǩ + private static JComboBox outerBoxComboBox;// ǩ + + private static JPanel panel6;// + private static JLabel explainLabel;//˵ + static JTextArea explainArea; + static JLabel attentionLabel;//ע + static JTextArea attentionArea; + //static JLabel + + + + + //private static JPanel panel6;// ͼƬ + private static JLabel imageLabel; + + private static JPanel rootPanel; + //ť + private static JButton okButton; + + //Table + static boolean isshown = false; + static JScrollPane jspTable; + static JTable table; + static JFrame dialog; + /** + * @param args + */ + public static void main(String[] args) { + // TODO Auto-generated method stub + dialog = new JFrame(); + dialog.setSize(800,500); + dialog.setLocationRelativeTo(null); + dialog.setLayout(new BorderLayout()); + dialog.setTitle("װ"); + //dialog.setPreferredSize(new Dimension(1000, 800)); + + titlePanel = new JPanel(); + //titlePanel.setPreferredSize(new Dimension(520,300)); + titleLabel = new JLabel("װ"); + titleLabel.setFont(new Font("", 1, 18)); + titlePanel.add(titleLabel); + + panel1 = new JPanel(new PropertyLayout()); + bzfsLabel = new JLabel("װʽ"); + bzfsComboBox = new JComboBox<>(); + bzfsComboBox.setPreferredSize(new Dimension(173, 20)); + qyfsLabel = new JLabel("?ͷʽ"); + qyfsComboBox = new JComboBox<>(); + qyfsComboBox.setPreferredSize(new Dimension(171, 20)); + numberLabel = new JLabel("ÿ"); + numberTextField = new JTextField(8); + label = new JLabel("/"); + panel1.add("1.1.left.top", bzfsLabel); + panel1.add("1.2.left.top", bzfsComboBox); + panel1.add("1.3.left.top", qyfsLabel); + panel1.add("1.4.left.top", qyfsComboBox); + panel1.add("1.5.left.top", numberLabel); + panel1.add("1.6.left.top", numberTextField); + panel1.add("1.7.left.top", label); + + panel2 = new JPanel(new PropertyLayout()); + cartonNameLabel = new JLabel("ֽ"); + cartonNameField = new CTextFieldButton (36){ + + @Override + public void handleClick(CTextFieldButton textFieldButton) { + // TODO Auto-generated method stub + if (isshown) { + dialog.getLayeredPane().remove(jspTable); + isshown = false; + } else { + jspTable = getJspTable(); + int x = mainPanel.getX()+numberLabel.getWidth(); + int y = mainPanel.getY()+5 + numberTextField.getHeight()*2; + System.out.println("X==============================="+x+"Y==============="+y); + jspTable.setLocation(x, y); + dialog.getLayeredPane().add(jspTable, 0); + isshown = true; + table.requestFocus(); + } + dialog.getLayeredPane().validate(); + dialog.getLayeredPane().repaint(); + }}; + packageQuotaLabel = new JLabel("װ"); + packageQuotaField = new JTextField(8); + label1 = new JLabel("/ʱ"); + panel2.add("1.1.left.top", cartonNameLabel); + panel2.add("1.2.left.top", cartonNameField); + panel2.add("1.3.left.top", packageQuotaLabel); + panel2.add("1.4.left.top", packageQuotaField); + panel2.add("1.5.left.top", label1); + panel3 = new JPanel(new PropertyLayout()); + nylonBagNameLabel = new JLabel(""); + nylonBagNameField = new CTextFieldButton (36){ + @Override + public void handleClick(CTextFieldButton textFieldButton) { + if (isshown) { + dialog.getLayeredPane().remove(jspTable); + isshown = false; + } else { + jspTable = getJspTable(); + int x = mainPanel.getX()+packageQuotaLabel.getWidth(); + int y = mainPanel.getY()+10 + nylonBagNameField.getHeight()*3; + System.out.println("X==============================="+x+"Y==============="+y); + jspTable.setLocation(x, y); + dialog.getLayeredPane().add(jspTable, 0); + isshown = true; + table.requestFocus(); + } + dialog.getLayeredPane().validate(); + dialog.getLayeredPane().repaint(); + }}; + finishedProductWeightLabel = new JLabel("Ʒ"); + finishedProductWeightField = new JTextField(8); + label2 = new JLabel("g"); + panel3.add("1.1.left.top", nylonBagNameLabel); + panel3.add("1.2.left.top", nylonBagNameField); + panel3.add("1.3.left.top", finishedProductWeightLabel); + panel3.add("1.4.left.top", finishedProductWeightField); + panel3.add("1.5.left.top", label2); + panel4 = new JPanel(new PropertyLayout()); + plasticUptakeNameLabel = new JLabel(" "); + plasticUptakeNameField = new CTextFieldButton (30){ + + @Override + public void handleClick(CTextFieldButton textFieldButton) { + // TODO Auto-generated method stub + + }}; + plasticUptakeName2Field = new JTextField(); + plasticUptakeName2Field.setPreferredSize(new Dimension(62, 20)); + roughWeightLabel = new JLabel("ë"); + roughWeightField = new JTextField(8); + label3 = new JLabel("kg"); + panel4.add("1.1.left.top", plasticUptakeNameLabel); + panel4.add("1.2.left.top", plasticUptakeNameField); + panel4.add("1.3.left.top", plasticUptakeName2Field); + panel4.add("1.4.left.top", roughWeightLabel); + panel4.add("1.5.left.top", roughWeightField); + panel4.add("1.6.left.top", label3); + panel5 = new JPanel(new PropertyLayout()); + outerBoxLabel = new JLabel("ǩ"); + outerBoxComboBox = new JComboBox<>(); + outerBoxComboBox.setPreferredSize(new Dimension(400, 20)); + panel5.add("1.1.left.top", outerBoxLabel); + panel5.add("1.2.left.top", outerBoxComboBox); + + imageLabel = new JLabel("ѡͼƬ"); + imageLabel.setPreferredSize(new Dimension(200,130)); + Image image = getImage(); + if(image!=null) + { + ImageIcon icon = new ImageIcon(image); + icon.setImage(icon.getImage().getScaledInstance((int)imageLabel.getPreferredSize().getWidth(),(int)imageLabel.getPreferredSize().getHeight(), Image.SCALE_DEFAULT)); + imageLabel.setIcon(icon); + } + imageLabel.setOpaque(true); + imageLabel.setBackground(Color.WHITE); + imageLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + // TODO Auto-generated method stub + if(arg0.getClickCount() == 2) + { + selectFileButtonEvent(arg0); + } + //super.mouseClicked(arg0); + } + }); + //panel6.add("2.2.left.top", panel10); + + rootPanel = new JPanel(new FlowLayout()); + okButton = new JButton(""); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + //ȡݿ +// SqlUtilT.getConnectionTC10(); + + //SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", "infodba"); + try { + Class.forName("oracle.jdbc.driver.OracleDriver"); + Connection con=DriverManager.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", "infodba"); + //ݿdengluΪݿsaΪݿʺż롣 + Statement stmt=con.createStatement(); //Statement + FileInputStream str=new FileInputStream(imagePath); + String sql="insert into rb3_test values(?)"; + PreparedStatement pstmt=con.prepareStatement(sql); + pstmt.setBinaryStream(1, str, str.available()); + pstmt.execute(); + } catch (Exception e) { + e.printStackTrace(); + } //ͼƬļ· + } + }); + rootPanel.add(okButton); + mainPanel = new JPanel(new PropertyLayout()); + mainPanel.add("1.1.left.top", panel1); + mainPanel.add("2.1.left.top", panel2); + mainPanel.add("3.1.left.top", panel3); + mainPanel.add("4.1.left.top", panel4); + mainPanel.add("5.1.left.top", panel5); + + JPanel panel = new JPanel(new PropertyLayout()); + panel.add("1.1.left.top",mainPanel); + panel.add("1.2.left.top",imageLabel); + + panel6 = new JPanel(new PropertyLayout()); + explainLabel = new JLabel("˵"); + explainArea = new JTextArea(); + explainArea.setPreferredSize(new Dimension(450, 200)); + + panel6.add("1.1.left.top", explainLabel); + panel6.add("2.1.left.top", explainArea); + + JPanel panel7 = new JPanel(new PropertyLayout()); + attentionLabel = new JLabel("ע"); + attentionArea = new JTextArea(); + attentionArea.setPreferredSize(new Dimension(400, 100)); + panel7.add("1.1.left.top", attentionLabel); + panel7.add("2.1.left.top", attentionArea); + + JPanel panel8 = new JPanel(new PropertyLayout()); + panel8.add("1.1.left.top", panel6); + panel8.add("1.2.left.top", panel7); + + JPanel panel9 = new JPanel(new PropertyLayout()); + panel9.add("1.1.left.top", panel); + panel9.add("2.1.left.top", panel8); + + + dialog.add(titlePanel,BorderLayout.NORTH); + dialog.add(rootPanel, BorderLayout.SOUTH); + dialog.add(panel9, BorderLayout.CENTER); + dialog.show(); + } + + /** + * + * @param e + */ + public static void selectFileButtonEvent(MouseEvent e) { + jfc = new JFileChooser(); + jfc.setFileFilter(new ImageFilter()); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + imagePath = f.getAbsolutePath(); + System.out.println(f.getAbsolutePath()); + ImageIcon icon = new ImageIcon(f.getAbsolutePath()); + icon.setImage(icon.getImage().getScaledInstance(icon.getIconWidth(), + icon.getIconHeight(), Image.SCALE_DEFAULT)); + ((JLabel)e.getSource()).setIcon(icon); + } + } + + static Image getImage() + { + try { + Class.forName("oracle.jdbc.driver.OracleDriver"); + Connection con=DriverManager.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", "infodba"); + Statement stmt=con.createStatement(); + ResultSet rs=null; + String sql = "select * from RB3_PACKAGEPROCESS"; + rs=stmt.executeQuery(sql); + if(rs.next()) { + //ͼƬ + InputStream in = rs.getBinaryStream("RB3_PACK_IMAGE"); + //byte b[] = new byte[0x7a120]; +// for(int i = in.read(b); i != -1;) +// { +// //ҳ +// in.read(b); +// } + return ImageIO.read(in); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + private static JScrollPane getJspTable() { + if (jspTable == null) { + Vector rowdata = new Vector(); + for (int i = 0; i < 10; i++) { + Vector row = new Vector(); + row.add("000" + i); + row.add("CustomName" + i); + row.add("CustomAddress" + i); + rowdata.add(row); + } + Vector header = new Vector(); + header.add(""); + header.add("ͺ"); + header.add(""); + header.add("Ʒ"); + table = new JTable(rowdata, header); + table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); + table.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 1) { + int row = table.getSelectedRow(); + nylonBagNameField.setText(table.getValueAt(row, 1).toString() + + "" + table.getValueAt(row, 2).toString() + + ""); + dialog.getLayeredPane().remove(jspTable); + isshown = false; + dialog.getLayeredPane().validate(); + dialog.getLayeredPane().repaint(); + } + } + }); + table.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent e) { + } + + public void focusLost(FocusEvent e) { + Component target = e.getOppositeComponent(); + if (target == nylonBagNameField) { + return; + } else { + dialog.getLayeredPane().remove(jspTable); + isshown = false; + dialog.getLayeredPane().validate(); + dialog.getLayeredPane().repaint(); + } + } + }); + jspTable = new JScrollPane(table); + //jspTable.setViewportView(table); + jspTable.setSize(new Dimension(350, 100)); + } + return jspTable; + } +} diff --git a/src/com/connor/renben/process/plm/test/D.java b/src/com/connor/renben/process/plm/test/D.java new file mode 100644 index 0000000..88bfbb9 --- /dev/null +++ b/src/com/connor/renben/process/plm/test/D.java @@ -0,0 +1,525 @@ +package com.connor.renben.process.plm.test; + +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JFileChooser; + +import org.apache.poi.ss.usermodel.Cell; +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.util.AreaReference; +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.XSSFDataFormat; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.spire.xls.Workbook; + + +public class D { + public static void main(String[] args) throws IOException, SQLException { +// boolean is_many = false; +// int num = 0; +// StringBuilder sql = +// new StringBuilder() +// .append("select rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff ,rb3_rl,rb3_pl,rb3_special,rb3_tstx,rb3_jqsb ,rb3_sjsj,rb3_gcsj,rb3_mjsj from rb3_controlplan where rb3_meopid='A0044_MEOP999' and type='RB3_SSCKZJH'") ;//and RB3_smjy like '%׼%'"; +// System.out.println(sql.toString()); +// ResultSet rs = null; +// com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); +// +// rs = com.connor.renben.process.plm.sql.util.SqlUtilT +// .read(sql.toString()); +// ArrayList> data = new ArrayList<>(); +// +// +// while(rs.next()){ +// ArrayList arr = new ArrayList<>(); +// String qptbh = getDate(rs.getString("RB3_QPTBH")); +//// arr.add(qptbh); +// arr.add(getDate(rs.getString("RB3_CP"))); +// if(rs.getString("RB3_CPGC").indexOf("-")!=-1){ +// num = Integer.valueOf(getNum(rs.getString("RB3_CPGC").split("-")[0])); +// +// } +// arr.add(getDate(rs.getString("RB3_CPGC"))+"special"+rs.getString("RB3_SPECIAL")); +// +// arr.add(qptbh); +//// if(!have_rb3_jqsb) +//// rb3_jqsb = getDate(rs.getString("RB3_JQSB")); +// +// +//// checkClFF(data,arr,qptbh,qptbhs,cpgc,1,is_first); +//// is_first = false; +//// qptbhs.add(qptbh); +// if(num!=0) +// for(int i = 0 ;i> data = new ArrayList<>(); +//// ArrayList arr = new ArrayList<>(); +//// arr.add("1"); +//// arr.add("2-1"); +//// arr.add("1"); +//// arr.add("1"); +//// arr.add("1"); +//// arr.add("1"); +//// data.add(arr); +// ArrayList list = new ArrayList<>(); +// list.add(" "); +// writeExcelForCXCheckTable("C:\\222222.xlsx", data, true,list); + + printFileAction(); + + + } + + private static void printFileAction() + + { + + JFileChooser fileChooser = new JFileChooser(); + + int state = fileChooser.showOpenDialog(null);// ļѡԻ + + if (state == fileChooser.APPROVE_OPTION)// ûѡļ + + { + File file = fileChooser.getSelectedFile();// ȡѡļ + //excel +// Document doc = new Document(); +// PDDocument doc = PDDocument.load(file); + //еPDFļ + //d.loadFromFile(file.getAbsolutePath()); + + //ΪDocļʽ + //doc.saveToFile("C:\\ToDoc.doc",FileFormat.DOC); + + Workbook workbook = new Workbook(); + workbook.loadFromFile(file.getAbsolutePath()); +// + // PrinterJob + PrinterJob printerJob = PrinterJob.getPrinterJob(); + + //ָӡҳΪĬϴСͷ + PageFormat pageFormat = printerJob.defaultPage(); + + //شӡѡ + Paper paper = pageFormat.getPaper(); + paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); + pageFormat.setPaper(paper); + printerJob.printDialog(); +// FileInputStream fis = new FileInputStream(file);// ӡļ +// +// DocAttributeSet das = new HashDocAttributeSet(); +// +// Doc doc = new SimpleDoc(fis, flavor, das);// ӡļʽ + + printerJob.setCopies(1); + printerJob.setPrintable(workbook, pageFormat); + + //ִдӡ + try { + printerJob.print(); + } catch (PrinterException e) { + e.printStackTrace(); + } + } + + +// // һļѡĬΪǰĿ¼ +// +//// PrinterJob printerJob = PrinterJob.getPrinterJob(); +// JFileChooser fileChooser = new JFileChooser(); +// +// int state = fileChooser.showOpenDialog(null);// ļѡԻ +// +// if (state == fileChooser.APPROVE_OPTION)// ûѡļ +// +// { +// +// File file = fileChooser.getSelectedFile();// ȡѡļ +// +// // ӡԼ +// +// PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); +// // ôӡʽΪδȷļͣѡ AUTOSENSE +// +// DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; +// +// // еĿôӡ +// +// PrintService printService[] = +// +// PrintServiceLookup.lookupPrintServices(null, pras); +// +// // λĬϵĴӡ +// +// PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); +// +// // ʾӡԻ +// +// PrintService service = ServiceUI.printDialog(null, 200, 200, printService +// +// , defaultService, null, pras); +// +// if (service != null) +// +// { +// +// try +// +// { +// DocPrintJob job = service.createPrintJob();// ӡҵ +// +// FileInputStream fis = new FileInputStream(file);// ӡļ +// +// DocAttributeSet das = new HashDocAttributeSet(); +// +// Doc doc = new SimpleDoc(fis, flavor, das);// ӡļʽ +// +// job.print(doc, pras);// ļĴӡ +// +// } +// +// catch (Exception e) +// +// { +// +// e.printStackTrace(); +// +// } +// +// } +// +// } + + } + + private static void writeExcelForCXCheckTable(String write_Address,ArrayList> date,boolean hava_minAndMax, ArrayList shousuobi_list){ + try { + InputStream is = D.class.getResourceAsStream("ιԼ¼.xlsx"); + XSSFWorkbook wb = new XSSFWorkbook(is); + is.close(); + OutputStream output = new FileOutputStream(new File(write_Address)); + XSSFCellStyle style = wb.createCellStyle(); +// if(rb3_jqsb!=null) +// ExcelUtil07.writeExcelWithOneCellName(wb, "豸", rb3_jqsb); + 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(); +// XSSFCellStyle style =wb.createCellStyle(); + XSSFDataFormat df = wb.createDataFormat(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + + XSSFSheet sheet = wb.getSheetAt(0); + sheet.setForceFormulaRecalculation(true); + sheet.protectSheet(""); + style.setLocked(false); + for (int i = 0; i < date.size(); i++) { + ArrayList cell_Date = date.get(i); + System.out.println(cell_Date.toString()); + for (int j = 0; j < cell_Date.size(); j++) { + + int namedCellIdx = wb.getNameIndex("head" + + String.valueOf(j + 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++) { + Sheet s = wb.getSheet(crefs[k].getSheetName()); + Row r = s.getRow(crefs[k].getRow() + i + 1); + Cell c = r.getCell(crefs[k].getCol()); + + if(j==1){ +// int num = 0; +// +// if(cell_Date.get(j).indexOf("-")!=-1){ +// num = Integer.valueOf(getNum(cell_Date.get(j).split("-")[0])); +// date.add(i+1,cell_Date); +// System.out.println(date.toString()); +// } +// for(int z = 0;z arr = getCPGCMaxAndMix(cell_Date.get(j)," "); + // if(shousuobi_list.get(i)!=" "){ + //// if(cell_Date.get(j).indexOf("")!=-1){ + //// c.setCellValue(cell_Date.get(j).split("")[0]+""+String.valueOf(after_shousuo)); + //// } + //// else{ + c.setCellValue(cell_Date.get(j)); + //// } + // + // } + if(hava_minAndMax){ + String ss = cell_Date.get(j+1); + // DecimalFormat df; + // if(ss.indexOf("")!=-1||ss.indexOf("ٷֱ")!=-1||ss.indexOf("ǧֱ")!=-1) + // df = new DecimalFormat("##0.00"); + // else + // df = new DecimalFormat("##0.00"); + // System.out.println(df.format(Double.valueOf(arr.get(1))*((100-Float.valueOf(shousuobi.split("%")[0]))/100.0))); + Cell minCell = null; + minCell = r.getCell(crefs[k].getCol()+1); + Cell maxCell = null; + maxCell = r.getCell(crefs[k].getCol()+2); + if(minCell == null) + { + minCell = r.createCell(crefs[k].getCol()+1); + } + if(maxCell == null) + { + maxCell = r.getCell(crefs[k].getCol()+2); + } + + XSSFCellStyle cellstyle = wb.createCellStyle(); + cellstyle = (XSSFCellStyle) minCell.getCellStyle(); + cellstyle = (XSSFCellStyle) maxCell.getCellStyle(); + // cellstyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); + // cellstyle.setBorderTop(XSSFCellStyle.BORDER_THIN); + // cellstyle.setBorderRight(XSSFCellStyle.BORDER_THIN); + // cellstyle.setBorderLeft(XSSFCellStyle.BORDER_THIN); + // cellstyle.setAlignment(XSSFCellStyle.ALIGN_CENTER); + String format = "0.0000000000"; + // if(position==0){ + // cellstyle.setDataFormat(df.getFormat(format.substring(0, position+2))); + // } + + // if(ss.indexOf("")!=-1||ss.indexOf("ٷֱ")!=-1||ss.indexOf("ǧֱ")!=-1) + // cellstyle.setDataFormat(df.getFormat("0.00")); + // else if(ss.indexOf("ǧֳ")!=-1) + // cellstyle.setDataFormat(df.getFormat("0.000")); + // else + // cellstyle.setDataFormat(df.getFormat("0.0000")); + + // if(!" ".equals(shousuobi_list.get(i))){ + // minCell.setCellValue(df.format(Double.valueOf(arr.get(0))*(Float.valueOf(shousuobi_list.get(i))))); + // maxCell.setCellValue(df.format(Double.valueOf(arr.get(1))*(Float.valueOf(shousuobi_list.get(i))))); + // } + // else{ + if(arr.get(0) != null && arr.get(0) != " " && arr.get(0)!="OK") + { + minCell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + minCell.setCellStyle(cellstyle); + minCell.setCellValue(Double.parseDouble(arr.get(0))); + + } + else + minCell.setCellValue(arr.get(0)); + if(arr.get(1)!=null&&arr.get(1)!= " " && arr.get(1)!="OK"){ + maxCell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + maxCell.setCellStyle(cellstyle); + maxCell.setCellValue(Double.parseDouble(arr.get(1))); + + } + else + maxCell.setCellValue(arr.get(1)); + // } + // maxCell.setCellValue(arr.get(1)); + + } + } + + else + c.setCellValue(cell_Date.get(j)); + + + } + + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + 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 str + * @return + */ + public static ArrayList getCPGCMaxAndMix(String str,String gc) { + ArrayList data = new ArrayList<>(); + List list = new ArrayList<>(); + if(str.indexOf("")!=-1){ + String[] ss = str.split(""); + System.out.println(ss.length); + for(String s :ss){ + System.out.println(s); + list.add(getNum(s)); + } + if(list.size()>=2){ + BigDecimal b0 = new BigDecimal(list.get(0)); + BigDecimal b1 = new BigDecimal(list.get(1)); + String v1 = null; + String v2 = null; + if(!" ".equals(gc)){ + + String s1 = getNum(list.get(1)); + BigDecimal b2 = null; + if(gc.indexOf("%")!=-1) + b2 = new BigDecimal(getNum((Double.valueOf(gc.split("%")[0])/100)+"")); + else + b2 = new BigDecimal(getNum(gc)); + v1 = String.valueOf(b0.subtract(new BigDecimal(Double.toString(b1.multiply(b2).doubleValue())))); + v2 = String.valueOf(b0.add(new BigDecimal(Double.toString(b1.multiply(b2).doubleValue())))); + data.add(v1); + data.add(v2); + } + else{ + v1 = String.valueOf(b0.subtract(b1)); + v2 = String.valueOf(b0.add(b1)); + data.add(v1); + data.add(v2); + } + int position1 = v1.length() - v1.indexOf(".")-1 ; + int position2 = v2.length() - v2.indexOf(".")-1 ; + } + return data; + } + if(str.toUpperCase().indexOf("MAX")!=-1||str.indexOf("")!=-1||str.indexOf("<")!=-1||str.indexOf("")!=-1){ + if(!" ".equals(gc)){ + String s1 = getNum(str); + BigDecimal b1 = new BigDecimal(getNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); + String val = String.valueOf(b1.multiply(b2).doubleValue()); + data.add("0"); + data.add(val); + } + else{ + data.add("0"); + data.add(getNum(str)); + } + return data; + + } + if(str.toUpperCase().indexOf("MIN")!=-1||str.indexOf("")!=-1||str.indexOf(">")!=-1||str.indexOf("")!=-1){ + if(!" ".equals(gc)&&!"0".equals(gc)){ + String s1 = getNum(str); + BigDecimal b1 = new BigDecimal(getNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); +// String val = String.valueOf(b1.multiply(b2).doubleValue()); + String val = String.valueOf(b1.divide(b2,10,BigDecimal.ROUND_HALF_UP).doubleValue()); + data.add(val); + data.add("0"); + } + else{ + data.add(getNum(str)); + data.add(" "); + } + return data; + + } + if(str.indexOf("~")!=-1){ + data.add(getNum(str.split("~")[0])); + data.add(getNum(str.split("~")[1])); + return data; + } + if(getNum(str)!=""){ + if(!" ".equals(gc)){ + String s1 = getNum(str); + BigDecimal b1 = new BigDecimal(getNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); + String val = String.valueOf(b1.multiply(b2).doubleValue()); + data.add("0"); + data.add(val); + + } + else{ + data.add("0"); + data.add(getNum(str)); + } + return data; + } + if(getNum(str)==""){ + data.add("OK"); + data.add("OK"); + return data; + } + return data; + } + private static String getNum(String str) { + Pattern p = Pattern.compile("(\\d+\\.\\d+)"); + //MatcherĹ췽Ҳ˽е,ⴴ,ֻͨPattern.matcher(CharSequence input)õʵ. + Matcher m = p.matcher(str); + //m.findжϸַǷ"(\\d+\\.\\d+)"ƥӴ + if (m.find()) { + //ƥ,жǷΪnull + //group()еIJ0ʾƥ1ʾƥһŵ,2ʾƥڶ,ֻһ,10һ + str = m.group(1) == null ? "" : m.group(1); + } else { + //ƥ䲻Сͽƥ + p = Pattern.compile("(\\d+)"); + m = p.matcher(str); + if (m.find()) { + //ƥ + str = m.group(1) == null ? "" : m.group(1); + } else { + //ûСƥ,ַûСΪ + str = ""; + } + } + return str; + } + private static String getDate(String str){ + if(str!=null) + return str.split("\n")[0]; + return " "; + } +} + diff --git a/src/com/connor/renben/process/plm/test/DialogTest.java b/src/com/connor/renben/process/plm/test/DialogTest.java new file mode 100644 index 0000000..c217dda --- /dev/null +++ b/src/com/connor/renben/process/plm/test/DialogTest.java @@ -0,0 +1,99 @@ +package com.connor.renben.process.plm.test; + +import java.awt.BorderLayout; +import java.awt.Dialog; +import java.awt.Dimension; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; + +import javax.swing.JComboBox; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; + +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomMethodUtil; + +public class DialogTest extends JFrame { + + + public DialogTest(Dialog owner) { + // TODO Auto-generated constructor stub + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.add(new MultiComboBox(new String[] {"1"},new String[] {"1"})); + this.pack(); + this.show(); + } + + private JPanel createIterationPane() { + JPanel pane = new JPanel(); + + pane.add(BorderLayout.WEST, new JLabel("")); + + JComboBox iterationBox = new JComboBox(); + + iterationBox.setPreferredSize(new Dimension(200, 20)); + + iterationBox.setEditable(true); + + // 弸ʼڵ + + File file = new File("C:\\Users\\Administrator\\Desktop\\web\\ίеѡ.xlsx"); + + DefaultMutableTreeNode parentNode = null; + 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(); + } + +// 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); + + // Ըڵ㴴 + + JTree tree = new JTree(parentNode); + + // Ƿʾڵġչ/۵ͼ,Ĭfalse + + tree.setShowsRootHandles(true); + + // ýڵǷɼ,Ĭtrue + + tree.setRootVisible(true); + + iterationBox.addItem(parentNode);// ӵ + + pane.add(iterationBox); + + return pane; + + } +} + + diff --git a/src/com/connor/renben/process/plm/test/MultiComboBox.java b/src/com/connor/renben/process/plm/test/MultiComboBox.java new file mode 100644 index 0000000..efbd8c9 --- /dev/null +++ b/src/com/connor/renben/process/plm/test/MultiComboBox.java @@ -0,0 +1,208 @@ +package com.connor.renben.process.plm.test; +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.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicArrowButton; + +import com.teamcenter.rac.util.PropertyLayout; + +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.setPreferredSize(new Dimension(465, 50)); + arrowButton.addMouseListener(new EditorHandler()); + add("1.1.left.top",editor); + 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(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()); + } + this.setPreferredSize(new Dimension(950, 20)); + } + + 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/test/MultiPopup.java b/src/com/connor/renben/process/plm/test/MultiPopup.java new file mode 100644 index 0000000..ca43ad3 --- /dev/null +++ b/src/com/connor/renben/process/plm/test/MultiPopup.java @@ -0,0 +1,206 @@ +package com.connor.renben.process.plm.test; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + + + +import javax.swing.JButton; +import javax.swing.JCheckBox; +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.TreePath; + +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.teamcenter.rac.util.MessageBox; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + //private List checkBoxList = new ArrayList(); + + private JTree tree; + + 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 treePane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + + // 弸ʼڵ + + File file = new File("C:\\Users\\Administrator\\Desktop\\web\\ίеѡ.xlsx"); + + DefaultMutableTreeNode parentNode = null; + 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); + + // Ըڵ㴴 + + tree = new JTree(parentNode); + + // Ƿʾڵġչ/۵ͼ,Ĭ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(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(treePane , 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(); + + 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)); + } + +} diff --git a/src/com/connor/renben/process/plm/test/NewItemMPPDialog2.java b/src/com/connor/renben/process/plm/test/NewItemMPPDialog2.java new file mode 100644 index 0000000..b650358 --- /dev/null +++ b/src/com/connor/renben/process/plm/test/NewItemMPPDialog2.java @@ -0,0 +1,18 @@ +package com.connor.renben.process.plm.test; + +import java.awt.Frame; + +import com.teamcenter.rac.cme.bvr.create.fromtemplate.NewMEProcessDialog; +import com.teamcenter.rac.kernel.TCSession; + + +public class NewItemMPPDialog2 extends NewMEProcessDialog +{ + + public NewItemMPPDialog2(Frame frame, TCSession tcsession) { + super(frame, tcsession); + } + + +} + diff --git a/src/com/connor/renben/process/plm/test/Test.java b/src/com/connor/renben/process/plm/test/Test.java new file mode 100644 index 0000000..d2ad09e --- /dev/null +++ b/src/com/connor/renben/process/plm/test/Test.java @@ -0,0 +1,29 @@ +package com.connor.renben.process.plm.test; + +import java.io.BufferedInputStream; +import java.io.File; +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.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +public class Test { + + /** + * @param args + */ + public static void main(String[] args) { + new DialogTest(null); + } + +} diff --git a/src/com/connor/renben/process/plm/test/TimerTestHandler.java b/src/com/connor/renben/process/plm/test/TimerTestHandler.java new file mode 100644 index 0000000..01c6faf --- /dev/null +++ b/src/com/connor/renben/process/plm/test/TimerTestHandler.java @@ -0,0 +1,274 @@ +package com.connor.renben.process.plm.test; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +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.io.InputStreamReader; +import java.sql.Blob; +import java.sql.ResultSet; +import java.sql.SQLException; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom032.TMom032AssembleProcessFormOutputDialog; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +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; + +public class TimerTestHandler extends AbstractHandler { + + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String path = this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // readBlob("S1670_MEOP025"); +// TCComponentMEOPRevision target = (TCComponentMEOPRevision) app.getTargetComponent(); +// TCComponent meopRevM = null; +// String gytz = null; +// try { +// meopRevM = target.getRelatedComponent("IMAN_master_form_rev"); +// gytz = meopRevM.getProperty("rb3_gytz"); +// if(gytz != null && gytz != ""){ +// updateProcess_Route(target.getProperty("item_id"),gytz); +// return null; +// } +// else{ +// System.out.println("null"); +// return null; +// } +// } catch (TCException e2) { +// // TODO Auto-generated catch block +// e2.printStackTrace(); +// } + path = path.substring(1, path.lastIndexOf("/") + 1) + "/Logsystem.exe"; + File file = new File(path); + if (file.exists()) { + new Thread() { + @Override + public void run() { + try { + executeCmd(path); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + super.run(); + } + }.start(); + } + System.out.println(path); + // ȡݿ + // getGYTZ("1"); + return null; + } + + /** @PARAM commandָexe· **/ + public static String executeCmd(String command) throws IOException { + System.err.println("Execute command : " + command); + Runtime runtime = Runtime.getRuntime(); + Process process = runtime.exec("cmd /c start " + command); + BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8")); + String line = null; + StringBuilder build = new StringBuilder(); + while ((line = br.readLine()) != null) { + System.err.println(line); + build.append(line); + } + return build.toString(); + } + + private File getGYTZ(String gytz_item_id) { + File file = null; + try { + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + TCComponentItem item = itemType.find(gytz_item_id.split("/")[0]); + TCComponentItemRevision itemRev = TMomMethodUtil.getLastItemRevision(item); + + AIFComponentContext[] aifccs = itemRev.getChildren(); + for (AIFComponentContext aifcc : aifccs) { + if ("RB3_AutoCAD".equals(aifcc.getComponent().getType())) { + TCComponentDataset dataSet = (TCComponentDataset) aifcc.getComponent(); + TCComponentTcFile[] tcFile = dataSet.getTcFiles(); + file = tcFile[0].getFmsFile(); + return file; +// bytes = getBytes(file); + // getFile(bytes, "C:/", "1.dwg"); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return file; + + } + + private void updateProcess_Route(String meop_id, String gytz) { + File file = getGYTZ(gytz); + BufferedInputStream fis = null; + try { + fis = new BufferedInputStream(new FileInputStream(file)); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs1 = null; + String selectSql = "select * from rb3_process_route where rb3_meopid = '" + meop_id + "'"; +// String updateSql = "update rb3_process_route set rb3_gytz_file='' where rb3_meopid = '"+meop_id+"'"; + String selectForUpdateSql = "select * from rb3_process_route where rb3_meopid = '" + meop_id + "' for update"; +// PreparedStatement ps = conn.prepareStatement(writeSql); +// ps.setInt(1, 7499); +// conn.setAutoCommit(false); +// ResultSet rs = ps.executeQuery();System.out.println(selectSql); + System.out.println(selectForUpdateSql); + try { + rs = SqlUtilT.read(selectSql); + if (rs != null) { +// rs2 = SqlUtilT.read(updateSql); + SqlUtilT.connection.setAutoCommit(false); + rs1 = SqlUtilT.read(selectForUpdateSql); +// rs1.next(); + System.out.println(rs1.getRow()); + while (rs1.next()) { + fis = new BufferedInputStream(new FileInputStream(file)); + oracle.sql.BLOB image = (oracle.sql.BLOB) rs1.getBlob("rb3_gytz_file"); + BufferedOutputStream bos = new BufferedOutputStream(image.getBinaryOutputStream()); + int c; + // ʵļеԶƵʽblobӦ + while ((c = fis.read()) != -1) { + bos.write(c); + } + bos.close(); + fis.close(); + } + SqlUtilT.connection.commit(); + } + } catch (SQLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs1 != null) { + SqlUtilT.free(rs1); + } + } + + } + + /** + * ݿж ڱ + */ + public void readBlob(String meop_id) { + // File file = new File(); + try { + SqlUtilT.getTCConnection(); + String readSql = "select * from rb3_process_route where rb3_meopid = '" + meop_id + "'"; + // PreparedStatement ps = conn.prepareStatement(readSql); + // ps.setInt(1, 7369); + ResultSet rs = SqlUtilT.read(readSql); + rs.next(); + Blob image = rs.getBlob("rb3_gytz_file"); +// DataOutputStream dos = +// // FileOutputStreamָļ· +// new DataOutputStream(new FileOutputStream(7369 + "_image.jpeg")); + InputStream fis = image.getBinaryStream(); + + int out; + byte[] outByte = new byte[700000]; + // blobд뱾 + while ((out = fis.read(outByte)) != -1) { +// dos.write(outByte); + getFile(outByte, "C:/", "2.dwg"); + } + + fis.close(); +// dos.flush(); +// dos.close(); + + rs.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private byte[] getBytes(File file) { + byte[] buffer = null; + try { + FileInputStream fis = new FileInputStream(file); + ByteArrayOutputStream bos = new ByteArrayOutputStream(1000); + byte[] b = new byte[(int) file.length()]; + int n; + while ((n = fis.read(b)) != -1) { + bos.write(b, 0, n); + } + fis.close(); + bos.close(); + buffer = bos.toByteArray(); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + return buffer; + } + + public static void getFile(byte[] bfile, String filePath, String fileName) { + BufferedOutputStream bos = null; + FileOutputStream fos = null; + File file = null; + try { + File dir = new File(filePath); + if (!dir.exists() && dir.isDirectory()) {// жļĿ¼Ƿ + dir.mkdirs(); + } + file = new File(filePath + "\\" + fileName); + fos = new FileOutputStream(file); + bos = new BufferedOutputStream(fos); + bos.write(bfile); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (bos != null) { + try { + bos.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + } + } +} diff --git a/src/com/connor/renben/process/plm/test/getGDTask.java b/src/com/connor/renben/process/plm/test/getGDTask.java new file mode 100644 index 0000000..9e376d5 --- /dev/null +++ b/src/com/connor/renben/process/plm/test/getGDTask.java @@ -0,0 +1,47 @@ +package com.connor.renben.process.plm.test; + +import java.io.File; +import java.util.List; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; + +import com.connor.renben.process.plm.bean.packageProcess.Preferences; +import com.connor.renben.process.plm.bean.packageProcess.Preferences.PackageProcess; +import com.connor.renben.process.plm.bean.packageProcess.Preferences.PackageProcess.TextFieldButton; +import com.connor.renben.process.plm.bean.packageProcess.Preferences.PackageProcess.TextFieldButton.Value; + +public class getGDTask { + + /** + * @param args + */ + public static void main(String[] args) { + JAXBContext context; + try { + context = JAXBContext.newInstance(Preferences.class); + Unmarshaller shaller = context.createUnmarshaller(); + JAXBElement root = shaller.unmarshal( + new StreamSource(new File( + "C:\\Users\\Administrator\\Desktop\\PackageProcess.XML")), + Preferences.class); + Preferences electronform = root.getValue(); + List PackageProcess = electronform.getPackageProcess(); + for (PackageProcess PackageProcess2 : PackageProcess) { + List TextFieldButton = PackageProcess2.getTextFieldButton(); + for (TextFieldButton textFieldButton2 : TextFieldButton) { + List values = textFieldButton2.getValue(); + for (Value value : values) { + System.out.println(value.getProperty1() + "====" + + value.getProperty2() + "====" + + value.getProperty3()); + } + } + } + } catch (Exception e) { + + } + } +} diff --git a/src/com/connor/renben/process/plm/test/sql.properties b/src/com/connor/renben/process/plm/test/sql.properties new file mode 100644 index 0000000..1c7d937 --- /dev/null +++ b/src/com/connor/renben/process/plm/test/sql.properties @@ -0,0 +1 @@ +CPTJSQL=SELECT XH,KHMC,KHXMH,CPMC,KHTH,CLBZ,SJRY,CXYJ,ZXYJ,CJSJ FROM RB3_PRODUCT WHERE 1=1 \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/test/testCommmand.java b/src/com/connor/renben/process/plm/test/testCommmand.java new file mode 100644 index 0000000..6d5a980 --- /dev/null +++ b/src/com/connor/renben/process/plm/test/testCommmand.java @@ -0,0 +1,41 @@ +package com.connor.renben.process.plm.test; + +import java.awt.Frame; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; + +public class testCommmand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + final AbstractAIFUIApplication localAbstractAIFUIApplication = AIFDesktop.getActiveDesktop().getCurrentApplication(); + Frame frame = AIFDesktop.getActiveDesktop(); + + public testCommmand(AbstractAIFApplication app,TCSession session) { + this.session = session; + this.app = app; + // TODO Auto-generated constructor stub + } + + @Override + public void executeModal() throws Exception { + if(frame instanceof AIFDesktop) + { + System.out.println("11234566"); + } + //new TimerTest02(); + new Thread() { + @Override + public void run() { + NewItemMPPDialog2 dialog = new NewItemMPPDialog2(frame, session); + dialog.showDialog(); + //setRunnable(dialog); + } + }.start(); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/test/成形作业指导书.xlsx b/src/com/connor/renben/process/plm/test/成形作业指导书.xlsx new file mode 100644 index 0000000..aa9c07c Binary files /dev/null and b/src/com/connor/renben/process/plm/test/成形作业指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/test/成形工序过程自检记录表(操作工).xlsx b/src/com/connor/renben/process/plm/test/成形工序过程自检记录表(操作工).xlsx new file mode 100644 index 0000000..b512595 Binary files /dev/null and b/src/com/connor/renben/process/plm/test/成形工序过程自检记录表(操作工).xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/Eldec热处理工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/Eldec热处理工艺指导书.xlsx new file mode 100644 index 0000000..2a3380e Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/Eldec热处理工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/ST处理作业指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/ST处理作业指导书.xlsx new file mode 100644 index 0000000..f45179a Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/ST处理作业指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructCommand.java b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructCommand.java new file mode 100644 index 0000000..b7016a6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructCommand.java @@ -0,0 +1,821 @@ +package com.connor.renben.process.plm.tmom001; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Map.Entry; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom014.TMom014CheckTableCommand; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ACLLine; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.MessageBox; + +public class TMom001CXInstructCommand extends AbstractAIFCommand { + private TCSession session; + private AbstractAIFUIApplication app; + private String fileSource; + private int operateCode; + private TCComponentMEOPRevision item;//ǰѡеĹ + private boolean toTC;//Ƿ뵽TC false--> + private String url; + private String controlPlayType;//Ƽƻ + private String controlPlayName;//Ƽƻ + private String rb3_jqsb; + private ArrayList> data; + + public TMom001CXInstructCommand(TCSession session, + AbstractAIFUIApplication app, int operateCode, String fileSource, boolean toTC,String url,String controlPlayType) { + this.session = session; + this.app = app; + this.operateCode = operateCode; + this.fileSource = fileSource; + this.toTC = toTC; + this.url = url; + this.controlPlayType = controlPlayType; + } + + @Override + public void executeModal() throws Exception{ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + try { + InterfaceAIFComponent targetcomp = this.app.getTargetComponent(); + item = (TCComponentMEOPRevision) targetcomp; + + } catch (ClassCastException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + MessageBox.post(rb.getString("qxzgxbbhcd01_display.TITLE"), "", MessageBox.ERROR); + return; + } + ResultSet ac_rs = null; + try { + //ӷֹ鿴ǰûǷȨ + String ac_sql = "select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,nvl(rb3_user,' ') as rb3_user,nvl(RB3_INSPECTIONUSER,' ') as RB3_INSPECTIONUSER from RB3_PERMISSIONS where RB3_MEOPID='"+item.getProperty("item_id")+"'"; + System.out.println(ac_sql); + com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); + ac_rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(ac_sql); + String inspectionUser = null; + while(ac_rs.next()){ + inspectionUser = ac_rs.getString("RB3_INSPECTIONUSER"); + } + if((inspectionUser!=null&&session.getUserName().equals(inspectionUser))||session.getUserName().equals("admin")){ + TCUtils.openLogByPass(session, "ָ"); + TMomMethodUtil.setByPass(session, true); + } + TCAccessControlService tccs = session.getTCAccessControlService(); + String[] privileges = {"READ","WRITE","DELETE"}; + boolean[] have_privileges = tccs.checkPrivileges(item, privileges); + for(boolean have_privilege:have_privileges){ + if(toTC){ + if(!have_privilege){ + MessageBox.post("\""+item+"\"ûдȨޣ", "", MessageBox.ERROR); + return; + } + } + } + String item_id = item.getProperty("item_id"); + System.out.println("item_id=>"+item_id); +// String controlPlayType = "RB3_SSCKZJH"; + if(toTC) + controlPlayType = getControlType(); + System.out.println("controlPlayType=========================>"+controlPlayType); + if(controlPlayType==null&&toTC){ + MessageBox.post(rb.getString("wzdyfbdkzjh01_display.TITLE"), "", MessageBox.WARNING); + return; + } + else{ + InputStream is = new FileInputStream(TMomMethodUtil.getFile(session, fileSource.split("\\.")[0],"MSExcelX")); +// is = this.getClass().getResourceAsStream(fileSource); + switch (operateCode) { + case 0: + data= getCXData(item_id,controlPlayType); + //if (toTC == false) toTC= true ; + new Thread() { + @Override + public void run() { + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,TMomFinalUtil.CXSJTY_CHECKTABLE, "׼Լ¼ͨã.xlsx",item,toTC,url,controlPlayType); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + Map cx_map = new HashMap<>(); + cx_map.put(TMomFinalUtil.CXSJCNCZY_CHECKTABLE, "׼Լ¼CNCרã.xlsx"); + cx_map.put(TMomFinalUtil.CXGCJ_CHECKTABLE, "ιԼ¼.xlsx"); + cx_map.put(TMomFinalUtil.CXMJ_CHECKTABLE, "ĩ¼.xlsx"); + cx_map.put(TMomFinalUtil.CXXJ_CHECKTABLE, "ιѲ.xlsx"); + for(Entry set:cx_map.entrySet()){ + TMom014CheckTableCommand command2 = new TMom014CheckTableCommand(session, app,set.getKey(), set.getValue(),item,toTC,url,controlPlayType); + try { + command2.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }.start(); + break; + case 1: + data= getZXData(item_id,controlPlayType); + //if (toTC == false) toTC= true ; + new Thread() { + @Override + public void run() { +// Map cx_map = new HashMap<>(); +// cx_map.put(TMomFinalUtil.CXGCJ_CHECKTABLE, "ιԼ¼.xlsx"); +// cx_map.put(TMomFinalUtil.CXMJ_CHECKTABLE, "ĩ¼.xlsx"); +// cx_map.put(TMomFinalUtil.CXXJ_CHECKTABLE, "ιѲ.xlsx"); +// for(Entry set:cx_map.entrySet()){ +// TMom014CheckTableCommand command2 = new TMom014CheckTableCommand(session, app,set.getKey(), set.getValue(),item,toTC,url,controlPlayType); +// try { +// command2.executeModal(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,TMomFinalUtil.ZX_CHECKTABLE, "Ʒ¼׼.xlsx",item,toTC,url,controlPlayType); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }.start(); + break; + case 2: + data = getSJData(item_id,controlPlayType); + //if (toTC == false) toTC= true ; + new Thread() { + @Override + public void run() { + + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,20, "(ս).xlsx",item,toTC,url,controlPlayType); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + }.start(); + break; + case 6: + //20181220-ReinhartEdit + data = getRCLData(item_id,controlPlayType); + //if (toTC == false) toTC= true ; + //System.out.println("Start output step 6"); + //MessageBox.post("Start output step 6", "Step", MessageBox.INFORMATION); + new Thread() { + @Override + public void run() { + Map cx_map = new HashMap<>(); + cx_map.put(TMomFinalUtil.MKSJ_CHECKTABLE, "ä׸Ӧ׼׼.xlsx"); + cx_map.put(TMomFinalUtil.MKGCJ_CHECKTABLE, "ä׸Ӧ̼¼.xlsx"); + cx_map.put(TMomFinalUtil.MKMJ_CHECKTABLE, "ä׸Ӧĩ¼.xlsx"); + for(Entry set:cx_map.entrySet()){ + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,set.getKey(), set.getValue(),item,toTC,url,controlPlayType); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }.start(); + break; + + case 10: + //20181220-ReinhartEdit + data = getRCLData(item_id,controlPlayType); + //if (toTC == false) toTC= true ; + //System.out.println("Start output step 10"); + //MessageBox.post("Start output step 10", "Step", MessageBox.INFORMATION); + new Thread() { + @Override + public void run() { + Map cx_map = new HashMap<>(); + cx_map.put(TMomFinalUtil.MKSJ_CHECKTABLE, "ä׸Ӧ׼׼.xlsx"); + cx_map.put(TMomFinalUtil.MKGCJ_CHECKTABLE, "ä׸Ӧ̼¼.xlsx"); + cx_map.put(TMomFinalUtil.MKMJ_CHECKTABLE, "ä׸Ӧĩ¼.xlsx"); + for(Entry set:cx_map.entrySet()){ + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,set.getKey(), set.getValue(),item,toTC,url,controlPlayType); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }.start(); + break; + + case 3: + case 4: + case 5: + case 7: + case 8: + case 9: + case 11: + case 12: + case 13: + case 14: + case 15: + case 16: + case 17: + FileOutputStream output = new FileOutputStream(new File( + url+ fileSource)); + XSSFWorkbook wb = new XSSFWorkbook(is); + is.close(); + wb.write(output); + output.close(); + + if(operateCode==5){ + new Thread() { + @Override + public void run() { + + TMom001CXInstructCommand command = new TMom001CXInstructCommand(session, app,17, "ҵָ.xlsx",toTC,url,controlPlayType); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ҵָʧ", "", MessageBox.ERROR); + } + } + + }.start(); + } + //ҵָͬʱ鱨 + if(operateCode==6||operateCode==10) + { + // + System.out.println("Start output step 0"); + // + } + //ҵָͬʱ鱨 + + if(operateCode==7||operateCode==8||operateCode==9||operateCode==11||operateCode==12||operateCode==13||operateCode==14||operateCode==15){ + new Thread() { + @Override + public void run() { + Map cx_map = new HashMap<>(); + cx_map.put(TMomFinalUtil.JJGSJ_CHECKTABLE, "ӹƲƷ׼.xlsx"); + cx_map.put(TMomFinalUtil.JJGGCJ_CHECKTABLE, "ӹƲƷ.xlsx"); + cx_map.put(TMomFinalUtil.JJGMJ_CHECKTABLE, "ӹƲƷĩ.xlsx"); + for(Entry set:cx_map.entrySet()){ + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,set.getKey(), set.getValue(),item,toTC,url,controlPlayType); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + }.start(); + } + break; + default: + break; + } + new Thread() { + @Override + public void run() { + session.queueOperation(new TMom001CXInstructOperation(app, session,operateCode,fileSource,item,toTC,url+fileSource,data,controlPlayName)); + } + }.start(); + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + MessageBox.post("ҵָ", "", MessageBox.ERROR); + return; + } finally { + TCUtils.closeLogByPass(session, "ָ"); + TMomMethodUtil.setByPass(session, false); + if (ac_rs != null) { + com.connor.renben.process.plm.sql.util.SqlUtilT.free(ac_rs); + } + + com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); + } + + try { + super.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * ȡ + * @param item_id + * @param type + * @return + */ + private ArrayList> getCXData(String item_id,String type) { + String sj_gc_sql ="select distinct t1.plmeid,t1.rb3_meopid,rb3_qptbh,rb3_cp,t1.rb3_cpgc,rb3_clff,rb3_rl_zj,rb3_pl_zj,rb3_special,rb3_tstx,rb3_jqsb,rb3_hh from ((select plmeid,rb3_meopid,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff ,rb3_special,rb3_tstx,rb3_jqsb,rb3_hh from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc not like '%飨%' and rb3_smjy like '%׼%' and rb3_qptbh is not null) t1 left join (select plmeid,rb3_qptbh q1,rb3_cpgc,rb3_rl rb3_rl_zj,rb3_pl rb3_pl_zj from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc not like '%飨%' and rb3_smjy like '%̼%') t2 on rb3_qptbh=q1 and t1.rb3_cpgc=t2.rb3_cpgc )order by rb3_hh";//to_number(replace(rb3_qptbh,chr(10)))"; + String xj_sql = "select distinct plmeid p1,rb3_qptbh,rb3_cpgc,rb3_clff,rb3_special,rb3_rl rb3_rl_xj,rb3_pl rb3_pl_xj,rb3_hh from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc like '%飨%' order by rb3_hh"; + String mj_sql = "select rb3_qptbh from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc not like '%飨%' and rb3_smjy like '%ĩ%' and rb3_qptbh is not null order by rb3_qptbh"; + System.out.println("sql=>"+sj_gc_sql); + System.out.println("sql=>"+xj_sql); + System.out.println("sql=>"+mj_sql); + ResultSet rs = null; + // ResultSet sj_gc_rs = null; + ResultSet xj_rs = null; + ResultSet mj_rs = null; + try { + com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); + rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(sj_gc_sql); + xj_rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(xj_sql); + mj_rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(mj_sql); + ArrayList> data = new ArrayList<>(); + boolean have_rb3_jqsb = false; + boolean is_first = true; + ArrayList> xj_data = new ArrayList<>(); + int count = 0; + while(xj_rs.next()){ + + + ArrayList list = new ArrayList<>(); + list.add(getData(xj_rs.getString("RB3_QPTBH"))); + list.add(getData(xj_rs.getString("RB3_CPGC"))+"special"+getData(xj_rs.getString("RB3_SPECIAL"))); + list.add(getData(xj_rs.getString("RB3_CLFF"))); + String rl_xj = getData(xj_rs.getString("RB3_RL_XJ")); + String pl_xj = getData(xj_rs.getString("RB3_PL_XJ")); + list.add(rl_xj+(" ".equals(rl_xj)&&" ".equals(pl_xj)?" ":"/")+pl_xj); + xj_data.add(list); + + } + ArrayList mjNum = new ArrayList<>(); + while(mj_rs.next()){ + mjNum.add(getData(mj_rs.getString("RB3_QPTBH"))); + } + ArrayList qptbhs = new ArrayList<>(); + while(rs.next()){ + if(count==24){ + System.out.println("in"); + } + ArrayList list = new ArrayList<>(); + String qptbh = getData(rs.getString("RB3_QPTBH")); + list.add(qptbh); + list.add(getData(rs.getString("RB3_CP"))); + String cpgc = getData(rs.getString("RB3_CPGC"))+"special"+" "; + + list.add(cpgc); + String clff = getData(rs.getString("RB3_CLFF")); + list.add(clff); + String rl_zj = getData(rs.getString("RB3_RL_ZJ")); + String pl_zj = getData(rs.getString("RB3_PL_ZJ")); + list.add(rl_zj+"/"+pl_zj); + boolean have_cpgc = false; + for(ArrayList xj_arr:xj_data){ + if(xj_arr.indexOf(qptbh)!=-1){ + list.add(xj_arr.get(3)); + have_cpgc = true; + break; + } + } + if(!have_cpgc){ + list.add("/"); + } + list.add(getData(rs.getString("RB3_TSTX"))); + list.add(""); + if(mjNum.indexOf(qptbh)!=-1){ + list.add(""); + } + else + list.add(" "); + if(qptbh.equals("33")) + System.out.println("enter!"); + checkClFF(data,list,qptbh,qptbhs,cpgc,clff,2,is_first); + is_first = false; + qptbhs.add(qptbh); + // data.add(list); + //ȡ豸 + if(!have_rb3_jqsb){ + rb3_jqsb = getData(rs.getString("RB3_JQSB")); + have_rb3_jqsb = true; + } + count++; + } + return data; + } + catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + com.connor.renben.process.plm.sql.util.SqlUtilT.free(rs); + } + com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); + } + return null; + } + + /** + * ȡ + * + * @param item_id + * @return + */ + private ArrayList> getZXData(String item_id, String type) { + String sql = "select distinct plmeid,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff,rb3_rl_sj,rb3_pl_sj,rb3_rl_gc,rb3_pl_gc,rb3_special,rb3_tstx,rb3_jqsb,rb3_hh from(select plmeid,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff ,rb3_special,rb3_rl rb3_rl_sj,rb3_pl rb3_pl_sj,rb3_tstx,rb3_jqsb,rb3_hh from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc not like '%飨%' and rb3_smjy like '%׼%' and rb3_qptbh is not null order by rb3_qptbh) t1 left join (select rb3_qptbh q1,rb3_rl rb3_rl_gc,rb3_pl rb3_pl_gc from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc not like '%飨%' and rb3_smjy like '%̼%') t2 on rb3_qptbh=q1 order by rb3_hh"; +// String sql = "select distinct plmeid,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff,rb3_rl,rb3_pl,rb3_special,rb3_tstx,rb3_jqsb,rb3_hh from(select plmeid,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff ,rb3_special,rb3_tstx,rb3_jqsb,rb3_hh from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc not like '%飨%' and rb3_smjy like '%׼%' and rb3_qptbh is not null order by rb3_qptbh) t1 left join (select rb3_qptbh q1,rb3_rl,rb3_pl from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc not like '%飨%' and rb3_smjy like '%̼%') t2 on rb3_qptbh=q1 order by rb3_hh"; +// String xj_sql = "select distinct plmeid p1,rb3_qptbh,rb3_rl rb3_rl_xj,rb3_pl rb3_pl_xj from rb3_controlplan where rb3_controlplan.rb3_meopid='"+item_id+"' and type='"+type+"' and rb3_gcmc like '%飨%' "; + System.out.println(sql); +// System.out.println(xj_sql); + ResultSet rs = null; + ResultSet xj_rs = null; + try { + com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); + rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(sql); +// xj_rs = com.connor.renben.process.plm.sql.util.SqlUtilT +// .read(xj_sql); + ArrayList> data = new ArrayList<>(); + ArrayList qptbhs = new ArrayList<>(); + boolean is_first = true; + boolean have_rb3_jqsb = false; + ArrayList> xj_data = new ArrayList<>(); +// while(xj_rs.next()){ +// ArrayList list = new ArrayList<>(); +// list.add(getData(xj_rs.getString("RB3_QPTBH"))); +// String rl_xj = getData(xj_rs.getString("RB3_RL_XJ")); +// String pl_xj = getData(xj_rs.getString("RB3_PL_XJ")); +// list.add(rl_xj+(" ".equals(rl_xj)&&" ".equals(pl_xj)?" ":"/")+pl_xj); +// xj_data.add(list); +// } + while(rs.next()){ + ArrayList list = new ArrayList<>(); + String qptbh = getData(rs.getString("RB3_QPTBH")); + list.add(qptbh); + list.add(getData(rs.getString("RB3_CP"))); + String cpgc = getData(rs.getString("RB3_CPGC")); + list.add(cpgc + "special"+getData(rs.getString("RB3_SPECIAL"))); + String clff = getData(rs.getString("RB3_CLFF")); + list.add(clff); + String rl_sj = getData(rs.getString("RB3_RL_SJ")); + String pl_sj = getData(rs.getString("RB3_PL_SJ")); + list.add(" ".equals(rl_sj)&&" ".equals(pl_sj)?" ":rl_sj+"/"+pl_sj); + String rl = getData(rs.getString("RB3_RL_GC")); + String pl = getData(rs.getString("RB3_PL_GC")); + list.add(" ".equals(rl)&&" ".equals(pl)?" ":rl+"/"+pl); + if(!(" ".equals(rl)&&" ".equals(pl))) + list.add("1/"); + else + list.add(" "); + list.add(getData(rs.getString("RB3_TSTX"))); + checkClFF(data,list,qptbh,qptbhs,cpgc,clff,2,is_first); + is_first = false; + qptbhs.add(qptbh); +// data.add(list); + if(!have_rb3_jqsb){ + rb3_jqsb = getData(rs.getString("RB3_JQSB")); + have_rb3_jqsb = true; + } + } + return data; + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + com.connor.renben.process.plm.sql.util.SqlUtilT.free(rs); + } + + com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); + } + return null; + } + /** + * ȡս + * @param rs + * @return + * @throws SQLException + */ + private ArrayList> getSJData(String item_id,String type) throws SQLException { + String sj_sql = "select * from RB3_CONTROLPLAN where rb3_meopid='"+ item_id + "' and type='"+type+"' and RB3_GCMC not like '飨%' and rb3_gc is null and rb3_qptbh is not null order by rb3_hh"; + System.out.println(sj_sql); + ResultSet rs = null; + try { + com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); + rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(sj_sql); + ArrayList> data = new ArrayList<>(); + ArrayList qptbhs = new ArrayList<>(); + boolean have_rb3_jqsb = false; + boolean is_first = true; + while (rs.next()) { + ArrayList array_SJ = new ArrayList<>(); + if (rs.getString("RB3_QPTBH") != null) { + String qptbh = getData(rs.getString("RB3_QPTBH")); + array_SJ.add(qptbh); + array_SJ.add(getData(rs.getString("RB3_CP"))); + String cpgc = getData(rs.getString("RB3_CPGC")); + array_SJ.add(cpgc + "special"+getData(rs.getString("RB3_SPECIAL"))); + String clff = getData(rs.getString("RB3_CLFF")); + array_SJ.add(clff); + String rl = getData(rs.getString("RB3_RL")); + String pl = getData(rs.getString("RB3_PL")); + array_SJ.add(rl+(" ".equals(rl)&&" ".equals(pl)?" ":"/")+pl); + array_SJ.add(getData(rs.getString("RB3_TSTX"))); + checkClFF(data,array_SJ,qptbh,qptbhs,cpgc,clff,2,is_first); + is_first = false; + qptbhs.add(qptbh); + if(!have_rb3_jqsb){ + rb3_jqsb = getData(rs.getString("RB3_JQSB")); + have_rb3_jqsb = true; + } + } + } + return data; + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + com.connor.renben.process.plm.sql.util.SqlUtilT.free(rs); + } + com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); + } + return null; + // TODO Auto-generated method stub + + } + + + + /** + * ȡȴ + * @param rs + * @return + * @throws SQLException + */ + private ArrayList> getRCLData(String item_id,String type) throws SQLException { + //String st_sql = "select * from RB3_CONTROLPLAN where rb3_meopid='"+ item_id + "' and type='"+type+"' and RB3_GCMC like '%ȴ%' and rb3_SMJY like '%豸%' order by rb3_hh "; + String st_sql = "select * from RB3_CONTROLPLAN where rb3_meopid='"+ item_id + "' and type='"+type+"' and rb3_SMJY like '%豸%' order by rb3_hh "; + + + //MessageBox.post(st_sql, "SQL", MessageBox.WARNING); + System.out.println(st_sql); + ResultSet rs = null; + int RowNum = 0; + try { + com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); + rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(st_sql); + ArrayList> data = new ArrayList<>(); + ArrayList qptbhs = new ArrayList<>(); + boolean have_rb3_jqsb = false; + boolean is_first = true; + + + + while (rs.next()) { + RowNum = RowNum +1; + ArrayList array_ST = new ArrayList<>(); + if (rs.getString("RB3_GC") != null) { + String qptbh = getData(rs.getString("RB3_QPTBH")); + array_ST.add(qptbh); + array_ST.add(getData(rs.getString("RB3_GC"))); + String cpgc = getData(rs.getString("RB3_CPGC")); + array_ST.add(cpgc +getData(rs.getString("RB3_SPECIAL"))); + String clff = getData(rs.getString("RB3_CLFF")); + array_ST.add(clff); + String rl = getData(rs.getString("RB3_RL")); + String pl = getData(rs.getString("RB3_PL")); + array_ST.add(rl+(" ".equals(rl)&&" ".equals(pl)?" ":"/")+pl); + array_ST.add(getData(rs.getString("RB3_TSTX"))); + checkClFF(data,array_ST,qptbh,qptbhs,cpgc,clff,2,is_first); + is_first = false; + qptbhs.add(qptbh); + if(!have_rb3_jqsb){ + rb3_jqsb = getData(rs.getString("RB3_JQSB")); + have_rb3_jqsb = true; + } + } + } + + if(RowNum == 0) + { + MessageBox.post("Have No Records", "Info", MessageBox.INFORMATION); + } + + + return data; + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + com.connor.renben.process.plm.sql.util.SqlUtilT.free(rs); + } + com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); + } + return null; + // TODO Auto-generated method stub + + } + + /** + * //жһĿǷж⹤ + * @param data + * @param list + * @param qptbh + * @param qptbhs + * @param clff + * @param + * @param i + * @param is_first + */ + private void checkClFF(ArrayList> data, + ArrayList list, String qptbh, ArrayList qptbhs, + String cpgc, String clff, int i, boolean is_first) { + boolean do_add = false; + if(!is_first){ + if(qptbhs.indexOf(qptbh)!=-1){ + for(ArrayList arr:data){ + if(arr.get(0).equals(qptbh)){ + if(!arr.get(i).equals(cpgc)){ + do_add = true; + } + } + } + } + else + data.add(list); + if(do_add){ + data.add(list); + do_add = false; + } + } + else + data.add(list); + + } + private static String getData(String str){ + if(str!=null) + { + if(str.indexOf("\n") > 0 && str.indexOf("\r") > 0) + { + return str.split("\n")[0].split("\r")[0].replace(" ", ""); + } + else if(str.indexOf("\n") > 0) + { + return str.split("\n")[0].replace(" ", ""); + } + else if(str.indexOf("\r") > 0) + { + return str.split("\r")[0].replace(" ", ""); + } + else + { + return str; + } + } + return " "; + } + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private String getControlType() throws Exception { + String kzjhType = null; + TCComponent[] its = item.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponentItemRevision tccir = (TCComponentItemRevision) its[0]; + AIFComponentContext[] aifccs = tccir.whereReferenced(); + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEProcess) { + TCComponentMEProcess tccmep = (TCComponentMEProcess) aifcc_MEOP.getComponent(); + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>"+kzjh); + if(toTC){ + if ("RB3_SCKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjh.getReleasedItemRevisions().length!=0){ + controlPlayName = getLatesReleasedItemRevision(kzjh).getProperty("object_string"); + kzjhType=itemType; + } + if ("RB3_SSCKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjh.getReleasedItemRevisions().length!=0) + if(!"RB3_SCKZJH".equals(kzjhType)){ + controlPlayName = getLatesReleasedItemRevision(kzjh).getProperty("object_string"); + kzjhType=itemType; + } + if ("RB3_YJKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjh.getReleasedItemRevisions().length!=0) + if(kzjhType==null){ + controlPlayName = getLatesReleasedItemRevision(kzjh).getProperty("object_string"); + kzjhType=itemType; + } + System.out.println("kzjhType========================>"+kzjhType); + } + else{ + if ("RB3_SCKZJH".equals(itemType)) + //жǷΪƼƻ + kzjhType=itemType; + + if ("RB3_SSCKZJH".equals(itemType)) + //жǷΪƼƻ + if(!"RB3_SCKZJH".equals(kzjhType)) + kzjhType=itemType; + + if ("RB3_YJKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjhType==null) + kzjhType=itemType; + + } + } + } + } + } + return kzjhType; + } + /** + * ȡѷĶ汾 + * @param item + * @return + * @throws NumberFormatException + * @throws TCException + */ + private TCComponentItemRevision getLatesReleasedItemRevision( + TCComponentItem item) throws Exception { + int revision_id = 0; + TCComponentItemRevision latestReleaseItemRevion = new TCComponentItemRevision(); + TCComponentItemRevision[] itemRevisions = item.getReleasedItemRevisions(); +// if(itemRevisions.length==1){ +// latestReleaseItemRevion = itemRevisions[0]; +// } +// else{ + for(TCComponentItemRevision itemRevision : itemRevisions){ + int current_revision_id = Integer.parseInt(itemRevision.getProperty("current_revision_id")); + if(current_revision_id >= revision_id){ + revision_id = current_revision_id; + latestReleaseItemRevion = itemRevision; + } + } +// } + return latestReleaseItemRevion; + } +} diff --git a/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructDialog.java b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructDialog.java new file mode 100644 index 0000000..4e03210 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructDialog.java @@ -0,0 +1,265 @@ +package com.connor.renben.process.plm.tmom001; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; +import java.util.ResourceBundle; + +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.connor.renben.process.plm.bean.CXListBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +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 TMom001CXInstructDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFUIApplication app; + private TCSession session; + private int operateCode; + private String fileSource; + private TCComponentMEOPRevision item; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private JPanel panel1; + private JPanel panel2; + private JPanel panel3; + private JPanel rootPanel; + private JRadioButton radioBtn1; + private JRadioButton radioBtn2; + private ButtonGroup bg; + private boolean have_ssckzjh; + private boolean have_sckzjh; + + public TMom001CXInstructDialog() { + super(false); + } + + public TMom001CXInstructDialog(AbstractAIFUIApplication app, + TCSession session, int operateCode, String fileSource) { + super(false); + this.app = app; + this.session = session; + this.operateCode = operateCode; + this.fileSource = fileSource; +// this.item = item; + + + init(); + + } + + public void init() { + getControlType(); + + this.setPreferredSize(new Dimension(480, 150)); + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("dc_display.TITLE")+fileSource.split("\\.")[0]); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + okButton = new JButton(rb.getString("qd_display.TITLE")); + celButton = new JButton(rb.getString("qx_display.TITLE")); + fileButton = new JButton("..."); + radioBtn1 = new JRadioButton(rb.getString("ssckzjh_display.TITLE"),true); + radioBtn2 = new JRadioButton(rb.getString("sckzjh_display.TITLE")); + ButtonGroup bg = new ButtonGroup(); + bg.add(radioBtn1); + bg.add(radioBtn2); + + fileButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + selectFileButtonEvent(e); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + try { + okEvent(e); +// MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + } catch (IOException e1) { + MessageBox.post("ʧ", "ʧ", MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + celEvent(e); + } + }); + pathText = new JTextField(30); + pathText.setText("C:"); + + panel1 = new JPanel(new PropertyLayout()); + panel1.add("1.1.right.top.preferred.preferred", new JLabel(" ")); + panel1.add("2.1.right.top.preferred.preferred", new JLabel(rb.getString("xzwjj_display.TITLE"))); + panel1.add("2.2.left.top.preferred.preferred", pathText); + panel1.add("2.3.left.top.preferred.preferred", fileButton); + panel2 = new JPanel(new FlowLayout()); + panel2.add(okButton); + panel2.add(new JLabel(" ")); + panel2.add(celButton); + if(have_ssckzjh&&have_sckzjh){ + panel3 = new JPanel(new FlowLayout()); + panel3.add(radioBtn1); + panel3.add(radioBtn2); + } + + rootPanel = new JPanel(new BorderLayout()); + rootPanel.add(panel1, BorderLayout.CENTER); + rootPanel.add(panel2, BorderLayout.SOUTH); + if(have_ssckzjh&&have_sckzjh){ + rootPanel.add(panel3, BorderLayout.NORTH); + } + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + /** + * ȷťҵ¼ + * + * @param e + * @throws IOException + */ + public void okEvent(ActionEvent e) throws IOException { + String kzjhType = null; + if(have_ssckzjh&&have_sckzjh) + kzjhType = this.radioBtn1.isSelected()?"RB3_SSCKZJH":"RB3_SCKZJH"; + else if(have_ssckzjh) + kzjhType = "RB3_SSCKZJH"; + else{ + kzjhType = "RB3_SCKZJH"; + } + TMom001CXInstructCommand command = new TMom001CXInstructCommand(session, app,operateCode, fileSource,false,this.pathText.getText()+"\\",kzjhType); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } +// System.out.println(this.pathText.getText()); + this.dispose(); + } + /** + * ȡťҵ¼ + * + * @param e + */ + public void celEvent(ActionEvent e) { + + 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()); + } + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private void getControlType() { + try { + String kzjhType = null; + InterfaceAIFComponent targetcomp = this.app.getTargetComponent(); + try { + item = (TCComponentMEOPRevision) targetcomp; + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ѡ汾󴫵ݣ", "", MessageBox.ERROR); + e.printStackTrace(); + } + TCComponent[] its = item.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponentItemRevision tccir = (TCComponentItemRevision) its[0]; + AIFComponentContext[] aifccs = tccir.whereReferenced(); + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEProcess) { + TCComponentItem tccmep = (TCComponentItem) aifcc_MEOP.getComponent(); + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + String type = tccmepChildren.getComponent().getType(); + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + + if ("RB3_SCKZJH".equals(itemType)){ + +// //жǷΪƼƻ +// kzjhType=itemType; + have_sckzjh = true; + } + + if ("RB3_SSCKZJH".equals(itemType)) { + //жǷΪƼƻ + if(!"RB3_SCKZJH".equals(kzjhType)) +// kzjhType=itemType; + have_ssckzjh = true; + } + + + + + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructHandler.java b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructHandler.java new file mode 100644 index 0000000..fb0cc83 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructHandler.java @@ -0,0 +1,122 @@ +package com.connor.renben.process.plm.tmom001; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + +public class TMom001CXInstructHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + int operateCode = -1; + String fileSource = null; + switch (commandId) { + case "com.connor.renben.process.plm.commands.CXInstructionOutputCommand": + operateCode = TMomFinalUtil.CX_INSTRUCTION; + fileSource="ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.ZXInstructionOutputCommand": + operateCode = TMomFinalUtil.ZX_INSTRUCTION; + fileSource="ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.SJInstructionOutputCommand": + operateCode = TMomFinalUtil.SJ_INSTRUCTION; + fileSource = "սҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.PSInstructionOutputCommand": + operateCode = TMomFinalUtil.PS_INSTRUCTION; + fileSource = "ɰҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.GSInstructionOutputCommand": + operateCode = TMomFinalUtil.GS_INSTRUCTION; + fileSource = "ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.STInstructionOutputCommand": + operateCode = TMomFinalUtil.ST_INSTRUCTION; + fileSource = "STҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.EldecRCLInstructionOutputCommand": + operateCode = TMomFinalUtil.ELDECRCL_INSTRUCTION; + fileSource = "Eldecȴָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.BZDXMJInstructionOutputCommand": + operateCode = TMomFinalUtil.BZDXMJ_INSTRUCTION; + fileSource = "Զëָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.GSJInstructionOutputCommand": + operateCode = TMomFinalUtil.GSJ_INSTRUCTION; + fileSource = "˿ָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JJG1InstructionOutputCommand": + operateCode = TMomFinalUtil.JJG_INSTRUCTION; + fileSource = "ӹָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JJG2InstructionOutputCommand": + operateCode = TMomFinalUtil.JJG_INSTRUCTION; + fileSource = "ӹָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.PTRCLInstructionOutputCommand": + operateCode = TMomFinalUtil.PTRCL_INSTRUCTION; + fileSource = "ͨȴָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.TZInstructionOutputCommand": + operateCode = TMomFinalUtil.TZ_INSTRUCTION; + fileSource = "̨깤ָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.TGSXMJInstructionOutputCommand": + operateCode = TMomFinalUtil.TGSXMJ_INSTRUCTION; + fileSource = "ͨʽëָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.TYMCInstructionOutputCommand": + operateCode = TMomFinalUtil.TYMC_INSTRUCTION; + fileSource = "ͨĥָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.WXMInstructionOutputCommand": + operateCode = TMomFinalUtil.WXM_INSTRUCTION; + fileSource = "ĥָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.YZInstructionOutputCommand": + operateCode = TMomFinalUtil.YZ_INSTRUCTION; + fileSource = "ѹװָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.TSInstructionOutputCommand": + operateCode = TMomFinalUtil.TS_INSTRUCTION; + fileSource = "̽ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CCInstructionOutputCommand": + operateCode = TMomFinalUtil.CC_INSTRUCTION; + fileSource = "ָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JGZXInstructionOutputCommand": + operateCode = TMomFinalUtil.JGZX_INSTRUCTION; + fileSource = "ӹĹָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.WGInstructionOutputCommand": + operateCode = TMomFinalUtil.WG_INSTRUCTION; + fileSource = "ָ.xlsx"; + break; + default: + break; + } + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); +// new TMom001CXInstructDialog(app,session,operateCode,fileSource); + TMom001CXInstructCommand command = new TMom001CXInstructCommand(session, app,operateCode, fileSource,true,"D:\\",null); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ҵָʧ", "", MessageBox.ERROR); + } + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructOperation.java b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructOperation.java new file mode 100644 index 0000000..a621466 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom001/TMom001CXInstructOperation.java @@ -0,0 +1,578 @@ +package com.connor.renben.process.plm.tmom001; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.MessageBox; + +public class TMom001CXInstructOperation extends AbstractAIFOperation { + + private AbstractAIFUIApplication app; + private TCSession session; + private int operateCode; + private String fileSource; + private String fileOutUrl; + private String meop_id; + private String meop_name; + private TCComponentMEOPRevision item; + private boolean toTC; + private String controlType; + private String controlPlayName; + Map map_CellNameAndProp = new HashMap(); + Map map_ItemAndProp = new HashMap(); + Map map_CellnameAndValue =new HashMap(); + ArrayList product_Props = new ArrayList<>(); + ArrayList productRevM_Props = new ArrayList<>(); + ArrayList product_CellNames = new ArrayList<>(); + ArrayList productRevM_CellNames = new ArrayList<>(); + ArrayList> data; + private List productNameList24 = new ArrayList(); + private List productNameList18 = new ArrayList(); + + + public TMom001CXInstructOperation(AbstractAIFUIApplication app, + TCSession session, int operateCode, String fileSource, TCComponentMEOPRevision item, boolean toTC,String fileOutUrl, ArrayList> data, String controlPlayName) { + this.app = app; + this.session = session; + this.operateCode = operateCode; + this.fileSource = fileSource; + this.fileOutUrl = fileOutUrl; + this.item = item; + this.toTC = toTC; + this.data = data; + this.controlPlayName = controlPlayName; +// this.is = is; + } + @Override + public void executeOperation() throws Exception { + writeProp(); + if(toTC){ + for (String key : map_CellnameAndValue.keySet()) { + System.out.println(key + ":" + map_CellnameAndValue.get(key)); + } + //"TC"ҵָ + //MessageBox.post("TCҵָ!!!!!", "Step", MessageBox.INFORMATION); + createCXZYZDS(); + } + else{ + //MessageBox.post("TCҵָ!!!!!", "Step", MessageBox.INFORMATION); + for (String key : map_CellnameAndValue.keySet()) { + System.out.println(key + ":" + map_CellnameAndValue.get(key)); + } + File newFile = new File(TMomMethodUtil.getFile(session, fileSource.split("\\.")[0], "MSExcelX").getPath()); + InputStream is = new FileInputStream(newFile); + byte[] model_file_byte = new byte[is.available()]; + is.read(model_file_byte); + is.close(); + OutputStream os = new FileOutputStream(fileOutUrl); + os.write(model_file_byte); + os.close(); +// setVersionNum(itme.getLatestItemRevision()); + map_CellnameAndValue.put("汾", " "); + File model_flie = new File(fileOutUrl); + + writeToFile(model_flie,true); + //ҵָ鵼 + ExcelUtil07.writeExcelWithCellName(model_flie,fileOutUrl,map_CellnameAndValue,operateCode,meop_name); + MessageBox.post(""+fileSource.split("\\.")[0]+"", "ɹ", MessageBox.INFORMATION); + } + System.out.println("over"); + TCUtils.closeLogByPass(session, "ָ"); + TMomMethodUtil.setByPass(session, false); + } +/** + * + * @throws Exception + */ +//ȡTCϵд뵽excel +private void writeProp(){ + // TODO Auto-generated method stub + getEquipmentValues(); + try { + getCellNameAndProp(); + meop_id = item.getProperty("item_id"); + meop_name = item.getProperty("object_name"); + if(operateCode!=0&&operateCode!=1&&operateCode!=2&&operateCode!=3&&operateCode!=4&&operateCode!=5&&operateCode!=16&&operateCode!=17) + map_CellnameAndValue.put("", meop_name.split("/")[0]); + //汾 + if(fileSource.indexOf("")!=-1){ + if(operateCode!=7&&operateCode!=8&&operateCode!=11&&operateCode!=12&&operateCode!=14){ + TCComponent itemRevM = item.getRelatedComponents("IMAN_master_form_rev")[0]; + map_CellnameAndValue.put("ӹ", itemRevM.getProperty("rb3_jgcx")); + if(operateCode==6||operateCode==10){ + map_CellnameAndValue.put("Ȧͺ", itemRevM.getProperty("rb3_xqxh")); + map_CellnameAndValue.put("Һͺ", itemRevM.getProperty("rb3_zhyxh")); + } + } + } + TCComponent[] its; + its = item.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponentItemRevision tccir= (TCComponentItemRevision) its[0]; + AIFComponentContext[] aifccs = tccir.whereReferenced(); + for(AIFComponentContext aifcc_MEOP:aifccs){ + TCComponentMEProcess tccmep = (TCComponentMEProcess) aifcc_MEOP.getComponent(); + AIFComponentContext[] aifcc_MEPs = tccmep.whereReferenced(); + if(operateCode!=17) + getMEToolList(map_CellnameAndValue, tccmep, meop_id); + + for(AIFComponentContext aifcc_MEP:aifcc_MEPs){ + String aifcc_MEP_Type = aifcc_MEP.getComponent().getType(); + if("RB3_Product".equals(aifcc_MEP_Type)){ + TCComponentItem product = (TCComponentItem) aifcc_MEP.getComponent(); + ArrayList product_Properties = (ArrayList)map_ItemAndProp.get(aifcc_MEP_Type); + for(int i = 0 ; i < product_Properties.size() ; i++){ + map_CellnameAndValue.put(product_CellNames.get(i), product.getProperty(product_Properties.get(i))); + TCComponentItemRevision productRev = product.getLatestItemRevision(); + TCComponent prodectRevM = productRev.getRelatedComponent("IMAN_master_form_rev"); + ArrayList productRevM_Properties = (ArrayList)map_ItemAndProp.get(prodectRevM.getType()); + for(int j = 0; j < productRevM_Properties.size() ; j++){ + map_CellnameAndValue.put(productRevM_CellNames.get(j), prodectRevM.getProperty(productRevM_Properties.get(j))); + } +// map_CellnameAndValue.put(productRevM_CellNames.get(0), prodectRevM.getProperty(productRevM_Properties.get(0))); + } + break; + } + } + break; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch(Exception e){ + e.printStackTrace(); + MessageBox.post("ѡ󴫵ݣ", "", MessageBox.ERROR); + } + } +/** + * ȡװ豸 + * @param itemն + * @param meop_idid + * @return + */ +private void getMEToolList(Map map,TCComponentItem item, String meop_id){ + try { + int daopianNum = 0; + int daoganNum = 0; + StringBuilder scsb = new StringBuilder();//豸 + StringBuilder gylc = new StringBuilder();// + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline=((TCComponentBOMLine) children.getComponent()); + if(operateCode!=0&&operateCode!=1&&operateCode!=2&&operateCode!=3&&operateCode!=4&&operateCode!=5&&operateCode!=17){ + if(gylc.length()!=0) + gylc.append("-"); + gylc.append(subline.getProperty("bl_rev_object_name").split("/")[0]); + map.put("",gylc.toString()); + } + if(meop_id.equals(subline.getProperty("bl_item_item_id"))){ + AIFComponentContext[] sublineChildrens = subline.getChildren(); + Map sbjt = new HashMap<>(); + for(AIFComponentContext sublineChildren:sublineChildrens){ + TCComponent meTool = (TCComponent) sublineChildren.getComponent(); + String meToolName= meTool.getProperty("bl_item_fnd0IcsClassNames"); + if("ѹ".equals(meToolName)||"ѹ".equals(meToolName)||"".equals(meToolName)||"ӹ".equals(meToolName)||"ս¯".equals(meToolName)||"¯".equals(meToolName)||"ST".equals(meToolName)||"ɰ".equals(meToolName)||"".equals(meToolName)||"豸".equals(meToolName)||"ϴ豸".equals(meToolName)||"ȴ".equals(meToolName)||"ĥ".equals(meToolName)||"ë".equals(meToolName)){ + String str = meTool.getProperty("bl_item_object_name"); + String[] keyAndValue = str.split("/"); + if(keyAndValue.length>1){ + String map_key = keyAndValue[0]; + String map_value = keyAndValue[1]; + if(sbjt.containsKey(map_key)) + sbjt.put(map_key, sbjt.get(map_key).append(",").append(map_value)); + else + sbjt.put(map_key, new StringBuilder (map_value)); + } + else + if(!sbjt.containsKey(str)){ + sbjt.put(str, null); + } + } + if(operateCode==9){ + if("Ƭ".equals(meToolName)){ + daopianNum++; + map.put("Ƭ"+daopianNum, meTool.getProperty("bl_rev_object_name")); + } + if("".equals(meToolName)){ + daoganNum++; + map.put(""+daoganNum, meTool.getProperty("bl_rev_object_name")); + } + } + if(operateCode==7||operateCode==8||operateCode==9||operateCode==11||operateCode==15) + if("о".equals(meToolName)||"ӹļо".equals(meToolName)){ + map.put("о", meTool.getProperty("bl_rev_object_name")); + } + } + for(String key:sbjt.keySet()){ + if(scsb.length()!=0) + scsb.append(";"); + if(sbjt.get(key)!=null) + scsb.append(key+"/"+sbjt.get(key)); + else + scsb.append(key); + } + map.put("豸", scsb.toString()); +// } + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } +} +/** + * ȡѡϢ + * @param itemType + * @return + */ + private void getCellNameAndProp() { + + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, "Cust_CellNames_Props"); + Map option_map = new HashMap<>(); + option_map.put("Ʒ", "RB3_Product"); + option_map.put("Ʒ汾", "RB3_ProductRevisionMaster"); + for(String prop : props){ + if(option_map.containsKey(prop.split(":")[0])){ + for(String cellNameAndProp :prop.split(":")[1].split("/")){ + String cellName = cellNameAndProp.split("@")[0]; + String property = null; + String all_Property = cellNameAndProp.split("@")[1]; + if(option_map.get(prop.split(":")[0]).equals(all_Property.split("-")[0])){ + property = all_Property.split("-")[1]; + + if("RB3_Product".equals(option_map.get(prop.split(":")[0]))){ + product_Props.add(property); + product_CellNames.add(cellName); + } + if("RB3_ProductRevisionMaster".equals(option_map.get(prop.split(":")[0]))){ + productRevM_Props.add(property); + productRevM_CellNames.add(cellName); + } + map_CellNameAndProp.put(cellName, property); + } + } + } +// if("Ʒ汾".equals(prop.split(":")[0])){ +// for(String cellNameAndProp :prop.split(":")[1].split("/")){ +// String cellName = cellNameAndProp.split("@")[0]; +// String property = null; +// String all_Property = cellNameAndProp.split("@")[1]; +// if("RB3_ProductRevisionMaster".equals(all_Property.split("-")[0])){ +// property = all_Property.split("-")[1]; +// productRevM_Props.add(property); +// productRevM_CellNames.add(cellName); +// map_CellNameAndProp.put(cellName, property); +// } +// +// } +// } + } + + map_ItemAndProp.put("RB3_Product",product_Props); + map_ItemAndProp.put("RB3_ProductRevisionMaster",productRevM_Props); + +} + + private void createCXZYZDS() { + try { + TCComponent[] zyzdss = item + .getRelatedComponents("RB3_zuoyezhidaoshu"); + boolean have_zyzds = false; + String itemName = map_CellnameAndValue.get("Ʒ")+fileSource.split("\\.")[0]; + for (TCComponent zyzds : zyzdss) { + TCComponentItem zyzds_final = null; + if ("RB3_ZYZDS".equals(zyzds.getType())) { + if(zyzds.getProperty("object_name").indexOf(fileSource.split("\\.")[0])!=-1){ + + zyzds_final = (TCComponentItem) zyzds; + zyzds_final.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev").setProperty("rb3_source",controlPlayName); + outputExcel(zyzds_final,itemName); + have_zyzds = true; + } + } + } + if(!have_zyzds){ + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("RB3_ZYZDS"); + TCComponentType uom = this.session.getTypeComponent("UnitOfMeasure"); + TCComponent[] uoms = uom.extent(); +// TCComponentItem oldItem = ccomponentitemtype.create("WI99999999","00","RB3_ZYZDS","TEST","",uoms[0]); + TCComponentItem newItem1 = null; + TCComponentItem newItem2 = null; + if(itemName.indexOf("")!=-1){ + newItem1 = ccomponentitemtype.create(ccomponentitemtype.getNewID(),"00","RB3_ZYZDS",itemName+"(ʽ)","",uoms[0]); + newItem2 = ccomponentitemtype.create(ccomponentitemtype.getNewID(),"00","RB3_ZYZDS",itemName+"(Զ)","",uoms[0]); + createGYJT(newItem1,ccomponentitemtype,itemName,uoms); + item.add("RB3_zuoyezhidaoshu", newItem1); + outputExcel(newItem1,itemName); + createGYJT(newItem2,ccomponentitemtype,itemName,uoms); + item.add("RB3_zuoyezhidaoshu", newItem2); + outputExcel(newItem2,itemName); + new File(fileOutUrl).delete(); + } + else if(itemName.indexOf("")!=-1){ + newItem1 = ccomponentitemtype.create(ccomponentitemtype.getNewID(),"00","RB3_ZYZDS",itemName+"(Զ)","",uoms[0]); + item.add("RB3_zuoyezhidaoshu", newItem1); + outputExcel(newItem1,itemName); + newItem2 = ccomponentitemtype.create(ccomponentitemtype.getNewID(),"00","RB3_ZYZDS",itemName+"(ֶ)","",uoms[0]); + item.add("RB3_zuoyezhidaoshu", newItem2); + outputExcel(newItem2,itemName); + } + else{ + newItem1 = ccomponentitemtype.create(ccomponentitemtype.getNewID(),"00","RB3_ZYZDS",itemName,"",uoms[0]); + item.add("RB3_zuoyezhidaoshu", newItem1); + + outputExcel(newItem1,itemName); + } + newItem1.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev").setProperty("rb3_source",controlPlayName); + if(newItem2!=null) + newItem2.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev").setProperty("rb3_source",controlPlayName); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * ιռͼ + * @param uoms + * @param itemName + * @param ccomponentitemtype + * @throws TCException + */ + private void createGYJT(TCComponentItem newItem, TCComponentItemType ccomponentitemtype, String itemName, TCComponent[] uoms) throws TCException { + if(operateCode==0){ + String as1[] = { TMomMethodUtil.getFile(session, "ռͼģ","RB3_AutoCAD").getPath()};// ļ· + String as2[] = { "RB3_dwg" }; + String as3[] = { "RB3_AutoCAD" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType + .create(map_CellnameAndValue.get("Ʒ")+"ܶȺͳߴָ.dwg", "RB3_dwg", + "RB3_AutoCAD"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + newItem.getLatestItemRevision().add("TC_Attaches", tccomponentDataset); + } + } + /** + * ҵָ + * @param itme + * @param itemName + * @throws Exception + */ + private void outputExcel(TCComponentItem itme, String itemName) throws Exception{ + + AIFComponentContext[] zyzdsChildrens = itme.getLatestItemRevision().getChildren(); + boolean have_Excel = false; + for(AIFComponentContext zyzdsChildren:zyzdsChildrens){ + if("MSExcelX".equals(zyzdsChildren.getComponent().getType())){ + have_Excel = true; + int getConfir = ConfirmationDialog.post(" ", fileSource.split("\\.")[0]+"ѴڣǷ񸲸ǣ"); + if(getConfir==ConfirmationDialog.YES){ + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + + writeToFile(tcFile[0].getFmsFile(),false); + } + else{ + return; + } + } + } + if(!have_Excel){ + + + File newFile = new File(TMomMethodUtil.getFile(session, fileSource.split("\\.")[0], "MSExcelX").getPath()); + MessageBox.post(fileSource, "fileSource", MessageBox.WARNING); + InputStream is = new FileInputStream(newFile); + byte[] model_file_byte = new byte[is.available()]; + is.read(model_file_byte); + is.close(); + OutputStream os = new FileOutputStream(fileOutUrl); + os.write(model_file_byte); + os.close(); + + setVersionNum(itme.getLatestItemRevision()); + File model_flie = new File(fileOutUrl); + //MessageBox.post("TCļ", " ", MessageBox.WARNING); + writeToFile(model_flie,true); + //MessageBox.post("ɱļ", " ", MessageBox.WARNING); + ExcelUtil07.writeExcelWithCellName(model_flie,fileOutUrl,map_CellnameAndValue,operateCode,meop_name); +// String as1[] = { TMomMethodUtil.getFile(session, fileSource.split("\\.")[0], "MSExcelX").getPath()};// ļ· +// String as1[] = { "C:\\ҵָ.xlsx"};// ļ· + String as2[] = { "excel" }; + String as3[] = { "MSExcelX" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType + .create(fileSource, "excel", + "MSExcelX"); + tccomponentDataset.setFiles(new String[]{fileOutUrl}, as3, as4, as2); + itme.getLatestItemRevision().getProperty("current_revision_id"); + itme.getLatestItemRevision().add("TC_Attaches", + tccomponentDataset); + MessageBox.post(""+fileSource.split("\\.")[0]+"", " ", MessageBox.INFORMATION); + } + + } + //дļ + private void writeToFile(File file ,boolean is_first) throws IOException { + file.setWritable(true); + boolean isMark = is_first ; + + if(data!=null){ + if(fileSource.indexOf("")!=-1){ + ExcelUtil07.writeExcelForCX(file.getPath(), file, data, 7, 7); + isMark = true ; + } + if(fileSource.indexOf("")!=-1){ + ExcelUtil07.writeExcelForZX(file.getPath(), file, data, 6, 9);// + isMark = true ; + } + if(fileSource.indexOf("ս")!=-1){ + + ExcelUtil07.writeExcelForSJ(file.getPath(), file, data, productNameList24, productNameList18); + isMark = true ; + } + + if(fileSource.indexOf("ȴ")!=-1){ + //MessageBox.post("Start output step 9", "Step", MessageBox.WARNING); + ExcelUtil07.writeExcelForRCL(file.getPath(), file, data, 26, 3);//26 3 + isMark = true ; + } + + } + //if(isMark) + //{ + // MessageBox.post("is true", "debug", MessageBox.WARNING); + //} + //if(!is_first){ + if(!isMark){ + //System.out.println("Start output step 100 "); + //MessageBox.post("Start output step 100", "Step", MessageBox.WARNING); + ExcelUtil07.writeExcelWithCellName(file,file.getPath(),map_CellnameAndValue,operateCode,meop_name); + } + + } + /** + * ȡ豸 + */ + private void getEquipmentValues() { + // TODO Auto-generated method stub + try { + //ȡµBOM + TCComponent[] components = item.getRelatedComponents("ps_children"); + if(components.length>0) + { + for (int j = 0; j < components.length; j++) { + String name = null; + String size = null; + TCComponent subChildrenline = components[j]; + if(subChildrenline.getType().indexOf("Equipment") >= 0) + { + TCComponentICO[] icos = ((TCComponentItemRevision)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() == 1012 && descriptions[k].getValue() != null + && !descriptions[k].getValue().equals("")) { + name = descriptions[k].getValue().toString(); + } + if(descriptions[k].getId() == 1013 && descriptions[k].getValue() != null + && !descriptions[k].getValue().equals("")) + { + size = descriptions[k].getValue().toString(); + } + + } + } + } + if(name != null && size.equals("24")) + { + if(name.indexOf("-") >= 0) + { + productNameList24.add(name.split("-")[0]); + } + else + { + productNameList24.add(name); + } + } + else if(name != null && size.equals("18")) + { + if(name.indexOf("-") >= 0) + { + productNameList18.add(name.split("-")[0]); + } + else + { + productNameList18.add(name); + } + } + } + } + } catch (Exception e) { + // TODO: handle exception; + e.printStackTrace(); + } + } + //ȡ汾 + public String setVersionNum(TCComponentItemRevision itemRev) throws TCException, IOException{ + String VerNum = itemRev.getProperty("current_revision_id"); + InputStream is = new FileInputStream(fileOutUrl); + XSSFWorkbook wb = new XSSFWorkbook(is); + is.close(); + ExcelUtil07.writeExcelWithOneCellName(wb, "汾", VerNum); + OutputStream os = new FileOutputStream(new File(fileOutUrl)); + wb.write(os); + os.close(); + + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom001/TMom001CheckCXInstructHandler.java b/src/com/connor/renben/process/plm/tmom001/TMom001CheckCXInstructHandler.java new file mode 100644 index 0000000..c5057c0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom001/TMom001CheckCXInstructHandler.java @@ -0,0 +1,118 @@ +package com.connor.renben.process.plm.tmom001; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom001CheckCXInstructHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + int operateCode = -1; + String fileSource = null; + switch (commandId) { + case "com.connor.renben.process.plm.commands.CheckCXInstructionOutputCommand": + operateCode = TMomFinalUtil.CX_INSTRUCTION; + fileSource="ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckZXInstructionOutputCommand": + operateCode = TMomFinalUtil.ZX_INSTRUCTION; + fileSource="ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckSJInstructionOutputCommand": + operateCode = TMomFinalUtil.SJ_INSTRUCTION; + fileSource = "սҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckPSInstructionOutputCommand": + operateCode = TMomFinalUtil.PS_INSTRUCTION; + fileSource = "ɰҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckGSInstructionOutputCommand": + operateCode = TMomFinalUtil.GS_INSTRUCTION; + fileSource = "ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckSTInstructionOutputCommand": + operateCode = TMomFinalUtil.ST_INSTRUCTION; + fileSource = "STҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckEldecRCLInstructionOutputCommand": + operateCode = TMomFinalUtil.ELDECRCL_INSTRUCTION; + fileSource = "Eldecȴָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckBZDXMJInstructionOutputCommand": + operateCode = TMomFinalUtil.BZDXMJ_INSTRUCTION; + fileSource = "Զëָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckGSJInstructionOutputCommand": + operateCode = TMomFinalUtil.GSJ_INSTRUCTION; + fileSource = "˿ָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJJG1InstructionOutputCommand": + operateCode = TMomFinalUtil.JJG_INSTRUCTION; + fileSource = "ӹָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJJG2InstructionOutputCommand": + operateCode = TMomFinalUtil.JJG_INSTRUCTION; + fileSource = "ӹָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckPTRCLInstructionOutputCommand": + operateCode = TMomFinalUtil.PTRCL_INSTRUCTION; + fileSource = "ͨȴָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckTZInstructionOutputCommand": + operateCode = TMomFinalUtil.TZ_INSTRUCTION; + fileSource = "̨깤ָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckTGSXMJInstructionOutputCommand": + operateCode = TMomFinalUtil.TGSXMJ_INSTRUCTION; + fileSource = "ͨʽëָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckTYMCInstructionOutputCommand": + operateCode = TMomFinalUtil.TYMC_INSTRUCTION; + fileSource = "ͨĥָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckWXMInstructionOutputCommand": + operateCode = TMomFinalUtil.WXM_INSTRUCTION; + fileSource = "ĥָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckYZInstructionOutputCommand": + operateCode = TMomFinalUtil.YZ_INSTRUCTION; + fileSource = "ѹװָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckTSInstructionOutputCommand": + operateCode = TMomFinalUtil.TS_INSTRUCTION; + fileSource = "̽ҵָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckCCInstructionOutputCommand": + operateCode = TMomFinalUtil.CC_INSTRUCTION; + fileSource = "ָ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJGZXInstructionOutputCommand": + operateCode = TMomFinalUtil.JGZX_INSTRUCTION; + fileSource = "ӹĹָ.xlsx"; + break; + default: + break; + } + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + new TMom001CXInstructDialog(app,session,operateCode,fileSource); +// TMom001CXInstructCommand command = new TMom001CXInstructCommand(session, app,operateCode, fileSource,true,"E:\\_"); +// try { +// command.executeModal(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// MessageBox.post("ҵָʧ", "", MessageBox.ERROR); +// } + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom001/Test.java b/src/com/connor/renben/process/plm/tmom001/Test.java new file mode 100644 index 0000000..76e5e8b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom001/Test.java @@ -0,0 +1,38 @@ +package com.connor.renben.process.plm.tmom001; + +import java.util.HashMap; +import java.util.Map; + +public class Test { + public static void main(String[] args) { + String[] s = {"A/a","A/b","B/a","C"};; + Map m = new HashMap<>(); + StringBuilder scsb = new StringBuilder(); + Map sbjt = new HashMap<>(); + for(String str:s){ + String[] keyAndValue = str.split("/"); + if(keyAndValue.length>1){ + String map_key = keyAndValue[0]; + String map_value = keyAndValue[1]; + if(sbjt.containsKey(map_key)) + sbjt.put(map_key, sbjt.get(map_key).append(",").append(map_value)); + else + sbjt.put(map_key, new StringBuilder (map_value)); + } + else + sbjt.put(str, null); + } + for(String key:sbjt.keySet()){ + if(scsb.length()!=0) + scsb.append(";"); + if(sbjt.get(key)!=null) + scsb.append(key+"/"+sbjt.get(key)); + else + scsb.append(key); + } + m.put("豸", scsb.toString()); + for(String key:m.keySet()){ + System.out.println(key+":"+m.get(key)); + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom001/光饰作业指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/光饰作业指导书.xlsx new file mode 100644 index 0000000..9923f36 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/光饰作业指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/半自动修毛机工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/半自动修毛机工艺指导书.xlsx new file mode 100644 index 0000000..057b4cc Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/半自动修毛机工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/压装工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/压装工艺指导书.xlsx new file mode 100644 index 0000000..7995cf0 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/压装工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/台钻工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/台钻工艺指导书.xlsx new file mode 100644 index 0000000..437d887 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/台钻工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/喷砂作业指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/喷砂作业指导书.xlsx new file mode 100644 index 0000000..13ed8bf Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/喷砂作业指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/成形作业指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/成形作业指导书.xlsx new file mode 100644 index 0000000..1a151fd Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/成形作业指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/攻丝机工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/攻丝机工艺指导书.xlsx new file mode 100644 index 0000000..bb1e977 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/攻丝机工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/整形作业指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/整形作业指导书.xlsx new file mode 100644 index 0000000..5bf033f Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/整形作业指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/无心磨工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/无心磨工艺指导书.xlsx new file mode 100644 index 0000000..6116be7 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/无心磨工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/普通热处理工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/普通热处理工艺指导书.xlsx new file mode 100644 index 0000000..2452976 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/普通热处理工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/机加工工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/机加工工艺指导书.xlsx new file mode 100644 index 0000000..2f4cda2 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/机加工工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/烧结作业指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/烧结作业指导书.xlsx new file mode 100644 index 0000000..7cef21a Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/烧结作业指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/通用磨床工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/通用磨床工艺指导书.xlsx new file mode 100644 index 0000000..289b2f3 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/通用磨床工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom001/通过式修毛机工艺指导书.xlsx b/src/com/connor/renben/process/plm/tmom001/通过式修毛机工艺指导书.xlsx new file mode 100644 index 0000000..ebbcca4 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom001/通过式修毛机工艺指导书.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002AbtractDialog.java b/src/com/connor/renben/process/plm/tmom002/TMom002AbtractDialog.java new file mode 100644 index 0000000..a5828e0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002AbtractDialog.java @@ -0,0 +1,1307 @@ +package com.connor.renben.process.plm.tmom002; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; + +import com.alibaba.fastjson.JSON; +import com.connor.renben.process.plm.bean.TMomCreatePropBean; +import com.connor.renben.process.plm.bean.TMomItemBean; +import com.connor.renben.process.plm.bean.TMomPropExplictBean; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.ServiceUtil; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +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.common.Activator; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +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.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom002AbtractDialog extends AbstractAIFOperation implements ActionListener { + private final String CUST_DELE_TYPE_PROP = "Cust_Del_Type_Props"; + private final String CUST_MODEL_AREA = "CUST_Model_Area"; + // private final String CUST_MODEL_AREA_TJ_NBTM = "CUST_Model_Area_TJ_NBTM"; + private JLabel newItemIDLabel; + private JLabel newItemRevIDLabel; + private JLabel newItemNameLabel; + private JLabel oldItemIDLabel; + private JLabel oldItemRevIDLabel; + private JLabel oldItemNameLabel; + private JLabel itemTypeLabel; + private JLabel itemUnitLabel; + + protected JTextField newItemIDText; + protected JTextField newItemRevIDText; + // protected JTextField newItemNameText; + protected JComboBox newItemNameText; + protected JTextField oldItemIDText; + protected JTextField oldItemRevIDText; + protected JTextField oldItemNameText; + protected JTextField itemTypeText; + protected JTextField itemUnitText; + + protected JButton okButton; + protected JButton celButton; + // ҳ + // protected JTable itemPropTable;// itemtable + // protected JTable itemFormPropTable;// itemformtable + // protected JTable revPropTable;// revtable + // protected JTable revFormPropTable;// revformtable + protected List itemPropTable; + protected List itemFormPropTable; + protected List revPropTable; + protected List revFormPropTable; + + protected List itemPropList;// itemб + protected List itemFormPropList;// itemformб + protected List revPropList;// 汾б + protected List revFormPropList;// 汾б + private DefaultTableModel dtm; + + private JPanel firstPanel; + private JPanel secondPanel; + private JPanel rootPanel; + + // ---Ҫõı + protected TCSession session; + protected AbstractAIFUIApplication app; + protected String title; + protected List itemList; + protected List itemListMsgBean; + private String specCode; + private Integer operateCode; + private TMomItemBean newItemBean; + private int index = 1; + private TCComponentFolder newStuffFolder; + private TCComponentFolder parentFolder; + private List explictBeanList; + + // private List folderList; + private JFrame jframe; + + private HashMap> custDeleTypeProp; + + private HashMap nameValueMap; + private boolean DEBUG = true; + private String[] itemNames; + + /** + * ȡϴδ͵ʱõ + * + * @param compType + */ + private void getNameValueMap(String compType) { + nameValueMap = new HashMap<>(); + nameValueMap.put("rb3_material", ""); + nameValueMap.put("rb3_press_drawing", ""); + nameValueMap.put("rb3_mb", ""); + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + if (!file.exists()) { + return; + } + try { + FileReader reader = new FileReader(file); + + BufferedReader br = new BufferedReader(reader); + + String info = br.readLine(); + if (info != null) { + String[] values = info.split("\\|"); + if (values == null || values.length != 3) { + return; + } + for (int i = 0; i < values.length; i++) { + String[] nameValues = values[i].split("="); + if (nameValues == null || nameValues.length != 2) { + continue; + } + + if (nameValueMap.containsKey(nameValues[0])) { + nameValueMap.remove(nameValues[0]); + nameValueMap.put(nameValues[0], nameValues[1]); + } + } + + } + br.close(); + reader.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + private void setNameValueMap(String compType) { + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + // if (!file.exists()) { + // return; + // } + + try { + FileWriter write = new FileWriter(file); + BufferedWriter bw = new BufferedWriter(write); + StringBuffer sb = new StringBuffer(); + + if (nameValueMap.containsKey("rb3_material")) { + sb.append("rb3_material"); + sb.append("="); + sb.append(nameValueMap.get("rb3_material")).append("|"); + } + if (nameValueMap.containsKey("rb3_press_drawing")) { + sb.append("rb3_press_drawing"); + sb.append("="); + sb.append(nameValueMap.get("rb3_press_drawing")).append("|"); + } + if (nameValueMap.containsKey("rb3_mb")) { + sb.append("rb3_mb"); + sb.append("="); + sb.append(nameValueMap.get("rb3_mb")); + + } + + bw.write(sb.toString()); + bw.close(); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + /** + * ȡҪص + */ + private void getCustDeleTypeProp() { + custDeleTypeProp = new HashMap<>(); + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, CUST_DELE_TYPE_PROP); + if (props != null) { + for (int i = 0; i < props.length; i++) { + String[] subStrs = props[i].split("\\:"); + if (subStrs == null || subStrs.length != 2) { + continue; + } + String[] propSubStrs = subStrs[1].split("\\/"); + if (propSubStrs == null || propSubStrs.length <= 0) { + continue; + } + custDeleTypeProp.put(subStrs[0], Arrays.asList(propSubStrs)); + } + } + } + + public TMom002AbtractDialog(TCSession session, AbstractAIFUIApplication app, String title, + List itemList, String specCode, int operateCode) { + super(false); + this.app = app; + this.session = session; + this.title = title; + this.itemList = itemList; + this.specCode = specCode; + this.operateCode = operateCode; + this.newItemBean = new TMomItemBean(); + jframe = new JFrame(); + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // this.folderList = new ArrayList<>(); + getCustDeleTypeProp(); + // ȡѡȡITEMĿϢ + this.itemListMsgBean = TMomMethodUtil.getTargetsMsg(itemList); + // ˵вҪʾ + this.explictBeanList = TMomMethodUtil.getExplictPropList(this.session); + getItemName(); + init(); + try { + getItemInfo(0); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ȡϢ + * + * @throws TCException + */ + public void getItemInfo(int index) throws TCException { + + TMomItemBean bean = null; + if (itemListMsgBean != null && itemListMsgBean.size() != 0) + bean = this.itemListMsgBean.get(index); + else { + + jframe.dispose(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("myxqITEMdx02_display.TITLE"), "", MessageBox.ERROR); + return; + } + this.parentFolder = bean.getFolder(); + this.oldItemIDText.setText(bean.getItemID()); + this.oldItemNameText.setText(bean.getName()); + // TCComponentItemType itemType = null; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + this.itemTypeText.setText(TMomFinalUtil.GY_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GY_TYPE); + getNameValueMap(TMomFinalUtil.GY_TYPE); + break; + case TMomFinalUtil.HISGY_CODE: + this.itemTypeText.setText(TMomFinalUtil.GY_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GY_TYPE); + getNameValueMap(TMomFinalUtil.GY_TYPE); + break; + case TMomFinalUtil.GX_CODE: + this.itemTypeText.setText(TMomFinalUtil.GX_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GX_TYPE); + getNameValueMap(TMomFinalUtil.GX_TYPE); + break; + default: + break; + } + this.itemUnitText.setText(bean.getUnitDis()); + // ȡITEMID + try { + // · + TCUtils.openLogByPass(session, this.title); + TMomMethodUtil.setByPass(session, true); + String newCode = TMomMethodUtil.getRuleItemID(session, bean.getItemID(), specCode, operateCode); + this.newItemIDText.setText(newCode); + this.newItemRevIDText.setText("00"); + this.newItemBean.setRevID("00"); + this.newItemNameText.setSelectedItem(bean.getName()); + } catch (Exception e) { + // TODO: handle exception + } finally { + // ر· + TCUtils.closeLogByPass(session, this.title); + TMomMethodUtil.setByPass(session, false); + } + + // this.newItemNameText.setText(bean.getName()); + } + + private void getItemName() { + TCPreferenceService service = this.session.getPreferenceService(); + String morderName = null; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + morderName = TMomFinalUtil.GY_ITEM_NAMES; + break; + case TMomFinalUtil.HISGY_CODE: + morderName = TMomFinalUtil.GY_ITEM_NAMES; + break; + case TMomFinalUtil.GX_CODE: + morderName = TMomFinalUtil.GX_ITEM_NAMES; + break; + default: + break; + } + if (morderName != null) { + String[] props = service.getStringArray(TCPreferenceService.TC_preference_site, morderName); + if (props != null || props.length > 0) { + this.itemNames = props; + } else { + this.itemNames = new String[] { "" }; + } + } else { + MessageBox.post("δҵӦITEM_NAMEѡ", "", MessageBox.ERROR); + } + } + + /** + * ȡϢ + * + * @param itemType + * @throws TCException + */ + public void getPropMsg(String itemType) throws TCException { + this.itemPropList = new ArrayList<>(); + this.itemFormPropList = new ArrayList<>(); + this.revPropList = new ArrayList<>(); + this.revFormPropList = new ArrayList<>(); + String startStr = "tm2"; + TCComponentType type = null; + + List explictList = new ArrayList<>(); + + type = this.session.getTypeComponent(itemType + "Revision Master"); + explictList.clear(); + for (TMomPropExplictBean explictBean : this.explictBeanList) { + if (explictBean.getType().equals(itemType + "Revision Master")) { + explictList = explictBean.getPropList(); + continue; + } + } + if (type != null && type instanceof TCComponentFormType) { + TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + for (TCPropertyDescriptor desc : descs) { + if (desc.getName().startsWith(startStr) && desc.isModifiable() && desc.isDisplayable()) { + if (custDeleTypeProp.containsKey(itemType + "Revision Master")) { + if (custDeleTypeProp.get(itemType + "Revision Master").contains(desc.getName())) { + continue; + } + } + if (explictList != null && explictList.contains(desc.getName())) { + continue; + } + TMomCreatePropBean bean = new TMomCreatePropBean(); + bean.setDescriptor(desc); + bean.setDisplayName(desc.getDisplayName()); + bean.setName(desc.getName()); + this.revFormPropList.add(bean); + } + } + } else { + System.out.println("revMaster"); + // return; + } + + } + + /** + * ʼ + */ + public void init() { + + try { + newStuffFolder = session.getUser().getNewStuffFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + jframe.setTitle(this.title); + jframe.setSize(850, 380); + jframe.setAutoRequestFocus(true); + jframe.setPreferredSize(new Dimension(430, 300)); + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + String info = rb.getString("xljid_display.TITLE"); + this.newItemIDLabel = new JLabel(info); + this.newItemRevIDLabel = new JLabel(rb.getString("bbid_display.TITLE")); + this.newItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.oldItemIDLabel = new JLabel(rb.getString("jlzjid_display.TITLE")); + this.oldItemRevIDLabel = new JLabel(rb.getString("bbid_display.TITLE")); + this.oldItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.newItemIDText = new JTextField(20); + // this.newItemIDText.setEditable(false); + this.newItemRevIDText = new JTextField(6); + this.newItemRevIDText.setEnabled(false); + this.newItemNameText = new JAutoCompleteComboBox(new DefaultComboBoxModel(itemNames)); + // this.newItemNameText = new JTextField(32); + this.oldItemIDText = new JTextField(20); + this.oldItemIDText.setEnabled(false); + this.oldItemRevIDText = new JTextField(6); + this.oldItemRevIDText.setEnabled(false); + this.oldItemNameText = new JTextField(32); + this.oldItemNameText.setEnabled(false); + 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.itemTypeLabel = new JLabel(rb.getString("lx_display.TITLE")); + this.itemTypeText = new JTextField(12); + this.itemTypeText.setEditable(false); + this.itemTypeText.setText(rb.getString("lx_display.TITLE")); + this.itemUnitLabel = new JLabel(rb.getString("dw_display.TITLE")); + this.itemUnitText = new JTextField(12); + this.itemUnitText.setEnabled(false); + this.itemUnitText.setText(rb.getString("dw_display.TITLE")); + + // PropertyLayout layout = new PropertyLayout(); + + // ʾ + JPanel newItemMsgPanel = new JPanel(new PropertyLayout()); + newItemMsgPanel + .setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), rb.getString("xljxx_display.TITLE"))); + newItemMsgPanel.add("1.1.left.top.preferred.preferred", newItemIDLabel); + newItemMsgPanel.add("1.2.left.top.preferred.preferred", newItemRevIDLabel); + newItemMsgPanel.add("1.3.left.top.preferred.preferred", newItemNameLabel); + // + newItemMsgPanel.add("2.1.left.top.preferred.preferred", newItemIDText); + newItemMsgPanel.add("2.2.left.top.preferred.preferred", newItemRevIDText); + newItemMsgPanel.add("2.3.left.top.preferred.preferred", newItemNameText); + JPanel typeAndUnitPanel = new JPanel(new PropertyLayout()); + // .setBorder(new TitledBorder(BorderFactory.createEtchedBorder(),"")); + typeAndUnitPanel.add("1.1.left.top.preferred.preferred", itemTypeLabel); + typeAndUnitPanel.add("1.2.left.top.preferred.preferred", itemTypeText); + typeAndUnitPanel.add("2.1.left.top.preferred.preferred", itemUnitLabel); + typeAndUnitPanel.add("2.2.left.top.preferred.preferred", itemUnitText); + // ʾ + JPanel oldItemMsgPanel = new JPanel(new PropertyLayout()); + oldItemMsgPanel + .setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), rb.getString("jy_display.TITLE"))); + oldItemMsgPanel.add("1.1.left.top.preferred.preferred", oldItemIDLabel); + oldItemMsgPanel.add("1.2.left.top.preferred.preferred", oldItemRevIDLabel); + oldItemMsgPanel.add("1.3.left.top.preferred.preferred", oldItemNameLabel); + // + oldItemMsgPanel.add("2.1.left.top.preferred.preferred", oldItemIDText); + oldItemMsgPanel.add("2.2.left.top.preferred.preferred", oldItemRevIDText); + oldItemMsgPanel.add("2.3.left.top.preferred.preferred", oldItemNameText); + // + this.secondPanel = new JPanel(new FlowLayout()); + this.secondPanel.add(okButton); + this.secondPanel.add(new JLabel(" ")); + this.secondPanel.add(celButton); + this.firstPanel = new JPanel(new PropertyLayout()); + this.firstPanel.add("1.1.left.top.preferred.preferred", newItemMsgPanel); + this.firstPanel.add("2.1.left.top.preferred.preferred", typeAndUnitPanel); + this.firstPanel.add("3.1.left.top.preferred.preferred", oldItemMsgPanel); + // ҳ------------------------------------------------------------ + if (operateCode == TMomFinalUtil.GY_CODE) { + try { + getNameValueMap(TMomFinalUtil.GY_TYPE); + getPropMsg(TMomFinalUtil.GY_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (operateCode == TMomFinalUtil.HISGY_CODE) { + try { + getNameValueMap(TMomFinalUtil.GY_TYPE); + getPropMsg(TMomFinalUtil.GY_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (operateCode == TMomFinalUtil.GX_CODE) { + try { + getNameValueMap(TMomFinalUtil.GX_TYPE); + getPropMsg(TMomFinalUtil.GX_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + JPanel propPanel = new JPanel(new PropertyLayout()); + int propIndex = 1; + if (this.itemPropList != null && this.itemPropList.size() != 0) { + this.itemPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemPropList, this.itemPropTable, propIndex, ""); + propIndex++; + } + if (this.itemFormPropList != null && this.itemFormPropList.size() != 0) { + this.itemFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemFormPropList, this.itemFormPropTable, propIndex, ""); + propIndex++; + } + if (this.revPropList != null && this.revPropList.size() != 0) { + this.revPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revPropList, this.revPropTable, propIndex, "汾"); + propIndex++; + } + if (this.revFormPropList != null && this.revFormPropList.size() != 0) { + // + this.revFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revFormPropList, this.revFormPropTable, propIndex, "汾"); + propIndex++; + System.out.println("revFormPropTable count =" + revFormPropTable.size()); + } + + // ҳ + JTabbedPane tabPane = new JTabbedPane(); + tabPane.add(rb.getString("lzjxx_display.TITLE"), firstPanel); + tabPane.add(rb.getString("sx_display.TITLE"), new JScrollPane(propPanel)); + + // + this.rootPanel = new JPanel(new BorderLayout()); + this.rootPanel.add(tabPane, BorderLayout.CENTER); + this.rootPanel.add(secondPanel, BorderLayout.SOUTH); + + jframe.add(rootPanel, "Center"); +// jframe.pack(); + // ôھ + jframe.setLocationRelativeTo(null); + jframe.setDefaultCloseOperation(2); + // ÿɼ + jframe.setVisible(true); + } + + /** + * Խ + * + * @param propPanel + * @param beanList + * @param compList + * @param propIndex + */ + private void setPropPanel(JPanel propPanel, List beanList, List compList, + int propIndex, String name) { + + JPanel itemPorpPanel = new JPanel(new PropertyLayout()); + itemPorpPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), name)); + + // //////////////////////////////////////////// + // compList = new ArrayList<>(); + String currentGroupName = null; + try { + currentGroupName = session.getCurrentGroup().getFullName(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + int indexx = currentGroupName.lastIndexOf("."); + // ȡǰʶ + String groupName = currentGroupName.substring(indexx + 1, currentGroupName.length()); + // ȡѡ + String[] lovValue = session.getPreferenceService().getStringArray(TCPreferenceService.TC_preference_site, + CUST_MODEL_AREA); + if (null == lovValue || lovValue.length <= 0) { + System.out.println("ûѡ" + CUST_MODEL_AREA); + MessageBox.post("ȱѡ" + CUST_MODEL_AREA + ",ϵԱ", "", MessageBox.ERROR); + return; + } + // ȡеĶ + Map groupLoV = new HashMap(); + // װ + for (String string : lovValue) { + String[] sp = string.split(":"); + String group = sp[0]; + String model = sp[1]; + String[] x = model.split("-"); + groupLoV.put(group, x); + } + + for (int i = 0; i < beanList.size(); i++) { + JLabel disNameLabel = new JLabel(beanList.get(i).getDisplayName()); + String defaultValueInfo = null; + if (this.nameValueMap.containsKey(beanList.get(i).getName())) { + defaultValueInfo = this.nameValueMap.get(beanList.get(i).getName()); + } else { + defaultValueInfo = null; + } + TCPropertyDescriptor desc = beanList.get(i).getDescriptor(); + JComponent valueComp = null; + TCComponentListOfValues lobList = desc.getLOV(); + + if (lobList != null) { + MyJCombox box = new MyJCombox(); + box.setEditable(true); + box.setPropName(desc.getName()); + try { + // ȡLOV-------------------- + ListOfValuesInfo info = lobList.getListOfValues(); + String[] valuesList; + String[] disValuesList = null; + if (groupLoV.containsKey(groupName) && "RB3_mb_lov".equals(info.toString())) { + // Ӧôѡлȡ + valuesList = groupLoV.get(groupName); + disValuesList = new String[valuesList.length + 1]; + + } else { + valuesList = info.getStringListOfValues(); + disValuesList = new String[valuesList.length + 1]; + } + if (DEBUG) { + for (String string : valuesList) { + System.out.print(string + "\t"); + } + } + disValuesList[0] = ""; + box.setValues(valuesList); + int index = -1; + for (int w = 1; w < disValuesList.length; w++) { + disValuesList[w] = info.getDisplayableValue(valuesList[w - 1]); + if (defaultValueInfo != null && defaultValueInfo.equals(valuesList[w - 1])) { + index = w; + } + } + box.setModel(new DefaultComboBoxModel(disValuesList)); + if (index != -1) { + box.setSelectedIndex(index); + } else if (null == disValuesList || index == -1) { + box.getModel().setSelectedItem(""); + } else { + box.getModel().setSelectedItem(defaultValueInfo); + } + } catch (TCException e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + // box.setModel(new DefaultComboBoxModel(new String[] { "" + // })); + } + valueComp = box; + } else { + // JTextField fied = new JTextField(12); + MyJTextfield valueText = new MyJTextfield(32); + valueText.setText(beanList.get(i).getDescriptor().getDefaultValue()); + valueText.setPropName(beanList.get(i).getName()); + valueComp = valueText; + if (defaultValueInfo != null) { + valueText.setText(defaultValueInfo); + } + + } + + itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", disNameLabel); + itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", valueComp); + compList.add(valueComp); + } + propPanel.add(propIndex + ".1.left.top.preferred.preferred", itemPorpPanel); + } + + /** + * comboxؼ + * + * @author hub + * + */ + + private class MyJCombox extends JComboBox { + private String[] values; + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String[] getValues() { + return values; + } + + public void setValues(String[] values) { + this.values = values; + } + + } + + /** + * + * @author hub + * + */ + private class MyJTextfield extends JTextField { + + public MyJTextfield(int len) { + super(len); + } + + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + } + + /** + * JTABLEͨ÷ + * + * @param partsTable + * @param titleNames + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 105; + int totleLen = 900; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)) { + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(105); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + /** + * tableؼ + * + * @param dtm + * @param columNameObjects + * @param objects + * @return + */ + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] columNameObjects, Object[][] objects) { + // Object[] columNameObjects = this.titleNames; //// , + // Object[][] objects = getValues(this.valueLists); + if (dtm == null) { + dtm = new DefaultTableModel(objects, columNameObjects); + } + return dtm; + } + + /** + * תΪMAP + * + * @param listBean + * @return + */ + public HashMap getValues(List listBean) { + HashMap valueMap = null; + if (listBean != null && listBean.size() > 0) { + valueMap = new HashMap<>(); + for (int i = 0; i < listBean.size(); i++) { + JComponent bean = listBean.get(i); + if (bean instanceof MyJTextfield) { + + valueMap.put(((MyJTextfield) bean).getPropName(), ((MyJTextfield) bean).getText()); + if (nameValueMap.containsKey(((MyJTextfield) bean).getPropName())) { + nameValueMap.remove(((MyJTextfield) bean).getPropName()); + nameValueMap.put(((MyJTextfield) bean).getPropName(), ((MyJTextfield) bean).getText()); + } + System.out.println(" ((MyJTextfield) bean).getPropName() =" + ((MyJTextfield) bean).getPropName() + + " | " + "((MyJTextfield) bean).getText()" + ((MyJTextfield) bean).getText()); + } else if (bean instanceof MyJCombox) { + + if (((MyJCombox) bean).getSelectedIndex() == -1) { + valueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel().getSelectedItem().toString()); + System.out.println(" tip text " + ((MyJCombox) bean).getModel().getSelectedItem().toString()); + if (nameValueMap.containsKey(((MyJCombox) bean).getPropName())) { + nameValueMap.remove(((MyJCombox) bean).getPropName()); + nameValueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel().getSelectedItem().toString()); + } + } else { + + valueMap.put(((MyJCombox) bean).getPropName(), (((MyJCombox) bean).getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex() - 1]); + if (nameValueMap.containsKey(((MyJCombox) bean).getPropName())) { + nameValueMap.remove(((MyJCombox) bean).getPropName()); + nameValueMap.put(((MyJCombox) bean).getPropName(), + (((MyJCombox) bean).getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex() + - 1]); + } + System.out.println(" 123=" + ((((MyJCombox) bean).getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex() - 1])); + } + + /* + * System.out .println((((MyJCombox) bean).getSelectedIndex() == -1 || + * ((MyJCombox) bean) .getSelectedIndex() == 0) ? ((MyJCombox) bean) + * .getToolTipText() : ((MyJCombox) bean) .getValues()[((MyJCombox) bean) + * .getSelectedIndex() - 1]); + */ + /* + * System.out .println("((MyJCombox) bean).getPropName() =" + ((MyJCombox) + * bean).getPropName() + " | " + + * "((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex()] =" + + * ((MyJCombox) bean).getValues()[((MyJCombox) bean) .getSelectedIndex()]); + */ + } + + } + } + + return valueMap; + + } + + private TCUserService userservice; + + public void setByPass(boolean val) throws TCException { + if (userservice == null) { + userservice = this.session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("ORIGIN_set_bypass", obj); + } else { + userservice.call("ORIGIN_close_bypass", obj); + } + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem item, ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + + TCComponentItem item = null; + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object obj = e.getSource(); + if (obj.equals(this.okButton)) { + new Thread() { + public void run() { + Activator.getDefault().openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents("com.teamcenter.rac.pse.PSEPerspective", + null); + }; + }.start(); + new Thread() { + @Override + public void run() { + if (operateCode == TMomFinalUtil.GY_CODE || operateCode == TMomFinalUtil.GX_CODE) { + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = session.getUserService(); + try { + TCUtils.openLogByPass(session, ""); + userservice.call("Connor_set_bypass", obj); + item = null; + Map valMap = new HashMap(); + valMap.put("id", newItemIDText.getText()); + valMap.put("revId", newItemRevIDText.getText()); + valMap.put("type", newItemBean.getType()); + valMap.put("name", newItemNameText.getSelectedItem().toString()); + valMap.put("unit", newItemBean.getUnit()); + valMap.put("item", getValues(itemPropTable)); + valMap.put("rev", getValues(revPropTable)); + valMap.put("revForm", getValues(revFormPropTable)); + String jsonString = JSON.toJSONString(valMap); + TCPreferenceService preService = session.getPreferenceService(); + //String notifies[] = preService.getStringValues("RB_loginUrl"); + TCComponentUser user = session.getUser(); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + String userUid = user.getUid(); + String groupUid = group.getUid(); +// String path1 = "C:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// File file = new File(path1); +// if (!file.exists()) { +// path1 = "D:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// } +// System.out.println(path1); + System.out.println(jsonString); +// System.out.println(notifies); + System.out.println(userUid); + System.out.println(groupUid); + System.out.println(itemList); + +// String cmd = "java -jar " + path1 + " \"" + jsonString.replaceAll("\"", "\\\\\"") + "\" \"" +// + notifies[0] + "\" \"" + notifies[1] + "\" \"" + notifies[2] + "\" \"" + userUid +// + "\" \"" + groupUid + "\" " + itemList.get(0).getLatestItemRevision().getUid(); +// System.out.println(cmd); +// Process process = Runtime.getRuntime().exec(cmd); +// InputStream inputStream = process.getInputStream(); +// InputStreamReader reader = new InputStreamReader(inputStream); +// BufferedReader bufferedReader = new BufferedReader(reader); +// String line = null; +// while ((line = bufferedReader.readLine()) != null) { +// System.out.println(line); +// } + + ServiceUtil.sendRequest(jsonString,"","","",userUid,groupUid,itemList.get(0).getLatestItemRevision().getUid()); +// String[] keys = new String[] { " ID" }; +// String[] value = new String[] { newItemIDText.getText() }; +// List queryObject = queryObject(" ID", keys, value); +// if(queryObject != null && queryObject.size() > 0) { +// item = (TCComponentItem)queryObject.get(0); +// }else { +// System.out.println( +// "[item_id= " + newItemIDText.getText() + " / rev =" + newItemRevIDText.getText() +// + " / name= " + newItemNameText.getSelectedItem().toString() + "]ʧ"); +// rootPanel.setBackground(Color.RED); +// return; +// } + TCComponentItemType ccomponentitemtype = (TCComponentItemType) session + .getTypeComponent(newItemBean.getType()); +// setByPass(true); + item = ccomponentitemtype.find(newItemIDText.getText()); + + // setByPass(false); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + try { + TCUtils.closeLogByPass(session, ""); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + } else { + item = TMomMethodUtil.createNewItemSoa(session, newItemIDText.getText(), + newItemRevIDText.getText(), newItemBean.getType(), + newItemNameText.getSelectedItem().toString(), "", newItemBean.getUnit(), + getValues(itemPropTable), getValues(revPropTable), getValues(revFormPropTable)); + } + + if (item != null) { + setNameValueMap(newItemBean.getType()); + String msg = new String(); + switch (operateCode) { + case TMomFinalUtil.GY_CODE: + for (int i = 0; i < itemList.size(); i++) { + try { + itemList.get(i).add("IMAN_reference", item); +// item.getLatestItemRevision().add("IMAN_METarget", +// itemList.get(i).getLatestItemRevision()); + // ƼƻPFMEAͼ + TCComponentItemType ssckzjhItemType = (TCComponentItemType) session + .getTypeComponent("RB3_SSCKZJH"); + TCComponentItemType pfmeaItemType = (TCComponentItemType) session + .getTypeComponent("RB3_PFMEA"); +// TCComponentItemType gclctItemType = (TCComponentItemType) this.session +// .getTypeComponent("RB3_GCLCT"); + TCComponentType uom = session.getTypeComponent("UnitOfMeasure"); + TCComponent[] uoms = uom.extent(); + // Ƽƻ id,汾,, + TCComponentItem ssckzjh = ssckzjhItemType.create(ssckzjhItemType.getNewID(), "00", + "RB3_SSCKZJH", oldItemIDText.getText() + "/Ƽƻ", "", uoms[0]); + TCComponent ssckzjhForm = ssckzjh.getLatestItemRevision() + .getRelatedComponent("IMAN_master_form_rev"); + ssckzjhForm.lock(); + ssckzjhForm.setStringProperty("rb3_cpxh", + itemList.get(i).getStringProperty("item_id")); + ssckzjhForm.save(); + ssckzjhForm.unlock(); + ssckzjhForm.refresh(); + TCComponentDataset kzjhDataSet = ExcelUtil07.getExcelToDataset(session, + ssckzjh.getLatestItemRevision(), "TC_Attaches", "MSExcelX"); + if (kzjhDataSet != null) { + kzjhDataSet.setStringProperty("object_name", + oldItemIDText.getText() + "/Ƽƻ"); + kzjhDataSet.save(); + kzjhDataSet.refresh(); + } + // PFMEA + TCComponentItem pfmea = pfmeaItemType.create(pfmeaItemType.getNewID(), "00", + "RB3_PFMEA", oldItemIDText.getText() + "/PFMEA", "", uoms[0]); + TCComponent pfmeaForm = pfmea.getLatestItemRevision() + .getRelatedComponent("IMAN_master_form_rev"); + pfmeaForm.lock(); + pfmeaForm.setStringProperty("rb3_cpxh", + itemList.get(i).getStringProperty("item_id")); + pfmeaForm.save(); + pfmeaForm.unlock(); + pfmeaForm.refresh(); + TCComponentDataset pfmeaDataSet = ExcelUtil07.getExcelToDataset(session, + pfmea.getLatestItemRevision(), "TC_Attaches", "MSExcel"); + if (pfmeaDataSet != null) { + pfmeaDataSet.setStringProperty("object_name", + oldItemIDText.getText() + "/PFMEA"); + pfmeaDataSet.save(); + pfmeaDataSet.refresh(); + } + // ͼ +// ExcelUtil.setFlowChart(valueMap, file); + item.add("IMAN_reference", pfmea); + // item.add("IMAN_reference", gclct); + item.add("IMAN_reference", ssckzjh); + rootPanel.setBackground(Color.GREEN); + + System.out.println(""); + // ͵ṹ + new Thread() { + public void run() { + Activator.getDefault().openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents("com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { item }); + }; + }.start(); + + System.out.println("ͽṹ"); + + jframe.dispose(); +// msg = "ڲƷ[" + this.oldItemNameText.getText() +// + "]"; + } catch (TCException e1) { + rootPanel.setBackground(Color.RED); + MessageBox.post(e1.toString(), "", MessageBox.ERROR); + e1.printStackTrace(); + } + } + break; + case TMomFinalUtil.HISGY_CODE: + for (int i = 0; i < itemList.size(); i++) { + try { + itemList.get(i).add("IMAN_reference", item); + item.getLatestItemRevision().add("IMAN_METarget", + itemList.get(i).getLatestItemRevision()); + // ƼƻPFMEAͼ + TCComponentItemType sckzjhItemType = (TCComponentItemType) session + .getTypeComponent("RB3_SCKZJH"); + TCComponentItemType pfmeaItemType = (TCComponentItemType) session + .getTypeComponent("RB3_PFMEA"); +// TCComponentItemType gclctItemType = (TCComponentItemType) this.session +// .getTypeComponent("RB3_GCLCT"); + TCComponentType uom = session.getTypeComponent("UnitOfMeasure"); + TCComponent[] uoms = uom.extent(); + // Ƽƻ id,汾,, + TCComponentItem sckzjh = sckzjhItemType.create(sckzjhItemType.getNewID(), "00", + "RB3_SCKZJH", oldItemIDText.getText() + "/Ƽƻ", "", uoms[0]); + TCComponent sckzjhForm = sckzjh.getLatestItemRevision() + .getRelatedComponent("IMAN_master_form_rev"); + sckzjhForm.lock(); + sckzjhForm.setStringProperty("rb3_cpxh", + itemList.get(i).getStringProperty("item_id")); + sckzjhForm.save(); + sckzjhForm.unlock(); + sckzjhForm.refresh(); + TCComponentDataset kzjhDataSet = ExcelUtil07.getExcelToDataset(session, + sckzjh.getLatestItemRevision(), "TC_Attaches", "MSExcelX"); + if (kzjhDataSet != null) { + kzjhDataSet.setStringProperty("object_name", + oldItemIDText.getText() + "/Ƽƻ"); + kzjhDataSet.save(); + kzjhDataSet.refresh(); + } + // PFMEA + TCComponentItem pfmea = pfmeaItemType.create(pfmeaItemType.getNewID(), "00", + "RB3_PFMEA", oldItemIDText.getText() + "/PFMEA", "", uoms[0]); + TCComponent pfmeaForm = pfmea.getLatestItemRevision() + .getRelatedComponent("IMAN_master_form_rev"); + pfmeaForm.lock(); + pfmeaForm.setStringProperty("rb3_cpxh", + itemList.get(i).getStringProperty("item_id")); + pfmeaForm.save(); + pfmeaForm.unlock(); + pfmeaForm.refresh(); + TCComponentDataset pfmeaDataSet = ExcelUtil07.getExcelToDataset(session, + pfmea.getLatestItemRevision(), "TC_Attaches", "MSExcel"); + if (pfmeaDataSet != null) { + pfmeaDataSet.setStringProperty("object_name", + oldItemIDText.getText() + "/PFMEA"); + pfmeaDataSet.save(); + pfmeaDataSet.refresh(); + } + // ͼ + item.add("IMAN_reference", pfmea); +// item.add("IMAN_reference", gclct); + item.add("IMAN_reference", sckzjh); + rootPanel.setBackground(Color.GREEN); + // ͵ṹ + + //disposeDialog(); + jframe.dispose(); +// new Thread() { +// @Override +// public void run() { + Activator.getDefault().openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents("com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { item }); +// } +// }.start(); + +// msg = "ڲƷ[" + this.oldItemNameText.getText() +// + "]"; + } catch (TCException e1) { + rootPanel.setBackground(Color.RED); + MessageBox.post(e1.toString(), "", MessageBox.ERROR); + e1.printStackTrace(); + } + } + break; + case TMomFinalUtil.GX_CODE: + ArrayList itemlists = new ArrayList(); + itemlists.add(item); + for (int i = 0; i < itemList.size(); i++) { + try { + recreateBom(itemList.get(i), itemlists, false); + rootPanel.setBackground(Color.GREEN); +// msg = "ڹ[" + this.oldItemIDText.getText() +// + "]BOMṹ"; + } catch (TCException e1) { + e1.printStackTrace(); + } + } + break; + default: + break; + } + if (msg != null && !msg.equals("")) { + rootPanel.setBackground(Color.GREEN); + + } + // ȡITEMID + String newCode = ""; + switch (operateCode) { + case TMomFinalUtil.GY_CODE: + newCode = TMomMethodUtil.getRuleItemID(session, newItemIDText.getText().split("_")[0], + specCode, operateCode); + break; + case TMomFinalUtil.GX_CODE: + newCode = TMomMethodUtil.getRuleItemID(session, newItemIDText.getText(), specCode, + operateCode); + break; + default: + break; + } + newItemIDText.setText(newCode); + } else { + System.out.println( + "[item_id= " + newItemIDText.getText() + " / rev =" + newItemRevIDText.getText() + + " / name= " + newItemNameText.getSelectedItem().toString() + "]ʧ"); + rootPanel.setBackground(Color.RED); + + } + } + }.start(); + + } else if (obj.equals(this.celButton)) { + jframe.dispose(); + } + } + /** + * ͨѯѯĿ + * + * @param queryName ѯ + * @param keys ѯ + * @param values ѯֵ + * @return + */ + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("ûҵѯ:" + queryName, "", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + // ָָ + public static void changeOwner(TCComponent comp, TCComponentUser user) throws TCException { + TCComponentUser o_user = (TCComponentUser) comp.getRelatedComponent("owning_user"); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + if (o_user != null && o_user.equals(user)) { + return; + } + comp.lock(); + comp.changeOwner(user, group); + comp.save(); + comp.unlock(); + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateGYTZDialog.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateGYTZDialog.java new file mode 100644 index 0000000..3b753ff --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateGYTZDialog.java @@ -0,0 +1,1083 @@ +package com.connor.renben.process.plm.tmom002; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.TMomCreatePropBean; +import com.connor.renben.process.plm.bean.TMomItemBean; +import com.connor.renben.process.plm.bean.TMomPropExplictBean; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom002CreateGYTZDialog extends AbstractAIFDialog implements + ActionListener { + private final String CUST_DELE_TYPE_PROP = "Cust_Del_Type_Props"; + private final String CUST_MODEL_AREA = "CUST_Model_Area"; + + private JLabel newItemIDLabel; + private JLabel newItemRevIDLabel; + private JLabel newItemNameLabel; + private JLabel oldItemIDLabel; + private JLabel oldItemRevIDLabel; + private JLabel oldItemNameLabel; + private JLabel itemTypeLabel; + private JLabel itemUnitLabel; + + protected JTextField newItemIDText; + protected JTextField newItemRevIDText; + protected JTextField newItemNameText; + protected JTextField oldItemIDText; + protected JTextField oldItemRevIDText; + protected JTextField oldItemNameText; + protected JTextField itemTypeText; + protected JTextField itemUnitText; + + protected JButton okButton; + protected JButton celButton; + // ҳ + // protected JTable itemPropTable;// itemtable + // protected JTable itemFormPropTable;// itemformtable + // protected JTable revPropTable;// revtable + // protected JTable revFormPropTable;// revformtable + protected List itemPropTable; + protected List itemFormPropTable; + protected List revPropTable; + protected List revFormPropTable; + + protected List itemPropList;// itemб + protected List itemFormPropList;// itemformб + protected List revPropList;// 汾б + protected List revFormPropList;// 汾б + private DefaultTableModel dtm; + + private JPanel firstPanel; + private JPanel secondPanel; + private JPanel rootPanel; + + // ---Ҫõı + protected TCSession session; + protected AbstractAIFUIApplication app; + protected String title; + protected List itemList; + protected List itemListMsgBean; + private String specCode; + private Integer operateCode; + private TMomItemBean newItemBean; + private int index = 1; + private TCComponentFolder newStuffFolder; + private TCComponentFolder parentFolder; + private List explictBeanList; + + // private List folderList; + + private HashMap> custDeleTypeProp; + + private HashMap nameValueMap; + private boolean DEBUG=true; + + /** + * ȡϴδ͵ʱõ + * + * @param compType + */ + private void getNameValueMap(String compType) { + nameValueMap = new HashMap<>(); + nameValueMap.put("rb3_material", ""); + nameValueMap.put("rb3_press_drawing", ""); + nameValueMap.put("rb3_mb", ""); + nameValueMap.put("rb3_weight", ""); + nameValueMap.put("rb3_gxmc", ""); + nameValueMap.put("rb3_scale", ""); + nameValueMap.put("rb3_quantity", ""); + nameValueMap.put("rb3_yhth", ""); + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + if (!file.exists()) { + return; + } + try { + FileReader reader = new FileReader(file); + + BufferedReader br = new BufferedReader(reader); + + String info = br.readLine(); + if (info != null) { + String[] values = info.split("\\|"); + if (values == null || values.length != 8) { + return; + } + for (int i = 0; i < values.length; i++) { + String[] nameValues = values[i].split("="); + if (nameValues == null || nameValues.length != 2) { + continue; + } + + if (nameValueMap.containsKey(nameValues[0])) { + nameValueMap.remove(nameValues[0]); + nameValueMap.put(nameValues[0], nameValues[1]); + } + } + + } + br.close(); + reader.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void setNameValueMap(String compType) { + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + // if (!file.exists()) { + // return; + // } + + try { + FileWriter write = new FileWriter(file); + BufferedWriter bw = new BufferedWriter(write); + StringBuffer sb = new StringBuffer(); + + if (nameValueMap.containsKey("rb3_material")) { + sb.append("rb3_material"); + sb.append("="); + sb.append(nameValueMap.get("rb3_material")).append("|"); + } + if (nameValueMap.containsKey("rb3_press_drawing")) { + sb.append("rb3_press_drawing"); + sb.append("="); + sb.append(nameValueMap.get("rb3_press_drawing")).append("|"); + } + if (nameValueMap.containsKey("rb3_mb")) { + sb.append("rb3_mb"); + sb.append("="); + sb.append(nameValueMap.get("rb3_mb")).append("|"); + + } + if (nameValueMap.containsKey("rb3_weight")) { + sb.append("rb3_weight"); + sb.append("="); + sb.append(nameValueMap.get("rb3_weight")).append("|"); + + } + if (nameValueMap.containsKey("rb3_gxmc")) { + sb.append("rb3_gxmc"); + sb.append("="); + sb.append(nameValueMap.get("rb3_gxmc")).append("|"); + + } + if (nameValueMap.containsKey("rb3_scale")) { + sb.append("rb3_scale"); + sb.append("="); + sb.append(nameValueMap.get("rb3_scale")).append("|"); + + } + if (nameValueMap.containsKey("rb3_quantity")) { + sb.append("rb3_quantity"); + sb.append("="); + sb.append(nameValueMap.get("rb3_quantity")).append("|"); + + } + if (nameValueMap.containsKey("rb3_yhth")) { + sb.append("rb3_yhth"); + sb.append("="); + sb.append(nameValueMap.get("rb3_yhth")); + } + + bw.write(sb.toString()); + bw.close(); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * ȡҪص + */ + private void getCustDeleTypeProp() { + custDeleTypeProp = new HashMap<>(); + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray( + TCPreferenceService.TC_preference_site, CUST_DELE_TYPE_PROP); + if (props != null) { + for (int i = 0; i < props.length; i++) { + String[] subStrs = props[i].split("\\:"); + if (subStrs == null || subStrs.length != 2) { + continue; + } + String[] propSubStrs = subStrs[1].split("\\/"); + if (propSubStrs == null || propSubStrs.length <= 0) { + continue; + } + custDeleTypeProp.put(subStrs[0], Arrays.asList(propSubStrs)); + } + } + } + + public TMom002CreateGYTZDialog(TCSession session, AbstractAIFUIApplication app, + String title, List itemList, String specCode, + int operateCode) { + super(false); + this.app = app; + this.session = session; + this.title = title; + this.itemList = itemList; + this.specCode = specCode; + this.operateCode = operateCode; + this.newItemBean = new TMomItemBean(); + // this.folderList = new ArrayList<>(); + getCustDeleTypeProp(); + this.itemListMsgBean = TMomMethodUtil.getTargetsMsg(itemList); + this.explictBeanList = TMomMethodUtil.getExplictPropList(this.session); + init(); + + getItemInfo(0); + } + + /** + * ȡϢ + */ + public void getItemInfo(int index) { + + TMomItemBean bean = null; + if (itemListMsgBean != null && itemListMsgBean.size() != 0) + bean = this.itemListMsgBean.get(index); + else { + this.dispose(); + MessageBox.post("ûѡȡITEMѡִд˲", "", MessageBox.ERROR); + return; + } + this.parentFolder = bean.getFolder(); + this.oldItemIDText.setText(bean.getItemID()); + this.oldItemNameText.setText(bean.getName()); + // TCComponentItemType itemType = null; + switch (this.operateCode) { + case TMomFinalUtil.GYTZ_CODE: + this.itemTypeText.setText(TMomFinalUtil.GYTZ_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GYTZ_TYPE); + getNameValueMap(TMomFinalUtil.GYTZ_TYPE); + if (revFormPropList != null && revFormPropList.size() > 0) + for (int i = 0; i < revFormPropList.size(); i++) { + // revFormPropTable rb3_material,rb3_scale rb3_cpxh rb3_cpmc + if (revFormPropList.get(i).getName().endsWith("rb3_cpxh")) { + if (revFormPropTable.get(i) instanceof MyJTextfield) { + ((MyJTextfield) revFormPropTable.get(i)) + .setText(bean.getItemID()); + ((MyJTextfield) revFormPropTable.get(i)) + .setEditable(false); + } + } else if (revFormPropList.get(i).getName() + .endsWith("rb3_cpmc")) { + if (revFormPropTable.get(i) instanceof MyJTextfield) { + ((MyJTextfield) revFormPropTable.get(i)) + .setText(bean.getName()); + ((MyJTextfield) revFormPropTable.get(i)) + .setEditable(false); + } + } + } + break; + default: + break; + } + this.itemUnitText.setText(bean.getUnitDis()); + String newCode = TMomMethodUtil.getRuleItemID(session, + bean.getItemID(), specCode, operateCode); + this.newItemIDText.setText(newCode); + this.newItemRevIDText.setText("00"); + this.newItemBean.setRevID("00"); + this.newItemNameText.setText(bean.getName()); + } + + /** + * ȡϢ + * + * @param itemType + * @throws TCException + */ + public void getPropMsg(String itemType) throws TCException { + this.itemPropList = new ArrayList<>(); + this.itemFormPropList = new ArrayList<>(); + this.revPropList = new ArrayList<>(); + this.revFormPropList = new ArrayList<>(); + String startStr = "tm2"; + TCComponentType type = null; + + // type = this.session.getTypeComponent(itemType); + // if (type != null && type instanceof TCComponentItemType) { + // TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + // for (TCPropertyDescriptor desc : descs) { + // if (desc.getName().startsWith(startStr) && desc.isModifiable()) { + // TMomCreatePropBean bean = new TMomCreatePropBean(); + // bean.setDescriptor(desc); + // bean.setDisplayName(desc.getDisplayName()); + // bean.setName(desc.getName()); + // this.itemPropList.add(bean); + // } + // } + // } else { + // System.out.println("item"); + // // return; + // } + // type = this.session.getTypeComponent(itemType + "Master"); + // if (type != null && type instanceof TCComponentItemRevisionType) { + // TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + // for (TCPropertyDescriptor desc : descs) { + // if (desc.getName().startsWith(startStr) && desc.isModifiable()) { + // TMomCreatePropBean bean = new TMomCreatePropBean(); + // bean.setDescriptor(desc); + // bean.setDisplayName(desc.getDisplayName()); + // bean.setName(desc.getName()); + // this.itemFormPropList.add(bean); + // } + // } + // } else { + // System.out.println("itemMaster"); + // // return; + // } + // type = this.session.getTypeComponent(itemType + "Revision"); + List explictList = new ArrayList<>(); + /* + * for (TMomPropExplictBean explictBean : this.explictBeanList) { if + * (explictBean.getType().equals(itemType + "Revision")) { explictList = + * explictBean.getPropList(); continue; } } if (type != null && type + * instanceof TCComponentItemRevisionType) { TCPropertyDescriptor[] + * descs = type.getPropertyDescriptors(); for (TCPropertyDescriptor desc + * : descs) { if (desc.getName().startsWith(startStr) && + * desc.isModifiable()) { if (explictList != null && + * explictList.contains(desc.getName())) { continue; } + * TMomCreatePropBean bean = new TMomCreatePropBean(); + * bean.setDescriptor(desc); bean.setDisplayName(desc.getDisplayName()); + * bean.setName(desc.getName()); this.revPropList.add(bean); } } } else + * { System.out.println("rev"); // return; } + */ + // ---------------------------------------------------------------------------------- + type = this.session.getTypeComponent(itemType + "RevisionMaster"); + explictList.clear(); + for (TMomPropExplictBean explictBean : this.explictBeanList) { + if (explictBean.getType().equals(itemType + "RevisionMaster")) { + explictList = explictBean.getPropList(); + continue; + } + } + if (type != null && type instanceof TCComponentFormType) { + TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + for (TCPropertyDescriptor desc : descs) { + if (desc.getName().startsWith(startStr) && desc.isModifiable() + && desc.isDisplayable()) { + if (custDeleTypeProp.containsKey(itemType + + "RevisionMaster")) { + if (custDeleTypeProp.get(itemType + "RevisionMaster") + .contains(desc.getName())) { + continue; + } + } + if (explictList != null + && explictList.contains(desc.getName())) { + continue; + } + TMomCreatePropBean bean = new TMomCreatePropBean(); + bean.setDescriptor(desc); + bean.setDisplayName(desc.getDisplayName()); + bean.setName(desc.getName()); + this.revFormPropList.add(bean); + } + } + } else { + System.out.println("revMaster"); + // return; + } + + } + + /** + * ʼ + */ + public void init() { + try { + newStuffFolder = session.getUser().getNewStuffFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(this.title); + this.setAutoRequestFocus(true); + this.setPreferredSize(new Dimension(430, 300)); + this.newItemIDLabel = new JLabel(rb.getString("xljid_display.TITLE")); + this.newItemRevIDLabel = new JLabel(rb.getString("bbid_display.TITLE")); + this.newItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.oldItemIDLabel = new JLabel(rb.getString("jlzjid_display.TITLE")); + this.oldItemRevIDLabel = new JLabel(rb.getString("bb_display.TITLE")); + this.oldItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.newItemIDText = new JTextField(20); + // this.newItemIDText.setEditable(false); + this.newItemRevIDText = new JTextField(6); + this.newItemRevIDText.setEnabled(false); + this.newItemNameText = new JTextField(32); + this.oldItemIDText = new JTextField(20); + this.oldItemIDText.setEnabled(false); + this.oldItemRevIDText = new JTextField(6); + this.oldItemRevIDText.setEnabled(false); + this.oldItemNameText = new JTextField(32); + this.oldItemNameText.setEnabled(false); + 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.itemTypeLabel = new JLabel(rb.getString("lx_display.TITLE")); + this.itemTypeText = new JTextField(12); + this.itemTypeText.setEditable(false); + this.itemTypeText.setText(rb.getString("lx_display.TITLE")); + this.itemUnitLabel = new JLabel(rb.getString("dw_display.TITLE")); + this.itemUnitText = new JTextField(12); + this.itemUnitText.setEnabled(false); + this.itemUnitText.setText(rb.getString("dw_display.TITLE")); + + // PropertyLayout layout = new PropertyLayout(); + + // ʾ + JPanel newItemMsgPanel = new JPanel(new PropertyLayout()); + newItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), rb.getString("xljxx_display.TITLE"))); + newItemMsgPanel.add("1.1.left.top.preferred.preferred", newItemIDLabel); + newItemMsgPanel.add("1.2.left.top.preferred.preferred", + newItemRevIDLabel); + newItemMsgPanel.add("1.3.left.top.preferred.preferred", + newItemNameLabel); + // + newItemMsgPanel.add("2.1.left.top.preferred.preferred", newItemIDText); + newItemMsgPanel.add("2.2.left.top.preferred.preferred", + newItemRevIDText); + newItemMsgPanel + .add("2.3.left.top.preferred.preferred", newItemNameText); + JPanel typeAndUnitPanel = new JPanel(new PropertyLayout()); + // .setBorder(new TitledBorder(BorderFactory.createEtchedBorder(),"")); + typeAndUnitPanel.add("1.1.left.top.preferred.preferred", itemTypeLabel); + typeAndUnitPanel.add("1.2.left.top.preferred.preferred", itemTypeText); + typeAndUnitPanel.add("2.1.left.top.preferred.preferred", itemUnitLabel); + typeAndUnitPanel.add("2.2.left.top.preferred.preferred", itemUnitText); + // ʾ + JPanel oldItemMsgPanel = new JPanel(new PropertyLayout()); + oldItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), rb.getString("jy_display.TITLE"))); + oldItemMsgPanel.add("1.1.left.top.preferred.preferred", oldItemIDLabel); + oldItemMsgPanel.add("1.2.left.top.preferred.preferred", + oldItemRevIDLabel); + oldItemMsgPanel.add("1.3.left.top.preferred.preferred", + oldItemNameLabel); + // + oldItemMsgPanel.add("2.1.left.top.preferred.preferred", oldItemIDText); + oldItemMsgPanel.add("2.2.left.top.preferred.preferred", + oldItemRevIDText); + oldItemMsgPanel + .add("2.3.left.top.preferred.preferred", oldItemNameText); + // + this.secondPanel = new JPanel(new FlowLayout()); + this.secondPanel.add(okButton); + this.secondPanel.add(new JLabel(" ")); + this.secondPanel.add(celButton); + this.firstPanel = new JPanel(new PropertyLayout()); + this.firstPanel + .add("1.1.left.top.preferred.preferred", newItemMsgPanel); + this.firstPanel.add("2.1.left.top.preferred.preferred", + typeAndUnitPanel); + this.firstPanel + .add("3.1.left.top.preferred.preferred", oldItemMsgPanel); + // ҳ------------------------------------------------------------ + if (operateCode == TMomFinalUtil.GYTZ_CODE) { + try { + getNameValueMap(TMomFinalUtil.GYTZ_TYPE); + getPropMsg(TMomFinalUtil.GYTZ_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + JPanel propPanel = new JPanel(new PropertyLayout()); + int propIndex = 1; + if (this.itemPropList != null && this.itemPropList.size() != 0) { + this.itemPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemPropList, this.itemPropTable, + propIndex, ""); + propIndex++; + } + if (this.itemFormPropList != null && this.itemFormPropList.size() != 0) { + this.itemFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemFormPropList, + this.itemFormPropTable, propIndex, ""); + propIndex++; + } + if (this.revPropList != null && this.revPropList.size() != 0) { + this.revPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revPropList, this.revPropTable, + propIndex, "汾"); + propIndex++; + } + if (this.revFormPropList != null && this.revFormPropList.size() != 0) { + // + this.revFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revFormPropList, + this.revFormPropTable, propIndex, "汾"); + propIndex++; + System.out.println("revFormPropTable count =" + + revFormPropTable.size()); + } + + // ҳ + JTabbedPane tabPane = new JTabbedPane(); + tabPane.add(rb.getString("lzjxx_display.TITLE"), firstPanel); + tabPane.add(rb.getString("sx_display.TITLE"), new JScrollPane(propPanel)); + + // + this.rootPanel = new JPanel(new BorderLayout()); + this.rootPanel.add(tabPane, BorderLayout.CENTER); + this.rootPanel.add(secondPanel, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + /** + * Խ + * + * @param propPanel + * @param beanList + * @param compList + * @param propIndex + */ + private void setPropPanel(JPanel propPanel, + List beanList, List compList, + int propIndex, String name) { + + JPanel itemPorpPanel = new JPanel(new PropertyLayout()); + itemPorpPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), name)); + + String currentGroupName = null; + try { + currentGroupName = session.getCurrentGroup().getFullName(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + int indexx = currentGroupName.lastIndexOf("."); + // ȡǰʶ + String groupName = currentGroupName.substring(indexx + 1, currentGroupName.length()); + // ȡѡ + String[] lovValue = session.getPreferenceService().getStringArray(TCPreferenceService.TC_preference_site, + CUST_MODEL_AREA); + if (null == lovValue||lovValue.length<=0) { + System.out.println("ûѡ" + CUST_MODEL_AREA); + MessageBox.post("ȱѡ" + CUST_MODEL_AREA + ",ϵԱ", "", MessageBox.ERROR); + return; + } + // ȡеĶ + Map groupLoV = new HashMap(); + // װ + for (String string : lovValue) { + String[] sp = string.split(":"); + String group = sp[0]; + String model = sp[1]; + String[] x=model.split("-"); + groupLoV.put(group, x); + } + + // compList = new ArrayList<>(); + for (int i = 0; i < beanList.size(); i++) { + JLabel disNameLabel = new JLabel(beanList.get(i).getDisplayName()); + String defaultValueInfo = null; + if (this.nameValueMap.containsKey(beanList.get(i).getName())) { + defaultValueInfo = this.nameValueMap.get(beanList.get(i) + .getName()); + } else { + defaultValueInfo = null; + } + TCPropertyDescriptor desc = beanList.get(i).getDescriptor(); + JComponent valueComp = null; + TCComponentListOfValues lobList = desc.getLOV(); + if (lobList != null) { + MyJCombox box = new MyJCombox(); + box.setEditable(true); + box.setPropName(desc.getName()); + try { + ListOfValuesInfo info = lobList.getListOfValues(); + String[] valuesList; + String[] disValuesList = null; + if (groupLoV.containsKey(groupName) && "RB3_mb_lov".equals(info.toString())) { + // Ӧôѡлȡ + valuesList = groupLoV.get(groupName); + disValuesList = new String[valuesList.length + 1]; + + } else { + valuesList = info.getStringListOfValues(); + disValuesList = new String[valuesList.length + 1]; + } + if (DEBUG) { + for (String string : valuesList) { + System.out.print(string + "\t"); + } + } + disValuesList[0] = ""; + box.setValues(valuesList); + int index = -1; + for (int w = 1; w < disValuesList.length; w++) { + disValuesList[w] = info + .getDisplayableValue(valuesList[w - 1]); + if (defaultValueInfo != null + && defaultValueInfo.equals(valuesList[w - 1])) { + index = w; + } + } + box.setModel(new DefaultComboBoxModel(disValuesList)); + if (index != -1) { + box.setSelectedIndex(index); + } else if (null == disValuesList || index== -1) { + box.getModel().setSelectedItem(""); + } else { + box.getModel().setSelectedItem(defaultValueInfo); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + // box.setModel(new DefaultComboBoxModel(new String[] { "" + // })); + } + valueComp = box; + } else { + // JTextField fied = new JTextField(12); + MyJTextfield valueText = new MyJTextfield(32); + valueText.setText(beanList.get(i).getDescriptor() + .getDefaultValue()); + // if (desc.getName().endsWith("rb3_material")) { + // valueText.setText(oldItemIDText.getText());//rb3_material,rb3_scale + // + // } else if (desc.getName().endsWith("rb3_scale")) { + // valueText.setText(oldItemNameText.getText()); + // + // } else { + // System.out.println("desc.getName()=>" + desc.getName()); + // + // } + valueText.setPropName(beanList.get(i).getName()); + valueComp = valueText; + if (defaultValueInfo != null) { + valueText.setText(defaultValueInfo); + } + + } + + itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", + disNameLabel); + itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", + valueComp); + compList.add(valueComp); + } + propPanel.add(propIndex + ".1.left.top.preferred.preferred", + itemPorpPanel); + } + + /** + * comboxؼ + * + * @author hub + * + */ + + private class MyJCombox extends JComboBox { + private String[] values; + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String[] getValues() { + return values; + } + + public void setValues(String[] values) { + this.values = values; + } + + } + + /** + * + * @author hub + * + */ + private class MyJTextfield extends JTextField { + + public MyJTextfield(int len) { + super(len); + } + + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + } + + /** + * JTABLEͨ÷ + * + * @param partsTable + * @param titleNames + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 105; + int totleLen = 900; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)) { + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(105); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + /** + * tableؼ + * + * @param dtm + * @param columNameObjects + * @param objects + * @return + */ + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] columNameObjects, Object[][] objects) { + // Object[] columNameObjects = this.titleNames; //// , + // Object[][] objects = getValues(this.valueLists); + if (dtm == null) { + dtm = new DefaultTableModel(objects, columNameObjects); + } + return dtm; + } + + /** + * תΪMAP + * + * @param listBean + * @return + */ + public HashMap getValues(List listBean) { + HashMap valueMap = null; + if (listBean != null && listBean.size() > 0) { + valueMap = new HashMap<>(); + for (int i = 0; i < listBean.size(); i++) { + JComponent bean = listBean.get(i); + if (bean instanceof MyJTextfield) { + + valueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + if (nameValueMap.containsKey(((MyJTextfield) bean) + .getPropName())) { + nameValueMap + .remove(((MyJTextfield) bean).getPropName()); + nameValueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + } + System.out.println(" ((MyJTextfield) bean).getPropName() =" + + ((MyJTextfield) bean).getPropName() + " | " + + "((MyJTextfield) bean).getText()" + + ((MyJTextfield) bean).getText()); + } else if (bean instanceof MyJCombox) { + + if (((MyJCombox) bean).getSelectedIndex() == -1) { + valueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel().getSelectedItem() + .toString()); + System.out.println(" tip text " + + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + } + } else { + + valueMap.put( + ((MyJCombox) bean).getPropName(), + (((MyJCombox) bean).getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean).getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap + .put(((MyJCombox) bean).getPropName(), + (((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + } + System.out + .println(" 123=" + + ((((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1])); + } + + /* + * System.out .println((((MyJCombox) + * bean).getSelectedIndex() == -1 || ((MyJCombox) bean) + * .getSelectedIndex() == 0) ? ((MyJCombox) bean) + * .getToolTipText() : ((MyJCombox) bean) + * .getValues()[((MyJCombox) bean) .getSelectedIndex() - + * 1]); + */ + /* + * System.out .println("((MyJCombox) bean).getPropName() =" + * + ((MyJCombox) bean).getPropName() + " | " + + * "((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex()] =" + * + ((MyJCombox) bean).getValues()[((MyJCombox) bean) + * .getSelectedIndex()]); + */ + } + + } + } + + return valueMap; + + } + + private TCUserService userservice; + + public void setByPass(boolean val) throws TCException { + if (userservice == null) { + userservice = this.session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("ORIGIN_set_bypass", obj); + } else { + userservice.call("ORIGIN_close_bypass", obj); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object obj = e.getSource(); + if (obj.equals(this.okButton)) { + + TCComponentItem item = TMomMethodUtil.createNewItemSoa( + this.session, this.newItemIDText.getText(), + this.newItemRevIDText.getText(), + this.newItemBean.getType(), this.newItemNameText.getText(), + "", this.newItemBean.getUnit(), getValues(itemPropTable), + getValues(revPropTable), getValues(revFormPropTable)); + + if (item != null) { + setNameValueMap(this.newItemBean.getType()); + TCComponentFolder folder = null; + String msg = new String(); + String releationName = null; + if (this.parentFolder != null) { + folder = this.parentFolder; + msg = "ŵ[" + this.oldItemNameText.getText() + "]ļ"; + + } else if (newStuffFolder != null) { + folder = newStuffFolder; + msg = "ŵ[Newstuff]ļ"; + } + if (operateCode == 1) { + + // TODO + if (specCode.equals("P")) { + releationName = "RB3_mjt"; + } else if (specCode.equals("R")) { + releationName = "RB3_jjt"; + } else if (specCode.equals("S")) { + releationName = "RB3_jzmj"; + } else { + releationName = "RB3_gjj"; + } + } + if (operateCode == 3) { + releationName = "RB3_zuoyezhidaoshu"; + } + if (folder != null) { + + try { + switch (operateCode) { + case 0: + folder.add("contents", item); + break; + case 1: + TCComponentItemRevision oldRev1 = ((TCComponentItemRevision) this.itemListMsgBean + .get(index - 1).getItem() + .getLatestItemRevision()); + if (oldRev1 != null) { + if (oldRev1.getTCProperty(releationName) != null) { + oldRev1.add(releationName, item); + oldRev1.refresh(); + System.out.println("releationName =" + + releationName); + } else { + folder.add("contents", item); + } + + } else { + folder.add("contents", item); + } + break; + case 2: + folder.add("contents", item); + break; + case 3: + TCComponentItemRevision oldRev = ((TCComponentItemRevision) this.itemListMsgBean + .get(index - 1).getItem() + .getLatestItemRevision()); + if (oldRev != null) { + if (oldRev.getTCProperty(releationName) != null) { + oldRev.add(releationName, item); + oldRev.refresh(); + System.out.println("releationName =" + + releationName); + } else { + folder.add("contents", item); + } + + } else { + folder.add("contents", item); + } + break; + default: + break; + } + folder.refresh(); + MessageBox.post( + "[item_id= " + this.newItemIDText.getText() + + " / rev =" + + this.newItemRevIDText.getText() + + " / name= " + + this.newItemNameText.getText() + + "]ɹ", "ɹ" + msg, + MessageBox.INFORMATION); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + MessageBox.post("ӵNEWSTUFFļʧܣ", "", + MessageBox.ERROR); + } + } + } else { + System.out.println("[item_id= " + + this.newItemIDText.getText() + " / rev =" + + this.newItemRevIDText.getText() + " / name= " + + this.newItemNameText.getText() + "]ʧ"); + MessageBox.post("[item_id= " + this.newItemIDText.getText() + + " / rev =" + this.newItemRevIDText.getText() + + " / name= " + this.newItemNameText.getText() + "]ʧ", + "", MessageBox.ERROR); + } + if (this.index < this.itemListMsgBean.size()) { + + getItemInfo(index); + index++; + this.okButton.setText("<>"); + } else { + this.okButton.setEnabled(false); + } + + } else if (obj.equals(this.celButton)) { + this.dispose(); + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateGYTZHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateGYTZHandler.java new file mode 100644 index 0000000..0031ee3 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateGYTZHandler.java @@ -0,0 +1,87 @@ +package com.connor.renben.process.plm.tmom002; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom002CreateGYTZHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + final TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] comps = app.getTargetComponents(); + final List itemList = getItemList( + comps, true, true); + if (itemList == null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzgxdxhcd02_display.TITLE"), "", MessageBox.ERROR); + return null; + } + new Thread() { + @Override + public void run() { + // TODO Auto-generated method stub + new TMom002CreateGYTZDialog(session, app, "ͼֽ", itemList, null, + TMomFinalUtil.GYTZ_CODE); + super.run(); + } + }.start(); + return null; + } + + /** + * жϻȡĶǷȫΪ汾 + * + * @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 && comps[i].getType().indexOf("MEOP") >= 0) { + 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; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateHistoryProcessHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateHistoryProcessHandler.java new file mode 100644 index 0000000..7832bf6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateHistoryProcessHandler.java @@ -0,0 +1,61 @@ +package com.connor.renben.process.plm.tmom002; + +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom002CreateHistoryProcessHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + final TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] comps = app.getTargetComponents(); + final List itemList = TMomMethodUtil.getItemList( + comps, true, true); + try { + if (itemList != null) { + for (int i = 0; i < itemList.size(); i++) { + if (!itemList.get(i).getStringProperty("object_type").equals("RB3_ZC")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzzcdxhcj02_display.TITLE"), "", MessageBox.ERROR); + return null; + } + } + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + new Thread() { + @Override + public void run() { + // TODO Auto-generated method stub + new TMom002AbtractDialog(session, app, "", itemList, null, + TMomFinalUtil.HISGY_CODE); + super.run(); + } + }.start(); + return null; + // CreateNewBOHandler handler = new CreateNewBOHandler("MEProcess"); + // handler.execute(arg0); + // return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEEquipmentHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEEquipmentHandler.java new file mode 100644 index 0000000..4e93e0e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEEquipmentHandler.java @@ -0,0 +1,19 @@ +package com.connor.renben.process.plm.tmom002; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; + +public class TMom002CreateMEEquipmentHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_MEEquipment"); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEStationHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEStationHandler.java new file mode 100644 index 0000000..57e2e0f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEStationHandler.java @@ -0,0 +1,19 @@ +package com.connor.renben.process.plm.tmom002; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; + +public class TMom002CreateMEStationHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + CreateNewBOHandler handler = new CreateNewBOHandler("MEStation"); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEToolHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEToolHandler.java new file mode 100644 index 0000000..f19516f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateMEToolHandler.java @@ -0,0 +1,19 @@ +package com.connor.renben.process.plm.tmom002; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; + +public class TMom002CreateMEToolHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_METool"); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateOPDialog.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateOPDialog.java new file mode 100644 index 0000000..8467084 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateOPDialog.java @@ -0,0 +1,1348 @@ +package com.connor.renben.process.plm.tmom002; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; + +import com.alibaba.fastjson.JSON; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.TMomCreatePropBean; +import com.connor.renben.process.plm.bean.TMomItemBean; +import com.connor.renben.process.plm.bean.TMomPropExplictBean; +import com.connor.renben.process.plm.test.MultiPopup; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.MultiComboBox2; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFilter; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +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.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom002CreateOPDialog extends AbstractAIFDialog implements + ActionListener { + private final String CUST_DELE_TYPE_PROP = "Cust_Del_Type_Props"; + private final String CUST_MODEL_AREA = "CUST_Model_Area"; + private List itemNameList = new ArrayList(); + private ItemNameDialog itemNameDialog; + // private final String CUST_MODEL_AREA_TJ_NBTM = "CUST_Model_Area_TJ_NBTM"; + private JLabel newItemIDLabel; + private JLabel newItemRevIDLabel; + private JLabel newItemNameLabel; + private JLabel oldItemIDLabel; + private JLabel oldItemRevIDLabel; + private JLabel oldItemNameLabel; + private JLabel itemTypeLabel; + private JLabel itemUnitLabel; + + protected JTextField newItemIDText; + protected JTextField newItemRevIDText; + // protected JTextField newItemNameText; + protected JTextField newItemNameText; + //protected JButton newItemNameButton; + protected JTextField oldItemIDText; + protected JTextField oldItemRevIDText; + protected JTextField oldItemNameText; + protected JTextField itemTypeText; + protected JTextField itemUnitText; + // + private JLabel scgcLabel; + private MultiComboBox2 scgcComboBox; + + protected JButton okButton; + protected JButton celButton; + // ҳ + // protected JTable itemPropTable;// itemtable + // protected JTable itemFormPropTable;// itemformtable + // protected JTable revPropTable;// revtable + // protected JTable revFormPropTable;// revformtable + protected List itemPropTable; + protected List itemFormPropTable; + protected List revPropTable; + protected List revFormPropTable; + + protected List itemPropList;// itemб + protected List itemFormPropList;// itemformб + protected List revPropList;// 汾б + protected List revFormPropList;// 汾б + private DefaultTableModel dtm; + + private JPanel firstPanel; + private JPanel secondPanel; + private JPanel rootPanel; + + // ---Ҫõı + protected TCSession session; + protected AbstractAIFUIApplication app; + protected String title; + protected List itemList; + protected List itemListMsgBean; + private String specCode; + private Integer operateCode; + private TMomItemBean newItemBean; + private int index = 1; + private TCComponentFolder newStuffFolder; + private TCComponentFolder parentFolder; + private List explictBeanList; + + // private List folderList; + + private HashMap> custDeleTypeProp; + + private HashMap nameValueMap; + private boolean DEBUG = true; + private String[] itemNames; + private String[] selectStringName;//¼ʵֵ + private String[] selectDisplayName;//¼ʾֵ + + /** + * ȡϴδ͵ʱõ + * + * @param compType + */ + private void getNameValueMap(String compType) { + nameValueMap = new HashMap<>(); + nameValueMap.put("rb3_material", ""); + nameValueMap.put("rb3_press_drawing", ""); + nameValueMap.put("rb3_mb", ""); + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + if (!file.exists()) { + return; + } + try { + FileReader reader = new FileReader(file); + + BufferedReader br = new BufferedReader(reader); + + String info = br.readLine(); + if (info != null) { + String[] values = info.split("\\|"); + if (values == null || values.length != 3) { + return; + } + for (int i = 0; i < values.length; i++) { + String[] nameValues = values[i].split("="); + if (nameValues == null || nameValues.length != 2) { + continue; + } + + if (nameValueMap.containsKey(nameValues[0])) { + nameValueMap.remove(nameValues[0]); + nameValueMap.put(nameValues[0], nameValues[1]); + } + } + + } + br.close(); + reader.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + private void setNameValueMap(String compType) { + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + // if (!file.exists()) { + // return; + // } + + try { + FileWriter write = new FileWriter(file); + BufferedWriter bw = new BufferedWriter(write); + StringBuffer sb = new StringBuffer(); + + if (nameValueMap.containsKey("rb3_material")) { + sb.append("rb3_material"); + sb.append("="); + sb.append(nameValueMap.get("rb3_material")).append("|"); + } + if (nameValueMap.containsKey("rb3_press_drawing")) { + sb.append("rb3_press_drawing"); + sb.append("="); + sb.append(nameValueMap.get("rb3_press_drawing")).append("|"); + } + if (nameValueMap.containsKey("rb3_mb")) { + sb.append("rb3_mb"); + sb.append("="); + sb.append(nameValueMap.get("rb3_mb")); + + } + + bw.write(sb.toString()); + bw.close(); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + /** + * ȡҪص + */ + private void getCustDeleTypeProp() { + custDeleTypeProp = new HashMap<>(); + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray( + TCPreferenceService.TC_preference_site, CUST_DELE_TYPE_PROP); + if (props != null) { + for (int i = 0; i < props.length; i++) { + String[] subStrs = props[i].split("\\:"); + if (subStrs == null || subStrs.length != 2) { + continue; + } + String[] propSubStrs = subStrs[1].split("\\/"); + if (propSubStrs == null || propSubStrs.length <= 0) { + continue; + } + custDeleTypeProp.put(subStrs[0], Arrays.asList(propSubStrs)); + } + } + } + + public TMom002CreateOPDialog(TCSession session, + AbstractAIFUIApplication app, String title, + List itemList, String specCode, int operateCode) { + super(false); + this.app = app; + this.session = session; + this.title = title; + this.itemList = itemList; + this.specCode = specCode; + this.operateCode = operateCode; + this.newItemBean = new TMomItemBean(); + // this.folderList = new ArrayList<>(); + getCustDeleTypeProp(); + // ȡѡȡITEMĿϢ + this.itemListMsgBean = TMomMethodUtil.getTargetsMsg(itemList); + // ˵вҪʾ + this.explictBeanList = TMomMethodUtil.getExplictPropList(this.session); + getItemName(); + init(); + getItemInfo(0); + } + + /** + * ȡϢ + */ + public void getItemInfo(int index) { + + TMomItemBean bean = null; + if (itemListMsgBean != null && itemListMsgBean.size() != 0) + bean = this.itemListMsgBean.get(index); + else { + this.dispose(); + MessageBox.post("ûѡȡITEMѡִд˲", "", MessageBox.ERROR); + return; + } + this.parentFolder = bean.getFolder(); + this.oldItemIDText.setText(bean.getItemID()); + this.oldItemNameText.setText(bean.getName()); + // TCComponentItemType itemType = null; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + this.itemTypeText.setText(TMomFinalUtil.GY_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GY_TYPE); + getNameValueMap(TMomFinalUtil.GY_TYPE); + break; + case TMomFinalUtil.HISGY_CODE: + this.itemTypeText.setText(TMomFinalUtil.GY_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GY_TYPE); + getNameValueMap(TMomFinalUtil.GY_TYPE); + break; + case TMomFinalUtil.GX_CODE: + this.itemTypeText.setText(TMomFinalUtil.GX_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GX_TYPE); + getNameValueMap(TMomFinalUtil.GX_TYPE); + break; + default: + break; + } + this.itemUnitText.setText(bean.getUnitDis()); + // ȡITEMID + String newCode = TMomMethodUtil.getRuleItemID(session, + bean.getItemID(), specCode, operateCode); + this.newItemIDText.setText(newCode); + this.newItemRevIDText.setText("00"); + this.newItemBean.setRevID("00"); + this.newItemNameText.setText(bean.getName()); + // this.newItemNameText.setText(bean.getName()); + } + + private void getItemName() { + TCPreferenceService service = this.session.getPreferenceService(); + String morderName = null; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + morderName = TMomFinalUtil.GY_ITEM_NAMES; + break; + case TMomFinalUtil.HISGY_CODE: + morderName = TMomFinalUtil.GY_ITEM_NAMES; + break; + case TMomFinalUtil.GX_CODE: + morderName = TMomFinalUtil.GX_ITEM_NAMES; + break; + default: + break; + } + if (morderName != null) { + String[] props = service.getStringArray( + TCPreferenceService.TC_preference_site, morderName); + if (props != null || props.length > 0) { + this.itemNames = props; + } else { + this.itemNames = new String[] { "" }; + } + } else { + MessageBox.post("δҵӦITEM_NAMEѡ", "", MessageBox.ERROR); + } + } + + /** + * ȡϢ + * + * @param itemType + * @throws TCException + */ + public void getPropMsg(String itemType) throws TCException { + this.itemPropList = new ArrayList<>(); + this.itemFormPropList = new ArrayList<>(); + this.revPropList = new ArrayList<>(); + this.revFormPropList = new ArrayList<>(); + String startStr = "tm2"; + TCComponentType type = null; + + List explictList = new ArrayList<>(); + + type = this.session.getTypeComponent(itemType + "Revision Master"); + explictList.clear(); + for (TMomPropExplictBean explictBean : this.explictBeanList) { + if (explictBean.getType().equals(itemType + "Revision Master")) { + explictList = explictBean.getPropList(); + continue; + } + } + if (type != null && type instanceof TCComponentFormType) { + TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + for (TCPropertyDescriptor desc : descs) { + if (desc.getName().startsWith(startStr) && desc.isModifiable() + && desc.isDisplayable()) { + if (custDeleTypeProp.containsKey(itemType + + "Revision Master")) { + if (custDeleTypeProp.get(itemType + "Revision Master") + .contains(desc.getName())) { + continue; + } + } + if (explictList != null + && explictList.contains(desc.getName())) { + continue; + } + TMomCreatePropBean bean = new TMomCreatePropBean(); + bean.setDescriptor(desc); + bean.setDisplayName(desc.getDisplayName()); + bean.setName(desc.getName()); + this.revFormPropList.add(bean); + } + } + } else { + System.out.println("revMaster"); + // return; + } + + } + + /** + * ʼ + */ + public void init() { + try { + newStuffFolder = session.getUser().getNewStuffFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + this.setTitle(this.title); + this.setAutoRequestFocus(true); + this.setPreferredSize(new Dimension(800, 500)); + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.newItemIDLabel = new JLabel(rb.getString("xljid_display.TITLE")); + this.newItemRevIDLabel = new JLabel(rb.getString("bbid_display.TITLE")); + this.newItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.oldItemIDLabel = new JLabel(rb.getString("jlzjid_display.TITLE")); + this.oldItemRevIDLabel = new JLabel(rb.getString("bbid_display.TITLE")); + this.oldItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.newItemIDText = new JTextField(20); + // this.newItemIDText.setEditable(false); + this.newItemRevIDText = new JTextField(6); + this.newItemRevIDText.setEnabled(false); +// this.newItemNameText = new JAutoCompleteComboBox( +// new DefaultComboBoxModel(itemNames)); + this.newItemNameText = new JTextField(); + this.newItemNameText.setPreferredSize(new Dimension(200, 21)); + this.oldItemIDText = new JTextField(20); + this.oldItemIDText.setEnabled(false); + this.oldItemRevIDText = new JTextField(6); + this.oldItemRevIDText.setEnabled(false); + this.oldItemNameText = new JTextField(32); + this.oldItemNameText.setEnabled(false); + 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.newItemNameButton = new JButton("ѡ"); + //this.newItemNameButton.addActionListener(this); + // ------------------------------ + this.itemTypeLabel = new JLabel(rb.getString("lx_display.TITLE")); + this.itemTypeText = new JTextField(12); + this.itemTypeText.setEditable(false); + this.itemTypeText.setText(rb.getString("lx_display.TITLE")); + this.itemUnitLabel = new JLabel(rb.getString("dw_display.TITLE")); + this.itemUnitText = new JTextField(12); + this.itemUnitText.setEnabled(false); + this.itemUnitText.setText(rb.getString("dw_display.TITLE")); + this.scgcLabel = new JLabel(rb.getString("scgc_display.TITLE")); + List> Values = findLovValueByKey(session,"RB3_SCGC1"); + this.selectDisplayName=Values.get(0).toArray(new String[]{}); + this.selectStringName=Values.get(1).toArray(new String[]{}); + this.scgcComboBox = new MultiComboBox2(this.selectDisplayName); + //this.scgcComboBox.setPreferredSize(new Dimension(350, 100)); + // PropertyLayout layout = new PropertyLayout(); + + // ʾ + JPanel newItemMsgPanel = new JPanel(new PropertyLayout()); + newItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), rb.getString("xljxx_display.TITLE"))); + newItemMsgPanel.add("1.1.left.top.preferred.preferred", newItemIDLabel); + newItemMsgPanel.add("1.2.left.top.preferred.preferred", + newItemRevIDLabel); + newItemMsgPanel.add("1.3.left.top.preferred.preferred", + newItemNameLabel); + // + newItemMsgPanel.add("2.1.left.top.preferred.preferred", newItemIDText); + newItemMsgPanel.add("2.2.left.top.preferred.preferred", + newItemRevIDText); + newItemMsgPanel + .add("2.3.left.top.preferred.preferred", newItemNameText); +// newItemMsgPanel +// .add("2.4.left.top.preferred.preferred", newItemNameButton); + JPanel typeAndUnitPanel = new JPanel(new PropertyLayout()); + // .setBorder(new TitledBorder(BorderFactory.createEtchedBorder(),"")); + typeAndUnitPanel.add("1.1.left.top.preferred.preferred", scgcLabel); + typeAndUnitPanel.add("1.2.left.top.preferred.preferred", scgcComboBox); + typeAndUnitPanel.add("2.1.left.top.preferred.preferred", itemTypeLabel); + typeAndUnitPanel.add("2.2.left.top.preferred.preferred", itemTypeText); + typeAndUnitPanel.add("3.1.left.top.preferred.preferred", itemUnitLabel); + typeAndUnitPanel.add("3.2.left.top.preferred.preferred", itemUnitText); + + // ʾ + JPanel oldItemMsgPanel = new JPanel(new PropertyLayout()); + oldItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), rb.getString("jy_display.TITLE"))); + oldItemMsgPanel.add("1.1.left.top.preferred.preferred", oldItemIDLabel); + oldItemMsgPanel.add("1.2.left.top.preferred.preferred", + oldItemRevIDLabel); + oldItemMsgPanel.add("1.3.left.top.preferred.preferred", + oldItemNameLabel); + // + oldItemMsgPanel.add("2.1.left.top.preferred.preferred", oldItemIDText); + oldItemMsgPanel.add("2.2.left.top.preferred.preferred", + oldItemRevIDText); + oldItemMsgPanel + .add("2.3.left.top.preferred.preferred", oldItemNameText); + // + this.secondPanel = new JPanel(new FlowLayout()); + this.secondPanel.add(okButton); + this.secondPanel.add(new JLabel(" ")); + this.secondPanel.add(celButton); + this.firstPanel = new JPanel(new PropertyLayout()); + this.firstPanel + .add("1.1.left.top.preferred.preferred", newItemMsgPanel); + this.firstPanel.add("2.1.left.top.preferred.preferred", + typeAndUnitPanel); + this.firstPanel + .add("3.1.left.top.preferred.preferred", oldItemMsgPanel); + // ҳ------------------------------------------------------------ + if (operateCode == TMomFinalUtil.GY_CODE) { + try { + getNameValueMap(TMomFinalUtil.GY_TYPE); + getPropMsg(TMomFinalUtil.GY_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (operateCode == TMomFinalUtil.HISGY_CODE) { + try { + getNameValueMap(TMomFinalUtil.GY_TYPE); + getPropMsg(TMomFinalUtil.GY_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (operateCode == TMomFinalUtil.GX_CODE) { + try { + getNameValueMap(TMomFinalUtil.GX_TYPE); + getPropMsg(TMomFinalUtil.GX_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + JPanel propPanel = new JPanel(new PropertyLayout()); + int propIndex = 1; + if (this.itemPropList != null && this.itemPropList.size() != 0) { + this.itemPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemPropList, this.itemPropTable, + propIndex, ""); + propIndex++; + } + if (this.itemFormPropList != null && this.itemFormPropList.size() != 0) { + this.itemFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemFormPropList, + this.itemFormPropTable, propIndex, ""); + propIndex++; + } + if (this.revPropList != null && this.revPropList.size() != 0) { + this.revPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revPropList, this.revPropTable, + propIndex, "汾"); + propIndex++; + } + if (this.revFormPropList != null && this.revFormPropList.size() != 0) { + // + this.revFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revFormPropList, + this.revFormPropTable, propIndex, "汾"); + propIndex++; + System.out.println("revFormPropTable count =" + + revFormPropTable.size()); + } + + // ҳ + JTabbedPane tabPane = new JTabbedPane(); + tabPane.add(rb.getString("lzjxx_display.TITLE"), firstPanel); + tabPane.add(rb.getString("sx_display.TITLE"), new JScrollPane(propPanel)); + + // + this.rootPanel = new JPanel(new BorderLayout()); + this.rootPanel.add(tabPane, BorderLayout.CENTER); + this.rootPanel.add(secondPanel, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + /** + * Խ + * + * @param propPanel + * @param beanList + * @param compList + * @param propIndex + */ + private void setPropPanel(JPanel propPanel, + List beanList, List compList, + int propIndex, String name) { + + JPanel itemPorpPanel = new JPanel(new PropertyLayout()); + itemPorpPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), name)); + + // //////////////////////////////////////////// + // compList = new ArrayList<>(); + String currentGroupName = null; + try { + currentGroupName = session.getCurrentGroup().getFullName(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + int indexx = currentGroupName.lastIndexOf("."); + // ȡǰʶ + String groupName = currentGroupName.substring(indexx + 1, + currentGroupName.length()); + // ȡѡ + String[] lovValue = session.getPreferenceService().getStringArray( + TCPreferenceService.TC_preference_site, CUST_MODEL_AREA); + if (null == lovValue || lovValue.length <= 0) { + System.out.println("ûѡ" + CUST_MODEL_AREA); + MessageBox.post("ȱѡ" + CUST_MODEL_AREA + ",ϵԱ", "", + MessageBox.ERROR); + return; + } + // ȡеĶ + Map groupLoV = new HashMap(); + // װ + for (String string : lovValue) { + String[] sp = string.split(":"); + String group = sp[0]; + String model = sp[1]; + String[] x = model.split("-"); + groupLoV.put(group, x); + } + + for (int i = 0; i < beanList.size(); i++) { + JLabel disNameLabel = new JLabel(beanList.get(i).getDisplayName()); + String defaultValueInfo = null; + if (this.nameValueMap.containsKey(beanList.get(i).getName())) { + defaultValueInfo = this.nameValueMap.get(beanList.get(i) + .getName()); + } else { + defaultValueInfo = null; + } + TCPropertyDescriptor desc = beanList.get(i).getDescriptor(); + JComponent valueComp = null; + TCComponentListOfValues lobList = desc.getLOV(); + + if (lobList != null) { + MyJCombox box = new MyJCombox(); + box.setEditable(true); + box.setPropName(desc.getName()); + try { + // ȡLOV-------------------- + ListOfValuesInfo info = lobList.getListOfValues(); + String[] valuesList; + String[] disValuesList = null; + if (groupLoV.containsKey(groupName) + && "RB3_mb_lov".equals(info.toString())) { + // Ӧôѡлȡ + valuesList = groupLoV.get(groupName); + disValuesList = new String[valuesList.length + 1]; + + } else { + valuesList = info.getStringListOfValues(); + disValuesList = new String[valuesList.length + 1]; + } + if (DEBUG) { + for (String string : valuesList) { + System.out.print(string + "\t"); + } + } + disValuesList[0] = ""; + box.setValues(valuesList); + int index = -1; + for (int w = 1; w < disValuesList.length; w++) { + disValuesList[w] = info + .getDisplayableValue(valuesList[w - 1]); + if (defaultValueInfo != null + && defaultValueInfo.equals(valuesList[w - 1])) { + index = w; + } + } + box.setModel(new DefaultComboBoxModel(disValuesList)); + if (index != -1) { + box.setSelectedIndex(index); + } else if (null == disValuesList || index == -1) { + box.getModel().setSelectedItem(""); + } else { + box.getModel().setSelectedItem(defaultValueInfo); + } + } catch (TCException e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + // box.setModel(new DefaultComboBoxModel(new String[] { "" + // })); + } + valueComp = box; + } else { + // JTextField fied = new JTextField(12); + MyJTextfield valueText = new MyJTextfield(32); + valueText.setText(beanList.get(i).getDescriptor() + .getDefaultValue()); + valueText.setPropName(beanList.get(i).getName()); + valueComp = valueText; + if (defaultValueInfo != null) { + valueText.setText(defaultValueInfo); + } + + } + + itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", + disNameLabel); + itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", + valueComp); + compList.add(valueComp); + } + propPanel.add(propIndex + ".1.left.top.preferred.preferred", + itemPorpPanel); + } + + /** + * comboxؼ + * + * @author hub + * + */ + + private class MyJCombox extends JComboBox { + private String[] values; + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String[] getValues() { + return values; + } + + public void setValues(String[] values) { + this.values = values; + } + + } + + /** + * + * @author hub + * + */ + private class MyJTextfield extends JTextField { + + public MyJTextfield(int len) { + super(len); + } + + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + } + + /** + * + * @author hub + * + */ + private class ItemNameDialog extends AbstractAIFDialog implements ActionListener { + + private CTMap map; + private JPanel findPanel; + private JTextField findTextField; + private JButton findButton; + private CTable table; + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + private List> dataList; + private TableRowSorter mainSorter; + private String[] titleNames = new String[]{"ID","ϵͳ","","Ӣ"}; + + public ItemNameDialog() { + getValues(); + init(); + } + + private void getValues() + { + //ȡExcelϢ + File file = TMomMethodUtil.getFile(session, "","MSExcelX"); + try { + dataList = ExcelUtil07.readExcel(file); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void init() { + // TODO Auto-generated method stub + this.findPanel = new JPanel(new PropertyLayout()); + this.findTextField = new JTextField(30); + this.findButton = new JButton(""); + this.findButton.addActionListener(this); + this.findPanel.add("1.1.left.top", this.findTextField); + this.findPanel.add("1.2.left.top", this.findButton); + table = getjTable(null, null, titleNames, null); + mainSorter = new TableRowSorter(this.table.getModel()); + this.table.setRowSorter(mainSorter); //ΪJTable + this.findButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(findTextField.getText().length()==0){ + mainSorter.setRowFilter(null); + }else{ + mainSorter.setRowFilter(RowFilter.regexFilter(findTextField.getText()));//ΪJTableûʽĹ + } + } + }); + table.setColumnSelectionAllowed(false); + table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("ȷ"); + this.okButton.addActionListener(this); + this.celButton = new JButton("ȡ"); + this.celButton.addActionListener(this); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + this.setLayout(new BorderLayout()); + this.add(findPanel, BorderLayout.NORTH); + this.add(new JScrollPane(table), BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.showDialog(); + } + + // 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); + map.setEditable(false); + setJTable(); + partsTable = new CTable(map); + partsTable.setRowHeight(20); + 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 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + for (int j = 0; j < titleNames.length; j++) { + map.setValueAt(rowList.get(j), i, j); + } + } + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + Object source = arg0.getSource(); + if(source.equals(this.okButton)){ + System.out.println(new Date() + "=============ʼ"); + itemNameList.clear(); + int[] selectRows = table.getSelectedRows(); + int[] selectColumns = table.getSelectedColumns(); + if(selectRows.length > 0 && selectColumns.length > 0) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < selectRows.length; i++) { + List nameList = new ArrayList<>(); + nameList.add(table.getValueAt(selectRows[i], 0).toString()); + nameList.add(table.getValueAt(selectRows[i], 1).toString()); + nameList.add(table.getValueAt(selectRows[i], 2)+"/"+table.getValueAt(selectRows[i], 3)); + sb.append(table.getValueAt(selectRows[i], 2)); + sb.append(","); + //itemNameList.add(nameList); + } + newItemNameText.setText(sb.substring(0, sb.length()-1)); + } + this.dispose(); + }else if(source.equals(this.celButton)){ + this.dispose(); + } + } + + } + + /** + * JTABLEͨ÷ + * + * @param partsTable + * @param titleNames + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 105; + int totleLen = 900; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)) { + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(105); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + /** + * tableؼ + * + * @param dtm + * @param columNameObjects + * @param objects + * @return + */ + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] columNameObjects, Object[][] objects) { + // Object[] columNameObjects = this.titleNames; //// , + // Object[][] objects = getValues(this.valueLists); + if (dtm == null) { + dtm = new DefaultTableModel(objects, columNameObjects); + } + return dtm; + } + + /** + * תΪMAP + * + * @param listBean + * @return + */ + public HashMap getValues(List listBean) { + HashMap valueMap = null; + if (listBean != null && listBean.size() > 0) { + valueMap = new HashMap<>(); + for (int i = 0; i < listBean.size(); i++) { + JComponent bean = listBean.get(i); + if (bean instanceof MyJTextfield) { + + valueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + if (nameValueMap.containsKey(((MyJTextfield) bean) + .getPropName())) { + nameValueMap + .remove(((MyJTextfield) bean).getPropName()); + nameValueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + } + System.out.println(" ((MyJTextfield) bean).getPropName() =" + + ((MyJTextfield) bean).getPropName() + " | " + + "((MyJTextfield) bean).getText()" + + ((MyJTextfield) bean).getText()); + } else if (bean instanceof MyJCombox) { + + if (((MyJCombox) bean).getSelectedIndex() == -1) { + valueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel().getSelectedItem() + .toString()); + System.out.println(" tip text " + + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + } + } else { + + valueMap.put( + ((MyJCombox) bean).getPropName(), + (((MyJCombox) bean).getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean).getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap + .put(((MyJCombox) bean).getPropName(), + (((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + } + System.out + .println(" 123=" + + ((((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1])); + } + + /* + * System.out .println((((MyJCombox) + * bean).getSelectedIndex() == -1 || ((MyJCombox) bean) + * .getSelectedIndex() == 0) ? ((MyJCombox) bean) + * .getToolTipText() : ((MyJCombox) bean) + * .getValues()[((MyJCombox) bean) .getSelectedIndex() - + * 1]); + */ + /* + * System.out .println("((MyJCombox) bean).getPropName() =" + * + ((MyJCombox) bean).getPropName() + " | " + + * "((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex()] =" + * + ((MyJCombox) bean).getValues()[((MyJCombox) bean) + * .getSelectedIndex()]); + */ + } + + } + } + + return valueMap; + + } + + private TCUserService userservice; + + public void setByPass(boolean val) throws TCException { + if (userservice == null) { + userservice = this.session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("ORIGIN_set_bypass", obj); + } else { + userservice.call("ORIGIN_close_bypass", obj); + } + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem item, + ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + //ȡѡĹʵֵ++++ + TCProperty sProperty=((TCComponent)revision).getTCProperty("rb3_scgc"); + if(this.scgcComboBox.getDisplayName()!=null) { + String[] StringName = new String[this.scgcComboBox.getDisplayName().length]; + int num=0; + for(int i=0;i 0) + { + String[] itemNames = newItemNameText.getText().split(","); + for (String string : itemNames) { + itemNameList.add(string); + } + } + else + { + itemNameList.add(newItemNameText.getText()); + } + System.out.println(new Date() + "===============itemNameList"+ itemNameList.size()); + for (int i = 0; i < itemNameList.size(); i++) { + System.out.println(new Date() + "==============е"+i+"ѭ"); + // ȡITEMID + String newCode = ""; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + newCode = TMomMethodUtil.getRuleItemID(session, + newItemIDText.getText().split("_")[0], specCode, operateCode); + break; + case TMomFinalUtil.GX_CODE: + newCode = TMomMethodUtil.getRuleItemID(session, + newItemIDText.getText(), specCode, operateCode); + break; + default: + break; + } + TCComponentItem item = null; +// if(this.operateCode == TMomFinalUtil.GY_CODE || this.operateCode == TMomFinalUtil.GX_CODE) { +// try { +// Map valMap = new HashMap(); +// valMap.put("id", newCode); +// valMap.put("revId", this.newItemRevIDText.getText()); +// valMap.put("type", this.newItemBean.getType()); +// valMap.put("name", itemNameList.get(i)); +// valMap.put("unit", this.newItemBean +// .getUnit()); +// valMap.put("item", getValues(itemPropTable)); +// valMap.put("rev", getValues(revPropTable)); +// valMap.put("revForm", getValues(revFormPropTable)); +// String jsonString = JSON.toJSONString(valMap); +// String cmd = "java -jar D:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar "+jsonString.replaceAll("\"", "\\\\\""); +// System.out.println(cmd); +// Process process= Runtime.getRuntime().exec(cmd); +// InputStream inputStream = process.getInputStream(); +// InputStreamReader reader=new InputStreamReader(inputStream); +// BufferedReader bufferedReader=new BufferedReader(reader); +// String line=null; +// while ((line=bufferedReader.readLine())!=null){ +// System.out.println(line); +// } +// TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent(this.newItemBean.getType()); +// item = ccomponentitemtype.find(newCode); +// TCComponentUser user = session.getUser(); +// TMom002AbtractDialog.changeOwner(item, user); +// TMom002AbtractDialog.changeOwner(item.getLatestItemRevision(), user); +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// }else { + item = TMomMethodUtil.createNewItemSoa( + this.session, newCode, + this.newItemRevIDText.getText(), + this.newItemBean.getType(), itemNameList.get(i), "", this.newItemBean + .getUnit(), getValues(itemPropTable), + getValues(revPropTable), getValues(revFormPropTable)); +// } + if (item != null) { + + setNameValueMap(this.newItemBean.getType()); + String msg = new String(); + switch (this.operateCode) { + case TMomFinalUtil.GX_CODE: +// try { +// item.setStringProperty("rb3_id", itemNameList.get(i).get(0)); +// item.setStringProperty("rb3_SysNo", itemNameList.get(i).get(1) == null ? "" : itemNameList.get(i).get(1)); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } + ArrayList itemlists = new ArrayList(); + itemlists.add(item); + for (int j = 0; j < this.itemList.size(); j++) { + try { + recreateBom(itemList.get(j), itemlists, false); + this.rootPanel.setBackground(Color.GREEN); +// msg = "ڹ[" + this.oldItemIDText.getText() +// + "]BOMṹ"; + } catch (TCException e1) { + e1.printStackTrace(); + } + } + break; + case TMomFinalUtil.BZGX_CODE: + + InterfaceAIFComponent comp = app.getTargetComponent(); + + TCComponentFolder filter = (TCComponentFolder)comp; + + try { + filter.add("contents", item); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + break; + default: + break; + } + if (msg != null && !msg.equals("")) { + this.rootPanel.setBackground(Color.GREEN); +// MessageBox.post( +// "[item_id= " +// + this.newItemIDText.getText() +// + " / rev =" +// + this.newItemRevIDText.getText() +// + " / name= " +// + this.newItemNameText.getSelectedItem() +// .toString() + "]ɹ", "ɹ" + msg, +// MessageBox.INFORMATION); + + } + } + } + } else if (obj.equals(this.celButton)) { + this.dispose(); + } +// else if (obj.equals(this.newItemNameButton)) { +// if (this.itemNameDialog == null) { +// this.itemNameDialog = new ItemNameDialog(); +// } else { +// this.itemNameDialog.showDialog(); +// } +// } + } + /** + * LOV KeyȡLOVֵ + * + * @param tcsession + * @param s + * @return + */ + public List> findLovValueByKey(TCSession tcsession, String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + String resultValue = null; + List> groupName = new ArrayList>(); + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession + .getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype + .find(s); + if (atccomponentlistofvalues != null&& atccomponentlistofvalues.length > 0) { + tccomponentlistofvalues = atccomponentlistofvalues[0]; + + ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); + //ʾֵʵֵ + groupName.add(Arrays.asList(rtlistOfValuesInfo.getLOVDisplayValues())); + groupName.add( Arrays.asList(rtlistOfValuesInfo.getStringListOfValues())); + } + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return groupName; + } + + + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateOPHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateOPHandler.java new file mode 100644 index 0000000..ee854a7 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateOPHandler.java @@ -0,0 +1,90 @@ +package com.connor.renben.process.plm.tmom002; + +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom002CreateOPHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + final TCSession session = (TCSession) app.getSession(); + final TCComponentGroup sessionGroup = session.getCurrentGroup();//˻ + //ӹȨ + if(!sessionGroup.toString().equals("dba")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("dqzhwqxtjgx02_display.TITLE"), "", MessageBox.ERROR); + return null; + } + try { + InterfaceAIFComponent[] comps = app.getTargetComponents(); + for (int i = 0; i < comps.length; i++) { + if (comps[i] instanceof TCComponentBOMLine) { + if (comps[i].getProperty("object_type").indexOf("MEProcess") < 0) { + comps[i] = ((TCComponentBOMLine) comps[i]).getItem(); + } + else + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qzjgglqz02_display.TITLE"), "", MessageBox.ERROR); + return null; + } + } + else + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qzjgglqz02_display.TITLE"), "", MessageBox.ERROR); + return null; + } + } + final List itemList = TMomMethodUtil.getItemList( + comps, true, true); +// if (itemList != null) { +// for (int i = 0; i < itemList.size(); i++) { +// if (itemList.get(i).getStringProperty("object_type") +// .indexOf("MEProcess") < 0) { +// MessageBox.post("ѡն󴴽", "", MessageBox.ERROR); +// return null; +// } +// } +// } + new Thread() { + @Override + public void run() { + // TODO Auto-generated method stub + new TMom002CreateOPDialog(session, app, "", itemList, + null, TMomFinalUtil.GX_CODE); + super.run(); + } + }.start(); + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return null; + // CreateNewBOHandler handler = new CreateNewBOHandler("MEOP"); + // handler.execute(arg0); + + } +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreatePFMEAHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreatePFMEAHandler.java new file mode 100644 index 0000000..0798d32 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreatePFMEAHandler.java @@ -0,0 +1,19 @@ +package com.connor.renben.process.plm.tmom002; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; + +public class TMom002CreatePFMEAHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_PFMEA"); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateProcessFlowChartHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateProcessFlowChartHandler.java new file mode 100644 index 0000000..8c6d386 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateProcessFlowChartHandler.java @@ -0,0 +1,19 @@ +package com.connor.renben.process.plm.tmom002; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; + +public class TMom002CreateProcessFlowChartHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_GCLCT"); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateProcessHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateProcessHandler.java new file mode 100644 index 0000000..4d87f04 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateProcessHandler.java @@ -0,0 +1,81 @@ +package com.connor.renben.process.plm.tmom002; + +import java.util.Arrays; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.AifrcpPlugin; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soaictstubs.TcUtility; + +public class TMom002CreateProcessHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + // + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) AifrcpPlugin.getSessionService(); + final TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] comps = app.getTargetComponents(); + if(comps.length==0||comps==null) { + MessageBox.post(rb.getString("wxzcpdxqcxxz02_display.TITLE"), "", MessageBox.ERROR);//"δѡвƷѡ" + return null; + } + final List itemList = TMomMethodUtil.getItemList( + comps, true, true); + //ȡѡֵ + String[] types = session.getPreferenceService().getStringValues("RB3_CreateProcessTypes"); + if(types == null || types.length == 0) { + MessageBox.post("ѡRB3_CreateProcessTypes", "", MessageBox.ERROR);//"ѡܳɻ㲿󴴽" + return null; + } + List asList = Arrays.asList(types); + try { + if (itemList != null) { + for (int i = 0; i < itemList.size(); i++) { + String stringProperty = itemList.get(i).getStringProperty("object_type"); + if (!asList.contains(stringProperty)) { + MessageBox.post(rb.getString("qxzzcdxhcj021_display.TITLE"), "", MessageBox.ERROR);//"ѡܳɻ㲿󴴽" + return null; + } + } + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + session.queueOperation(new TMom002AbtractDialog(session, app, "", itemList, null, + TMomFinalUtil.GY_CODE));//""); +// new Thread() { +// @Override +// public void run() { +// // TODO Auto-generated method stub +// +// super.run(); +// } +// }.start(); + return null; + // CreateNewBOHandler handler = new CreateNewBOHandler("MEProcess"); + // handler.execute(arg0); + // return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateSCControlPlanHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateSCControlPlanHandler.java new file mode 100644 index 0000000..10fbd92 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateSCControlPlanHandler.java @@ -0,0 +1,287 @@ +package com.connor.renben.process.plm.tmom002; + +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 org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.CreateNewBOHandler; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; + +public class TMom002CreateSCControlPlanHandler extends AbstractHandler { + private boolean isOk = true; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + isOk = true; + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + try { + if(app.getTargetComponent().getType().indexOf("MEProcess") >= 0 && app.getTargetComponent() instanceof TCComponentItem) + { + TCComponentItem meprocessItem = (TCComponentItem)app.getTargetComponent(); + //ȡµĿƼƻ + TCComponent[] items = meprocessItem.getRelatedComponents("IMAN_reference"); + for (int i = 0; i < items.length; i++) { + if(items[i].getType().indexOf("RB3_SCKZJH") >= 0) + { + isOk = false; + + } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_SCKZJH"); + handler.execute(arg0); + if(isOk) + { + SqlUtilT.getTCConnection(); + //ѯݿе + ResultSet rs = null; + ResultSet rs1 = null; + ResultSet rs2 = null; + ResultSet rs3 = null; + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + TCSession session = (TCSession) app.getSession(); + String sql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\'", app.getTargetComponent().getUid()); + rs = SqlUtilT.read(sql); + if(rs.next()) + { + //ɾ + String selectSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SCKZJH\'", app.getTargetComponent().getUid()); + rs1 = SqlUtilT.read(selectSql); + if(rs1.next()) + { + String deleteSql = String.format("delete from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SCKZJH\'", app.getTargetComponent().getUid()); + SqlUtilT.delete(deleteSql); + } + // + String sscSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SSCKZJH\'", app.getTargetComponent().getUid()); + rs2 = SqlUtilT.read(sscSql); + if(rs2.next()) + { + List> dataList = new ArrayList>(); + do { + 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); + } while (rs2.next()); + for (int i = 0; i < dataList.size(); i++) { + UUID sckzjhUid = UUID.randomUUID(); +// // ݲ뵽Ƽƻ + String insertSQL = pro.getProperty("INSERTSQL"); +// // Ƽƻ + SqlUtilT.write( + new String[] { + sckzjhUid.toString().replace("-", ""), + dataList.get(i).get(0),dataList.get(i).get(1), + dataList.get(i).get(2),dataList.get(i).get(3), + dataList.get(i).get(4),dataList.get(i).get(5), + dataList.get(i).get(6),dataList.get(i).get(7), + dataList.get(i).get(8),dataList.get(i).get(9), + dataList.get(i).get(10),dataList.get(i).get(11), + dataList.get(i).get(12),dataList.get(i).get(13), + dataList.get(i).get(14),dataList.get(i).get(15), + dataList.get(i).get(16),dataList.get(i).get(17), + dataList.get(i).get(18),dataList.get(i).get(19), + dataList.get(i).get(20),dataList.get(i).get(21), + dataList.get(i).get(22),dataList.get(i).get(23), + dataList.get(i).get(24),dataList.get(i).get(25), + dataList.get(i).get(26),"RB3_SCKZJH","1","0","","0" }, + insertSQL); + } + } + else + { + String yjSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_YJKZJH\'", app.getTargetComponent().getUid()); + rs3 = SqlUtilT.read(yjSql); + List> dataList = new ArrayList>(); + while (rs3.next()) { + List rowList = new ArrayList(); + rowList.add(rs3.getString(2)); + rowList.add(rs3.getString(3));rowList.add(rs3.getString(4)); + rowList.add(rs3.getString(5));rowList.add(rs3.getString(6)); + rowList.add(rs3.getString(7));rowList.add(rs3.getString(8)); + rowList.add(rs3.getString(9));rowList.add(rs3.getString(10)); + rowList.add(rs3.getString(11));rowList.add(rs3.getString(12)); + rowList.add(rs3.getString(13));rowList.add(rs3.getString(14)); + rowList.add(rs3.getString(15));rowList.add(rs3.getString(16)); + rowList.add(rs3.getString(17));rowList.add(rs3.getString(18)); + rowList.add(rs3.getString(19));rowList.add(rs3.getString(20)); + rowList.add(rs3.getString(21));rowList.add(rs3.getString(22)); + rowList.add(rs3.getString(23));rowList.add(rs3.getString(24)); + rowList.add(rs3.getString(25));rowList.add(rs3.getString(26)); + rowList.add(rs3.getString(27));rowList.add(rs3.getString(28)); + dataList.add(rowList); + } + for (int i = 0; i < dataList.size(); i++) { + UUID yjkzjhUid = UUID.randomUUID(); +// // ݲ뵽Ƽƻ + String insertSQL = pro.getProperty("INSERTSQL"); +// // Ƽƻ + SqlUtilT.write( + new String[] { + yjkzjhUid.toString().replace("-", ""), + dataList.get(i).get(0),dataList.get(i).get(1), + dataList.get(i).get(2),dataList.get(i).get(3), + dataList.get(i).get(4),dataList.get(i).get(5), + dataList.get(i).get(6),dataList.get(i).get(7), + dataList.get(i).get(8),dataList.get(i).get(9), + dataList.get(i).get(10),dataList.get(i).get(11), + dataList.get(i).get(12),dataList.get(i).get(13), + dataList.get(i).get(14),dataList.get(i).get(15), + dataList.get(i).get(16),dataList.get(i).get(17), + dataList.get(i).get(18),dataList.get(i).get(19), + dataList.get(i).get(20),dataList.get(i).get(21), + dataList.get(i).get(22),dataList.get(i).get(23), + dataList.get(i).get(24),dataList.get(i).get(25), + dataList.get(i).get(26),"RB3_SCKZJH","1","0","","0" }, + insertSQL); + } + } + + } +// else +// { +// //շ͵ṹȡBOMϢ +// TCComponentBOMWindow bomWindow = null; +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(((TCComponentItem)app.getTargetComponent()), +// ((TCComponentItem)app.getTargetComponent()).getLatestItemRevision(), null, null); +// // ȡ +// AIFComponentContext aif[] = topline.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// TCComponentICO[] icos = subline.getItem() +// .getClassificationObjects(); +// 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")); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int j = 0; j < descriptions.length; j++) { +// if (descriptions[j].getId() == 1004) { +// propertie +// .add(descriptions[j].getValue() == null ? "" +// : descriptions[j].getValue()); +// } +// } +// } else { +// propertie.add(""); +// } +// // propertie.add(); +// properties.add(propertie); +// } +// //ݿв +// for (int i = 0; i < aif.length; i++) { +// 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("-", ""), +// topline.getItem().getUid(), properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2), +// properties.get(i).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_SCKZJH" }, +// insertSQL); +// // ƼƻѲ +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), topline.getItem().getUid(), +// properties.get(i).get(0), +// number.toString(), name, +// "", "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_SCKZJH" }, +// insertSQL); +// } +// } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs1 != null) { + SqlUtilT.free(rs1); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (rs3 != null) { + SqlUtilT.free(rs3); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateSSCControlPlanHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateSSCControlPlanHandler.java new file mode 100644 index 0000000..451fb4c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateSSCControlPlanHandler.java @@ -0,0 +1,370 @@ +package com.connor.renben.process.plm.tmom002; + +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 org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.CreateNewBOHandler; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; + +public class TMom002CreateSSCControlPlanHandler extends AbstractHandler { + private boolean isOk = true; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + isOk = true; + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + try { + if(app.getTargetComponent().getType().indexOf("MEProcess") >= 0 && app.getTargetComponent() instanceof TCComponentItem) + { + TCComponentItem meprocessItem = (TCComponentItem)app.getTargetComponent(); + //ȡµĿƼƻ + TCComponent[] items = meprocessItem.getRelatedComponents("IMAN_reference"); + for (int i = 0; i < items.length; i++) { + if(items[i].getType().indexOf("RB3_SSCKZJH") >= 0) + { + isOk = false; + + } + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_SSCKZJH"); + handler.execute(arg0); + if(isOk) + { + SqlUtilT.getTCConnection(); + // ѯݿе + ResultSet rs = null; + ResultSet rs1 = null; + //ResultSet rs2 = null; + ResultSet rs3 = null; + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + TCSession session = (TCSession) app.getSession(); + String sql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\'", app.getTargetComponent().getUid()); + rs = SqlUtilT.read(sql); + if(rs.next()) + { + //ɾ + String selectSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SSCKZJH\'", app.getTargetComponent().getUid()); + rs1 = SqlUtilT.read(selectSql); + if(rs1.next()) + { + String deleteSql = String.format("delete from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SSCKZJH\'", app.getTargetComponent().getUid()); + SqlUtilT.delete(deleteSql); + } + // +// String yjSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_YJKZJH\'", app.getTargetComponent().getUid()); +// rs2 = SqlUtilT.read(yjSql); + String scSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SCKZJH\'", app.getTargetComponent().getUid()); + rs3 = SqlUtilT.read(scSql); +// if(rs2.next()) +// { +// List> dataList = new ArrayList>(); +// do { +// 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); +// } while (rs2.next()); +// for (int i = 0; i < dataList.size(); i++) { +// UUID scckzjhUid = UUID.randomUUID(); +//// // ݲ뵽Ƽƻ +// String insertSQL = pro.getProperty("INSERTSQL"); +//// // Ƽƻ +// SqlUtilT.write( +// new String[] { +// scckzjhUid.toString().replace("-", ""), +// dataList.get(i).get(0),dataList.get(i).get(1), +// dataList.get(i).get(2),dataList.get(i).get(3), +// dataList.get(i).get(4),dataList.get(i).get(5), +// dataList.get(i).get(6),dataList.get(i).get(7), +// dataList.get(i).get(8),dataList.get(i).get(9), +// dataList.get(i).get(10),dataList.get(i).get(11), +// dataList.get(i).get(12),dataList.get(i).get(13), +// dataList.get(i).get(14),dataList.get(i).get(15), +// dataList.get(i).get(16),dataList.get(i).get(17), +// dataList.get(i).get(18),dataList.get(i).get(19), +// dataList.get(i).get(20),dataList.get(i).get(21), +// dataList.get(i).get(22),dataList.get(i).get(23), +// dataList.get(i).get(24),dataList.get(i).get(25), +// dataList.get(i).get(26),"RB3_SSCKZJH","1","0","","0" }, +// insertSQL); +// } +// } +// else + if(rs3.next()) + { + List> dataList = new ArrayList>(); + do { + List rowList = new ArrayList(); + rowList.add(rs3.getString(2)); + rowList.add(rs3.getString(3));rowList.add(rs3.getString(4)); + rowList.add(rs3.getString(5));rowList.add(rs3.getString(6)); + rowList.add(rs3.getString(7));rowList.add(rs3.getString(8)); + rowList.add(rs3.getString(9));rowList.add(rs3.getString(10)); + rowList.add(rs3.getString(11));rowList.add(rs3.getString(12)); + rowList.add(rs3.getString(13));rowList.add(rs3.getString(14)); + rowList.add(rs3.getString(15));rowList.add(rs3.getString(16)); + rowList.add(rs3.getString(17));rowList.add(rs3.getString(18)); + rowList.add(rs3.getString(19));rowList.add(rs3.getString(20)); + rowList.add(rs3.getString(21));rowList.add(rs3.getString(22)); + rowList.add(rs3.getString(23));rowList.add(rs3.getString(24)); + rowList.add(rs3.getString(25));rowList.add(rs3.getString(26)); + rowList.add(rs3.getString(27));rowList.add(rs3.getString(28)); + dataList.add(rowList); + } while (rs3.next()); + for (int i = 0; i < dataList.size(); i++) { + UUID scckzjhUid = UUID.randomUUID(); +// // ݲ뵽Ƽƻ + String insertSQL = pro.getProperty("INSERTSQL"); +// // Ƽƻ + SqlUtilT.write( + new String[] { + scckzjhUid.toString().replace("-", ""), + dataList.get(i).get(0),dataList.get(i).get(1), + dataList.get(i).get(2),dataList.get(i).get(3), + dataList.get(i).get(4),dataList.get(i).get(5), + dataList.get(i).get(6),dataList.get(i).get(7), + dataList.get(i).get(8),dataList.get(i).get(9), + dataList.get(i).get(10),dataList.get(i).get(11), + dataList.get(i).get(12),dataList.get(i).get(13), + dataList.get(i).get(14),dataList.get(i).get(15), + dataList.get(i).get(16),dataList.get(i).get(17), + dataList.get(i).get(18),dataList.get(i).get(19), + dataList.get(i).get(20),dataList.get(i).get(21), + dataList.get(i).get(22),dataList.get(i).get(23), + dataList.get(i).get(24),dataList.get(i).get(25), + dataList.get(i).get(26),"RB3_SSCKZJH","1","0","","0" }, + insertSQL); + } + } + else + { + //շ͵ṹȡBOMϢ + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(((TCComponentItem)app.getTargetComponent()), + ((TCComponentItem)app.getTargetComponent()).getLatestItemRevision(), null, null); + // ȡ + AIFComponentContext aif[] = topline.getChildren(); + List> properties = new ArrayList>(); + for (int i = 0; i < aif.length; i++) { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + TCComponentICO[] icos = subline.getItem() + .getClassificationObjects(); + List propertie = new ArrayList(); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + propertie.add(subline.getStringProperty("bl_sequence_no")); + //propertie.add(subline.getStringProperty("RB3_GXH")); + propertie + .add(subline + .getStringProperty("bl_item_object_name") == null ? "" + : subline + .getStringProperty("bl_item_object_name")); + if (icos.length > 0) { + ICSProperty[] descriptions = icos[0] + .getICSProperties(true); + for (int j = 0; j < descriptions.length; j++) { + if (descriptions[j].getId() == 1004) { + propertie + .add(descriptions[j].getValue() == null ? "" + : descriptions[j].getValue()); + } + } + } else { + propertie.add(""); + } + // propertie.add(); + properties.add(propertie); + } + //ݿв + for (int i = 0; i < aif.length; i++) { + 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("-", ""), + topline.getItem().getUid(), properties.get(i).get(0), + properties.get(i).get(1), + properties.get(i).get(2), + properties.get(i).get(3), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_SSCKZJH","1","0","","0" }, + insertSQL); + // ƼƻѲ + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), topline.getItem().getUid(), + properties.get(i).get(0), + number.toString(), name, + properties.get(i).get(3), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_SSCKZJH","1","0","","0" }, + insertSQL); + } + } + } +// else +// { +// //շ͵ṹȡBOMϢ +// TCComponentBOMWindow bomWindow = null; +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(((TCComponentItem)app.getTargetComponent()), +// ((TCComponentItem)app.getTargetComponent()).getLatestItemRevision(), null, null); +// // ȡ +// AIFComponentContext aif[] = topline.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// TCComponentICO[] icos = subline.getItem() +// .getClassificationObjects(); +// 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")); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int j = 0; j < descriptions.length; j++) { +// if (descriptions[j].getId() == 1004) { +// propertie +// .add(descriptions[j].getValue() == null ? "" +// : descriptions[j].getValue()); +// } +// } +// } else { +// propertie.add(""); +// } +// // propertie.add(); +// properties.add(propertie); +// } +// //ݿв +// for (int i = 0; i < aif.length; i++) { +// 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("-", ""), +// topline.getItem().getUid(), properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2), +// properties.get(i).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_SSCKZJH" }, +// insertSQL); +// // ƼƻѲ +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), topline.getItem().getUid(), +// properties.get(i).get(0), +// number.toString(), name, +// properties.get(i).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_SSCKZJH" }, +// insertSQL); +// } +// } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs1 != null) { + SqlUtilT.free(rs1); + } + if (rs3 != null) { + SqlUtilT.free(rs3); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateStandardOPDialog.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateStandardOPDialog.java new file mode 100644 index 0000000..a738d35 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateStandardOPDialog.java @@ -0,0 +1,1236 @@ +package com.connor.renben.process.plm.tmom002; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; + +import com.connor.renben.process.plm.bean.TMomCreatePropBean; +import com.connor.renben.process.plm.bean.TMomItemBean; +import com.connor.renben.process.plm.bean.TMomPropExplictBean; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFilter; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom002CreateStandardOPDialog extends AbstractAIFDialog implements + ActionListener { + private final String CUST_DELE_TYPE_PROP = "Cust_Del_Type_Props"; + private final String CUST_MODEL_AREA = "CUST_Model_Area"; + private List itemNameList = new ArrayList(); + private ItemNameDialog itemNameDialog; + // private final String CUST_MODEL_AREA_TJ_NBTM = "CUST_Model_Area_TJ_NBTM"; + private JLabel newItemIDLabel; + private JLabel newItemRevIDLabel; + private JLabel newItemNameLabel; + private JLabel oldItemIDLabel; + private JLabel oldItemRevIDLabel; + private JLabel oldItemNameLabel; + private JLabel itemTypeLabel; + private JLabel itemUnitLabel; + + protected JTextField newItemIDText; + protected JTextField newItemRevIDText; + // protected JTextField newItemNameText; + protected JTextField newItemNameText; + //protected JButton newItemNameButton; + protected JTextField oldItemIDText; + protected JTextField oldItemRevIDText; + protected JTextField oldItemNameText; + protected JTextField itemTypeText; + protected JTextField itemUnitText; + + protected JButton okButton; + protected JButton celButton; + // ҳ + // protected JTable itemPropTable;// itemtable + // protected JTable itemFormPropTable;// itemformtable + // protected JTable revPropTable;// revtable + // protected JTable revFormPropTable;// revformtable + protected List itemPropTable; + protected List itemFormPropTable; + protected List revPropTable; + protected List revFormPropTable; + + protected List itemPropList;// itemб + protected List itemFormPropList;// itemformб + protected List revPropList;// 汾б + protected List revFormPropList;// 汾б + private DefaultTableModel dtm; + + private JPanel firstPanel; + private JPanel secondPanel; + private JPanel rootPanel; + + // ---Ҫõı + protected TCSession session; + protected AbstractAIFUIApplication app; + protected String title; + protected List itemList; + protected List itemListMsgBean; + private String specCode; + private Integer operateCode; + private TMomItemBean newItemBean; + private int index = 1; + private TCComponentFolder newStuffFolder; + private TCComponentFolder parentFolder; + private List explictBeanList; + + // private List folderList; + + private HashMap> custDeleTypeProp; + + private HashMap nameValueMap; + private boolean DEBUG = true; + private String[] itemNames; + + /** + * ȡϴδ͵ʱõ + * + * @param compType + */ + private void getNameValueMap(String compType) { + nameValueMap = new HashMap<>(); + nameValueMap.put("rb3_material", ""); + nameValueMap.put("rb3_press_drawing", ""); + nameValueMap.put("rb3_mb", ""); + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + if (!file.exists()) { + return; + } + try { + FileReader reader = new FileReader(file); + + BufferedReader br = new BufferedReader(reader); + + String info = br.readLine(); + if (info != null) { + String[] values = info.split("\\|"); + if (values == null || values.length != 3) { + return; + } + for (int i = 0; i < values.length; i++) { + String[] nameValues = values[i].split("="); + if (nameValues == null || nameValues.length != 2) { + continue; + } + + if (nameValueMap.containsKey(nameValues[0])) { + nameValueMap.remove(nameValues[0]); + nameValueMap.put(nameValues[0], nameValues[1]); + } + } + + } + br.close(); + reader.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + private void setNameValueMap(String compType) { + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + // if (!file.exists()) { + // return; + // } + + try { + FileWriter write = new FileWriter(file); + BufferedWriter bw = new BufferedWriter(write); + StringBuffer sb = new StringBuffer(); + + if (nameValueMap.containsKey("rb3_material")) { + sb.append("rb3_material"); + sb.append("="); + sb.append(nameValueMap.get("rb3_material")).append("|"); + } + if (nameValueMap.containsKey("rb3_press_drawing")) { + sb.append("rb3_press_drawing"); + sb.append("="); + sb.append(nameValueMap.get("rb3_press_drawing")).append("|"); + } + if (nameValueMap.containsKey("rb3_mb")) { + sb.append("rb3_mb"); + sb.append("="); + sb.append(nameValueMap.get("rb3_mb")); + + } + + bw.write(sb.toString()); + bw.close(); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + /** + * ȡҪص + */ + private void getCustDeleTypeProp() { + custDeleTypeProp = new HashMap<>(); + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray( + TCPreferenceService.TC_preference_site, CUST_DELE_TYPE_PROP); + if (props != null) { + for (int i = 0; i < props.length; i++) { + String[] subStrs = props[i].split("\\:"); + if (subStrs == null || subStrs.length != 2) { + continue; + } + String[] propSubStrs = subStrs[1].split("\\/"); + if (propSubStrs == null || propSubStrs.length <= 0) { + continue; + } + custDeleTypeProp.put(subStrs[0], Arrays.asList(propSubStrs)); + } + } + } + + public TMom002CreateStandardOPDialog(TCSession session, + AbstractAIFUIApplication app, String title, + List itemList, String specCode, int operateCode) { + super(false); + this.app = app; + this.session = session; + this.title = title; + this.itemList = itemList; + this.specCode = specCode; + this.operateCode = operateCode; + this.newItemBean = new TMomItemBean(); + // this.folderList = new ArrayList<>(); + getCustDeleTypeProp(); + // ȡѡȡITEMĿϢ + this.itemListMsgBean = TMomMethodUtil.getTargetsMsg(itemList); + // ˵вҪʾ + this.explictBeanList = TMomMethodUtil.getExplictPropList(this.session); + getItemName(); + init(); + getItemInfo(0); + } + + /** + * ȡϢ + */ + public void getItemInfo(int index) { + + TMomItemBean bean = null; + if (itemListMsgBean != null && itemListMsgBean.size() != 0) + { + bean = this.itemListMsgBean.get(index); + this.parentFolder = bean.getFolder(); + this.oldItemIDText.setText(bean.getItemID()); + this.oldItemNameText.setText(bean.getName()); + } + else { + //this.dispose(); + //MessageBox.post("ûѡȡITEMѡִд˲", "", MessageBox.ERROR); + //return; + } + // TCComponentItemType itemType = null; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + this.itemTypeText.setText(TMomFinalUtil.GY_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GY_TYPE); + getNameValueMap(TMomFinalUtil.GY_TYPE); + break; + case TMomFinalUtil.HISGY_CODE: + this.itemTypeText.setText(TMomFinalUtil.GY_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GY_TYPE); + getNameValueMap(TMomFinalUtil.GY_TYPE); + break; + case TMomFinalUtil.GX_CODE: + this.itemTypeText.setText(TMomFinalUtil.GX_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GX_TYPE); + getNameValueMap(TMomFinalUtil.GX_TYPE); + break; + case TMomFinalUtil.BZGX_CODE: + this.itemTypeText.setText(TMomFinalUtil.GX_TYPE_DIS); + this.newItemBean.setType(TMomFinalUtil.GX_TYPE); + getNameValueMap(TMomFinalUtil.GX_TYPE); + break; + default: + break; + } +// this.itemUnitText.setText(bean.getUnitDis()); +// // ȡITEMID +// String newCode = TMomMethodUtil.getRuleItemID(session, +// bean.getItemID(), specCode, operateCode); + this.newItemIDText.setText(""); + this.newItemRevIDText.setText("00"); + this.newItemBean.setRevID("00"); + this.newItemNameText.setText(""); + // this.newItemNameText.setText(bean.getName()); + } + + private void getItemName() { + TCPreferenceService service = this.session.getPreferenceService(); + String morderName = null; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + morderName = TMomFinalUtil.GY_ITEM_NAMES; + break; + case TMomFinalUtil.HISGY_CODE: + morderName = TMomFinalUtil.GY_ITEM_NAMES; + break; + case TMomFinalUtil.GX_CODE: + morderName = TMomFinalUtil.GX_ITEM_NAMES; + break; + default: + break; + } + if (morderName != null) { + String[] props = service.getStringArray( + TCPreferenceService.TC_preference_site, morderName); + if (props != null || props.length > 0) { + this.itemNames = props; + } else { + this.itemNames = new String[] { "" }; + } + } else { + //MessageBox.post("δҵӦITEM_NAMEѡ", "", MessageBox.ERROR); + } + } + + /** + * ȡϢ + * + * @param itemType + * @throws TCException + */ + public void getPropMsg(String itemType) throws TCException { + this.itemPropList = new ArrayList<>(); + this.itemFormPropList = new ArrayList<>(); + this.revPropList = new ArrayList<>(); + this.revFormPropList = new ArrayList<>(); + String startStr = "tm2"; + TCComponentType type = null; + + List explictList = new ArrayList<>(); + + type = this.session.getTypeComponent(itemType + "Revision Master"); + explictList.clear(); + for (TMomPropExplictBean explictBean : this.explictBeanList) { + if (explictBean.getType().equals(itemType + "Revision Master")) { + explictList = explictBean.getPropList(); + continue; + } + } + if (type != null && type instanceof TCComponentFormType) { + TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + for (TCPropertyDescriptor desc : descs) { + if (desc.getName().startsWith(startStr) && desc.isModifiable() + && desc.isDisplayable()) { + if (custDeleTypeProp.containsKey(itemType + + "Revision Master")) { + if (custDeleTypeProp.get(itemType + "Revision Master") + .contains(desc.getName())) { + continue; + } + } + if (explictList != null + && explictList.contains(desc.getName())) { + continue; + } + TMomCreatePropBean bean = new TMomCreatePropBean(); + bean.setDescriptor(desc); + bean.setDisplayName(desc.getDisplayName()); + bean.setName(desc.getName()); + this.revFormPropList.add(bean); + } + } + } else { + System.out.println("revMaster"); + // return; + } + + } + + /** + * ʼ + */ + public void init() { + try { + newStuffFolder = session.getUser().getNewStuffFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + this.setTitle(this.title); + this.setAutoRequestFocus(true); + this.setPreferredSize(new Dimension(630, 300)); + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.newItemIDLabel = new JLabel(rb.getString("xljid_display.TITLE")); + this.newItemRevIDLabel = new JLabel(rb.getString("bbid_display.TITLE")); + this.newItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.oldItemIDLabel = new JLabel(rb.getString("jlzjid_display.TITLE")); + this.oldItemRevIDLabel = new JLabel(rb.getString("bbid_display.TITLE")); + this.oldItemNameLabel = new JLabel(rb.getString("mc_display.TITLE")); + this.newItemIDText = new JTextField(20); + // this.newItemIDText.setEditable(false); + this.newItemRevIDText = new JTextField(6); + this.newItemRevIDText.setEnabled(false); +// this.newItemNameText = new JAutoCompleteComboBox( +// new DefaultComboBoxModel(itemNames)); + this.newItemNameText = new JTextField(); + this.newItemNameText.setPreferredSize(new Dimension(200, 21)); + this.oldItemIDText = new JTextField(20); + this.oldItemIDText.setEnabled(false); + this.oldItemRevIDText = new JTextField(6); + this.oldItemRevIDText.setEnabled(false); + this.oldItemNameText = new JTextField(32); + this.oldItemNameText.setEnabled(false); + 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.newItemNameButton = new JButton("ѡ"); + //this.newItemNameButton.addActionListener(this); + // ------------------------------ + this.itemTypeLabel = new JLabel(rb.getString("lx_display.TITLE")); + this.itemTypeText = new JTextField(12); + this.itemTypeText.setEditable(false); + this.itemTypeText.setText(rb.getString("lx_display.TITLE")); + this.itemUnitLabel = new JLabel(rb.getString("dw_display.TITLE")); + this.itemUnitText = new JTextField(12); + this.itemUnitText.setEnabled(false); + this.itemUnitText.setText(rb.getString("dw_display.TITLE")); + + // PropertyLayout layout = new PropertyLayout(); + + // ʾ + JPanel newItemMsgPanel = new JPanel(new PropertyLayout()); + newItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), rb.getString("xljxx_display.TITLE"))); + newItemMsgPanel.add("1.1.left.top.preferred.preferred", newItemIDLabel); + newItemMsgPanel.add("1.2.left.top.preferred.preferred", + newItemRevIDLabel); + newItemMsgPanel.add("1.3.left.top.preferred.preferred", + newItemNameLabel); + // + newItemMsgPanel.add("2.1.left.top.preferred.preferred", newItemIDText); + newItemMsgPanel.add("2.2.left.top.preferred.preferred", + newItemRevIDText); + newItemMsgPanel + .add("2.3.left.top.preferred.preferred", newItemNameText); +// newItemMsgPanel +// .add("2.4.left.top.preferred.preferred", newItemNameButton); + JPanel typeAndUnitPanel = new JPanel(new PropertyLayout()); + // .setBorder(new TitledBorder(BorderFactory.createEtchedBorder(),"")); + typeAndUnitPanel.add("1.1.left.top.preferred.preferred", itemTypeLabel); + typeAndUnitPanel.add("1.2.left.top.preferred.preferred", itemTypeText); + typeAndUnitPanel.add("2.1.left.top.preferred.preferred", itemUnitLabel); + typeAndUnitPanel.add("2.2.left.top.preferred.preferred", itemUnitText); + // ʾ + JPanel oldItemMsgPanel = new JPanel(new PropertyLayout()); + oldItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), rb.getString("jy_display.TITLE"))); + oldItemMsgPanel.add("1.1.left.top.preferred.preferred", oldItemIDLabel); + oldItemMsgPanel.add("1.2.left.top.preferred.preferred", + oldItemRevIDLabel); + oldItemMsgPanel.add("1.3.left.top.preferred.preferred", + oldItemNameLabel); + // + oldItemMsgPanel.add("2.1.left.top.preferred.preferred", oldItemIDText); + oldItemMsgPanel.add("2.2.left.top.preferred.preferred", + oldItemRevIDText); + oldItemMsgPanel + .add("2.3.left.top.preferred.preferred", oldItemNameText); + // + this.secondPanel = new JPanel(new FlowLayout()); + this.secondPanel.add(okButton); + this.secondPanel.add(new JLabel(" ")); + this.secondPanel.add(celButton); + this.firstPanel = new JPanel(new PropertyLayout()); + this.firstPanel + .add("1.1.left.top.preferred.preferred", newItemMsgPanel); + this.firstPanel.add("2.1.left.top.preferred.preferred", + typeAndUnitPanel); + this.firstPanel + .add("3.1.left.top.preferred.preferred", oldItemMsgPanel); + // ҳ------------------------------------------------------------ + if (operateCode == TMomFinalUtil.GY_CODE) { + try { + getNameValueMap(TMomFinalUtil.GY_TYPE); + getPropMsg(TMomFinalUtil.GY_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (operateCode == TMomFinalUtil.HISGY_CODE) { + try { + getNameValueMap(TMomFinalUtil.GY_TYPE); + getPropMsg(TMomFinalUtil.GY_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (operateCode == TMomFinalUtil.GX_CODE) { + try { + getNameValueMap(TMomFinalUtil.GX_TYPE); + getPropMsg(TMomFinalUtil.GX_TYPE); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + JPanel propPanel = new JPanel(new PropertyLayout()); + int propIndex = 1; + if (this.itemPropList != null && this.itemPropList.size() != 0) { + this.itemPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemPropList, this.itemPropTable, + propIndex, ""); + propIndex++; + } + if (this.itemFormPropList != null && this.itemFormPropList.size() != 0) { + this.itemFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemFormPropList, + this.itemFormPropTable, propIndex, ""); + propIndex++; + } + if (this.revPropList != null && this.revPropList.size() != 0) { + this.revPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revPropList, this.revPropTable, + propIndex, "汾"); + propIndex++; + } + if (this.revFormPropList != null && this.revFormPropList.size() != 0) { + // + this.revFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revFormPropList, + this.revFormPropTable, propIndex, "汾"); + propIndex++; + System.out.println("revFormPropTable count =" + + revFormPropTable.size()); + } + + // ҳ + JTabbedPane tabPane = new JTabbedPane(); + tabPane.add(rb.getString("lzjxx_display.TITLE"), firstPanel); + tabPane.add(rb.getString("sx_display.TITLE"), new JScrollPane(propPanel)); + + // + this.rootPanel = new JPanel(new BorderLayout()); + this.rootPanel.add(tabPane, BorderLayout.CENTER); + this.rootPanel.add(secondPanel, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + /** + * Խ + * + * @param propPanel + * @param beanList + * @param compList + * @param propIndex + */ + private void setPropPanel(JPanel propPanel, + List beanList, List compList, + int propIndex, String name) { + + JPanel itemPorpPanel = new JPanel(new PropertyLayout()); + itemPorpPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), name)); + + // //////////////////////////////////////////// + // compList = new ArrayList<>(); + String currentGroupName = null; + try { + currentGroupName = session.getCurrentGroup().getFullName(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + int indexx = currentGroupName.lastIndexOf("."); + // ȡǰʶ + String groupName = currentGroupName.substring(indexx + 1, + currentGroupName.length()); + // ȡѡ + String[] lovValue = session.getPreferenceService().getStringArray( + TCPreferenceService.TC_preference_site, CUST_MODEL_AREA); + if (null == lovValue || lovValue.length <= 0) { + System.out.println("ûѡ" + CUST_MODEL_AREA); + MessageBox.post("ȱѡ" + CUST_MODEL_AREA + ",ϵԱ", "", + MessageBox.ERROR); + return; + } + // ȡеĶ + Map groupLoV = new HashMap(); + // װ + for (String string : lovValue) { + String[] sp = string.split(":"); + String group = sp[0]; + String model = sp[1]; + String[] x = model.split("-"); + groupLoV.put(group, x); + } + + for (int i = 0; i < beanList.size(); i++) { + JLabel disNameLabel = new JLabel(beanList.get(i).getDisplayName()); + String defaultValueInfo = null; + if (this.nameValueMap.containsKey(beanList.get(i).getName())) { + defaultValueInfo = this.nameValueMap.get(beanList.get(i) + .getName()); + } else { + defaultValueInfo = null; + } + TCPropertyDescriptor desc = beanList.get(i).getDescriptor(); + JComponent valueComp = null; + TCComponentListOfValues lobList = desc.getLOV(); + + if (lobList != null) { + MyJCombox box = new MyJCombox(); + box.setEditable(true); + box.setPropName(desc.getName()); + try { + // ȡLOV-------------------- + ListOfValuesInfo info = lobList.getListOfValues(); + String[] valuesList; + String[] disValuesList = null; + if (groupLoV.containsKey(groupName) + && "RB3_mb_lov".equals(info.toString())) { + // Ӧôѡлȡ + valuesList = groupLoV.get(groupName); + disValuesList = new String[valuesList.length + 1]; + + } else { + valuesList = info.getStringListOfValues(); + disValuesList = new String[valuesList.length + 1]; + } + if (DEBUG) { + for (String string : valuesList) { + System.out.print(string + "\t"); + } + } + disValuesList[0] = ""; + box.setValues(valuesList); + int index = -1; + for (int w = 1; w < disValuesList.length; w++) { + disValuesList[w] = info + .getDisplayableValue(valuesList[w - 1]); + if (defaultValueInfo != null + && defaultValueInfo.equals(valuesList[w - 1])) { + index = w; + } + } + box.setModel(new DefaultComboBoxModel(disValuesList)); + if (index != -1) { + box.setSelectedIndex(index); + } else if (null == disValuesList || index == -1) { + box.getModel().setSelectedItem(""); + } else { + box.getModel().setSelectedItem(defaultValueInfo); + } + } catch (TCException e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + // box.setModel(new DefaultComboBoxModel(new String[] { "" + // })); + } + valueComp = box; + } else { + // JTextField fied = new JTextField(12); + MyJTextfield valueText = new MyJTextfield(32); + valueText.setText(beanList.get(i).getDescriptor() + .getDefaultValue()); + valueText.setPropName(beanList.get(i).getName()); + valueComp = valueText; + if (defaultValueInfo != null) { + valueText.setText(defaultValueInfo); + } + + } + + itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", + disNameLabel); + itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", + valueComp); + compList.add(valueComp); + } + propPanel.add(propIndex + ".1.left.top.preferred.preferred", + itemPorpPanel); + } + + /** + * comboxؼ + * + * @author hub + * + */ + + private class MyJCombox extends JComboBox { + private String[] values; + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String[] getValues() { + return values; + } + + public void setValues(String[] values) { + this.values = values; + } + + } + + /** + * + * @author hub + * + */ + private class MyJTextfield extends JTextField { + + public MyJTextfield(int len) { + super(len); + } + + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + } + + /** + * + * @author hub + * + */ + private class ItemNameDialog extends AbstractAIFDialog implements ActionListener { + + private CTMap map; + private JPanel findPanel; + private JTextField findTextField; + private JButton findButton; + private CTable table; + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + private List> dataList; + private TableRowSorter mainSorter; + private String[] titleNames = new String[]{"ID","ϵͳ","","Ӣ"}; + + public ItemNameDialog() { + getValues(); + init(); + } + + private void getValues() + { + //ȡExcelϢ + File file = TMomMethodUtil.getFile(session, "","MSExcelX"); + try { + dataList = ExcelUtil07.readExcel(file); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private void init() { + // TODO Auto-generated method stub + this.findPanel = new JPanel(new PropertyLayout()); + this.findTextField = new JTextField(30); + this.findButton = new JButton(""); + this.findButton.addActionListener(this); + this.findPanel.add("1.1.left.top", this.findTextField); + this.findPanel.add("1.2.left.top", this.findButton); + table = getjTable(null, null, titleNames, null); + mainSorter = new TableRowSorter(this.table.getModel()); + this.table.setRowSorter(mainSorter); //ΪJTable + this.findButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if(findTextField.getText().length()==0){ + mainSorter.setRowFilter(null); + }else{ + mainSorter.setRowFilter(RowFilter.regexFilter(findTextField.getText()));//ΪJTableûʽĹ + } + } + }); + table.setColumnSelectionAllowed(false); + table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("ȷ"); + this.okButton.addActionListener(this); + this.celButton = new JButton("ȡ"); + this.celButton.addActionListener(this); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + this.setLayout(new BorderLayout()); + this.add(findPanel, BorderLayout.NORTH); + this.add(new JScrollPane(table), BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.showDialog(); + } + + // 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); + map.setEditable(false); + setJTable(); + partsTable = new CTable(map); + partsTable.setRowHeight(20); + 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 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + for (int j = 0; j < titleNames.length; j++) { + map.setValueAt(rowList.get(j), i, j); + } + } + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + Object source = arg0.getSource(); + if(source.equals(this.okButton)){ + itemNameList.clear(); + int[] selectRows = table.getSelectedRows(); + int[] selectColumns = table.getSelectedColumns(); + if(selectRows.length > 0 && selectColumns.length > 0) + { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < selectRows.length; i++) { + List nameList = new ArrayList<>(); + nameList.add(table.getValueAt(selectRows[i], 0).toString()); + nameList.add(table.getValueAt(selectRows[i], 1).toString()); + nameList.add(table.getValueAt(selectRows[i], 2)+"/"+table.getValueAt(selectRows[i], 3)); + sb.append(table.getValueAt(selectRows[i], 2)); + sb.append(","); + //itemNameList.add(nameList); + } + newItemNameText.setText(sb.substring(0, sb.length()-1)); + } + this.dispose(); + }else if(source.equals(this.celButton)){ + this.dispose(); + } + } + + } + + /** + * JTABLEͨ÷ + * + * @param partsTable + * @param titleNames + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 105; + int totleLen = 900; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)) { + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(105); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + /** + * tableؼ + * + * @param dtm + * @param columNameObjects + * @param objects + * @return + */ + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] columNameObjects, Object[][] objects) { + // Object[] columNameObjects = this.titleNames; //// , + // Object[][] objects = getValues(this.valueLists); + if (dtm == null) { + dtm = new DefaultTableModel(objects, columNameObjects); + } + return dtm; + } + + /** + * תΪMAP + * + * @param listBean + * @return + */ + public HashMap getValues(List listBean) { + HashMap valueMap = null; + if (listBean != null && listBean.size() > 0) { + valueMap = new HashMap<>(); + for (int i = 0; i < listBean.size(); i++) { + JComponent bean = listBean.get(i); + if (bean instanceof MyJTextfield) { + + valueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + if (nameValueMap.containsKey(((MyJTextfield) bean) + .getPropName())) { + nameValueMap + .remove(((MyJTextfield) bean).getPropName()); + nameValueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + } + System.out.println(" ((MyJTextfield) bean).getPropName() =" + + ((MyJTextfield) bean).getPropName() + " | " + + "((MyJTextfield) bean).getText()" + + ((MyJTextfield) bean).getText()); + } else if (bean instanceof MyJCombox) { + + if (((MyJCombox) bean).getSelectedIndex() == -1) { + valueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel().getSelectedItem() + .toString()); + System.out.println(" tip text " + + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + } + } else { + + valueMap.put( + ((MyJCombox) bean).getPropName(), + (((MyJCombox) bean).getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean).getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap + .put(((MyJCombox) bean).getPropName(), + (((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + } + System.out + .println(" 123=" + + ((((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1])); + } + + /* + * System.out .println((((MyJCombox) + * bean).getSelectedIndex() == -1 || ((MyJCombox) bean) + * .getSelectedIndex() == 0) ? ((MyJCombox) bean) + * .getToolTipText() : ((MyJCombox) bean) + * .getValues()[((MyJCombox) bean) .getSelectedIndex() - + * 1]); + */ + /* + * System.out .println("((MyJCombox) bean).getPropName() =" + * + ((MyJCombox) bean).getPropName() + " | " + + * "((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex()] =" + * + ((MyJCombox) bean).getValues()[((MyJCombox) bean) + * .getSelectedIndex()]); + */ + } + + } + } + + return valueMap; + + } + + private TCUserService userservice; + + public void setByPass(boolean val) throws TCException { + if (userservice == null) { + userservice = this.session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("ORIGIN_set_bypass", obj); + } else { + userservice.call("ORIGIN_close_bypass", obj); + } + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem item, + ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object obj = e.getSource(); + if (obj.equals(this.okButton)) { + itemNameList.clear(); + if(newItemNameText.getText().isEmpty()) + { + MessageBox.post("ƲΪգ", "", MessageBox.ERROR); + return; + } + if(newItemNameText.getText().indexOf(",") > 0) + { + String[] itemNames = newItemNameText.getText().split(","); + for (String string : itemNames) { + itemNameList.add(string); + } + } + else + { + itemNameList.add(newItemNameText.getText()); + } + for (int i = 0; i < itemNameList.size(); i++) { + // ȡITEMID + String newCode = ""; + switch (this.operateCode) { + case TMomFinalUtil.GY_CODE: + newCode = TMomMethodUtil.getRuleItemID(session, + newItemIDText.getText().split("_")[0], specCode, operateCode); + break; + case TMomFinalUtil.GX_CODE: + newCode = TMomMethodUtil.getRuleItemID(session, + newItemIDText.getText(), specCode, operateCode); + break; + default: + break; + } + TCComponentItem item = TMomMethodUtil.createNewItemSoa( + this.session, newCode, + this.newItemRevIDText.getText(), + this.newItemBean.getType(), itemNameList.get(i), "", this.newItemBean + .getUnit(), getValues(itemPropTable), + getValues(revPropTable), getValues(revFormPropTable)); + if (item != null) { + setNameValueMap(this.newItemBean.getType()); + String msg = new String(); + switch (this.operateCode) { + case TMomFinalUtil.GX_CODE: +// try { +// item.setStringProperty("rb3_id", itemNameList.get(i).get(0)); +// item.setStringProperty("rb3_SysNo", itemNameList.get(i).get(1) == null ? "" : itemNameList.get(i).get(1)); +// } catch (TCException e2) { +// e2.printStackTrace(); +// } + ArrayList itemlists = new ArrayList(); + itemlists.add(item); + for (int j = 0; j < this.itemList.size(); j++) { + try { + recreateBom(itemList.get(j), itemlists, false); + this.rootPanel.setBackground(Color.GREEN); +// msg = "ڹ[" + this.oldItemIDText.getText() +// + "]BOMṹ"; + } catch (TCException e1) { + e1.printStackTrace(); + } + } + break; + case TMomFinalUtil.BZGX_CODE: + + InterfaceAIFComponent comp = app.getTargetComponent(); + + TCComponentFolder filter = (TCComponentFolder)comp; + + try { + filter.add("contents", item); + this.rootPanel.setBackground(Color.GREEN); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + break; + default: + break; + } + if (msg != null && !msg.equals("")) { + this.rootPanel.setBackground(Color.GREEN); +// MessageBox.post( +// "[item_id= " +// + this.newItemIDText.getText() +// + " / rev =" +// + this.newItemRevIDText.getText() +// + " / name= " +// + this.newItemNameText.getSelectedItem() +// .toString() + "]ɹ", "ɹ" + msg, +// MessageBox.INFORMATION); + + } + } + } + } else if (obj.equals(this.celButton)) { + this.dispose(); + } +// else if (obj.equals(this.newItemNameButton)) { +// if (this.itemNameDialog == null) { +// this.itemNameDialog = new ItemNameDialog(); +// } else { +// this.itemNameDialog.showDialog(); +// } +// } + } +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateStandardOPHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateStandardOPHandler.java new file mode 100644 index 0000000..71d47a1 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateStandardOPHandler.java @@ -0,0 +1,69 @@ +package com.connor.renben.process.plm.tmom002; + +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentFilter; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom002CreateStandardOPHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // + // TODO Auto-generated method stub + final AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + final TCSession session = (TCSession) app.getSession(); + try { + InterfaceAIFComponent[] comps = app.getTargetComponents(); + for (int i = 0; i < comps.length; i++) { + if (!(comps[i] instanceof TCComponentFolder)) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzwjjhcj02_display.TITLE"), "", MessageBox.ERROR); + return null; + } + } +// if (itemList != null) { +// for (int i = 0; i < itemList.size(); i++) { +// if (itemList.get(i).getStringProperty("object_type") +// .indexOf("MEProcess") < 0) { +// MessageBox.post("ѡն󴴽", "", MessageBox.ERROR); +// return null; +// } +// } +// } + new Thread() { + @Override + public void run() { + // TODO Auto-generated method stub + new TMom002CreateStandardOPDialog(session, app, "׼", null, + null, TMomFinalUtil.BZGX_CODE); + super.run(); + } + }.start(); + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return null; + // CreateNewBOHandler handler = new CreateNewBOHandler("MEOP"); + // handler.execute(arg0); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateYJControlPlanHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateYJControlPlanHandler.java new file mode 100644 index 0000000..18eac40 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateYJControlPlanHandler.java @@ -0,0 +1,296 @@ +package com.connor.renben.process.plm.tmom002; + +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 org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.CreateNewBOHandler; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; + +public class TMom002CreateYJControlPlanHandler extends AbstractHandler { + private boolean isOk = true; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub +// isOk = true; +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// try { +// if(app.getTargetComponent().getType().indexOf("MEProcess") >= 0 && app.getTargetComponent() instanceof TCComponentItem) +// { +// TCComponentItem meprocessItem = (TCComponentItem)app.getTargetComponent(); +// //ȡµĿƼƻ +// TCComponent[] items = meprocessItem.getRelatedComponents("IMAN_reference"); +// for (int i = 0; i < items.length; i++) { +// if(items[i].getType().indexOf("RB3_YJKZJH") >= 0) +// { +// isOk = false; +// +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_YJKZJH"); + handler.execute(arg0); +// if(isOk) +// { +// SqlUtilT.getTCConnection(); +// // ѯݿе +// ResultSet rs = null; +// ResultSet rs1 = null; +// ResultSet rs2 = null; +// ResultSet rs3 = null; +// InputStream input = null; +// try { +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// TCSession session = (TCSession) app.getSession(); +// String sql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\'", app.getTargetComponent().getUid()); +// rs = SqlUtilT.read(sql); +// if(rs.next()) +// { +// //ɾ +// String selectSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_YJKZJH\'", app.getTargetComponent().getUid()); +// rs1 = SqlUtilT.read(selectSql); +// if(rs1.next()) +// { +// String deleteSql = String.format("delete from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_YJKZJH\'", app.getTargetComponent().getUid()); +// SqlUtilT.delete(deleteSql); +// } +// // +// String sscSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SSCKZJH\'", app.getTargetComponent().getUid()); +// rs2 = SqlUtilT.read(sscSql); +// String scSql = String.format("select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'RB3_SCKZJH\'", app.getTargetComponent().getUid()); +// rs3 = SqlUtilT.read(scSql); +// if(rs2.next()) +// { +// List> dataList = new ArrayList>(); +// do { +// 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); +// } while (rs2.next()); +// for (int i = 0; i < dataList.size(); i++) { +// UUID yjkzjhUid = UUID.randomUUID(); +//// // ݲ뵽Ƽƻ +// String insertSQL = pro.getProperty("INSERTSQL"); +//// // Ƽƻ +// SqlUtilT.write( +// new String[] { +// yjkzjhUid.toString().replace("-", ""), +// dataList.get(i).get(0),dataList.get(i).get(1), +// dataList.get(i).get(2),dataList.get(i).get(3), +// dataList.get(i).get(4),dataList.get(i).get(5), +// dataList.get(i).get(6),dataList.get(i).get(7), +// dataList.get(i).get(8),dataList.get(i).get(9), +// dataList.get(i).get(10),dataList.get(i).get(11), +// dataList.get(i).get(12),dataList.get(i).get(13), +// dataList.get(i).get(14),dataList.get(i).get(15), +// dataList.get(i).get(16),dataList.get(i).get(17), +// dataList.get(i).get(18),dataList.get(i).get(19), +// dataList.get(i).get(20),dataList.get(i).get(21), +// dataList.get(i).get(22),dataList.get(i).get(23), +// dataList.get(i).get(24),dataList.get(i).get(25), +// dataList.get(i).get(26),"RB3_YJKZJH" }, +// insertSQL); +// } +// } +// else if(rs3.next()) +// { +// List> dataList = new ArrayList>(); +// do { +// List rowList = new ArrayList(); +// rowList.add(rs3.getString(2)); +// rowList.add(rs3.getString(3));rowList.add(rs3.getString(4)); +// rowList.add(rs3.getString(5));rowList.add(rs3.getString(6)); +// rowList.add(rs3.getString(7));rowList.add(rs3.getString(8)); +// rowList.add(rs3.getString(9));rowList.add(rs3.getString(10)); +// rowList.add(rs3.getString(11));rowList.add(rs3.getString(12)); +// rowList.add(rs3.getString(13));rowList.add(rs3.getString(14)); +// rowList.add(rs3.getString(15));rowList.add(rs3.getString(16)); +// rowList.add(rs3.getString(17));rowList.add(rs3.getString(18)); +// rowList.add(rs3.getString(19));rowList.add(rs3.getString(20)); +// rowList.add(rs3.getString(21));rowList.add(rs3.getString(22)); +// rowList.add(rs3.getString(23));rowList.add(rs3.getString(24)); +// rowList.add(rs3.getString(25));rowList.add(rs3.getString(26)); +// rowList.add(rs3.getString(27));rowList.add(rs3.getString(28)); +// dataList.add(rowList); +// } while (rs3.next()); +// for (int i = 0; i < dataList.size(); i++) { +// UUID yjkzjhUid = UUID.randomUUID(); +//// // ݲ뵽Ƽƻ +// String insertSQL = pro.getProperty("INSERTSQL"); +//// // Ƽƻ +// SqlUtilT.write( +// new String[] { +// yjkzjhUid.toString().replace("-", ""), +// dataList.get(i).get(0),dataList.get(i).get(1), +// dataList.get(i).get(2),dataList.get(i).get(3), +// dataList.get(i).get(4),dataList.get(i).get(5), +// dataList.get(i).get(6),dataList.get(i).get(7), +// dataList.get(i).get(8),dataList.get(i).get(9), +// dataList.get(i).get(10),dataList.get(i).get(11), +// dataList.get(i).get(12),dataList.get(i).get(13), +// dataList.get(i).get(14),dataList.get(i).get(15), +// dataList.get(i).get(16),dataList.get(i).get(17), +// dataList.get(i).get(18),dataList.get(i).get(19), +// dataList.get(i).get(20),dataList.get(i).get(21), +// dataList.get(i).get(22),dataList.get(i).get(23), +// dataList.get(i).get(24),dataList.get(i).get(25), +// dataList.get(i).get(26),"RB3_YJKZJH" }, +// insertSQL); +// } +// } +// else +// { +// +// } +// } +// else +// { +// //շ͵ṹȡBOMϢ +// TCComponentBOMWindow bomWindow = null; +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session +// .getTypeComponent("BOMWindow"); +// bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(((TCComponentItem)app.getTargetComponent()), +// ((TCComponentItem)app.getTargetComponent()).getLatestItemRevision(), null, null); +// // ȡ +// AIFComponentContext aif[] = topline.getChildren(); +// List> properties = new ArrayList>(); +// for (int i = 0; i < aif.length; i++) { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// TCComponentICO[] icos = subline.getItem() +// .getClassificationObjects(); +// 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")); +// if (icos.length > 0) { +// ICSProperty[] descriptions = icos[0] +// .getICSProperties(true); +// for (int j = 0; j < descriptions.length; j++) { +// if (descriptions[j].getId() == 1004) { +// propertie +// .add(descriptions[j].getValue() == null ? "" +// : descriptions[j].getValue()); +// } +// } +// } else { +// propertie.add(""); +// } +// // propertie.add(); +// properties.add(propertie); +// } +// //ݿв +// for (int i = 0; i < aif.length; i++) { +// 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("-", ""), +// topline.getItem().getUid(), properties.get(i).get(0), +// properties.get(i).get(1), +// properties.get(i).get(2), +// properties.get(i).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH" }, +// insertSQL); +// // ƼƻѲ +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString() +// .replace("-", ""), topline.getItem().getUid(), +// properties.get(i).get(0), +// number.toString(), name, +// properties.get(i).get(3), "", "", "", "", +// "", "", "", "", "", "", "", "", "", "", "", +// "", "", "", "", "", "", "", "RB3_YJKZJH" }, +// insertSQL); +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// if (rs1 != null) { +// SqlUtilT.free(rs1); +// } +// if (rs2 != null) { +// SqlUtilT.free(rs2); +// } +// if (rs3 != null) { +// SqlUtilT.free(rs3); +// } +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// SqlUtilT.freeAll(); +// } +// } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom002/TMom002CreateZYZDSHandler.java b/src/com/connor/renben/process/plm/tmom002/TMom002CreateZYZDSHandler.java new file mode 100644 index 0000000..04bc6fe --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom002/TMom002CreateZYZDSHandler.java @@ -0,0 +1,21 @@ +package com.connor.renben.process.plm.tmom002; + +import java.util.Map; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.CreateNewBOHandler; + +public class TMom002CreateZYZDSHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + CreateNewBOHandler handler = new CreateNewBOHandler("RB3_ZYZDS"); + handler.execute(arg0); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGCommand.java b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGCommand.java new file mode 100644 index 0000000..a1d1c22 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGCommand.java @@ -0,0 +1,159 @@ +package com.connor.renben.process.plm.tmom003; + +/** + * ȡѡжµͼֽlist + */ +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.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 TMom003DownLoadDWGCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private List fileNameList; + private List filePathList; + private StringBuffer sb; + + public TMom003DownLoadDWGCommand() { + super(); + } + + public TMom003DownLoadDWGCommand(AbstractAIFApplication app, + TCSession session) { + this.app = app; + this.session = session; + } + + /** + * ȡѡеͼֽ + * + * @throws IOException + * @throws FileNotFoundException + * @throws TCException + */ + public void getControlPlanMsg() throws FileNotFoundException, IOException, + TCException, Exception { + sb = new StringBuffer(); + // ȡѡĿ + InterfaceAIFComponent[] comp = this.app.getTargetComponents(); + fileNameList = new ArrayList(); + filePathList = new ArrayList(); + // жѡĶǷǰ汾 + if (comp != null && comp.length > 0) { + for (int i = 0; i < comp.length; i++) { + TCComponentItem item = null; + if (comp[i] instanceof TCComponentItem) { + // ȡ + item = (TCComponentItem) comp[i]; + } else if (comp[i] instanceof TCComponentItemRevision) { + // ȡ + item = ((TCComponentItemRevision) comp[i]).getItem(); + } + // ȡµѷ汾 + if (item == null) { + continue; + } + String itemName = item.getProperty("object_string"); + TCComponentItemRevision[] revs = item + .getReleasedItemRevisions(); + if (revs == null && revs.length == 0) { + continue; + } + for (int j = 0; j < revs.length - 1; j++) { + for (int k = 0; k < revs.length - 1; k++) { + if (Integer.parseInt(revs[k] + .getProperty("item_revision_id")) < Integer + .parseInt(revs[k + 1] + .getProperty("item_revision_id"))) { + + TCComponentItemRevision temp = revs[j]; + + revs[k] = revs[k + 1]; + + revs[k + 1] = temp; + } + } + } + if (revs == null || revs.length == 0) { + sb.append(String.format("%sвѷİ汾", itemName)); + continue; + } + System.out.println("°汾ţ" + + revs[0].getProperty("item_revision_id")); + // ȡĬϵճϵ + // String defaultRelation = rev.getDefaultPasteRelation(); + // System.out.println("defaultRelation =" + defaultRelation); + // ȡTC_AttachesϵµеĶ + List compList = new ArrayList(); + TCComponent[] comps = revs[0] + .getReferenceListProperty("TC_Attaches"); + TCComponent[] comps2 = revs[0] + .getReferenceListProperty("IMAN_specification"); + for (TCComponent compt : comps) { + compList.add(compt); + } + for (TCComponent compt : comps2) { + compList.add(compt); + } + System.out.println("count =" + compList == null ? "null" + : compList.size()); + // TC_Attachesϵµж + for (TCComponent compt : compList) { + // ȡ + String type = compt.getType(); + String filePath; + String fileName; + System.out.println(" TYPE = " + type); + // жǷΪMSExcelX + if (type.equals("RB3_AutoCAD")) { + // ݼļ + filePath = TMomMethodUtil.downLoadFile(compt); + fileName = compt.getProperty("object_string"); + fileNameList.add(fileName); + filePathList.add(filePath); + System.out.println("FILE NAME = " + fileName + + " ,FILE PATH = " + filePath); + } + } + } + } + } + + @Override + public void executeModal() throws Exception { + getControlPlanMsg(); + if (sb != null && sb.length() > 0) { + MessageBox.post(sb.substring(0, sb.length() - 1), "", + MessageBox.ERROR); + } + if (filePathList == null || filePathList.size() == 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("xzdxzmyyfbd03_display.TITLE"), "", MessageBox.ERROR); + return; + } + new Thread() { + @Override + public void run() { + TMom003DownLoadDWGDialog dislog = new TMom003DownLoadDWGDialog( + session, fileNameList, filePathList); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGDialog.java b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGDialog.java new file mode 100644 index 0000000..af218c2 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGDialog.java @@ -0,0 +1,122 @@ +package com.connor.renben.process.plm.tmom003; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom003DownLoadDWGDialog extends AbstractAIFDialog implements + ActionListener { + private TCSession session; + private List fileNameList; + private List filePathList; + private JFileChooser fileChooser;// ļѡ + private String foldPath = "C:\\";// Ĭϵַ + // ؼ + private JPanel mainPanel; + private JLabel pathLabel; + private JTextField pathField; + private JButton fileButton; + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + + public TMom003DownLoadDWGDialog() { + super(false); + } + + public TMom003DownLoadDWGDialog(TCSession session, + List fileNameList, List filePathList) { + super(false); + this.session = session; + this.fileNameList = fileNameList; + this.filePathList = filePathList; + init(); + } + + private void init() { + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + setTitle(rb.getString("pldctz_display.TITLE")); + this.pathLabel = new JLabel(rb.getString("dcd_display.TITLE")); + this.pathField = new JTextField(foldPath, 30); + this.fileButton = new JButton(rb.getString("ll_display.TITLE")); + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.mainPanel = new JPanel(new PropertyLayout()); + this.mainPanel.add("1.1.left.top", this.pathLabel); + this.mainPanel.add("1.2.left.top", this.pathField); + this.mainPanel.add("1.3.left.top", this.fileButton); + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + this.setLayout(new BorderLayout()); + this.add(this.mainPanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.createActionEvent(); + this.pack(); + + this.showDialog(); + // ʼļѡ + this.fileChooser = new JFileChooser(); + this.fileChooser.setCurrentDirectory(new File(foldPath)); + + } + + // Ӱť + public void createActionEvent() { + this.fileButton.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + } + + // ļѡ + private void foldPath() { + this.fileChooser.setFileSelectionMode(1); + // ļѡ + int state = this.fileChooser.showOpenDialog(null); + if (state == 1) { + return; + } else { + File f = fileChooser.getSelectedFile(); + this.foldPath = f.getAbsolutePath(); + } + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + Object source = actionevent.getSource(); + if (source.equals(this.fileButton)) { + this.foldPath(); + this.pathField.setText(this.foldPath); + } else if (source.equals(this.okButton)) { + TMom003DownLoadDWGOperation operation = new TMom003DownLoadDWGOperation( + session, fileNameList, filePathList, + this.pathField.getText()); + session.queueOperation(operation); + this.disposeDialog(); + this.dispose(); + } else if (source.equals(this.celButton)) { + this.disposeDialog(); + this.dispose(); + TMomMethodUtil.deleteFile(this.filePathList); + } + } + +} diff --git a/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGHandler.java b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGHandler.java new file mode 100644 index 0000000..f735894 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGHandler.java @@ -0,0 +1,68 @@ +package com.connor.renben.process.plm.tmom003; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +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 TMom003DownLoadDWGHandler extends AbstractHandler { + private final String stuffCheckOption = "Cust_DownLoadDWG_Check"; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + TCPreferenceService service = session.getPreferenceService(); + String currentUserID = null; + try { + currentUserID = session.getUser().getUserId(); + } catch (TCException e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + String[] value = service.getStringArray( + TCPreferenceService.TC_preference_site, stuffCheckOption); + if (value == null || value.length == 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("nmyqxzxccz03_display.TITLE"), "", MessageBox.ERROR); + return null; + } + Boolean isOk = false; + for (String userName : value) { + if (userName.equals(currentUserID)) { + isOk = true; + } + } + if (!isOk) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("nmyqxzxccz03_display.TITLE"), "", MessageBox.ERROR); + return null; + } + + TMom003DownLoadDWGCommand command = new TMom003DownLoadDWGCommand(app, + session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("pldctzsb03_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGOperation.java b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGOperation.java new file mode 100644 index 0000000..1a16986 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom003/TMom003DownLoadDWGOperation.java @@ -0,0 +1,54 @@ +package com.connor.renben.process.plm.tmom003; + +import java.io.File; +import java.util.List; + +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +public class TMom003DownLoadDWGOperation extends AbstractAIFOperation { + private TCSession session; + private List fileNameList; + private List filePathList; + private String filePath; + + public TMom003DownLoadDWGOperation(TCSession session, + List fileNameList, List filePathList, + String filePath) { + this.session = session; + this.fileNameList = fileNameList; + this.filePathList = filePathList; + this.filePath = filePath; + } + + @Override + public void executeOperation() throws Exception { + int sum = 0; + for (int i = 0; i < fileNameList.size(); i++) { + String filePath = String.format("%s\\%s", this.filePath, + this.fileNameList.get(i)); + System.out.println("ַ" + this.filePathList.get(i)); + // FileInputStream inputStream = new FileInputStream(new + // File(this.filePathList.get(i))); + System.out.println("ַ" + filePath); + // FileOutputStream outputStream = new FileOutputStream( new + // File(filePath)); + File file = new File(this.filePathList.get(i)); + File dirFile = new File(filePath); + FileUtility.copyFile(file, dirFile); + // byte[] b = new byte[inputStream.available()]; + // inputStream.read(b); + // outputStream.write(b); + // inputStream.close(); + // outputStream.close(); + sum++; + } + TMomMethodUtil.deleteFile(this.filePathList); + MessageBox.post(String.format("ͼֽɹͼֽ %d š", sum), "ɹ", + MessageBox.INFORMATION); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom004/CTMap.java b/src/com/connor/renben/process/plm/tmom004/CTMap.java new file mode 100644 index 0000000..7c82db6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/CTMap.java @@ -0,0 +1,342 @@ +package com.connor.renben.process.plm.tmom004; + +import java.awt.Dimension; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + public int rowSize; + public int columnSize; + public int[][][] span; // CellSpan + public boolean isEditable = true; + public List processRowList; + public Map> labelRows;//ע + public int row = -1; + public 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; + } + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + @Override + //õԪ񲻿ɱ༭ + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (processRowList != null && processRowList.size() > 0) { + if (!processRowList.contains(arg0) || arg1 == 1 || arg1 == 2) { + return false; + } else { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + } else { + return false; + } + } + + @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); + } + } + } + //עм1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null + && listRow == row) { + labelRowList.remove(i); + } else if (labelRowList.get(i) != null + && listRow > row) { + labelRowList.set(i, ((Integer)(listRow-1)).toString()); + } + } + } + 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 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]; + try { + 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; + }catch(Exception e) { + + } + + } + + 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); + } + } + } + //ע+1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null && i > index + && listRow >= row) { + labelRowList.set(i, ((Integer)(listRow + 1)).toString()); + } + } + } + + // չ span ʼ + for (int j = 0; j < columnSize; j++) { + span[row][j][COLUMN] = 1; + span[row][j][ROW] = 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/tmom004/CTMap2.java b/src/com/connor/renben/process/plm/tmom004/CTMap2.java new file mode 100644 index 0000000..9acac51 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/CTMap2.java @@ -0,0 +1,39 @@ +package com.connor.renben.process.plm.tmom004; + +import java.awt.Dimension; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap2 extends CTMap { + + + public CTMap2(int numRows, int numColumns) { + super(numRows, numColumns); + // TODO Auto-generated constructor stub + } + + @Override + //õԪ񲻿ɱ༭ + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (processRowList != null && processRowList.size() > 0) { + if (!processRowList.contains(arg0) || arg1 == 1 || arg1 == 2 || arg1 == 3) { + return false; + } else { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + } else { + return false; + } + } + + +} diff --git a/src/com/connor/renben/process/plm/tmom004/CTUI.java b/src/com/connor/renben/process/plm/tmom004/CTUI.java new file mode 100644 index 0000000..eb7db74 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom004; + +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/tmom004/CTable.java b/src/com/connor/renben/process/plm/tmom004/CTable.java new file mode 100644 index 0000000..a14b17a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/CTable.java @@ -0,0 +1,266 @@ +package com.connor.renben.process.plm.tmom004; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.connor.renben.process.plm.util.TMomMethodUtil; + +public class CTable extends JTable { + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + ComboBoxCellEditor comboBoxCellEditor2 = new ComboBoxCellEditor( + new Object[] { "׼\nFirst off inspection", "̼\nProcessing inspection", "ĩ\nLast off inspection","Ѳ\nPatrol inspection", "豸\nEquipment parameter adjustment" }); + ComboBoxCellEditor gaugeComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_GAUGE_VALUES")); + ComboBoxCellEditor frequencyComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_FREQUENCY_VALUES")); + + ComboBoxCellEditor owningComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_OWNING_VALUES")); + ComboBoxCellEditor reactionPlanComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_REACTION_VALUES")); + ComboBoxCellEditor controlMethodComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_CONTROLMETHOD_VALUES")); + CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + + 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 new ComboBoxCellEditor(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + } +// else if (this.getColumnName(column).equals("ĩ/ҵ׼")) +// { +// comboBoxCellEditor2.setEditable(true); +// return comboBoxCellEditor2; +// } +// else if (this.getColumnName(column).equals("/")) +// { +// gaugeComboBoxCellEditor.setEditable(true); +// return gaugeComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("Ƶ")) +// { +// frequencyComboBoxCellEditor.setEditable(true); +// return frequencyComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("")) { +// return checkBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("")) { +// owningComboBoxCellEditor.setEditable(true); +// return owningComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("Ʒ")) { +// controlMethodComboBoxCellEditor.setEditable(true); +// return controlMethodComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("Ӧƻ")) { +// reactionPlanComboBoxCellEditor.setEditable(true); +// return reactionPlanComboBoxCellEditor; +// } + else { + return cellEditor; + } + // Point point = new Point(row,column); + // if(map.containsKey(point)){ + // return map.get(point); + // }else{ + // return super.getCellEditor(row, column); + // } + } + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + //TODO Auto-generated method stub + if (this.getColumnName(column).equals("")) { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + 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/tmom004/CellSpan.java b/src/com/connor/renben/process/plm/tmom004/CellSpan.java new file mode 100644 index 0000000..202e023 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.tmom004; + +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/tmom004/CheckBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom004/CheckBoxCellEditor.java new file mode 100644 index 0000000..210f656 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/CheckBoxCellEditor.java @@ -0,0 +1,120 @@ +package com.connor.renben.process.plm.tmom004; + +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.JComboBox; +import javax.swing.JLabel; +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.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 CTMap tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(""); + // 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("")) { + 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/tmom004/ComboBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom004/ComboBoxCellEditor.java new file mode 100644 index 0000000..4b676a9 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/ComboBoxCellEditor.java @@ -0,0 +1,89 @@ +package com.connor.renben.process.plm.tmom004; + +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() { + //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 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/tmom004/CopyOfTMom004SetControlPlanDialog.java b/src/com/connor/renben/process/plm/tmom004/CopyOfTMom004SetControlPlanDialog.java new file mode 100644 index 0000000..ffda59c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/CopyOfTMom004SetControlPlanDialog.java @@ -0,0 +1,1681 @@ +package com.connor.renben.process.plm.tmom004; +//package com.connor.renben.process.plm.tmom004; +// +//import java.awt.BorderLayout; +//import java.awt.Color; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Font; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//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.HashMap; +//import java.util.Iterator; +//import java.util.List; +//import java.util.Map; +//import java.util.Properties; +// +//import javax.swing.BorderFactory; +//import javax.swing.JButton; +//import javax.swing.JCheckBox; +//import javax.swing.JLabel; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JSplitPane; +//import javax.swing.JTabbedPane; +//import javax.swing.JTable; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.DefaultMutableTreeNode; +// +//import com.connor.renben.process.plm.bean.ControlPlanBean; +//import com.connor.renben.process.plm.bean.ControlPlanTreeBean; +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.connor.renben.process.plm.tmom010.CTable; +//import com.connor.renben.process.plm.util.CTextField; +//import com.connor.renben.process.plm.util.CTreeNode; +//import com.connor.renben.process.plm.util.MyTableModel; +//import com.teamcenter.rac.aif.AIFDesktop; +//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.TCComponentItemType; +//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.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; +// +//public class CopyOfTMom004SetControlPlanDialog extends AbstractAIFDialog +// implements ActionListener { +// private AbstractAIFApplication app; +// private TCSession session; +// private TCProperty[] properties; +// private CTMap map; +// static JScrollPane scrollPane; +// // private String[] header = new +// // String[]{"PLM
EID","/
ձ","",",豸
,װ,о","ͼ","ߴ","Ʒ","" +// // ,"
Է","Ʒ//
/","/
","","Ƶ","","Ʒ" +// // ,"淶/
¼
","Ӧƻ"}; +// private String[] header = new String[] { "PLMEID", "/ձ", "", +// ",豸,װ,о", "ĩ", "ͼ", "ߴ", "Ʒ", "", "Է", +// "Ʒ///", "/", "", "Ƶ", "׼ռٷֱ", "ռٷֱ", +// "ĩռٷֱ", "", "Ʒ", "淶/¼", "Ӧƻ", "λ" }; +// private String[] header2 = new String[] { "PLMEID", "ͼ", "ߴ", "Ʒ", +// "", "Է", "Ʒ///", "/", "", "Ƶ", "׼ռٷֱ", +// "ĩռٷֱ", "ռٷֱ", "", "Ʒ", "淶/¼", "Ӧƻ", +// "ڵID", "ַλ" }; +// private Map combineMap;// źϲԪ +// private TCComponent form;// ѡжİ汾 +// private TCComponent item;// ѡж +// private TCComponent meprocess;// ѡڵĹ +// // private List> processRowList;//ǰû޸ĵк +// private List processRows;// ǰû޸ĵк +// private List> dataList; +// private List meopId;// ItemId +// private List deleteRows = new ArrayList(); +// // private TextAreaCellEditor textAreaCellEditor; +// private SpecialDialog specialDialog; +// private LibraryDialog libraryDialog; +// private ControlPlanTreeBean bean; +// private Properties pro = new Properties(); +// private boolean isComplete = false; +// private boolean isOwning; +// +// // ؼ +// private JPanel titlePanel;// +// private JLabel titleLabel; +// +// private JPanel mainPanel;// д +// +// private JPanel checkPanel;// ѡ +// private JCheckBox scCheckBox;// +// private JCheckBox sscCheckBox;// +// private JCheckBox yjCheckBox;// +// +// private JPanel panel1;// һ +// private JLabel kzjhbhLabel;// Ƽƻ +// private CTextField kzjhbhField; +// private JLabel zylxrLabel;// Ҫϵ +// private CTextField zylxrField; +// private JLabel zylxrdhLabel;// Ҫϵ˵绰 +// private CTextField zylxrdhField; +// private JLabel bzriqLabel;// ڣƣ +// private CTextField bzriqField; +// private JLabel xdrqLabel;// ڣ޶ +// private CTextField xdrqField;// ڣ޶ +// +// private JPanel panel2;// ڶ +// private JLabel sorhmLabel;// SOR +// private CTextField sorhmField; +// private JLabel ljhLabel;// +// private CTextField ljhField; +// private JLabel hxxzLabel;// С +// private CTextField hxxzField; +// private JLabel gkgcpzLabel;// ˿͹׼/ +// private CTextField gkgcpzField; +// +// private JPanel panel3;// +// private JLabel khtzbhLabel;// ͻͼֽ +// private CTextField khtzbhField; +// private JLabel ljmcLabel;// / +// private CTextField ljmcField; +// private JLabel gfpzrqLabel;// /׼/ +// private CTextField gfpzrqField; +// private JLabel gkzlpzLabel;// ˿׼/ +// private CTextField gkzlpzField; +// +// private JPanel panel4;// +// private JLabel gfgcLabel;// / +// private CTextField gfgcField; +// private JLabel gfdhLabel;// +// private CTextField gfdhField; +// private JLabel xgdjLabel;// ޸ĵȼ +// private CTextField xgdjField; +// private JLabel cxLabel;// +// private CTextField cxField; +// private JLabel gkpzLabel;// ˿׼/ +// private CTextField gkpzField; +// private JLabel qtpzLabel;// ׼/ +// private CTextField qtpzField; +// private JLabel qtpzrqLabel;// ׼ +// private CTextField qtpzrqField; +// +// private JPanel topPanel;// һеԺ͸ѡ +// +// private JPanel tablePanel;// ؼ +// private TableCellTextAreaRenderer renderer;// Ⱦ +// private static CTable table; +// +// private JPanel rootPanel;// ť +// private JButton addButton;// +// private JButton remButton;// Ƴ +// private JButton comBinebutton;// ϲ +// private JButton splitButton;// +// private JButton saveButton;// +// private JButton completeButton;// +// private JButton deleteSpecialButton;// Ƴ +// private JButton addSpecialButton;// +// private JButton libraryButton;// 򿪿Ƽƻ +// +// private JPanel centerPanel; +// +// public CopyOfTMom004SetControlPlanDialog(AbstractAIFApplication app, +// TCSession session, List processRows, TCComponent form, +// TCComponent item, TCComponent meprocess, TCProperty[] properties, +// Map combineMap, List> dataList, +// List meopId, boolean isOwning) { +// super(false); +// // this.processRowList = processRowList; +// this.processRows = processRows; +// this.dataList = dataList; +// this.meopId = meopId; +// this.combineMap = combineMap; +// this.form = form; +// this.item = item; +// this.meprocess = meprocess; +// this.properties = properties; +// this.app = app; +// this.session = session; +// this.isOwning = isOwning; +// init(); +// comBine(); +// } +// +// 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()); +// } +// } +// } +// +// // /** +// // * ̬ÿ޸ +// // */ +// // 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 void init() { +// this.setTitle("дƼƻ"); +// this.setPreferredSize(new Dimension(1280, 810)); +// // ʼⲿֿؼ +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel("CONTROL PLAN/Ƽƻ"); +// this.titleLabel.setFont(new Font("", 1, 18)); +// this.titlePanel.add(titleLabel); +// // ʼ˵ֿؼ +// this.yjCheckBox = new JCheckBox(""); +// this.sscCheckBox = new JCheckBox(""); +// this.scCheckBox = new JCheckBox(""); +// this.checkPanel = new JPanel(new BorderLayout()); +// this.checkPanel.setPreferredSize(new Dimension(175, 50)); +// this.checkPanel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.checkPanel.add(scCheckBox, BorderLayout.EAST); +// this.checkPanel.add(sscCheckBox, BorderLayout.CENTER); +// this.checkPanel.add(yjCheckBox, BorderLayout.WEST); +// +// this.panel1 = new JPanel(new PropertyLayout()); +// this.panel1.setPreferredSize(new Dimension(795, 50)); +// this.kzjhbhLabel = new JLabel("Ƽƻ"); +// this.kzjhbhLabel.setPreferredSize(new Dimension(150, 20)); +// this.kzjhbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.kzjhbhField = new CTextField(this.properties[0].getStringValue()); +// this.kzjhbhField.setPreferredSize(new Dimension(150, 20)); +// this.zylxrLabel = new JLabel("Ҫϵ/"); +// this.zylxrLabel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.zylxrLabel.setPreferredSize(new Dimension(150, 20)); +// this.zylxrField = new CTextField(this.properties[1].getStringValue()); +// this.zylxrField.setPreferredSize(new Dimension(150, 20)); +// this.zylxrdhLabel = new JLabel("Ҫϵ˵绰/˵绰"); +// this.zylxrdhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.zylxrdhLabel.setPreferredSize(new Dimension(170, 20)); +// this.zylxrdhField = new CTextField(this.properties[2].getStringValue()); +// this.zylxrdhField.setPreferredSize(new Dimension(170, 20)); +// this.bzriqLabel = new JLabel("ڣƣ"); +// this.bzriqLabel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.bzriqLabel.setPreferredSize(new Dimension(151, 20)); +// this.bzriqField = new CTextField(this.properties[3].getStringValue()); +// this.bzriqField.setPreferredSize(new Dimension(151, 20)); +// this.xdrqLabel = new JLabel("ڣ޶"); +// this.xdrqLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.xdrqLabel.setPreferredSize(new Dimension(151, 20)); +// this.xdrqField = new CTextField(this.properties[4].getStringValue()); +// xdrqField.setPreferredSize(new Dimension(151, 20)); +// this.panel1.add("1.1.left.top", kzjhbhLabel); +// this.panel1.add("1.2.left.top", zylxrLabel); +// this.panel1.add("1.3.left.top", zylxrdhLabel); +// this.panel1.add("1.4.left.top", bzriqLabel); +// this.panel1.add("1.5.left.top", xdrqLabel); +// +// this.panel1.add("2.1.left.top", kzjhbhField); +// this.panel1.add("2.2.left.top", zylxrField); +// this.panel1.add("2.3.left.top", zylxrdhField); +// this.panel1.add("2.4.left.top", bzriqField); +// this.panel1.add("2.5.left.top", xdrqField); +// +// this.topPanel = new JPanel(new PropertyLayout()); +// this.topPanel.add("1.1.left.top", this.checkPanel); +// this.topPanel.add("1.2.left.top", this.panel1); +// +// this.panel2 = new JPanel(new PropertyLayout()); +// this.panel2.setPreferredSize(new Dimension(975, 50)); +// this.sorhmLabel = new JLabel("SOR/"); +// this.sorhmLabel.setPreferredSize(new Dimension(175, 20)); +// this.sorhmLabel.setBorder((BorderFactory +// .createLineBorder(Color.gray, 1))); +// this.sorhmField = new CTextField(this.properties[5].getStringValue()); +// this.sorhmField.setPreferredSize(new Dimension(175, 20)); +// this.ljhLabel = new JLabel("/հ汾"); +// this.ljhLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.ljhLabel.setPreferredSize(new Dimension(150, 20)); +// this.ljhField = new CTextField(this.properties[6].getStringValue()); +// this.ljhField.setPreferredSize(new Dimension(150, 20)); +// this.hxxzLabel = new JLabel("С"); +// this.hxxzLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.hxxzLabel.setPreferredSize(new Dimension(324, 20)); +// this.hxxzField = new CTextField(this.properties[7].getStringValue()); +// this.hxxzField.setPreferredSize(new Dimension(324, 20)); +// this.gkgcpzLabel = new JLabel("˿͹׼/"); +// this.gkgcpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.gkgcpzLabel.setPreferredSize(new Dimension(308, 20)); +// this.gkgcpzField = new CTextField(this.properties[8].getStringValue()); +// this.gkgcpzField.setPreferredSize(new Dimension(308, 20)); +// +// this.panel2.add("1.1.left.top", sorhmLabel); +// this.panel2.add("1.2.left.top", ljhLabel); +// this.panel2.add("1.3.left.top", hxxzLabel); +// this.panel2.add("1.4.left.top", gkgcpzLabel); +// +// this.panel2.add("2.1.left.top", sorhmField); +// this.panel2.add("2.2.left.top", ljhField); +// this.panel2.add("2.3.left.top", hxxzField); +// this.panel2.add("2.4.left.top", gkgcpzField); +// +// this.panel3 = new JPanel(new PropertyLayout()); +// this.panel3.setPreferredSize(new Dimension(975, 50)); +// this.khtzbhLabel = new JLabel("ͻͼֽ"); +// this.khtzbhLabel.setPreferredSize(new Dimension(175, 20)); +// this.khtzbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.khtzbhField = new CTextField(this.properties[9].getStringValue()); +// this.khtzbhField.setPreferredSize(new Dimension(175, 20)); +// this.ljmcLabel = new JLabel("/"); +// this.ljmcLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.ljmcLabel.setPreferredSize(new Dimension(150, 20)); +// this.ljmcField = new CTextField(this.properties[10].getStringValue()); +// this.ljmcField.setPreferredSize(new Dimension(150, 20)); +// this.gfpzrqLabel = new JLabel("/׼/"); +// this.gfpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.gfpzrqLabel.setPreferredSize(new Dimension(324, 20)); +// this.gfpzrqField = new CTextField(this.properties[11].getStringValue()); +// this.gfpzrqField.setPreferredSize(new Dimension(324, 20)); +// this.gkzlpzLabel = new JLabel("˿׼/"); +// this.gkzlpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.gkzlpzLabel.setPreferredSize(new Dimension(308, 20)); +// this.gkzlpzField = new CTextField(this.properties[12].getStringValue()); +// this.gkzlpzField.setPreferredSize(new Dimension(308, 20)); +// +// panel3.add("1.1.left.top", khtzbhLabel); +// panel3.add("1.2.left.top", ljmcLabel); +// panel3.add("1.3.left.top", gfpzrqLabel); +// panel3.add("1.4.left.top", gkzlpzLabel); +// +// panel3.add("2.1.left.top", khtzbhField); +// panel3.add("2.2.left.top", ljmcField); +// panel3.add("2.3.left.top", gfpzrqField); +// panel3.add("2.4.left.top", gkzlpzField); +// +// this.panel4 = new JPanel(new PropertyLayout()); +// this.panel4.setPreferredSize(new Dimension(975, 50)); +// this.gfgcLabel = new JLabel("/"); +// this.gfgcLabel.setPreferredSize(new Dimension(175, 20)); +// this.gfgcLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.gfgcField = new CTextField(this.properties[13].getStringValue()); +// this.gfgcField.setPreferredSize(new Dimension(175, 20)); +// this.gfdhLabel = new JLabel(""); +// this.gfdhLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.gfdhLabel.setPreferredSize(new Dimension(72, 20)); +// this.gfdhField = new CTextField(this.properties[14].getStringValue()); +// this.gfdhField.setPreferredSize(new Dimension(72, 20)); +// this.xgdjLabel = new JLabel("޸ĵȼ"); +// this.xgdjLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.xgdjLabel.setPreferredSize(new Dimension(72, 20)); +// this.xgdjField = new CTextField(this.properties[15].getStringValue()); +// this.xgdjField.setPreferredSize(new Dimension(72, 20)); +// this.cxLabel = new JLabel("/"); +// this.cxLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.cxLabel.setPreferredSize(new Dimension(159, 20)); +// this.cxField = new CTextField(this.properties[16].getStringValue()); +// this.cxField.setPreferredSize(new Dimension(159, 20)); +// this.gkpzLabel = new JLabel("˿׼/"); +// this.gkpzLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.gkpzLabel.setPreferredSize(new Dimension(160, 20)); +// this.gkpzField = new CTextField(this.properties[17].getStringValue()); +// this.gkpzField.setPreferredSize(new Dimension(160, 20)); +// this.qtpzLabel = new JLabel("׼/"); +// this.qtpzLabel +// .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.qtpzLabel.setPreferredSize(new Dimension(152, 20)); +// this.qtpzField = new CTextField(this.properties[18].getStringValue()); +// this.qtpzField.setPreferredSize(new Dimension(152, 20)); +// this.qtpzrqLabel = new JLabel("׼/"); +// this.qtpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, +// 1))); +// this.qtpzrqLabel.setPreferredSize(new Dimension(152, 20)); +// this.qtpzrqField = new CTextField(this.properties[19].getStringValue()); +// this.qtpzrqField.setPreferredSize(new Dimension(152, 20)); +// panel4.add("1.1.left.top", gfgcLabel); +// panel4.add("1.2.left.top", gfdhLabel); +// panel4.add("1.3.left.top", xgdjLabel); +// panel4.add("1.4.left.top", cxLabel); +// panel4.add("1.5.left.top", gkpzLabel); +// panel4.add("1.6.left.top", qtpzLabel); +// panel4.add("1.7.left.top", qtpzrqLabel); +// +// panel4.add("2.1.left.top", gfgcField); +// panel4.add("2.2.left.top", gfdhField); +// panel4.add("2.3.left.top", xgdjField); +// panel4.add("2.4.left.top", cxField); +// panel4.add("2.5.left.top", gkpzField); +// panel4.add("2.6.left.top", qtpzField); +// panel4.add("2.7.left.top", qtpzrqField); +// +// this.mainPanel = new JPanel(new PropertyLayout()); +// this.mainPanel.add("1.1.left.top", topPanel); +// this.mainPanel.add("2.1.left.top", panel2); +// this.mainPanel.add("3.1.left.top", panel3); +// this.mainPanel.add("4.1.left.top", panel4); +// +// this.tablePanel = new JPanel(new BorderLayout()); +// this.table = getjTable(null, null, header, null); +// // ӹ +// this.tablePanel.add(new JScrollPane(this.table), BorderLayout.CENTER); +// +// 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(""); +// this.completeButton = new JButton(""); +// this.addSpecialButton = new JButton(""); +// this.deleteSpecialButton = 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); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(completeButton); +// this.rootPanel.add(addSpecialButton); +// this.rootPanel.add(deleteSpecialButton); +// // this.rootPanel.add(sendbutton); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// centerPanel.add(mainPanel, BorderLayout.CENTER); +// +// // JPanel centerPanel2 = new JPanel(new BorderLayout()); +// // centerPanel2.add(centerPanel,BorderLayout.NORTH); +// // centerPanel2.add(tablePanel, BorderLayout.CENTER); +// +// JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); +// splitPane.setOneTouchExpandable(true);// ÷ָʾͷ +// splitPane.setContinuousLayout(true);// ͷػͼ +// splitPane.setTopComponent(centerPanel); +// splitPane.setBottomComponent(tablePanel); +// +// // +// this.createActionEvent(); +// this.setLayout(new BorderLayout()); +// // this.add(centerPanel, BorderLayout.NORTH); +// this.add(splitPane, BorderLayout.CENTER); +// // dialog.add(tablePanel, BorderLayout.CENTER); +// this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.showDialog(); +// +// } +// +// // Ӽ +// public void createActionEvent() { +// this.addButton.addActionListener(this); +// this.remButton.addActionListener(this); +// this.comBinebutton.addActionListener(this); +// this.splitButton.addActionListener(this); +// this.saveButton.addActionListener(this); +// this.addSpecialButton.addActionListener(this); +// this.deleteSpecialButton.addActionListener(this); +// this.completeButton.addActionListener(this); +// } +// +// /** +// * дݵJtable +// */ +// private void setJTable() { +// for (int i = 0; i < dataList.size(); i++) { +// List rowList = dataList.get(i); +// for (int j = 0; j < header.length; j++) { +// map.setValueAt(rowList.get(j), i, j); +// } +// } +// } +// +// // 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); +// if (processRows != null && processRows.size() > 0) { +// this.map.setProcessRowList(processRows); +// } +// setJTable(); +// partsTable = new CTable(map); +// // partsTable.setRowHeight(1, 50); +// // partsTable.setRowHeight(2, 100); +// partsTable.setRowHeight(50); +// // +// partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// // Ӽ +// partsTable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 1) { +// map.setRow(table.getSelectedRow()); +// map.setColumn(table.getSelectedColumn()); +// } +// } +// }); +// // //ʾȾ +// this.renderer = new TableCellTextAreaRenderer(); +// this.renderer.setProcessRows(processRows); +// // //þ +// partsTable.setDefaultRenderer(Object.class, this.renderer); +// // //ñ༭Ⱦ +// // 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); +// } +// } +// return partsTable; +// } +// +// // 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(false); +// 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 actionPerformed(ActionEvent arg0) { +// Object source = arg0.getSource(); +// if (source.equals(this.addButton)) { +// 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); +// this.processRows = map.getProcessRowList(); +// this.renderer.setProcessRows(processRows); +// 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(); +// } else if (source.equals(this.remButton)) { +// if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { +// (table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn())).stopCellEditing(); +// } +// 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]); +// } +// if (i < newKey.length) { +// newKey[i] = entry.getKey()[i]; +// } +// } +// it.remove(); +// 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++) { +// 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(); +// this.renderer.setProcessRows(processRows); +// 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(); +// } else if (source.equals(this.comBinebutton)) { +// // table.setRowHeight(2, 50); +// int[] rows = table.getSelectedRows(); +// int[] columns = table.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()); +// table.revalidate(); +// table.repaint(); +// } else if (source.equals(this.splitButton)) { +// 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; +// } +// Map cellMap = new HashMap(); +// 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(); +// } else if (source.equals(this.saveButton)) { +// okEvent(); +// } else if (source.equals(addSpecialButton)) { +// if (this.specialDialog == null) { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } else { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } else if (source.equals(libraryButton)) { +// 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.showDialog(); +// } +// } else if (source.equals(this.deleteSpecialButton)) { +// String columnName = table.getColumnName(table.getSelectedColumn()); +// String columnValue = table.getValueAt(table.getSelectedRow(), +// table.getColumnCount() - 1).toString(); +// if (columnValue != null && !columnValue.equals("")) { +// if (columnValue.indexOf("|") >= 0) { +// String[] columnValues = columnValue.split("\\|"); +// StringBuffer sb = new StringBuffer(); +// for (int i = 0; i < columnValues.length; i++) { +// if (columnValues[i].indexOf(columnName) < 0) { +// sb.append(columnValues[i]); +// sb.append("-"); +// } +// } +// table.setValueAt(sb.substring(0, sb.length() - 1), +// table.getSelectedRow(), table.getColumnCount() - 1); +// } else { +// if (columnValue.indexOf(columnName) >= 0) { +// table.setValueAt("", table.getSelectedRow(), +// table.getColumnCount() - 1); +// } +// } +// } +// } else if (source.equals(completeButton)) { +// if (isOwning) { +// okEvent(); +// this.disposeDialog(); +// this.dispose(); +// } else { +// try { +// InterfaceAIFComponent[] components = new InterfaceAIFComponent[meopId +// .size()]; +// TCComponentItemType itemType = (TCComponentItemType) this.session +// .getTypeComponent("Item"); +// for (int i = 0; i < meopId.size(); i++) { +// components[i] = itemType.find(meopId.get(i)); +// } +// NewProcessCommand command = new NewProcessCommand( +// AIFDesktop.getActiveDesktop(), +// AIFDesktop.getActiveDesktop() +// .getCurrentApplication(), components); +// isComplete = true; +// okEvent(); +// this.disposeDialog(); +// this.dispose(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// } else { +// this.disposeDialog(); +// this.dispose(); +// } +// } +// +// private void okEvent() { +// // TODO Auto-generated method stub +// // ݱ浽 +// try { +// if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { +// (table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn())).stopCellEditing(); +// } +// // table.getDefaultEditor(Object.class).stopCellEditing(); +// // TMomMethodUtil.setByPass(session, true); +// // form.getTCProperty("rb3_hbdyg").setStringValueArray(setCombineMap()); +// // form.getTCProperty("rb3_zhs").setIntValue(sumRow); +// ControlPlanBean controlPlan = new ControlPlanBean(); +// if (isOwning) { +// controlPlan.setKzjhbh(this.kzjhbhField.getText()); +// controlPlan.setZylxr(this.zylxrField.getText()); +// controlPlan.setZylxrdh(this.zylxrdhField.getText()); +// controlPlan.setBzriq(this.bzriqField.getText()); +// controlPlan.setXdrq(this.xdrqField.getText()); +// controlPlan.setSorhm(this.sorhmField.getText()); +// controlPlan.setLjh(this.ljhField.getText()); +// controlPlan.setHxxz(this.hxxzField.getText()); +// controlPlan.setGkgcpz(this.gkgcpzField.getText()); +// controlPlan.setKhtzbh(this.khtzbhField.getText()); +// controlPlan.setLjmc(this.ljmcField.getText()); +// controlPlan.setGfpzrq(this.gfpzrqField.getText()); +// controlPlan.setGkzlpz(this.gkzlpzField.getText()); +// controlPlan.setGfgc(this.gfgcField.getText()); +// controlPlan.setGfdh(this.gfdhField.getText()); +// controlPlan.setXgdj(this.xgdjField.getText()); +// controlPlan.setCx(this.cxField.getText()); +// controlPlan.setGkpz(this.gkpzField.getText()); +// controlPlan.setQtpz(this.qtpzField.getText()); +// controlPlan.setQtpzrq(this.qtpzrqField.getText()); +// } +// // ȡJTableе +// List> dataValeList = getTableValue(); +// TMom004SetControlPlanOperation operation = new TMom004SetControlPlanOperation( +// this.form, this.meprocess, this.session, properties, +// controlPlan, dataValeList, deleteRows, isOwning); +// session.queueOperation(operation); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// MessageBox.post(e.toString(), "", MessageBox.ERROR); +// e.printStackTrace(); +// } +// } +// +// // ؼʼ +// /** +// * ȡݿе +// */ +// public void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // ȡSQL +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// pro.load(input); +// // // ȡݿ +// SqlUtilT.getConnectionTC10(); +// // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +// // "tc10", "infodba"); +// String sql = String +// .format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID is null"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// bean = getChidren(beans.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(); +// } +// } +// } +// +// } +// +// public ControlPlanTreeBean getChidren( +// ControlPlanTreeBean controlPlanTreeBean) { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// try { +// // ѯȨ޿ +// String sql = String +// .format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID = \'%s\'", +// controlPlanTreeBean.getId()); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// if (beans.size() > 0) { +// controlPlanTreeBean.setChidrenBeans(beans); +// for (ControlPlanTreeBean controlPlanTreeBean2 : beans) { +// getChidren(controlPlanTreeBean2); +// } +// } +// return controlPlanTreeBean; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// return controlPlanTreeBean; +// } +// +// public CTreeNode createNodes(DefaultMutableTreeNode node, +// ControlPlanTreeBean bean) { +// CTreeNode root = null; +// System.out.println(bean.getName()); +// root = new CTreeNode(bean); +// ResultSet rs = null; +// try { +// if (bean != null) { +// // ѯȨ޿ +// String sql = String.format( +// pro.getProperty("CONTROLPLANLIBRARYSELECT"), +// bean.getId()); +// rs = SqlUtilT.read(sql); +// List> rowList = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// list.add(rs.getString("RB3_QPTBH")); +// list.add(rs.getString("RB3_CC")); +// list.add(rs.getString("RB3_CP")); +// list.add(rs.getString("RB3_GC")); +// list.add(rs.getString("RB3_TSTX")); +// list.add(rs.getString("RB3_CPGC")); +// list.add(rs.getString("RB3_CLFF")); +// list.add(rs.getString("RB3_RL")); +// list.add(rs.getString("RB3_PL")); +// list.add(rs.getString("RB3_SJSJ")); +// list.add(rs.getString("RB3_GCSJ")); +// list.add(rs.getString("RB3_MJSJ")); +// list.add(rs.getString("RB3_FZR")); +// list.add(rs.getString("RB3_KZFF")); +// list.add(rs.getString("RB3_CZGF")); +// list.add(rs.getString("RB3_FYJH")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("RB3_SPECIAL")); +// rowList.add(list); +// } +// if (rowList.size() > 0) { +// final JTable jtable = getNewjTable(null, null, header2, +// rowList.size() + 1); +// for (int i = 0; i < rowList.size() + 1; i++) { +// if (i == 0) { +// for (int j = 0; j < header2.length; j++) { +// jtable.setValueAt(header2[j], i, j); +// } +// } else { +// for (int j = 0; j < rowList.get(i - 1).size(); j++) { +// jtable.setValueAt(rowList.get(i - 1).get(j), i, +// j); +// } +// } +// } +// // Ӽ +// jtable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 2) { +// if (table.getSelectedRow() >= 0) { +// table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn()) +// .stopCellEditing(); +// for (int i = 1; i < jtable.getColumnCount(); i++) { +// if (i == jtable.getColumnCount() - 2) { +// continue; +// } else if (i == jtable.getColumnCount() - 1) { +// table.setValueAt( +// jtable.getValueAt(jtable +// .getSelectedRow(), +// i), table +// .getSelectedRow(), +// i + 3); +// } else { +// table.setValueAt( +// jtable.getValueAt(jtable +// .getSelectedRow(), +// i), table +// .getSelectedRow(), +// i + 4); +// } +// } +// } +// } +// } +// }); +// DefaultMutableTreeNode child = new DefaultMutableTreeNode( +// jtable); +// root.add(child); +// node.add(root); +// if (bean.getChidrenBeans() != null) { +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root, bean.getChidrenBeans().get(i)); +// } +// } +// } else if (bean.getChidrenBeans() == null +// || bean.getChidrenBeans().size() == 0) { +// if (node != null) { +// node.add(root); +// } +// } else { +// if (node != null) { +// node.add(root); +// } +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root, bean.getChidrenBeans().get(i)); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// return root; +// } +// +// private List> getTableValue() { +// // TODO Auto-generated method stub +// List> dataValeList = new ArrayList>(); +// +// for (int j = 0; j < processRows.size(); j++) { +// List rowValue = new ArrayList(); +// for (int j2 = 0; j2 < this.map.getColumnCount(); j2++) { +// rowValue.add(getCellValue(processRows.get(j), j2)); +// } +// rowValue.add(processRows.get(j).toString()); +// // rowValue.add("1"); +// if (combineMap.size() > 0) { +// Iterator> it = combineMap.entrySet() +// .iterator(); +// 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] == processRows.get(j)) { +// if (rowValue.size() == 24) { +// rowValue.set( +// 23, +// rowValue.get(23) +// + "-" +// + rowSb.substring(0, +// rowSb.length() - 1) +// + "/" +// + columnSb.substring(0, +// columnSb.length() - 1)); +// } else { +// rowValue.add(rowSb.substring(0, rowSb.length() - 1) +// + "/" +// + columnSb.substring(0, +// columnSb.length() - 1)); +// } +// } +// // else +// // { +// // rowValue.add(""); +// // } +// } +// } +// if (rowValue.size() == 23) { +// rowValue.add(""); +// } +// if (isComplete) { +// rowValue.add("1"); +// } else { +// rowValue.add("0"); +// } +// rowValue.add("1"); +// rowValue.add(item.getType().toUpperCase()); +// 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 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 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() { +// // TODO Auto-generated method stub +// this.setTitle("ѡ"); +// 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("ȷ"); +// this.okButton.addActionListener(this); +// this.celButton = new JButton("ȡ"); +// 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 = CopyOfTMom004SetControlPlanDialog.table +// .getSelectedRow(); +// int column = CopyOfTMom004SetControlPlanDialog.table +// .getSelectedColumn(); +// // λ +// String columnName = CopyOfTMom004SetControlPlanDialog.table +// .getColumnName(CopyOfTMom004SetControlPlanDialog.table +// .getSelectedColumn()); +// +// int cursorIndex = ((TextAreaCellEditor) (CopyOfTMom004SetControlPlanDialog.table +// .getCellEditor(row, column))).getIndex(); +// System.out.println("index+" + cursorIndex); +// (CopyOfTMom004SetControlPlanDialog.table.getCellEditor(row, +// column)).stopCellEditing(); +// // TMom004SetControlPlanDialog.table.getDefaultEditor(Object.class).stopCellEditing(); +// StringBuilder sb = new StringBuilder( +// CopyOfTMom004SetControlPlanDialog.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 = CopyOfTMom004SetControlPlanDialog.table +// .getValueAt(row, +// CopyOfTMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// if (special == null || special.toString() == "") { +// CopyOfTMom004SetControlPlanDialog.table.setValueAt( +// columnName + "-" + cursorIndex, row, +// CopyOfTMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// } else { +// CopyOfTMom004SetControlPlanDialog.table.setValueAt(special +// + "|" + columnName + "-" + cursorIndex, row, +// CopyOfTMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// } +// System.out.println(sb.length()); +// String s = sb.insert( +// cursorIndex, +// this.table.getValueAt(this.table.getSelectedRow(), +// this.table.getSelectedColumn()).toString()) +// .toString(); +// CopyOfTMom004SetControlPlanDialog.table.setValueAt(s, +// CopyOfTMom004SetControlPlanDialog.table +// .getSelectedRow(), +// CopyOfTMom004SetControlPlanDialog.table +// .getSelectedColumn()); +// System.out.println(CopyOfTMom004SetControlPlanDialog.table +// .getValueAt(row, column).toString()); +// } else { +// this.dispose(); +// } +// } +// } +// +// /** +// * Ƽƻ +// * +// * @author Administrator +// * +// */ +// private class LibraryDialog extends AbstractAIFDialog { +// // ؼ +// private JPanel titlePanel;// +// private JLabel titleLabel; +// +// // ǩؼ +// private JTabbedPane tabbedPane; +// +// public LibraryDialog() { +// // TODO Auto-generated constructor stub +// super(); +// getData(); +// init(); +// } +// +// private void init() { +// // TODO Auto-generated method stub +// this.setTitle("PFMEA"); +// this.setPreferredSize(new Dimension(800, 600)); +// // ʼⲿֿؼ +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel("DZʧЧģʽ"); +// this.titleLabel.setFont(new Font("", 1, 18)); +// this.titlePanel.add(this.titleLabel); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// +// this.setLayout(new BorderLayout()); +// this.add(centerPanel, BorderLayout.NORTH); +// this.add(this.tabbedPane, BorderLayout.CENTER); +// // dialog.add(tablePanel, BorderLayout.CENTER); +// // this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.showDialog(); +// } +// +// // ȡPFMEA +// /** +// * ȡݿе +// */ +// private void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // ȡSQL +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// pro.load(input); +// // ȡݿ +// // SqlUtilT.getConnectionTC10(); +// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +// "tc10", "infodba"); +// String sql = String +// .format("select * from RB3_CONTROLPLAN_TREE"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// 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(); +// } +// } +// } +// +// } +// +// public void createTabbedPane(List beans) { +// this.tabbedPane = new JTabbedPane(); +// try { +// if (beans != null && beans.size() > 0) { +// for (int i = 0; i < beans.size(); i++) { +// ResultSet rs = null; +// // ѯȨ޿ +// String sql = String.format( +// pro.getProperty("CONTROLPLANLIBRARYSELECT"), +// beans.get(i).getId()); +// rs = SqlUtilT.read(sql); +// List> dataList = new ArrayList>(); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// rowList.add(rs.getString("RB3_QPTBH")); +// rowList.add(rs.getString("RB3_CC")); +// rowList.add(rs.getString("RB3_CP")); +// rowList.add(rs.getString("RB3_GC")); +// rowList.add(rs.getString("RB3_TSTX")); +// rowList.add(rs.getString("RB3_CPGC")); +// rowList.add(rs.getString("RB3_CLFF")); +// rowList.add(rs.getString("RB3_RL")); +// rowList.add(rs.getString("RB3_PL")); +// rowList.add(rs.getString("RB3_SJSJ")); +// rowList.add(rs.getString("RB3_GCSJ")); +// rowList.add(rs.getString("RB3_MJSJ")); +// rowList.add(rs.getString("RB3_FZR")); +// rowList.add(rs.getString("RB3_KZFF")); +// rowList.add(rs.getString("RB3_CZGF")); +// rowList.add(rs.getString("RB3_FYJH")); +// rowList.add(rs.getString("PARENT_ID")); +// rowList.add(rs.getString("RB3_SPECIAL")); +// dataList.add(rowList); +// } +// final CTable jtable; +// if (dataList.size() > 0) { +// jtable = getNewjTable(null, null, header2, +// dataList.size()); +// for (int j = 0; j < dataList.size(); j++) { +// for (int k = 0; k < dataList.get(j).size(); k++) { +// jtable.setValueAt(dataList.get(j).get(k), +// j, k); +// } +// } +// } else { +// jtable = getNewjTable(null, null, header2, +// dataList.size() + 1); +// jtable.setValueAt(beans.get(i).getId(), 0, +// jtable.getColumnCount() - 2); +// } +// // Ӽ +// jtable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 2) { +// if (table.getSelectedRow() >= 0) { +// table.getCellEditor( +// table.getSelectedRow(), +// table.getSelectedColumn()) +// .stopCellEditing(); +// for (int i = 1; i < jtable +// .getColumnCount(); i++) { +// if (i == jtable.getColumnCount() - 2) { +// continue; +// } else if (i == jtable +// .getColumnCount() - 1) { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 3); +// } else { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 4); +// } +// } +// } +// } +// } +// }); +// tabbedPane.add(beans.get(i).getName(), new JScrollPane( +// jtable)); +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// SqlUtilT.free(); +// } +// } +// } +// +//} diff --git a/src/com/connor/renben/process/plm/tmom004/TMom004LibraryTree.java b/src/com/connor/renben/process/plm/tmom004/TMom004LibraryTree.java new file mode 100644 index 0000000..23c2edc --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TMom004LibraryTree.java @@ -0,0 +1,75 @@ +package com.connor.renben.process.plm.tmom004; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class TMom004LibraryTree { + public void getLibrary(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); + getLibrary(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 + MessageBox.post(e.toString(), "", MessageBox.ERROR); + 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); + getLibrary(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 + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + + return tree; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanCommand.java b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanCommand.java new file mode 100644 index 0000000..5adc53e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanCommand.java @@ -0,0 +1,760 @@ +package com.connor.renben.process.plm.tmom004; + +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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +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.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.connor.renben.process.plm.bean.ControlPlanBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.CollectControlPlan; +import com.connor.renben.process.plm.util.SaveControlPlan; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentRole; +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.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom004SetControlPlanCommand extends AbstractAIFCommand { + private TCSession session; + private AbstractAIFApplication app;// ȡѡĿ + private InterfaceAIFComponent comp; + private TCComponentItem item; + private TCComponentItemRevision itemRevision; + private TCComponent form; + private TCComponentItem meprocess; + private boolean isOwning = false; + private boolean meopIsComplete = false; + private JFrame frame = new JFrame("ڼ...");// + private JProgressBar progressBar = new JProgressBar();// + private String[] properName = new String[] { + "rb3_kzjhbh",//Ƽƻ + "rb3_zylxdh", // Ҫϵ˵绰 + "rb3_bzrq",// + "rb3_xdrq",//޶ + "rb3_sor", // SOR/ + "rb3_ljhzzbb",///հ汾 + "rb3_hxxz", // С + "rb3_gkgcpz",// ˿͹׼/ + "rb3_khtzbh",//ͻͼֽ + "rb3_ljmcms",/// + "rb3_gfgcpz", // /׼/ + "rb3_gkzlpz",// ˿׼/ + "rb3_gfgc",// / + "rb3_gfdh",// + "rb3_gkpz",// ˿׼/ + "rb3_qtpzrq1", // ׼/1 + "rb3_qtpzrq2" }; // ׼/2; + private Map combineMap = new HashMap();// źϲԪ + private TCProperty[] properties; + // private List> processRowList = new + // ArrayList>(); + private List processRows = new ArrayList(); + private List meopNameList; + private Map> labelRows = new HashMap>();//ע + private TCComponentUser user;// ǰ¼û + private List> dataList = new ArrayList>();// е + private List plmeidList = new ArrayList();// plmeid + private List meopId = new ArrayList();// ID + private List> completeDataList = new ArrayList>();// ɵԱ + private String UID; + boolean isRelease=false; + public TMom004SetControlPlanCommand() { + super(); + } + + public TMom004SetControlPlanCommand(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 getControlPlanCompleteUser() { + // ȡµĹ + ResultSet rs = null; + try { + form.refresh(); + //TCProperty[] tcProperties = form.getTCProperties(new String[] { + // "rb3_complete_user", "rb3_complete_date" }); + //String[] users = tcProperties[0].getStringValueArray(); + //String[] date = tcProperties[1].getStringValueArray(); + Map completeUser = new HashMap(); + //for (int i = 0; i < date.length; i++) { + // completeUser.put(users[i], date[i]); + //} + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + // ȡݿ + SqlUtilT.getTCConnection(); + //ݹTO_NUMBER(concat(substr(replace(t1.RB3_GYBH,chr(10),''),0,5),ascii(substr(replace(t1.RB3_GYBH,chr(10),''),-1)))) + String sql = String + .format("select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " from (select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,nvl(rb3_user,' ') as rb3_user,nvl(RB3_INSPECTIONUSER,' ') as RB3_INSPECTIONUSER " + + " from RB3_PERMISSIONS)" + + " unpivot (rb3_user_id for type in (rb3_user, RB3_INSPECTIONUSER) ) " + + " where PROCESSPUID = \'%s\' " + + " group by PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " order by to_number(RB3_GYBH),type desc", meprocess.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("RB3_MEOPID")); + rowList.add(rs.getString("RB3_GYBH")); + rowList.add(rs.getString("RB3_GCMC")); + if (rs.getString("TYPE").toString().equals("RB3_USER")) { + rowList.add("Լ"); + } else if (rs.getString("TYPE").toString() + .equals("RB3_INSPECTIONUSER")) { + rowList.add("Ѳ"); + Integer meopId = 0; + if(Integer.parseInt(rowList.get(1)) % 10 ==0) + { + meopId = Integer.parseInt(rowList.get(1))+5; + } + else + { + meopId = Integer.parseInt(rowList.get(1))+1; + } + rowList.set(1, meopId.toString()); + } + if (!rs.getString("RB3_USER_ID").equals(" ")) { + rowList.add(type.find(rs.getString("RB3_USER_ID")) + .getStringProperty("user_name")); + } else { + rowList.add(""); + } + // Ƿ + if (completeUser.keySet().contains(rs.getString("RB3_USER_ID"))) { + rowList.add(""); + rowList.add(completeUser.get(rs.getString("RB3_USER_ID"))); + } else { + rowList.add(""); + rowList.add(""); + } +// if(!meopNameList.contains(rs.getString("RB3_GCMC")) && rs.getString("TYPE").toString() +// .equals("RB3_INSPECTIONUSER")) +// { +// continue; +// } + completeDataList.add(rowList); + } + // ȡȨޱе + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + + SqlUtilT.freeAll(); + } + } + + /** + * ȡݿе + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + System.out.println(pro.getProperty("CONTROLPLANSELECT")); + String sql = String.format(pro.getProperty("CONTROLPLANSELECT"), + meprocess.getUid(), item.getType().toUpperCase(),comp.getUid()); + rs = SqlUtilT.read(sql); + + while (rs.next()) { + //+++ + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID"));//0 + rowList.add(rs.getString("RB3_GYBH"));//1 + rowList.add(rs.getString("RB3_GCMC"));//2 + rowList.add(rs.getString("RB3_JQSB"));//3 + rowList.add(rs.getString("RB3_QPTBH"));//4 + rowList.add(rs.getString("RB3_CP"));//5 + rowList.add(rs.getString("RB3_GC"));//6 + rowList.add(rs.getString("RB3_TSTX"));//7 + rowList.add(rs.getString("RB3_CPGC"));//8 + rowList.add(rs.getString("RB3_CLFF"));//9 + rowList.add(rs.getString("RB3_RL"));//10 + rowList.add(rs.getString("RB3_PL"));//11 + rowList.add(rs.getString("RB3_KZFF"));//12 + rowList.add(rs.getString("RB3_FYJH"));//13 + rowList.add(rs.getInt("RB3_HH"));//14 + rowList.add(rs.getString("RB3_HBDYG"));//15 + rowList.add(rs.getInt("RB3_HHC"));//16 + rowList.add(rs.getInt("NO"));//17 + dataList.add(rowList); + } + System.out.println("ݻȡ"); + // е,ȡǰû޸ĵк + String userName = form.getReferenceProperty("owning_user") + .getStringProperty("user_id"); + + //Ƿ񷢲ждȨжȨ + boolean bool1 = user.getGroups()[0].getGroupName().equals("dba"); + boolean bool2 = isRelease && !user.getGroups()[0].getGroupName().equals("dba"); + boolean bool3 = user.getUserId().equals(userName); + for (int i = 0; i < dataList.size(); i++) { + // кŲ + dataList.get(i).set(16,i- Integer.parseInt(dataList.get(i).get(14).toString())); + if(bool1)//Ա + { + isOwning = true; + processRows.add(i); + plmeidList.add(dataList.get(i).get(0).toString()); + continue; + } + else if (bool2) + { + continue; + } + else if (bool3){ + isOwning = true; + processRows.add(i); + if(dataList.get(i)==null) { + MessageBox.post("dataList.get("+"):"+dataList.get(i).toString(), "", MessageBox.ERROR); + } + if(dataList.get(i).get(0)==null) { + MessageBox.post(dataList.get(i).toString(), "", MessageBox.ERROR); + } + plmeidList.add(dataList.get(i).get(0).toString()); + } + } + System.out.println("Ȩж"); + input.close(); + } 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(); + } + + } + + private void getItem() { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + try { + // ȡѡжİ汾 +// if (comp instanceof TCComponentItem) { +// MessageBox.post("ѡƼƻ汾", "", MessageBox.ERROR); +// +// //throw new Exception("δҵ"); +// } else + if (comp instanceof TCComponentItemRevision&&comp.getType().toUpperCase().indexOf("KZJH") >= 0) { + AIFComponentContext[] context = ((TCComponentItemRevision) comp) + .getItem().whereReferenced(); + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("MEProcess")) { + meprocess = (TCComponentItem) context[i].getComponent(); + } + } + itemRevision = ((TCComponentItemRevision) comp); + item = itemRevision.getItem(); + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + }else { + MessageBox.post(rb.getString("qxzkzjhbbdx04_display.TITLE"), "", MessageBox.ERROR); + return; + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + //ǷDOڵ + public boolean isDoTask(String meopId,String userId) { + try { + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem meopItem = itemType.find(meopId); + if(meopItem != null) + { + TCComponent[] items = meopItem + .getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + if (items[i].getType().indexOf("DoTask") >= 0) { + TCComponentUser user = (TCComponentUser) items[i].getRelatedComponent("owning_user"); + if(user.getUserId().equals(userId)) + { + return true; + } + } + + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + //Ƿڵ + public boolean isReviewTask(String meopId,String userId) { + try { + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem meopItem = itemType.find(meopId); + if(meopItem != null) + { + TCComponent[] items = meopItem + .getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + if (items[i].getType().indexOf("ReviewTask") >= 0) { + TCComponentUser user = (TCComponentUser) items[i].getRelatedComponent("owning_user"); + if(user.getUserId().equals(userId)) + { + return true; + } + } + + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + + public void getCombineMap() { + try { + if (dataList != null && dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + if (dataList.get(i).get(15) != null + && !dataList.get(i).get(15).equals("")) { + String sombine = dataList.get(i).get(15).toString(); + int rowDif = Integer.parseInt(dataList.get(i).get(16) + .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) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + + /** + * ȡмĹ + * @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 = new String[props.length]; + for (int i = 0; i < props.length; i++) { + if(props[i].indexOf("/") >= 0) + { + values[i] = props[i].split("/")[0]; + } + else + { + values[i] = props[i]; + } + } + } + } + else + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("wzdsxx04_display.TITLE"), "", MessageBox.ERROR); + } + return Arrays.asList(values); + } + + @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Ͳ༭ + //MessageBox.post("ûдȨ", "", MessageBox.ERROR); + isRelease = true; + break; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + if(!isRelease) { + //жǷǩ + if(((TCComponent) comp).isCheckedOut()) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("kzjhzzbj04_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ûǩڴʱǩ + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + } + + //+++ + getItem(); + + //+++ӽ + 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); + //+++ + + meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); +// //ûİ汾Ҫͬbom +// if(comp.getProperty("release_status_list")==null||comp.getProperty("release_status_list").equals("")) { +// CollectControlPlan collectControlPlan = new CollectControlPlan(session, item.getType().toUpperCase(), meprocess); +// SaveControlPlan saveControlPlan = new SaveControlPlan(session, meprocess,comp); +// saveControlPlan.insertData(); +// } + + //ȡ + final ControlPlanBean controlPlanBean = new ControlPlanBean(); + + controlPlanBean.setKzjhbh(comp.getProperty("item_id") + "/"+ comp.getProperty("item_revision_id")); + + controlPlanBean.setZylxr(item.getReferenceProperty("owning_user").getStringProperty("user_name")); + 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") != "") + { + controlPlanBean.setBzriq(revComponent.getProperty("date_released")); + } + if(revId == newestRevisiovId) + { + controlPlanBean.setXdrq(revComponent.getProperty("date_released")); + } + } + } + progressBar.setValue(5); + if(controlPlanBean.getBzriq() == null) + { + controlPlanBean.setBzriq(""); + } + if(controlPlanBean.getXdrq() == null) + { + controlPlanBean.setXdrq(""); + } + //ݹȡƷ + 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(); + TCComponentItemRevision productLastRevision = product.getLatestItemRevision(); + controlPlanBean.setLjh(productLastRevision.getProperty("item_id") + "/"+ productLastRevision.getProperty("item_revision_id")); + controlPlanBean.setLjmc(product.getStringProperty("object_name")); + //ȡ汾 + TCComponent revMaster = productLastRevision.getRelatedComponent("IMAN_master_form_rev"); + controlPlanBean.setKhtzbh(revMaster.getStringProperty("rb3_press_drawing")); + } + } + progressBar.setValue(10); +// ƼƻţƼƻITME_ID/汾 +// ҪϵˣƼƻ +// ڣƣһ汾ʱ +// ڣ޶°淢ʱ +// /հ汾ƷITEM_ID/汾 +// /Ʒobject_name +// ͻͼֽţƷ汾еĿͻͼ + if (form != null) { + properties = form.getTCProperties(properName); + } + + //++++汾İ汾ǡ00ͻȡ汾ݸ޶İ汾 + // ȡݿ + ResultSet rs0 = null; + ResultSet rs = null; + InputStream input = null; + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + System.out.println("=======."+input); + 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("CONTROLPLANSELECT"), + meprocess.getUid(), item.getType().toUpperCase(),app.getTargetComponent().getUid()); + rs0 = SqlUtilT.read(sql0); + if(!revisionID.equals("00")&&!rs0.next()) { + + List> addData=new ArrayList>(); + try { + String sql = String.format(pro.getProperty("CONTROLPLANSELECT"), + meprocess.getUid(), item.getType().toUpperCase(),Revisions[Revisions.length-2].getUid()); + SqlUtilT.getTCConnection(); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List dataList=new ArrayList(); + dataList.add(UUID.randomUUID().toString().replace("-", "")); + dataList.add(rs.getString("PROCESSPUID")); + dataList.add(rs.getString("RB3_MEOPID")); + dataList.add(rs.getString("RB3_GYBH")); + dataList.add(rs.getString("RB3_GCMC")); + dataList.add(rs.getString("RB3_JQSB")); + dataList.add(rs.getString("RB3_SMJY")); + dataList.add(rs.getString("RB3_QPTBH")); + dataList.add(rs.getString("RB3_CC")); + dataList.add(rs.getString("RB3_CP")); + dataList.add(rs.getString("RB3_GC")); + dataList.add(rs.getString("RB3_TSTX")); + dataList.add(rs.getString("RB3_CPGC")); + dataList.add(rs.getString("RB3_CLFF")); + dataList.add(rs.getString("RB3_RL")); + dataList.add(rs.getString("RB3_PL")); + dataList.add(rs.getString("RB3_SJSJ")); + dataList.add(rs.getString("RB3_GCSJ")); + dataList.add(rs.getString("RB3_MJSJ")); + dataList.add(rs.getString("RB3_FZR")); + dataList.add(rs.getString("RB3_KZFF")); + dataList.add(rs.getString("RB3_CZGF")); + dataList.add(rs.getString("RB3_FYJH")); + dataList.add(rs.getString("RB3_HH")); + dataList.add(rs.getString("RB3_HBDYG")); + dataList.add(rs.getString("RB3_SFWC")); + dataList.add(rs.getString("RB3_HHC")); + dataList.add(rs.getString("RB3_SPECIAL")); + dataList.add(rs.getString("TYPE")); + dataList.add(rs.getString("RB3_CONCEAL")); + dataList.add(rs.getString("RB3_LABEL")); + dataList.add(rs.getString("RB3_NO")); + dataList.add(rs.getString("RB3_TOOL_INSPECT")); + dataList.add(comp.getUid());//ѡĶpuidݿREVISIONID + dataList.add(rs.getString("NO"));//Ʋұ + addData.add(dataList); + } + }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(); + } + if(!"IMPORT TO EXCEL".equals(comp.getProperty("object_desc"))) { + for(int i=0;i dataList=new ArrayList(); + dataList=addData.get(i); + String[] data=dataList.toArray(new String[]{}); + String insertSQL = pro.getProperty("INSERTSQL"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(data, insertSQL); + } + } + } + if (rs0 != null) { + SqlUtilT.free(rs0); + } + progressBar.setValue(15); + //++++++++ + + + //ûİ汾Ҫͬbom + if(!isRelease) { + System.out.println("111111111111111"); + CollectControlPlan collectControlPlan = new CollectControlPlan(session, item.getType().toUpperCase(), meprocess); + System.out.println("222222222222222"); + SaveControlPlan saveControlPlan = new SaveControlPlan(session, meprocess,comp); + System.out.println("333333333333333"); + saveControlPlan.insertData(); + System.out.println("444444444444444"); + } + + progressBar.setValue(40); + + getData(); + progressBar.setValue(70); + System.out.println("55555"); + getCombineMap(); + progressBar.setValue(80); + System.out.println("6666"); + getControlPlanCompleteUser(); + progressBar.setValue(90); + System.out.println("7777"); + //ӡcombineMapϲ + for (int[] name : combineMap.keySet()) { + String key = Arrays.toString(name); + String value = Arrays.toString(combineMap.get(name)); + System.out.println("===>"+key + " " + value); + } + if (properties == null) { + return; + } + //properties[0].getPropertyValue() + //жǷ + if(processRows.size() > 0 && dataList.get(processRows.get(0)).get(16).toString().equals("1")) + { + meopIsComplete = true; + } + progressBar.setValue(100); + System.out.println(dataList); + new Thread() { + @Override + public void run() { + TMom004SetControlPlanDialog dislog = new TMom004SetControlPlanDialog( + app, session, processRows,labelRows, form, item,itemRevision, meprocess, + properties,controlPlanBean, combineMap, dataList, completeDataList, + meopId,plmeidList, isOwning,meopIsComplete,UID); + frame.dispose(); + } + }.start(); + super.executeModal(); + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanDialog.java b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanDialog.java new file mode 100644 index 0000000..f722621 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanDialog.java @@ -0,0 +1,3667 @@ +package com.connor.renben.process.plm.tmom004; + +import java.awt.BorderLayout; +import javax.swing.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringReader; +import java.util.Enumeration; +import java.util.EventObject; +import java.util.Vector; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.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.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.sql.ResultSet; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +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.Timer; +import java.util.TimerTask; +import java.util.UUID; + +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.plaf.FontUIResource; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +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.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.eclipse.jface.viewers.DoubleClickEvent; +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.ControlPlanBean; +import com.connor.renben.process.plm.bean.TMomControlPlanBean; +import com.connor.renben.process.plm.bean.TMomControlPlanSimpleBean; +import com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom010.TMom010SetPFMEADialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTextField; +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.SaveControlPlan; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.services.impl.BasicRenderIconObjectService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom004SetControlPlanDialog extends JFrame implements ActionListener { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCProperty[] properties; + private ControlPlanBean controlPlanBean; + private TMomControlPlanBean tMomControlPlanBean; + private CTMap2 map; + static JScrollPane scrollPane; + private Timer timer; + // private String[] header = new + // String[]{"PLM
EID","/
ձ","",",豸
,װ,о","ͼ","ߴ","Ʒ","" + // ,"
Է","Ʒ//
/","/
","","Ƶ","","Ʒ" + // ,"淶/
¼
","Ӧƻ"};ljgybh04_display.TITLE + + // ȡʻԱ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + + private String[] header = new String[] { "PLMEID", rb.getString("ljgybh04_display.TITLE"), + rb.getString("gcmc04_display.TITLE"), rb.getString("jqsbgzjj04_display.TITLE"), + rb.getString("bh04_display.TITLE"), rb.getString("cp04_display.TITLE"), rb.getString("gc04_display.TITLE"), + rb.getString("tstxfl04_display.TITLE"), rb.getString("cpgcgfgc04_display.TITLE"), + rb.getString("pgclff04_display.TITLE"), rb.getString("rl04_display.TITLE"), + rb.getString("pl04_display.TITLE"), rb.getString("kzff04_display.TITLE"), + rb.getString("fyjh04_display.TITLE"), rb.getString("tsfhwz04_display.TITLE"), + rb.getString("sfwc04_display.TITLE"), "ұ" }; + + private String[] header2 = new String[] { "PLMEID", "ID", rb.getString("jqsbgzjj04_display.TITLE"), + rb.getString("smjyzyzb04_display.TITLE"), rb.getString("bh04_display.TITLE"), + rb.getString("cp04_display.TITLE"), rb.getString("gc04_display.TITLE"), + rb.getString("tstxfl04_display.TITLE"), rb.getString("cpgcgfgc04_display.TITLE"), + rb.getString("pgclff04_display.TITLE"), rb.getString("rl04_display.TITLE"), + rb.getString("pl04_display.TITLE"), rb.getString("kzff04_display.TITLE"), + rb.getString("fyjh04_display.TITLE"), rb.getString("fjdID04_display.TITLE"), + rb.getString("tszfszwz04_display.TITLE") }; + + private String[] thesaurusHeader = new String[] { "PLMEID", rb.getString("xh04_display.TITLE"), + rb.getString("z04_display.TITLE"), rb.getString("fjdID04_display.TITLE") }; + + private String[] leftHeader = new String[] { "PLMEID", "ID", rb.getString("mc04_display.TITLE"), + rb.getString("mc04_display.TITLE") }; + +// private String[] header = new String[] { "PLMEID", "/ձ", "", +// ",豸,װ,о", "ĩ/ҵ׼", "", +// "Ʒ", "","Է", +// "Ʒ///", "/", "", +// "Ƶ", "Ʒ", "Ӧƻ", +// "λ", "Ƿ" }; +// +// private String[] header2 = new String[] { "PLMEID", "ID", ",豸,װ,о", +// "ĩ/ҵ׼", "", "Ʒ", +// "", "Է", "Ʒ///", +// "/","", "Ƶ", +// "Ʒ", "Ӧƻ", "ڵID", +// "ַλ" }; +// private String[] thesaurusHeader = new String[] { "PLMEID", "", +// "ֵ", "ڵID" }; +// private String[] completeUserHeader = new String[] { "ID", "", "", "", "û", "", "" }; +// private String[] leftHeader = new String[] { "PLMEID", "ID", +// "", "" }; + private Map combineMap;// źϲԪ + private TCComponent form;// ѡжİ汾 + private TCComponent item;// ѡж + private TCComponentItemRevision itemRevision;// ѡж + private TCComponentItem meprocess;// ѡڵĹ + // private List> processRowList;//ǰû޸ĵк + private List processRows;// ǰû޸ĵк + private Map> labelRows;// ע + private List> dataList; + private List> completeDataList;// ɵԱ + private List plmeidList;// plmeid + private List meopId;// + private List deleteRows = new ArrayList(); + // private TextAreaCellEditor textAreaCellEditor; + + private LibraryDialog libraryDialog; + private ThesaurusDialog thesaurusDialog; + private TreeBean bean; + private Properties pro = new Properties(); + private boolean isComplete = false; + private boolean meopIsComplete = false; + private boolean isOwning; + private int selectRow = -1; + private int selectColumn = -1; + // жϵԪʾǷȡ + private boolean isFocusOwner = false; + + // ؼ + private JPanel titlePanel;// + private JLabel titleLabel; + + private JPanel mainPanel;// д + + private JPanel checkPanel;// ѡť + private JRadioButton scCheckBox;// + private JRadioButton sscCheckBox;// + private JRadioButton yjCheckBox;// + + private JPanel panel1;// һ + private JLabel kzjhbhLabel;// Ƽƻ + private CTextField kzjhbhField; + private JLabel zylxrLabel;// Ҫϵ + private CTextField zylxrField; + private JLabel zylxrdhLabel;// Ҫϵ˵绰 + private CTextField zylxrdhField; + private JLabel bzriqLabel;// ڣƣ + private CTextField bzriqField; + private JLabel xdrqLabel;// ڣ޶ + private CTextField xdrqField;// ڣ޶ + + private JPanel panel2;// ڶ + private JLabel sorhmLabel;// SOR + private CTextField sorhmField; + private JLabel ljhLabel;// + private CTextField ljhField; + private JLabel hxxzLabel;// С + private CTextField hxxzField; + private JLabel gkgcpzLabel;// ˿͹׼/ + private CTextField gkgcpzField; + + private JPanel panel3;// + private JLabel khtzbhLabel;// ͻͼֽ + private CTextField khtzbhField; + private JLabel ljmcLabel;// / + private CTextField ljmcField; + private JLabel gfpzrqLabel;// /׼/ + private CTextField gfpzrqField; + private JLabel gkzlpzLabel;// ˿׼/ + private CTextField gkzlpzField; + + private JPanel panel4;// + private JLabel gfgcLabel;// / + private CTextField gfgcField; + private JLabel gfdhLabel;// + private CTextField gfdhField; + private JLabel xgdjLabel;// ޸ĵȼ + private CTextField xgdjField; + private JLabel cxLabel;// + private CTextField cxField; + private JLabel gkpzLabel;// ˿׼/ + private CTextField gkpzField; + private JLabel qtpzLabel;// ׼/ + private CTextField qtpzField; + private JLabel qtpzrqLabel;// ׼ + private CTextField qtpzrqField; + + private JPanel topPanel;// һеԺ͸ѡ + + // ʾѡеԪ + private JTextPane showValuePane; + private JPanel tablePanel;// ؼ + private TableCellTextAreaRenderer renderer;// Ⱦ + private static CTable table; + // + private CTable completeUserTable;// Ƽƻ + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem addItem; + private JMenuItem addCombineRowsItem; + private JMenuItem addMeopItem; + private JMenuItem remItem; + private JMenuItem comBineItem; + private JMenuItem splitItem; + private JMenuItem shrinkColumnItem; + private JMenuItem celShrinkColumnItem; + private JMenuItem testItem;// Բ˵ + // private JMenuItem deleteSpecialItem; + private JPanel rootPanel;// ť + private JButton saveButton;// + private JButton completeButton;// + private JButton refButton;// ¼ + // private JButton deleteSpecialButton;// Ƴ + // private JButton addSpecialButton;// + private JButton libraryButton;// 򿪿Ƽƻ + private JButton thesaurusButton;// 򿪴ʿ + private JButton impexcel; + private String UID; + private JPanel centerPanel; + private Boolean isImpToExcel = true; + + + static { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + Font f = UIManager.getFont("Label.font"); + System.out.println("Label.font==========>"+f); + } + }); + setGlobalFont(new Font("",Font.PLAIN , 12)); + } + private static void setGlobalFont(Font font) { + for (Object key : UIManager.getLookAndFeelDefaults().keySet()) { + if (key instanceof String + && ((String) key).endsWith(".font")) { // Button.fontTextField.font + UIManager.put(key, font); + } + } + } + public static String getUUID() { + UUID uuid = UUID.randomUUID(); + String str = uuid.toString(); + String uuidStr = str.replace("-", ""); + return uuidStr; + } + + public TMom004SetControlPlanDialog(AbstractAIFApplication app, TCSession session, List processRows, + Map> labelRows, TCComponent form, TCComponent item, + TCComponentItemRevision itemRevision, TCComponent meprocess, TCProperty[] properties, + ControlPlanBean controlPlanBean, Map combineMap, List> dataList, + List> completeDataList, List meopId, List plmeidList, boolean isOwning, + boolean meopIsComplete, String UID) { + super(); + // this.processRowList = processRowList; + this.processRows = processRows; + this.labelRows = labelRows; + this.dataList = dataList; + this.completeDataList = completeDataList; + this.plmeidList = plmeidList; + this.meopId = meopId; + this.combineMap = combineMap; + this.form = form; + this.item = item; + this.itemRevision = itemRevision; + this.meprocess = (TCComponentItem) meprocess; + this.properties = properties; + this.controlPlanBean = controlPlanBean; + this.app = app; + this.session = session; + this.isOwning = isOwning; + this.meopIsComplete = meopIsComplete; + this.UID = UID; + this.comp = app.getTargetComponent(); +// setGlobalFont(); + init(); + + // runTask();//Զ + comBine(); + } + + 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()); + } + } + } + + private void init() { + // ȡʻ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + this.setTitle(rb.getString("txkzjh_display.TITLE")); + this.setPreferredSize(new Dimension(1000, 800)); + this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + if (!isOwning) { + TMom004SetControlPlanDialog.this.dispose(); + } else { + int i = JOptionPane.showConfirmDialog(null, "Ƿ񱣴棿", "", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + okEvent(false); + TMom004SetControlPlanDialog.this.dispose(); + } else if (i == JOptionPane.NO_OPTION) { + TMom004SetControlPlanDialog.this.dispose(); + } + } + + } + }); + // ʼⲿֿؼ + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("CP/kzjh_display.TITLE")); + this.titleLabel.setFont(new Font("", 1, 18)); + this.titlePanel.add(titleLabel); + // ʼ˵ֿؼ + // MessageBox.post(itemRevision.toString(), "", MessageBox.ERROR); + this.yjCheckBox = new JRadioButton(rb.getString("yj_display.TITLE")); + this.yjCheckBox.setSelected(item.getType().toUpperCase().equals("RB3_YJKZJH")); + // this.yjCheckBox.setSelected(true); + this.sscCheckBox = new JRadioButton(rb.getString("ssc_display.TITLE")); + this.sscCheckBox.setSelected(item.getType().toUpperCase().equals("RB3_SSCKZJH")); + this.scCheckBox = new JRadioButton(rb.getString("sc_display.TITLE")); + this.scCheckBox.setSelected(item.getType().toUpperCase().equals("RB3_SCKZJH")); + ButtonGroup group = new ButtonGroup(); + group.add(this.yjCheckBox); + group.add(this.sscCheckBox); + group.add(this.scCheckBox); + this.checkPanel = new JPanel(new BorderLayout()); + this.checkPanel.setPreferredSize(new Dimension(175, 50)); + this.checkPanel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.checkPanel.add(scCheckBox, BorderLayout.EAST); + this.checkPanel.add(sscCheckBox, BorderLayout.CENTER); + this.checkPanel.add(yjCheckBox, BorderLayout.WEST); + + this.panel1 = new JPanel(new PropertyLayout()); + this.panel1.setPreferredSize(new Dimension(795, 50)); + this.kzjhbhLabel = new JLabel(rb.getString("kzjhbh_display.TITLE")); + this.kzjhbhLabel.setPreferredSize(new Dimension(150, 20)); + this.kzjhbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.kzjhbhField = new CTextField(this.properties[0].getStringValue()); + this.kzjhbhField.setPreferredSize(new Dimension(150, 20)); + this.zylxrLabel = new JLabel(rb.getString("zylxrbzr_display.TITLE")); + this.zylxrLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.zylxrLabel.setPreferredSize(new Dimension(150, 20)); + this.zylxrField = new CTextField(this.controlPlanBean.getZylxr()); + this.zylxrField.setPreferredSize(new Dimension(150, 20)); + this.zylxrdhLabel = new JLabel(rb.getString("zylxrdhbzrdh_display.TITLE")); + this.zylxrdhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.zylxrdhLabel.setPreferredSize(new Dimension(170, 20)); + this.zylxrdhField = new CTextField(this.properties[1].getStringValue()); + this.zylxrdhField.setPreferredSize(new Dimension(170, 20)); + this.bzriqLabel = new JLabel(rb.getString("rq(bz)_display.TITLE")); + this.bzriqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.bzriqLabel.setPreferredSize(new Dimension(151, 20)); + this.bzriqField = new CTextField(this.properties[2].getStringValue()); + this.bzriqField.setPreferredSize(new Dimension(151, 20)); + this.xdrqLabel = new JLabel(rb.getString("rq(xd)_display.TITLE")); + this.xdrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.xdrqLabel.setPreferredSize(new Dimension(151, 20)); + this.xdrqField = new CTextField(this.properties[3].getStringValue()); + xdrqField.setPreferredSize(new Dimension(151, 20)); + this.panel1.add("1.1.left.top", kzjhbhLabel); + this.panel1.add("1.2.left.top", zylxrLabel); + this.panel1.add("1.3.left.top", zylxrdhLabel); + this.panel1.add("1.4.left.top", bzriqLabel); + this.panel1.add("1.5.left.top", xdrqLabel); + + this.panel1.add("2.1.left.top", kzjhbhField); + this.panel1.add("2.2.left.top", zylxrField); + this.panel1.add("2.3.left.top", zylxrdhField); + this.panel1.add("2.4.left.top", bzriqField); + this.panel1.add("2.5.left.top", xdrqField); + + this.topPanel = new JPanel(new PropertyLayout()); + this.topPanel.add("1.1.left.top", this.checkPanel); + this.topPanel.add("1.2.left.top", this.panel1); + + this.panel2 = new JPanel(new PropertyLayout()); + this.panel2.setPreferredSize(new Dimension(975, 50)); + this.sorhmLabel = new JLabel(rb.getString("SORhmmc_display.TITLE")); + this.sorhmLabel.setPreferredSize(new Dimension(175, 20)); + this.sorhmLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.sorhmField = new CTextField(this.properties[4].getStringValue()); + this.sorhmField.setPreferredSize(new Dimension(175, 20)); + this.ljhLabel = new JLabel(rb.getString("ljhzzbb_display.TITLE")); + this.ljhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.ljhLabel.setPreferredSize(new Dimension(150, 20)); + this.ljhField = new CTextField(this.properties[5].getStringValue()); + this.ljhField.setPreferredSize(new Dimension(150, 20)); + this.hxxzLabel = new JLabel(rb.getString("hxxz_display.TITLE")); + this.hxxzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.hxxzLabel.setPreferredSize(new Dimension(324, 20)); + this.hxxzField = new CTextField(this.properties[6].getStringValue()); + this.hxxzField.setPreferredSize(new Dimension(324, 20)); + this.gkgcpzLabel = new JLabel(rb.getString("gkgcpzrq_display.TITLE")); + this.gkgcpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gkgcpzLabel.setPreferredSize(new Dimension(308, 20)); + this.gkgcpzField = new CTextField(this.properties[7].getStringValue()); + this.gkgcpzField.setPreferredSize(new Dimension(308, 20)); + + this.panel2.add("1.1.left.top", sorhmLabel); + this.panel2.add("1.2.left.top", ljhLabel); + this.panel2.add("1.3.left.top", hxxzLabel); + this.panel2.add("1.4.left.top", gkgcpzLabel); + + this.panel2.add("2.1.left.top", sorhmField); + this.panel2.add("2.2.left.top", ljhField); + this.panel2.add("2.3.left.top", hxxzField); + this.panel2.add("2.4.left.top", gkgcpzField); + + this.panel3 = new JPanel(new PropertyLayout()); + this.panel3.setPreferredSize(new Dimension(975, 50)); + this.khtzbhLabel = new JLabel(rb.getString("khtzbh_display.TITLE")); + this.khtzbhLabel.setPreferredSize(new Dimension(175, 20)); + this.khtzbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.khtzbhField = new CTextField(this.properties[8].getStringValue()); + this.khtzbhField.setPreferredSize(new Dimension(175, 20)); + this.ljmcLabel = new JLabel(rb.getString("ljmcms_display.TITLE")); + this.ljmcLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.ljmcLabel.setPreferredSize(new Dimension(150, 20)); + this.ljmcField = new CTextField(this.properties[9].getStringValue()); + this.ljmcField.setPreferredSize(new Dimension(150, 20)); + this.gfpzrqLabel = new JLabel(rb.getString("gfgcpzrq_display.TITLE")); + this.gfpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gfpzrqLabel.setPreferredSize(new Dimension(324, 20)); + this.gfpzrqField = new CTextField(this.properties[10].getStringValue()); + this.gfpzrqField.setPreferredSize(new Dimension(324, 20)); + this.gkzlpzLabel = new JLabel(rb.getString("gkzlpzrq_display.TITLE")); + this.gkzlpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gkzlpzLabel.setPreferredSize(new Dimension(308, 20)); + this.gkzlpzField = new CTextField(this.properties[11].getStringValue()); + this.gkzlpzField.setPreferredSize(new Dimension(308, 20)); + + panel3.add("1.1.left.top", khtzbhLabel); + panel3.add("1.2.left.top", ljmcLabel); + panel3.add("1.3.left.top", gfpzrqLabel); + panel3.add("1.4.left.top", gkzlpzLabel); + + panel3.add("2.1.left.top", khtzbhField); + panel3.add("2.2.left.top", ljmcField); + panel3.add("2.3.left.top", gfpzrqField); + panel3.add("2.4.left.top", gkzlpzField); + + this.panel4 = new JPanel(new PropertyLayout()); + this.panel4.setPreferredSize(new Dimension(975, 50)); + this.gfgcLabel = new JLabel(rb.getString("gfgc_display.TITLE")); + this.gfgcLabel.setPreferredSize(new Dimension(175, 20)); + this.gfgcLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gfgcField = new CTextField( + this.properties[12].getStringValue() == "" ? "" : this.properties[12].getStringValue()); + this.gfgcField.setPreferredSize(new Dimension(175, 20)); + this.gfdhLabel = new JLabel(rb.getString("gfdh_display.TITLE")); + this.gfdhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gfdhLabel.setPreferredSize(new Dimension(72, 20)); + this.gfdhField = new CTextField( + this.properties[13].getStringValue() == "" ? "" : this.properties[13].getStringValue()); + this.gfdhField.setPreferredSize(new Dimension(72, 20)); +// this.xgdjLabel = new JLabel("޸ĵȼ"); +// this.xgdjLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.xgdjLabel.setPreferredSize(new Dimension(72, 20)); +// this.xgdjField = new CTextField(this.properties[8].getStringValue()); +// this.xgdjField.setPreferredSize(new Dimension(72, 20)); +// this.cxLabel = new JLabel("/"); +// this.cxLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); +// this.cxLabel.setPreferredSize(new Dimension(159, 20)); +// this.cxField = new CTextField(this.properties[9].getStringValue()); +// this.cxField.setPreferredSize(new Dimension(159, 20)); + this.gkpzLabel = new JLabel(rb.getString("gkpzrq_display.TITLE")); + this.gkpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gkpzLabel.setPreferredSize(new Dimension(160, 20)); + this.gkpzField = new CTextField(this.properties[14].getStringValue()); + this.gkpzField.setPreferredSize(new Dimension(160, 20)); + this.qtpzLabel = new JLabel(rb.getString("qtpzrq_display.TITLE")); + this.qtpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.qtpzLabel.setPreferredSize(new Dimension(152, 20)); + this.qtpzField = new CTextField(this.properties[15].getStringValue()); + this.qtpzField.setPreferredSize(new Dimension(152, 20)); + this.qtpzrqLabel = new JLabel(rb.getString("qtpzrq_display.TITLE")); + this.qtpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.qtpzrqLabel.setPreferredSize(new Dimension(152, 20)); + this.qtpzrqField = new CTextField(this.properties[16].getStringValue()); + this.qtpzrqField.setPreferredSize(new Dimension(152, 20)); + panel4.add("1.1.left.top", gfgcLabel); + panel4.add("1.2.left.top", gfdhLabel); + // panel4.add("1.3.left.top", xgdjLabel); + // panel4.add("1.4.left.top", cxLabel); + panel4.add("1.3.left.top", gkpzLabel); + panel4.add("1.4.left.top", qtpzLabel); + panel4.add("1.5.left.top", qtpzrqLabel); + + panel4.add("2.1.left.top", gfgcField); + panel4.add("2.2.left.top", gfdhField); + // panel4.add("2.3.left.top", xgdjField); + // panel4.add("2.4.left.top", cxField); + panel4.add("2.3.left.top", gkpzField); + panel4.add("2.4.left.top", qtpzField); + panel4.add("2.5.left.top", qtpzrqField); + + this.mainPanel = new JPanel(new PropertyLayout()); + this.mainPanel.add("1.1.left.top", topPanel); + this.mainPanel.add("2.1.left.top", panel2); + this.mainPanel.add("3.1.left.top", panel3); + this.mainPanel.add("4.1.left.top", panel4); + + // JPanel showValuePanel = new JPanel(); + 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) +// { +// System.out.println("ѡ===="+selectRow+"ѡ====="+selectColumn+"ֵ====="+showValuePane.getText()); +// table.setValueAt(showValuePane.getText(), selectRow, selectColumn); +// } +// if(this.row == -1 && this.column == -1) +// { +// return; +// } +// System.out.println(":"+this.row+""+this.column+"ֵ"+showValuePane.getText()); + } + + @Override + public void focusGained(FocusEvent focusevent) { + // TODO Auto-generated method stub + + isFocusOwner = true; + // if(table.) +// this.row = table.getSelectedRow(); +// this.column = table.getSelectedColumn(); +// if(this.row == -1 || this.column == -1 || table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()) == null) +// { +// showValuePane.setText(""); +// } +// else +// { +// System.out.println("ѡ:"+this.row+"ѡ"+this.column+"ֵ"+table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); +// showValuePane.setText(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); +// } + } + }); + showValuePane.setPreferredSize(new Dimension(800, 40)); + // JScrollPane js = new JScrollPane(this.showValuePane); + // showValuePanel.add(js); + + this.tablePanel = new JPanel(new BorderLayout()); + this.table = getjTable(null, null, header, null); + // õڶСк͵вɱ༭ +// int[] nonEditableColumns = {1, 2, 3}; +// for (int col : nonEditableColumns) { +// table.getColumnModel().getColumn(col).setCellEditor(new DefaultCellEditor(new JTextField()) { +// @Override +// public boolean isCellEditable(EventObject anEvent) { +// return false; +// } +// }); +// } + + // Ӽ̼ + this.table.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + // delete + if (arg0.getKeyChar() == 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 > 2 && j < table.getColumnCount() - 3) { + table.setValueAt("", selectRows[i], selectColumns[j]); + } + } else { + table.setValueAt("", selectRows[i], selectColumns[j]); + } + } + } + } + + if (arg0.getKeyCode() == 16) {// shift16Ӽ + comBineCell(); + } + if (arg0.getKeyCode() == 20) {// caps_lock20Ӽ + splitCell(); + } + 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); + // int ddd=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); + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + this.tablePanel.add(scrollPane, BorderLayout.CENTER); + + // ʼҼ˵ + // Ҽ˵ + 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")); + addMeopItem = new JMenuItem(rb.getString("tjgx_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")); + testItem = new JMenuItem(rb.getString("txbz_display.TITLE")); + // deleteSpecialItem = 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); + } + + // menu.add(testItem); + // menu.add(deleteSpecialItem); + + 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")); + if (isOwning) { + this.completeButton = new JButton(rb.getString("dcnbkzjh_display.TITLE")); + } else { + this.completeButton = new JButton(rb.getString("dcnbkzjh_display.TITLE")); + } + // this.addSpecialButton = new JButton(""); + // this.deleteSpecialButton = new JButton("Ƴ"); + this.libraryButton = new JButton(rb.getString("kzjhk_display.TITLE")); + this.thesaurusButton = new JButton(rb.getString("ck_display.TITLE")); + this.refButton = new JButton(rb.getString("cxjz_display.TITLE")); + this.impexcel = new JButton(rb.getString("drexcel_display.TITLE")); + // 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); +// } else if (!meopIsComplete) { +// this.rootPanel.add(completeButton); +// } + // ++++ + if (isOwning) { + this.rootPanel.add(saveButton); + this.rootPanel.add(completeButton); + this.rootPanel.add(refButton); + this.rootPanel.add(libraryButton); + this.rootPanel.add(thesaurusButton); + this.rootPanel.add(impexcel); + } else { + this.rootPanel.add(completeButton); + setPanelEnabled(mainPanel, false); + setPanelEnabled(panel1, false); + } + // ++++ + + // +// JPanel completeUserTablePanel = new JPanel(new BorderLayout()); +// this.completeUserTable = getNewjTable(null, null, completeUserHeader, completeDataList.size()); +// this.completeUserTable.setRowHeight(30); +// for (int j = 0; j < completeDataList.size(); j++) { +// for (int k = 0; k < completeDataList.get(j).size(); k++) { +// this.completeUserTable.setValueAt(completeDataList.get(j).get(k), j, k); +// } +// } + // ӹ +// JScrollPane scrollPane1 = new JScrollPane(this.completeUserTable); +// scrollPane1.getVerticalScrollBar().setUnitIncrement(10); +// completeUserTablePanel.add(scrollPane1, BorderLayout.CENTER); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + centerPanel.add(mainPanel, BorderLayout.CENTER); + + JSplitPane showSeleceCellValuePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + showSeleceCellValuePanel.setOneTouchExpandable(true);// ÷ָʾͷ + showSeleceCellValuePanel.setContinuousLayout(true);// ͷػͼ + showSeleceCellValuePanel.setTopComponent(new JScrollPane(showValuePane)); + showSeleceCellValuePanel.setBottomComponent(tablePanel); + +// JPanel showSeleceCellValuePanel = new JPanel(new BorderLayout()); +// showSeleceCellValuePanel.add(new JScrollPane(showValuePane),BorderLayout.NORTH); +// showSeleceCellValuePanel.add(tablePanel,BorderLayout.CENTER); + + // JPanel centerPanel2 = new JPanel(new BorderLayout()); + // centerPanel2.add(centerPanel,BorderLayout.NORTH); + // centerPanel2.add(tablePanel, BorderLayout.CENTER); + + JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setTopComponent(centerPanel); + splitPane.setBottomComponent(showSeleceCellValuePanel); + +// JSplitPane splitPane2 = new JSplitPane(); +// splitPane2.setOneTouchExpandable(true);// ÷ָʾͷ +// splitPane2.setContinuousLayout(true);// ͷػͼ +// splitPane2.setLeftComponent(splitPane); +// splitPane2.setRightComponent(completeUserTablePanel); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + + } + + // Ӽ + public void createActionEvent() { + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.addItem.addActionListener(this); + this.addCombineRowsItem.addActionListener(this); + this.addMeopItem.addActionListener(this); + this.remItem.addActionListener(this); + this.comBineItem.addActionListener(this); + this.splitItem.addActionListener(this); + this.shrinkColumnItem.addActionListener(this); + this.celShrinkColumnItem.addActionListener(this); + this.testItem.addActionListener(this); + this.saveButton.addActionListener(this); + this.refButton.addActionListener(this); + // this.addSpecialButton.addActionListener(this); + this.libraryButton.addActionListener(this); + this.thesaurusButton.addActionListener(this); + // this.deleteSpecialItem.addActionListener(this); + this.completeButton.addActionListener(this); + this.impexcel.addActionListener(this); + } + + /** + * дݵJtable + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + int qq = header.length; + int qqq = rowList.size(); + for (int j = 0; j < header.length; j++) { + if (j < 14) { + map.setValueAt(rowList.get(j), i, j); + } else { + if (j == header.length - 1) { + map.setValueAt(rowList.get(rowList.size() - 1), i, j); + } else { + map.setValueAt("", i, j); + } + } + + } + } + } + + // ÿؼȨ + 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ͨ÷ + public CTable getjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + this.map = new CTMap2(dataList.size(), titleNames.length); + map.setColumnIdentifiers(titleNames); + + if (processRows != null && processRows.size() > 0) { + this.map.setProcessRowList(processRows); + } + if (labelRows != null && labelRows.size() > 0) { + this.map.setLabelRows(labelRows); + } + setJTable(); + partsTable = new CTable(map) { + //@Override + //public boolean isCellEditable(int row, int column) { + // return column > 3; // ֻе1У0ɱ༭2-4У1-3ɱ༭ + //} + }; + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length - 1); + partsTable.HiddenCell(titleNames.length - 2); + partsTable.HiddenCell(titleNames.length - 3);// + // + // 䵽ڱϷɱ༭ + 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 && selectColumn > 3) { + table.setValueAt(showValuePane.getText(), selectRow, selectColumn); + } + + // System.out.println("row="+table.getSelectedRow()+"column="+table.getSelectedColumn()); + if (table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()) != null) { + showValuePane.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.renderer = new TableCellTextAreaRenderer(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(labelRows); + // //þ + partsTable.setDefaultRenderer(Object.class, this.renderer); + // //ñ༭Ⱦ + // 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 CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); + partsTable = new CTable(map); + // ʾȾ + TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); + 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 dispose() { + // TODO Auto-generated method stub +// this.timer.cancel();/// labelRows completeDataList plmeidList meopId deleteRows +// dataList = null; +// processRows = null; +// labelRows = null; +// completeDataList = null; +// plmeidList = null; +// meopId = null; +// deleteRows = null; +// dataList.clear(); +// processRows.clear(); +// labelRows.clear(); +// completeDataList.clear(); +// plmeidList.clear(); +// meopId.clear(); +// deleteRows.clear(); + super.dispose(); + // رȨ޸ + closePermission(); + } + + // ֽڽȡַ + 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(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + Object source = arg0.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.addRowItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row))) + || !isOwning) { + MessageBox.post(rb.getString("wqxtjh04_display.TITLE"), "", MessageBox.ERROR); + return; + } + addRow(1); + } else if (source.equals(this.addRowsItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row))) + || !isOwning) { + MessageBox.post(rb.getString("wqxtjh04_display.TITLE"), "", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else if (source.equals(this.addItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row))) + || !isOwning) { + MessageBox.post(rb.getString("wqxtjh04_display.TITLE"), "", MessageBox.ERROR); + return; + } + addCombineRow(1); + } else if (source.equals(this.addCombineRowsItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row))) + || !isOwning) { + MessageBox.post(rb.getString("wqxtjh04_display.TITLE"), "", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } else if (source.equals(this.addMeopItem)) { + int row = table.getSelectedRow(); + if ((this.processRows != null && this.processRows.size() != 0 && !(this.processRows.contains(row))) + || !isOwning) { + MessageBox.post(rb.getString("wqxtjgx04_display.TITLE"), "", MessageBox.ERROR); + return; + } + AddMeopDialog addRowsDialog = new AddMeopDialog(source); + } else if (source.equals(this.remItem)) { + if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + int[] rows = table.getSelectedRows(); + int i = JOptionPane.showConfirmDialog(null, rb.getString("sfscxzh04_display.TITLE"), "ɾ", + JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + return; + } + for (int i1 = 0; i1 < rows.length; i1++) { + if ((this.processRows != null && this.processRows.size() > 0 + && !(this.processRows.contains(table.getSelectedRow()))) || !isOwning) { + MessageBox.post(rb.getString("wqxsch04_display.TITLE"), "", MessageBox.ERROR); + return; + } + remRow(table.getSelectedRow()); + } + } else if (source.equals(this.comBineItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxhbdyg04_display.TITLE"), "", MessageBox.ERROR); + return; + } + comBineCell(); + } else if (source.equals(this.splitItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxcfdyg04_display.TITLE"), "", MessageBox.ERROR); + return; + } + splitCell(); + } else if (source.equals(this.saveButton)) { + if(table.getRowCount()<1) { + isImpToExcel = false; + try { + itemRevision.setStringProperty("object_desc", ""); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(isImpToExcel!=null && isImpToExcel) { + try { + itemRevision.setStringProperty("object_desc", "IMPORT TO EXCEL"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (isOwning) { + + okEvent(false); + } else { + MessageBox.post(rb.getString("yfb04_display.TITLE"), "", MessageBox.ERROR); + return; + } + // this.dispose(); + } +// else if (source.equals(addSpecialButton)) { +// if (this.specialDialog == null) { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } else { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } + else if (source.equals(libraryButton)) { + 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(thesaurusButton)) { + if (this.thesaurusDialog == null) { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.thesaurusDialog = new ThesaurusDialog(); + } else { + System.out.println(table.getSelectedRow() + "===" + table.getSelectedColumn()); + this.thesaurusDialog.show(); + } + } else if (source.equals(impexcel)) { + + // ȡJtableе + try { + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); + chooser.setFileFilter(new FileNameExtensionFilter("Excelļ", new String[] { "xls", "xlsx" })); + int returnVal = chooser.showOpenDialog(chooser); + File file = chooser.getSelectedFile(); + FileInputStream fis = new FileInputStream(file); + String filepath = file.getPath(); + // ȡļ + String fileType = filepath.substring(filepath.lastIndexOf(".") + 1, filepath.length()); + InputStream is = new FileInputStream(new File(filepath)); + Workbook wb = null; + if (fileType.endsWith("xlsx")) { + // Excel 2007 + wb = new XSSFWorkbook(is); + } else if (fileType.endsWith("xls")) { + // Excel 2003 + wb = new HSSFWorkbook(is); + } else { + throw new Exception("ȡIJexcelļ"); + } + // ȡExcelĵһsheetҳ + Sheet sheet = wb.getSheetAt(0); + //ɾ + + + //豸Ӧ + HashMap shebeiMap = new HashMap(); + for(int i=0;i rowIterator = sheet.iterator(); + while (rowIterator.hasNext()) { + System.out.println("ʼexcelе"); + List rowList = new ArrayList(); + String uuid = getUUID(); + rowList.add(uuid); + Row row = rowIterator.next(); + int rowNum = row.getRowNum(); + if(rowNum<9) { + continue; + } + // Ԫ + Iterator cellIterator = row.iterator(); + int ok = 0; + int hb = 0; + while (cellIterator.hasNext()) { + Cell cell = cellIterator.next(); + if(hb != 0) { + hb--; + continue; + } + int columnIndex = cell.getColumnIndex(); + if(columnIndex>15) { + break; + } + + // ȡԪֵ + String value = null; + try { + value = cell.getStringCellValue(); + } catch (Exception e) { + // TODO Auto-generated catch block + double numericCellValue = cell.getNumericCellValue(); + value = String.format("%.0f", numericCellValue); + } + + // жϵԪǷΪϲԪ + CellRangeAddress mergedRegion = null; + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + if (region.isInRange(cell.getRowIndex(), cell.getColumnIndex())) { + mergedRegion = region; + break; + } + } + // ԪǺϲԪȡϲԪֵ + if (mergedRegion != null) { + int firstRow = mergedRegion.getFirstRow(); + int lastRow = mergedRegion.getLastRow(); + int firstColumn = mergedRegion.getFirstColumn(); + int lastColumn = mergedRegion.getLastColumn(); + try { + value = sheet.getRow(firstRow).getCell(firstColumn).getStringCellValue(); + } catch (Exception e) { + // TODO Auto-generated catch block + + value = String.valueOf(sheet.getRow(firstRow).getCell(firstColumn).getNumericCellValue()); + } + if(firstColumn!=lastColumn) { + hb = lastColumn-firstColumn; + } + } + if(columnIndex==1 && ("".equals(value)||value==null)) { + System.out.println("ȡ˿,˳ѭ"); + ok = 1; + break; + } + // Ԫֵ + rowList.add(value); + } + if (ok == 1) { + break; + } + rowList.add(""); + rowList.add(""); + int rowCountnum = table.getRowCount() * 10; + String valueOf = String.valueOf(rowCountnum); + rowList.add(valueOf); + + + //豸ֵ + if(shebeiMap.size() > 0) { + for (Map.Entry map : shebeiMap.entrySet()) { + if(map.getKey().equals(rowList.get(1))) { + rowList.set(3, map.getValue()); + } + } + }else { + rowList.set(3, ""); + } + System.out.println("excelе" + rowList.toString()); + map.addRow(); + for (int a = 0; a < table.getColumnCount(); a++) { + try { + table.setValueAt(rowList.get(a), table.getRowCount() - 1, a); + } catch (Exception e) { + // TODO Auto-generated catch block + table.setValueAt("", table.getRowCount() - 1, a); + } + } + processRows.add(table.getRowCount()-1); +// } + } + // رļ + fis.close(); + } catch (Exception e) { + MessageBox.post(rb.getString("excel_display.TITLE"), "", MessageBox.ERROR); + e.printStackTrace(); + } + //excelеݺ󣬽ȫֱisImpToExcelΪtrue + isImpToExcel = true; + } + 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(completeButton)) { + + if (processRows != null && processRows.size() > 0) { + if (isOwning) { + // this.disposeDialog(); + // Excel + try { + okEvent(true); + if(!"IMPORT TO EXCEL".equals(comp.getProperty("object_desc"))) { + SaveControlPlan saveControlPlan = new SaveControlPlan(session, meprocess, + app.getTargetComponent()); + saveControlPlan.insertData(); + } + this.tMomControlPlanBean = exchangeFormMsgToBean(this.form); + File file = null; + String outFileName = ""; +// if( ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision)app.getTargetComponent(), "TC_Attaches") != null) +// { +// String filePath = ExcelUtil07.downLoadFile(ExcelUtil07.getExcelToDataset(session, (TCComponentItemRevision)app.getTargetComponent(), "TC_Attaches"), "MSExcelX"); +// System.out.println(filePath); +// file = new File(filePath); +// //file = ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision)app.getTargetComponent(), "TC_Attaches"); +// } + // TODO Auto-generated method stub + switch (item.getType().toUpperCase()) { + case "RB3_SCKZJH": + if (file == null) { + file = TMomMethodUtil.getFile(session, "Ƽƻ", "MSExcelX"); + } + outFileName = "Ƽƻ"; + break; + case "RB3_SSCKZJH": + if (file == null) { + // Ƽƻ + file = TMomMethodUtil.getFile(session, "Ƽƻ", "MSExcelX"); + } + outFileName = "Ƽƻ"; + break; + case "RB3_YJKZJH": + if (file == null) { + file = TMomMethodUtil.getFile(session, "Ƽƻ", "MSExcelX"); + } + outFileName = "Ƽƻ"; + break; + default: + break; + } + if (file == null) { + MessageBox.post(rb.getString("wzdkzjhmb04_display.TITLE"), "", MessageBox.ERROR); + return; + } + // System.out.println(this.tMomControlPlanBean.toString()); + String outFilePath = System.getenv("TEMP") + "\\" + outFileName + ".xlsx"; + ExcelUtil07.writeControlPlanToExcel(this.tMomControlPlanBean, file, outFilePath); + if (ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision) itemRevision, + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + new File(outFilePath).delete(); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, outFileName, "TC_Attaches", + "MSExcelX", true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + this.dispose(); + } else { + try { + itemRevision.refresh(); + if (itemRevision.isCheckedOut()) { + MessageBox.post(rb.getString("kzjhbbyqc04_display.TITLE"), "", MessageBox.ERROR); + return; + } + InterfaceAIFComponent[] components = new InterfaceAIFComponent[meopId.size() + 1]; + components[0] = itemRevision; + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + for (int i = 1; i <= meopId.size(); i++) { + components[i] = itemType.find(meopId.get(i - 1)); + itemType.find(meopId.get(i - 1)).refresh(); + if (itemType.find(meopId.get(i - 1)).isCheckedOut()) { + MessageBox.post(rb.getString("gxyqc04_display.TITLE"), "", MessageBox.ERROR); + return; + } + } + NewProcessCommand command = new NewProcessCommand(AIFDesktop.getActiveDesktop(), + AIFDesktop.getActiveDesktop().getCurrentApplication(), components); + isComplete = true; + okEvent(true); + // this.disposeDialog(); + this.dispose(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + } else { + // MessageBox.post("ѷ!", "", MessageBox.ERROR); + try { + + File file = TMomMethodUtil.getFile(session, "Ƽƻ", "MSExcelX"); + if (file == null) { + MessageBox.post(rb.getString("wzdkzjhmb04_display.TITLE"), "", MessageBox.ERROR); + return; + } + String outFileName = "Ƽƻ"; + this.tMomControlPlanBean = exchangeFormMsgToBean(this.form); + // ѡ񵼳· + new selectExportPath(this.tMomControlPlanBean, file); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } else if (source.equals(refButton)) { + this.dispose(); + TMom004SetControlPlanCommand command = new TMom004SetControlPlanCommand(app, session, UID); + try { + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + //¼غ󣬽excelıǻԭ + try { + isImpToExcel = false; + itemRevision.setStringProperty("object_desc", ""); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else if (source.equals(testItem)) { + // д׼ + // ʿ + 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 { + // this.disposeDialog(); + this.dispose(); + + } + } + + private void okEvent(boolean isAutoSave) { + // TODO Auto-generated method stub + // ݱ浽 + try { + //ʱжǷǴexcelе + if(isImpToExcel !=null && isImpToExcel) { + itemRevision.setStringProperty("object_desc", "IMPORT TO EXCEL"); + } + if (table.getRowCount() != 0) { + if (table.getValueAt(0, 0) == "") { + MessageBox.post(rb.getString("czsw04_display.TITLE"), "", MessageBox.ERROR); + return; + } + } + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + } + // table.getDefaultEditor(Object.class).stopCellEditing(); + // TMomMethodUtil.setByPass(session, true); + // form.getTCProperty("rb3_hbdyg").setStringValueArray(setCombineMap()); + // form.getTCProperty("rb3_zhs").setIntValue(sumRow); + ControlPlanBean controlPlan = new ControlPlanBean(); + if (isOwning) { + System.out.println("ʼ"); + controlPlan.setKzjhbh(this.kzjhbhField.getText()); + System.out.println(this.kzjhbhField.getText()); + controlPlan.setZylxrdh(this.zylxrdhField.getText()); + System.out.println(this.zylxrdhField.getText()); + controlPlan.setBzriq(this.bzriqField.getText()); + System.out.println(this.bzriqField.getText()); + controlPlan.setXdrq(this.xdrqField.getText()); + System.out.println(this.xdrqField.getText()); + controlPlan.setSorhm(this.sorhmField.getText()); + System.out.println(this.sorhmField.getText()); + controlPlan.setLjh(this.ljhField.getText()); + System.out.println(this.ljhField.getText()); + controlPlan.setHxxz(this.hxxzField.getText()); + System.out.println(this.hxxzField.getText()); + controlPlan.setGkgcpz(this.gkgcpzField.getText()); + System.out.println(this.gkgcpzField.getText()); + controlPlan.setKhtzbh(this.khtzbhField.getText()); + System.out.println(this.khtzbhField.getText()); + controlPlan.setLjmc(this.ljmcField.getText()); + System.out.println(this.ljmcField.getText()); + controlPlan.setGfpzrq(this.gfpzrqField.getText()); + System.out.println(this.gfpzrqField.getText()); + controlPlan.setGkzlpz(this.gkzlpzField.getText()); + System.out.println(this.gkzlpzField.getText()); + controlPlan.setGfgc(this.gfgcField.getText()); + System.out.println(this.gfgcField.getText()); + controlPlan.setGfdh(this.gfdhField.getText()); + System.out.println(this.gfdhField.getText()); + controlPlan.setGkpz(this.gkpzField.getText()); + System.out.println(this.gkpzField.getText()); + controlPlan.setQtpz(this.qtpzField.getText()); + System.out.println(this.qtpzField.getText()); + controlPlan.setQtpzrq(this.qtpzrqField.getText()); + System.out.println(this.qtpzrqField.getText()); + }else { + System.out.println("isOwning:"+isOwning); + } + // ȡJTableе + List> dataValeList = getTableValue(); + for(List data:dataValeList) { + //data.forEach(System.out::println); + System.out.println(data.toString()); + } + TMom004SetControlPlanOperation operation = new TMom004SetControlPlanOperation(this.form, this.meprocess, + this.session, properties, controlPlan, dataValeList, deleteRows, plmeidList, isOwning, isAutoSave, + app.getTargetComponent(), UID); + operation.executeOperation(); + for (int j = 0; j < processRows.size(); j++) { + if (!plmeidList.contains(table.getValueAt(processRows.get(j), 0))) { + plmeidList.add(table.getValueAt(processRows.get(j), 0).toString()); + } + } + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + 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 void closePermission() { + if (isOwning) { + // رȨ޸ + if (((TCComponent) comp).isCheckedOut()) { + ReservationService service = ReservationService.getService((TCSession) app.getSession()); + service.checkin(new TCComponent[] { (TCComponent) this.comp });// ǩ + } + } + } + + private List> getTableValue() { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < processRows.size(); j++) { + List rowValue = new ArrayList(); + // 17 + for (int j2 = 0; j2 < this.map.getColumnCount() - 1; j2++) { +// if (isOwning) { +// if(j2==3) { + rowValue.add(getCellValue(processRows.get(j), j2)); +// rowValue.add(" ");//ĩ +// }else { +// rowValue.add(getCellValue(processRows.get(j), j2)); +// } +// } else { +// if(j2==3) { +// rowValue.add("0"); +// rowValue.add(" ");//ĩ +// }else { +// rowValue.add("0"); +// } +//// if (isComplete && table.getColumnName(j2).equals("Ƿ")) { +//// rowValue.add("0"); +//// } else { +//// rowValue.add(getCellValue(processRows.get(j), j2)); +//// } +// } + } + rowValue.add(processRows.get(j).toString());// 16к + // rowValue.add("1"); + if (combineMap.size() > 0) { + rowValue.add(TMomMethodUtil.getCombineCell(combineMap, processRows.get(j)));// 17ϲԪ + } else { + rowValue.add(""); + } + rowValue.add("");// 18кŲ + rowValue.add(item.getType().toUpperCase());// 19TYPE + 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 (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())); + } + } + if (this.map.getValueAt(row, cloumn) != null) { + resultValue = this.map.getValueAt(row, cloumn).toString(); + } + } else { + if (this.map.getValueAt(row, cloumn) != null) { + return this.map.getValueAt(row, cloumn).toString(); + } + } + return resultValue; + } + + 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 addImpRow(int index,int row) { + + // TODO Auto-generated method stub + 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(row + 1); + table.setValueAt(table.getValueAt(row, 1), row + 1, 1); + table.setValueAt(table.getValueAt(row, 2), row + 1, 2); + table.setValueAt(table.getValueAt(row, 3), row + 1, 3); + // table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), + // table.getSelectedRow() + 1, 4); + // table.setValueAt("0", table.getSelectedRow() + 1, table.getColumnCount() - + // 3); + if (table.getValueAt(row, 4) != null + && isStr2Num(table.getValueAt(row, 4).toString())) { + table.setValueAt(Integer.parseInt(table.getValueAt(row, 4).toString()) + index, + row + 1, 4); + } else { + table.setValueAt(0 + index, row + 1, 4); + } + table.setValueAt(table.getValueAt(row, table.getColumnCount() - 2), + row + 1, table.getColumnCount() - 2); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), row + 1, 0); + table.setValueAt(table.getValueAt(row, table.getColumnCount() - 1), + row + 1, table.getColumnCount() - 1); + this.processRows = map.getProcessRowList(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(map.getLabelRows()); + 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 addRow(int index) { + // TODO Auto-generated method stub + 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]; + 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(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++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 1), table.getSelectedRow() + 1, 1); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 2), table.getSelectedRow() + 1, 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); + // table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), + // table.getSelectedRow() + 1, 4); + // table.setValueAt("0", table.getSelectedRow() + 1, table.getColumnCount() - + // 3); + if (table.getValueAt(table.getSelectedRow(), 4) != null + && isStr2Num(table.getValueAt(table.getSelectedRow(), 4).toString())) { + table.setValueAt(Integer.parseInt(table.getValueAt(table.getSelectedRow(), 4).toString()) + index, + table.getSelectedRow() + 1, 4); + } else { + table.setValueAt(0 + index, table.getSelectedRow() + 1, 4); + } + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 2), + table.getSelectedRow() + 1, table.getColumnCount() - 2); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), + table.getSelectedRow() + 1, table.getColumnCount() - 1); + this.processRows = map.getProcessRowList(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(map.getLabelRows()); + 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(int index) { + // TODO Auto-generated method stub + 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]); + } + 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(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++) { + 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(), 1), table.getSelectedRow() + 1, 1); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 2), table.getSelectedRow() + 1, 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); + // table.setValueAt("0", table.getSelectedRow() + 1, table.getColumnCount() - + // 3); + if (table.getValueAt(table.getSelectedRow(), 4) != null + && isStr2Num(table.getValueAt(table.getSelectedRow(), 4).toString())) { + table.setValueAt(Integer.parseInt(table.getValueAt(table.getSelectedRow(), 4).toString()) + index, + table.getSelectedRow() + 1, 4); + } else { + table.setValueAt(0 + index, table.getSelectedRow() + 1, 4); + } + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 2), + table.getSelectedRow() + 1, table.getColumnCount() - 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount() - 1), + table.getSelectedRow() + 1, table.getColumnCount() - 1); + this.processRows = map.getProcessRowList(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(map.getLabelRows()); + 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(int row) { + // TODO Auto-generated method stub + 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]); + } + if (i < newKey.length) { + newKey[i] = entry.getKey()[i]; + } + } + it.remove(); + 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++) { + 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(row, 0) != null + && plmeidList.contains(map.getValueAt(row, 0))) { + deleteRows.add(map.getValueAt(row, 0).toString()); + } + map.removeRow(row); + // this.processRows = map.getProcessRowList(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(map.getLabelRows()); + 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 comBineCell() { + // TODO Auto-generated method stub + // table.setRowHeight(2, 50); + int[] rows = table.getSelectedRows(); + int[] columns = table.getSelectedColumns(); + if (rows.length <= 0) { + MessageBox.post(rb.getString("qxzyhbddyg04_display.TITLE"), "", 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(rb.getString("wqxhbdyg04_display.TITLE"), "", 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()); + 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(rb.getString("qxzycfddyg04_display.TITLE"), "", MessageBox.ERROR); + return; + } + if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(row))) { + MessageBox.post(rb.getString("wqxcfdyg04_display.TITLE"), "", MessageBox.ERROR); + return; + } + Map cellMap = new HashMap(); + 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(); + } + + /** + * FormеתΪbeanе + * + * @param revMasterForm + * @return + * @throws TCException + */ + public TMomControlPlanBean exchangeFormMsgToBean(TCComponent revMasterForm) throws TCException, Exception { + TMomControlPlanBean controlPlanBean = new TMomControlPlanBean(); + if (revMasterForm == null) { + return null; + } + String[] propNames = new String[] { "rb3_kzjhbh", // Ƽƻ + "rb3_zylxdh", // Ҫϵ˵绰 + "rb3_bzrq", // + "rb3_xdrq", // ޶ + "rb3_sor", // SOR/ + "rb3_ljhzzbb", // /հ汾 + "rb3_hxxz", // С + "rb3_gkgcpz", // ˿͹׼/ + "rb3_khtzbh", // ͻͼֽ + "rb3_ljmcms", // / + "rb3_gfgcpz", // /׼/ + "rb3_gkzlpz", // ˿׼/ + "rb3_gfgc", // / + "rb3_gfdh", // + "rb3_gkpz", // ˿׼/ + "rb3_qtpzrq1", // ׼/1 + "rb3_qtpzrq2" };// ׼/2; + // ȡԶ + TCProperty[] propValues = revMasterForm.getTCProperties(propNames); + if (propValues == null) {// || propValues.length != TMomControlPlanBean.PROP_COUNT + return null; + } + // õԵֵ + if (propValues[0] != null && propValues[0].getStringValue() != null) + controlPlanBean.setControlPlanNo(propValues[0].getStringValue()); + + // controlPlanBean.setKeyPersion(this.controlPlanBean.getZylxr());//Ҫϵ + + if (propValues[1] != null && propValues[1].getStringValue() != null) + controlPlanBean.setKeyPhone(propValues[1].getStringValue()); + + if (propValues[2] != null && propValues[2].getStringValue() != null) + controlPlanBean.setCreateDateStr(propValues[2].getStringValue()); + + if (propValues[3] != null && propValues[3].getStringValue() != null) + controlPlanBean.setUpdateDateStr(propValues[3].getStringValue()); + + if (propValues[4] != null && propValues[4].getStringValue() != null) + controlPlanBean.setSorName(propValues[4].getStringValue()); + + if (propValues[5] != null && propValues[5].getStringValue() != null) + controlPlanBean.setPartNumber(propValues[5].getStringValue()); + + if (propValues[6] != null && propValues[6].getStringValue() != null) + controlPlanBean.setCoreTeam(propValues[6].getStringValue()); + + if (propValues[7] != null && propValues[7].getStringValue() != null) + controlPlanBean.setCustromEngineeringApprovalDateStr(propValues[7].getStringValue()); + + if (propValues[8] != null && propValues[8].getStringValue() != null) + controlPlanBean.setCustromDrawingNumber(propValues[8].getStringValue()); + + if (propValues[9] != null && propValues[9].getStringValue() != null) + controlPlanBean.setPartNameDesc(propValues[9].getStringValue()); + + if (propValues[10] != null && propValues[10].getStringValue() != null) + controlPlanBean.setSupplierApprovalDateStr(propValues[10].getStringValue()); + + if (propValues[11] != null && propValues[11].getStringValue() != null) + controlPlanBean.setCustromQuantyApprovalDateStr(propValues[11].getStringValue()); + + if (propValues[12] != null && propValues[12].getStringValue() != null) + controlPlanBean.setSupplier(propValues[12].getStringValue()); + + if (propValues[13] != null && propValues[13].getStringValue() != null) + controlPlanBean.setSupplierCode(propValues[13].getStringValue()); + + if (propValues[14] != null && propValues[14].getStringValue() != null) + controlPlanBean.setCustromApprovalDateStr(propValues[14].getStringValue()); + + if (propValues[15] != null && propValues[15].getStringValue() != null) + controlPlanBean.setOtherApprovalDateStr(propValues[15].getStringValue()); + + if (propValues[16] != null && propValues[16].getStringValue() != null) + controlPlanBean.setOtherApprovalIfDateStr(propValues[16].getStringValue()); + +// if (propValues[0] != null && propValues[0].getStringValue() != null) +// controlPlanBean.setControlType(propValues[0].getStringValue()); +// controlPlanBean.setControlPlanNo(this.controlPlanBean.getKzjhbh()); +// if (propValues[2] != null && propValues[2].getStringValue() != null) +// controlPlanBean.setKeyPhone(propValues[2].getStringValue()); +// controlPlanBean.setCreateDateStr(this.controlPlanBean.getBzriq()); +// controlPlanBean.setUpdateDateStr(this.controlPlanBean.getXdrq());// 5 +// if (propValues[5] != null && propValues[5].getStringValue() != null) +// controlPlanBean.setSorName(propValues[5].getStringValue()); +// controlPlanBean.setPartNumber(this.controlPlanBean.getLjh()); +// if (propValues[7] != null && propValues[7].getStringValue() != null) +// controlPlanBean.setCoreTeam(propValues[7].getStringValue()); +// if (propValues[8] != null && propValues[8].getStringValue() != null) +// controlPlanBean.setCustromEngineeringApprovalDateStr(propValues[8] +// .getStringValue()); +// controlPlanBean.setCustromPartNumber(this.controlPlanBean.getKhtzbh());// 10 +// if (propValues[10] != null && propValues[10].getStringValue() != null) +// controlPlanBean.setPartNameDesc(propValues[10].getStringValue()); +// if (propValues[11] != null && propValues[11].getStringValue() != null) +// controlPlanBean.setSupplierApprovalDateStr(propValues[11] +// .getStringValue()); +// if (propValues[12] != null && propValues[12].getStringValue() != null) +// controlPlanBean.setCustromQuantyApprovalDateStr(propValues[12] +// .getStringValue()); +// if (propValues[13] != null && propValues[13].getStringValue() != null) +// controlPlanBean.setSupplier(propValues[13].getStringValue()); +// if (propValues[14] != null && propValues[14].getStringValue() != null) +// controlPlanBean.setSupplierCode(propValues[14].getStringValue());// 15 +// if (propValues[15] != null && propValues[15].getStringValue() != null) +// controlPlanBean.setMode(propValues[15].getStringValue()); +// if (propValues[16] != null && propValues[16].getStringValue() != null) +// controlPlanBean.setOtherApprovalDateStr(propValues[16] +// .getStringValue()); +// if (propValues[17] != null && propValues[17].getStringValue() != null) +// controlPlanBean.setOtherApprovalIfDateStr(propValues[17] +// .getStringValue()); +// controlPlanBean.setKeyPersion(this.controlPlanBean.getZylxr()); +// controlPlanBean.setPartNameDesc(this.ljmcField.getText()); +// if (propValues[38] != null && propValues[38].getStringValue() != null) +// controlPlanBean.setCustromApprovalDateStr(propValues[38] +// .getStringValue()); +// if (propValues[39] != null && propValues[39].getStringValue() != null) +// controlPlanBean.setChangeLev(propValues[39].getStringValue()); + + ResultSet rs = null; + try { + // Եֵ + SqlUtilT.getTCConnection(); + String sql = String.format( + "SELECT RB3_GYBH,RB3_GCMC,RB3_JQSB,RB3_SMJY,RB3_QPTBH,RB3_CC,RB3_NO,RB3_CP,RB3_GC,RB3_TSTX,RB3_CPGC,RB3_CLFF,RB3_RL,RB3_PL,RB3_FZR,RB3_KZFF,RB3_CZGF,RB3_FYJH,RB3_HBDYG,RB3_SPECIAL,RB3_CONCEAL,NO FROM RB3_CONTROLPLAN where processpuid = \'%s\' and type = \'%s\' and REVISIONUID=\'%s\' order by to_number(NO),to_number(RB3_HH)", + meprocess.getUid(), item.getType().toUpperCase(), UID); + System.out.println(sql); + rs = SqlUtilT.read(sql); + List simpleBeanList = new ArrayList<>(); + while (rs.next()) { + TMomControlPlanSimpleBean bean = new TMomControlPlanSimpleBean(); + bean.setPartProcessNumber(rs.getString("RB3_GYBH"));// ձ + bean.setProcessName(rs.getString("RB3_GCMC"));// + bean.setMachineDevice(rs.getString("RB3_JQSB"));// 豸 + bean.setSmjy(rs.getString("RB3_SMJY"));// ĩ + bean.setBubbledPrintNo(rs.getString("RB3_QPTBH"));// ͼ(ɾRB3_QPTBHڷŵDZࣨ򣩺) + bean.setNo(rs.getString("RB3_QPTBH"));// + bean.setSize(rs.getString("RB3_CC"));// 5 ߴ + bean.setProduct(rs.getString("RB3_CP"));// Ʒ + bean.setProcess(rs.getString("RB3_GC"));// + bean.setSpecialClass(rs.getString("RB3_TSTX"));// + bean.setProductProcessSpecificationTolerance(rs.getString("RB3_CPGC"));// 10 Ʒ๫ + bean.setEvaluationMeasurementTechnique(rs.getString("RB3_CLFF"));// + bean.setSampleSize(rs.getString("RB3_RL"));// Ʒ + bean.setSampleFreq(rs.getString("RB3_PL"));// 15 ƷƵ + bean.setResp(rs.getString("RB3_FZR"));// rs.getString("") + bean.setControlMethod(rs.getString("RB3_KZFF"));// Ʒ + bean.setOperationCriteria(rs.getString("RB3_CZGF"));// 淶 + bean.setReactionPlan(rs.getString("RB3_FYJH"));// Ӧƻ + bean.setHbdyg(rs.getString("RB3_HBDYG")); + bean.setSpecial(rs.getString("RB3_SPECIAL")); + bean.setConceal(rs.getString("RB3_CONCEAL")); + simpleBeanList.add(bean); + } + controlPlanBean.setSimpleBeanList(simpleBeanList); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } +// if (propValues[18] != null) { +// String[] strValues = propValues[18].getStringArrayValue(); +// if (strValues != null) { +// int valueCount = strValues.length; +// List simpleBeanList = new ArrayList<>(); +// for (int i = 0; i < valueCount; i++) { +// +// TMomControlPlanSimpleBean simpleBean = new TMomControlPlanSimpleBean(); +// simpleBeanList.add(simpleBean); +// } +// for (int i = 18; i < TMomControlPlanBean.PROP_COUNT_T; i++) { +// getSimpleBean(simpleBeanList, i, valueCount, propValues[i]); +// } +// controlPlanBean.setSimpleBeanList(simpleBeanList); +// } +// } + + return controlPlanBean; + } + + /** + * 鿴һַǷתΪ + * + * @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("....."); + // okEvent(true);//Զ + + } + }, 300 * 1000, 300 * 1000); + // ++++ +// final long timeInterval = 120000;// һ +// Runnable runnable = new Runnable() { +// public void run() { +// while (true) { +// // ------- code for task to run +// okEvent(); +// // ------- ends here +// try { +// Thread.sleep(timeInterval); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// } +// }; +// 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 TMomControlPlanBean tMomControlPlanBean; + private File file; + + public selectExportPath(TMomControlPlanBean tMomControlPlanBean, File file) { + this.tMomControlPlanBean = tMomControlPlanBean; + this.file = file; + 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:\\"));// ļѡijʼĿ¼Ϊ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("Ƽƻ"); + 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.fleName.getText() + ".xlsx"; + try { + ExcelUtil07.writeControlPlanToExcel(this.tMomControlPlanBean, file, outFilePath); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post(rb.getString("dcexcelcg04_display.TITLE"), "ɹ", 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()); + } + } + } + + + /** + * Ƽƻ + * + * @author Administrator + * + */ + private class LibraryDialog extends JFrame { + private List beans = new ArrayList(); + private int index = -1; + private TableRowSorter mainSorter; + // ؼ + private JPanel titlePanel;// + private JLabel titleLabel; + + private JTextPane selectCellValuePane; + // ѯ + private JTextField findLeftField; + private JButton findLeftButton; + // ѯ + private JTextField findMainField; + private JButton findMainButton; + // + private CTable leftTable; + private CTable mainTable; + // Ҽ˵ + private JPopupMenu libraryMenu; + // Ҽ˵ + private JMenuItem copyRowItem;// ƶ + + // ǩؼ + // private JTabbedPane tabbedPane; + + public LibraryDialog() { + // TODO Auto-generated constructor stub + super(); + getTreeBeanData(); + // getData(); + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("Ƽƻ"); + this.setPreferredSize(new Dimension(850, 600)); + // ʼⲿֿؼ + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("CONTROL PLAN/Ƽƻ"); + 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(""); + findLeftPanel.add("1.1.left.top", this.findLeftField); + findLeftPanel.add("1.2.left.top", this.findLeftButton); + this.leftTable = getNewjTable(null, null, leftHeader, beans.size()); + // + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.setRowHeight(30); + 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); + } + final TableRowSorter sorter = new TableRowSorter(this.leftTable.getModel()); + this.leftTable.setRowSorter(sorter); // ΪJTable + + 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) { + refreshTable(); + index = leftTable.getSelectedRow(); + } else if (index != -1 && index != leftTable.getSelectedRow()) { + refreshTable(); + index = leftTable.getSelectedRow(); + } + } + }); + JPanel findMainPanel = new JPanel(new PropertyLayout()); + this.findMainField = new JTextField(); + this.findMainField.setPreferredSize(new Dimension(100, 20)); + this.findMainButton = new JButton(""); + findMainPanel.add("1.1.left.top", this.findMainField); + findMainPanel.add("1.2.left.top", this.findMainButton); + this.mainTable = getNewjTable(null, null, header2, 0); + // + mainTable.HiddenCell(0); + mainTable.HiddenCell(header2.length - 1); + mainTable.HiddenCell(header2.length - 2); + mainTable.setRowHeight(40); + mainSorter = new TableRowSorter(this.mainTable.getModel()); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + + this.findMainButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (findMainField.getText().length() == 0) { + mainSorter.setRowFilter(null); + } else { + mainSorter.setRowFilter(RowFilter.regexFilter(findMainField.getText()));// ΪJTableûʽĹ + } + } + }); + // + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 2) { + if (table.getSelectedRow() >= 0) { + table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn()).stopCellEditing(); + for (int i = 1; i < mainTable.getColumnCount(); i++) { + if (i == mainTable.getColumnCount() - 2 || i == 1) { + continue; + } +// else if (i == mainTable.getColumnCount() - 1) { +// table.setValueAt(mainTable.getValueAt(mainTable.getSelectedRow(), i), +// table.getSelectedRow(), i + 2); +// } + else { + table.setValueAt(mainTable.getValueAt(mainTable.getSelectedRow(), i), + table.getSelectedRow(), i + 1); + } + } + } + } + if (mouseevent.getClickCount() == 1) { + if (mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) { + selectCellValuePane.setText(mainTable + .getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } else { + selectCellValuePane.setText(""); + } + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + libraryMenu.show(mainTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane = new JScrollPane(mainTable); + scrollPane.getVerticalScrollBar().setUnitIncrement(2); + JScrollPane scrollPane2 = new JScrollPane(leftTable); + scrollPane2.setPreferredSize(new Dimension(150, 600)); + scrollPane2.getVerticalScrollBar().setUnitIncrement(2); + + JSplitPane splitPane2 = new JSplitPane(); + splitPane2.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane2.setContinuousLayout(true);// ͷػͼ + splitPane2.setLeftComponent(scrollPane2); + splitPane2.setRightComponent(scrollPane); + // Ҽ˵ + libraryMenu = new JPopupMenu(); + // + copyRowItem = new JMenuItem("ƶ"); + copyRowItem.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable jtable = mainTable; + for (int i = 0; i < jtable.getSelectedRows().length; i++) { + if (table.getSelectedRow() >= 0) { + table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn()).stopCellEditing(); + for (int j = 1; j < jtable.getColumnCount(); j++) { + if (j == jtable.getColumnCount() - 2 || j == 1) { + continue; + } +// else if (j == jtable.getColumnCount() - 1) { +// table.setValueAt(jtable.getValueAt(jtable.getSelectedRows()[i], j), +// table.getSelectedRow() + i, j + 2); +// } + else { + table.setValueAt(jtable.getValueAt(jtable.getSelectedRows()[i], j), + table.getSelectedRow() + i, j + 1); + } + } + } + } + } +// } +// } + }); + libraryMenu.add(copyRowItem); + + selectCellValuePane = new JTextPane(); + selectCellValuePane.setPreferredSize(new Dimension(500, 40)); + + JPanel southPanel = new JPanel(new PropertyLayout()); + southPanel.add("1.1.left.top", findLeftPanel); + southPanel.add("1.2.left.top", new JScrollPane(selectCellValuePane)); + southPanel.add("1.3.left.top", findMainPanel); + + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane2, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + // this.add(new JScrollPane(selectCellValuePane), BorderLayout.SOUTH); + this.add(southPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + 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("RB3_JQSB")); + list.add(rs.getString("RB3_SMJY")); + list.add(rs.getString("RB3_QPTBH")); + // list.add(rs.getString("RB3_CC")); + // list.add(rs.getString("RB3_NO")); + list.add(rs.getString("RB3_CP")); + list.add(rs.getString("RB3_GC")); + list.add(rs.getString("RB3_TSTX")); + list.add(rs.getString("RB3_CPGC")); + list.add(rs.getString("RB3_CLFF")); + list.add(rs.getString("RB3_RL")); + list.add(rs.getString("RB3_PL")); + // list.add(rs.getString("RB3_FZR")); + list.add(rs.getString("RB3_KZFF")); + // list.add(rs.getString("RB3_CZGF")); + list.add(rs.getString("RB3_FYJH")); + // list.add(rs.getString("RB3_SJSJ")); + // list.add(rs.getString("RB3_GCSJ")); + // list.add(rs.getString("RB3_MJSJ")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("RB3_SPECIAL")); + rowList.add(list); + } + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(), header2.length); + map.setColumnIdentifiers(header2); + map.setEditable(true); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + 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); + } + } + } else { + CTMap map = new CTMap(1, header2.length); + map.setColumnIdentifiers(header2); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 2); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(header2.length - 1); + mainTable.HiddenCell(header2.length - 2); + 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 getTreeBeanData() { + // 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("TM2CONTROLPLANTREESELECT")); + // String sql = String.format("select * from RB3_CONTROLPLAN_TREE"); + 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(); + } + } + +// public void createTabbedPane(List beans) { +// this.tabbedPane = new JTabbedPane(); +// try { +// if (beans != null && beans.size() > 0) { +// for (int i = 0; i < beans.size(); i++) { +// ResultSet rs = null; +// // ѯȨ޿ +// String sql = String.format( +// pro.getProperty("CONTROLPLANLIBRARYSELECT"), +// beans.get(i).getId()); +// rs = SqlUtilT.read(sql); +// List> dataList = new ArrayList>(); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// rowList.add(rs.getString("RB3_QPTBH")); +// rowList.add(rs.getString("RB3_CC")); +// rowList.add(rs.getString("RB3_CP")); +// rowList.add(rs.getString("RB3_GC")); +// rowList.add(rs.getString("RB3_TSTX")); +// rowList.add(rs.getString("RB3_CPGC")); +// rowList.add(rs.getString("RB3_CLFF")); +// rowList.add(rs.getString("RB3_RL")); +// rowList.add(rs.getString("RB3_PL")); +// rowList.add(rs.getString("RB3_SJSJ")); +// rowList.add(rs.getString("RB3_GCSJ")); +// rowList.add(rs.getString("RB3_MJSJ")); +// rowList.add(rs.getString("RB3_FZR")); +// rowList.add(rs.getString("RB3_KZFF")); +// rowList.add(rs.getString("RB3_CZGF")); +// rowList.add(rs.getString("RB3_FYJH")); +// rowList.add(rs.getString("PARENT_ID")); +// rowList.add(rs.getString("RB3_SPECIAL")); +// dataList.add(rowList); +// } +// final CTable jtable; +// if (dataList.size() > 0) { +// jtable = getNewjTable(null, null, header2, +// dataList.size()); +// // ʾȾ +// TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); +// jtable.setDefaultRenderer(Object.class, renderer); +// for (int j = 0; j < dataList.size(); j++) { +// for (int k = 0; k < dataList.get(j).size(); k++) { +// jtable.setValueAt(dataList.get(j).get(k), +// j, k); +// } +// } +// } else { +// jtable = getNewjTable(null, null, header2, +// dataList.size() + 1); +// // ʾȾ +// TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); +// jtable.setDefaultRenderer(Object.class, renderer); +// jtable.setValueAt(beans.get(i).getId(), 0, +// jtable.getColumnCount() - 2); +// } +// // +// jtable.HiddenCell(0); +// jtable.HiddenCell(header2.length - 1); +// jtable.HiddenCell(header2.length - 2); +// jtable.setRowHeight(40); +// // Ӽ +// jtable.addMouseListener(new MouseAdapter() { +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 2) { +// if (table.getSelectedRow() >= 0) { +// table.getCellEditor( +// table.getSelectedRow(), +// table.getSelectedColumn()) +// .stopCellEditing(); +// for (int i = 1; i < jtable +// .getColumnCount(); i++) { +// if (i == jtable.getColumnCount() - 2) { +// continue; +// } else if (i == jtable +// .getColumnCount() - 1) { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 3); +// } else { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 4); +// } +// } +// } +// } +// if(mouseevent.getButton() == MouseEvent.BUTTON3) +// { +// libraryMenu.show(jtable, mouseevent.getX(), mouseevent.getY()); +// } +// } +// }); +// JScrollPane scrollPane = new JScrollPane(jtable); +// scrollPane.getVerticalScrollBar().setUnitIncrement(10); +// tabbedPane.add(beans.get(i).getName(), scrollPane); +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// SqlUtilT.free(); +// } +// } + } + + /** + * ʿ + * + * @author Administrator + * + */ + private class ThesaurusDialog extends JFrame { + + private List beans = new ArrayList(); + private int index = -1; + private TableRowSorter mainSorter; + // ؼ + private JPanel titlePanel;// + private JLabel titleLabel; + + private JButton other; + + // ѯ + private JTextPane selectCellValuePane; + private JButton findButton; + // + private CTable leftTable; + private CTable mainTable; + + public ThesaurusDialog() { + // TODO Auto-generated constructor stub + getTreeBeanData(); + // getData(); + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("ʿ"); + this.setPreferredSize(new Dimension(800, 600)); + // ʼⲿֿؼ + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("ʿ"); + this.titleLabel.setFont(new Font("", 1, 18)); + this.titlePanel.add(this.titleLabel); + + this.setAlwaysOnTop(true); + JPanel typePanel = new JPanel(); + other = new JButton(""); + other.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + String s = mainTable.getValueAt(mainTable.getSelectedRow(), 3).toString(); + String s2 = mainTable.getValueAt(mainTable.getSelectedRow(), 4).toString(); + AddStandard addStandard = new AddStandard(s, s2); + } + }); + // typePanel.add(other); + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + centerPanel.add(typePanel, BorderLayout.SOUTH); + this.leftTable = getNewjTable(null, null, leftHeader, beans.size()); + // + leftTable.HiddenCell(0); + leftTable.HiddenCell(3); + leftTable.setRowHeight(30); + leftTable.getColumnModel().getColumn(2).setPreferredWidth(200); + 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 + if (index == -1) { + refreshThesaurusTable(); + index = leftTable.getSelectedRow(); + } else if (index != -1 && index != leftTable.getSelectedRow()) { + refreshThesaurusTable(); + index = leftTable.getSelectedRow(); + } + } + }); + this.mainTable = getNewjTable(null, null, thesaurusHeader, 0); + // + mainTable.HiddenCell(0); + mainTable.HiddenCell(thesaurusHeader.length - 1); + mainTable.setRowHeight(20); + mainTable.getColumnModel().getColumn(2).setPreferredWidth(300); + mainSorter = new TableRowSorter(this.mainTable.getModel()); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + this.findButton = new JButton(""); + this.findButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (selectCellValuePane.getText().length() == 0) { + mainSorter.setRowFilter(null); + } else { + mainSorter.setRowFilter(RowFilter.regexFilter(selectCellValuePane.getText()));// ΪJTableûʽĹ + } + } + }); + // + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 2) { + if (table.getSelectedRow() >= 0) { + System.out.println(leftTable.getValueAt(leftTable.getSelectedRow(), 3)); + if (leftTable.getValueAt(leftTable.getSelectedRow(), 2).equals("")) { + int row = TMom004SetControlPlanDialog.table.getSelectedRow(); + int column = TMom004SetControlPlanDialog.table.getSelectedColumn(); + // λ + String columnName = TMom004SetControlPlanDialog.table + .getColumnName(TMom004SetControlPlanDialog.table.getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (TMom004SetControlPlanDialog.table + .getCellEditor(row, column))).getIndex(); + System.out.println("index+" + cursorIndex); + (TMom004SetControlPlanDialog.table.getCellEditor(row, column)).stopCellEditing(); + // TMom004SetControlPlanDialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder( + TMom004SetControlPlanDialog.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 = TMom004SetControlPlanDialog.table.getValueAt(row, + TMom004SetControlPlanDialog.table.getColumnCount() - 1); + System.out.println(sb.length()); + String s = sb.insert(cursorIndex, + mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) + .toString()) + .toString(); + TMom004SetControlPlanDialog.table.setValueAt(s, + TMom004SetControlPlanDialog.table.getSelectedRow(), + TMom004SetControlPlanDialog.table.getSelectedColumn()); + System.out + .println(TMom004SetControlPlanDialog.table.getValueAt(row, column).toString()); + } else { + table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn()) + .stopCellEditing(); + table.setValueAt(mainTable.getValueAt(mainTable.getSelectedRow(), 2), + table.getSelectedRow(), table.getSelectedColumn()); + } + } + } + if (mouseevent.getClickCount() == 1) { + ((CTMap) mainTable.getModel()).setRow(mainTable.getSelectedRow()); + ((CTMap) mainTable.getModel()).setRow(mainTable.getSelectedColumn()); + if (mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) { + selectCellValuePane.setText(mainTable + .getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } else { + selectCellValuePane.setText(""); + } + } + } + }); + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane = new JScrollPane(mainTable); + scrollPane.setPreferredSize(new Dimension(180, 600)); + scrollPane.getVerticalScrollBar().setUnitIncrement(2); + JScrollPane scrollPane2 = new JScrollPane(leftTable); + scrollPane2.setPreferredSize(new Dimension(300, 600)); + scrollPane2.getVerticalScrollBar().setUnitIncrement(2); + + JSplitPane splitPane2 = new JSplitPane(); + splitPane2.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane2.setContinuousLayout(true);// ͷػͼ + splitPane2.setLeftComponent(scrollPane2); + splitPane2.setRightComponent(scrollPane); + selectCellValuePane = new JTextPane(); + selectCellValuePane.setPreferredSize(new Dimension(325, 20)); + + JPanel southPanel = new JPanel(new PropertyLayout()); + southPanel.add("1.1.left.top", new JScrollPane(selectCellValuePane)); + southPanel.add("1.2.left.top", findButton); + + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane2, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + // this.add(new JScrollPane(selectCellValuePane), BorderLayout.SOUTH); + this.add(southPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /** + * ȡݿе + */ + private void getTreeBeanData() { + // 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("TM2THESAURUSTREESELECT")); + // String sql = String.format("select * from RB3_CONTROLPLAN_TREE"); + 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 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("RB3_VALUE")); + // list.add(rs.getString("RB3_VALUE2")); + // list.add(rs.getString("RB3_EXAMPLE")); + list.add(rs.getString("PARENT_ID")); + rowList.add(list); + } + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(), thesaurusHeader.length); + map.setColumnIdentifiers(thesaurusHeader); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2).setPreferredWidth(300); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + 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); + } + } + } + } else { + CTMap map = new CTMap(1, thesaurusHeader.length); + map.setColumnIdentifiers(thesaurusHeader); + map.setEditable(true); + mainTable.setModel(map); + mainTable.getColumnModel().getColumn(2).setPreferredWidth(300); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + map.setValueAt(leftTable.getValueAt(leftTable.getSelectedRow(), 1), 0, + mainTable.getColumnCount() - 1); + } + mainTable.HiddenCell(0); + mainTable.HiddenCell(thesaurusHeader.length - 1); + mainTable.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(); + } + } + + } + + private 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) { + super(); + this.source = source; + init(); + } + + private void init() { + this.panel = new JPanel(new PropertyLayout()); + this.label = new JLabel(""); + 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("ȷ"); + 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(rb.getString("qsrzqdsz04_display.TITLE"), "!", MessageBox.ERROR); + return; + } + for (int i1 = Integer.parseInt(textField.getText()); i1 > 0; i1--) { + addRow(i1); + } + this.disposeDialog(); + this.dispose(); + } else if (this.source.equals(addCombineRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post(rb.getString("qsrzqdsz04_display.TITLE"), "!", MessageBox.ERROR); + return; + } + for (int i1 = Integer.parseInt(textField.getText()); i1 > 0; i1--) { + addCombineRow(i1); + } + this.disposeDialog(); + this.dispose(); + } + } + + } + + /** + * ӱ׼ + * + */ + private class AddStandard extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; + private JPanel rootPanel; + private JLabel label1; + private JTextField textField1; + private JLabel label2; + private JTextField textField2; + private JLabel label3; + private JTextField textField3; + private JLabel label4; + private JTextField textField4; + private JLabel label5; + private JTextField textField5; + + private JLabel labelStandard1; + private JLabel labelStandard2; + private JLabel labelExample1; + private JLabel labelExample2; + private JButton button; + + private String standard;// ׼ + + private String example;// + + public AddStandard(String standard, String example) { + super(); + this.standard = standard; + this.example = example; + init(); + } + + private void init() { + this.panel = new JPanel(new PropertyLayout()); + + List resultList = TMomMethodUtil.getListByRegular(standard); + this.label1 = new JLabel(resultList.get(0)); + this.label2 = new JLabel(resultList.get(1)); + this.label3 = new JLabel(resultList.get(2)); + this.label4 = new JLabel(resultList.get(3)); + + this.textField1 = new JTextField(20); + this.textField2 = new JTextField(20); + this.textField3 = new JTextField(20); + this.textField4 = new JTextField(20); + + this.labelStandard1 = new JLabel("׼"); + this.labelStandard2 = new JLabel(this.standard); + + this.labelExample1 = new JLabel("׼"); + this.labelExample2 = new JLabel(example); + + this.panel.add("1.1.left.top", label1); + this.panel.add("1.2.left.top", textField1); + + this.panel.add("2.1.left.top", label2); + this.panel.add("2.2.left.top", textField2); + + this.panel.add("3.1.left.top", label3); + this.panel.add("3.2.left.top", textField3); + + this.panel.add("4.1.left.top", label4); + this.panel.add("4.2.left.top", textField4); + + this.panel.add("5.1.left.top", labelStandard1); + this.panel.add("5.2.left.top", labelStandard2); + + this.panel.add("5.3.left.top", labelExample1); + this.panel.add("5.4.left.top", labelExample2); + + this.button = new JButton("ȷ"); + this.button.addActionListener(this); + + this.rootPanel = new JPanel(new BorderLayout()); + + this.rootPanel.add(button); + + this.add(this.panel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + 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.label1.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label1.getText() + "]", this.textField1.getText()); + } + if (!this.label2.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label2.getText() + "]", this.textField2.getText()); + } + if (!this.label3.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label3.getText() + "]", this.textField3.getText()); + } + if (!this.label4.getText().isEmpty()) { + this.standard = this.standard.replace("[" + this.label4.getText() + "]", this.textField4.getText()); + } + table.setValueAt(this.standard, table.getSelectedRow(), table.getSelectedColumn()); + } + + } + + private class AddMeopDialog extends AbstractAIFDialog implements ActionListener { + + private JPanel panel; +// private JLabel meopIDLabel; +// private JTextField meopIDTextField; + private JLabel idLabel; + private JTextField idTextField; + private JLabel nameLabel; + private JTextPane nameTextField; + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + + private Object source; + + public AddMeopDialog(Object source) { + // TODO Auto-generated constructor stub + super(); + this.source = source; + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.panel = new JPanel(new PropertyLayout()); +// this.meopIDLabel = new JLabel("ID"); +// this.meopIDTextField = new JTextField(); +// this.idTextField.setPreferredSize(new Dimension(200,50)); + this.idLabel = new JLabel("/ձ"); + this.idTextField = new JTextField(); + this.idTextField.setPreferredSize(new Dimension(200, 20)); + this.nameLabel = new JLabel(""); + this.nameTextField = new JTextPane(); + this.nameTextField.setPreferredSize(new Dimension(200, 50)); +// this.panel.add("1.1.left.top", meopIDLabel); +// this.panel.add("1.2.left.top", meopIDTextField); + this.panel.add("1.1.left.top", idLabel); + this.panel.add("1.2.left.top", idTextField); + this.panel.add("2.1.left.top", nameLabel); + this.panel.add("2.2.left.top", nameTextField); + + this.rootPanel = new JPanel(); + this.okButton = new JButton("ȷ"); + this.okButton.addActionListener(this); + this.celButton = new JButton("ȡ"); + this.celButton.addActionListener(this); + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + + this.add(this.panel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if (source.equals(this.okButton)) { + if (!isStr2Num(this.idTextField.getText())) { + MessageBox.post(rb.getString("qsrzqdsz04_display.TITLE"), "!", MessageBox.ERROR); + return; + } + if (this.nameTextField.getText() == null || this.nameTextField.getText().equals("")) { + MessageBox.post(rb.getString("qsrgcmc04_display.TITLE"), "!", MessageBox.ERROR); + return; + } +// if(this.meopIDTextField.getText() == null || this.meopIDTextField.getText().equals("")) +// { +// MessageBox.post("빤ID!", "!", 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 ]; +// 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(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++) { + newKey[i] = entry.getKey()[i] + 1; + } + it.remove(); + cellMap.put(newKey, entry.getValue()); + } + } + if (Integer.parseInt(table.getValueAt(table.getSelectedRow(), 1).toString()) > Integer + .parseInt(this.idTextField.getText())) { + map.insertRow(table.getSelectedRow()); + table.setValueAt(this.idTextField.getText(), table.getSelectedRow(), 1); + table.setValueAt(this.nameTextField.getText(), table.getSelectedRow(), 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow(), 3); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 4), table.getSelectedRow(), 4); + // table.setValueAt(table.getValueAt(table.getSelectedRow(), + // table.getColumnCount()-1), table.getSelectedRow() - 1, + // table.getColumnCount()-1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow(), 0); + } else { + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(this.idTextField.getText(), table.getSelectedRow() + 1, 1); + table.setValueAt(this.nameTextField.getText(), table.getSelectedRow() + 1, 2); + table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); + 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); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + } + processRows = map.getProcessRowList(); + renderer.setProcessRows(processRows); + renderer.setLabelRows(map.getLabelRows()); + 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(); + this.disposeDialog(); + this.dispose(); + } else if (source.equals(this.celButton)) { + this.dispose(); + this.disposeDialog(); + } + } + + } + +} + +//++++ +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/renben/process/plm/tmom004/TMom004SetControlPlanHandler.java b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanHandler.java new file mode 100644 index 0000000..d82e962 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanHandler.java @@ -0,0 +1,61 @@ +package com.connor.renben.process.plm.tmom004; + +import java.sql.ResultSet; + +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.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentRole; +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; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom004SetControlPlanHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if(app.getTargetComponent()==null + ||!(app.getTargetComponent() instanceof TCComponentItemRevision) + ||!(app.getTargetComponent().getType().toUpperCase().indexOf("KZJH") >= 0)) { + MessageBox.post("δѡпƼƻ汾ѡ", "", MessageBox.ERROR); + return null; + } + String UID; + UID=app.getTargetComponent().getUid(); + TMom004SetControlPlanCommand command = new TMom004SetControlPlanCommand( + app, session,UID); + if(UID==null) { + MessageBox.post("ѡ", "", MessageBox.ERROR); + + return null; + } + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("дƼƻʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanOperation.java b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanOperation.java new file mode 100644 index 0000000..43e4dd8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TMom004SetControlPlanOperation.java @@ -0,0 +1,252 @@ +package com.connor.renben.process.plm.tmom004; + +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + + +import com.connor.renben.process.plm.bean.ControlPlanBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +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 TMom004SetControlPlanOperation extends AbstractAIFOperation { + private TCProperty[] properties; + private ControlPlanBean controlPlan; + private InterfaceAIFComponent comp; + private List> dataValueList; + private TCSession session; + private TCComponent form; + private TCComponent meprocess; + private List deleteRows; + private List plmeidList; + private boolean isOwning; + private boolean isAutoSave; + private boolean isNotStandard; + private String UID; + private ProgressBarThread wait; + + public TMom004SetControlPlanOperation(TCComponent form, TCComponent meprocess, TCSession session, + TCProperty[] properties, ControlPlanBean controlPlan, List> dataValueList, + List deleteRows, List plmeidList, boolean isOwning, boolean isAutoSave, + InterfaceAIFComponent comp,String UID) { + this.form = form; + this.meprocess = meprocess; + this.session = session; + this.properties = properties; + this.controlPlan = controlPlan; + this.dataValueList = dataValueList; + this.deleteRows = deleteRows; + this.plmeidList = plmeidList; + this.isOwning = isOwning; + this.isAutoSave = isAutoSave; + this.comp=comp; + this.UID=UID; + } + + @Override + public void executeOperation() throws Exception { + //+++ӽ + wait = new ProgressBarThread("","ڱ..."); + wait.start(); + //+++ + Connection connection = null; + PreparedStatement pstmtUpdate = null; + PreparedStatement pstmtInsert = null; + PreparedStatement pstmtDelete = null; + ResultSet rs = null; + InputStream input = null; + try { + if (isOwning) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.controlPlan.getKzjhbh()); + this.properties[1].setStringValue(this.controlPlan.getZylxrdh()); + this.properties[2].setStringValue(this.controlPlan.getBzriq()); + this.properties[3].setStringValue(this.controlPlan.getXdrq()); + this.properties[4].setStringValue(this.controlPlan.getSorhm()); + this.properties[5].setStringValue(this.controlPlan.getLjh()); + this.properties[6].setStringValue(this.controlPlan.getHxxz()); + this.properties[7].setStringValue(this.controlPlan.getGkgcpz()); + this.properties[8].setStringValue(this.controlPlan.getKhtzbh()); + this.properties[9].setStringValue(this.controlPlan.getLjmc()); + this.properties[10].setStringValue(this.controlPlan.getGfpzrq()); + this.properties[11].setStringValue(this.controlPlan.getGkzlpz()); + this.properties[12].setStringValue(this.controlPlan.getGfgc()); + this.properties[13].setStringValue(this.controlPlan.getGfdh()); + this.properties[14].setStringValue(this.controlPlan.getGkpz()); + this.properties[15].setStringValue(this.controlPlan.getQtpz()); + this.properties[16].setStringValue(this.controlPlan.getQtpzrq()); + this.form.save(); + this.form.unlock(); + this.form.refresh(); + + } + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ȡݿ + connection = SqlUtilT.getTCConnection(); + connection.setAutoCommit(false); + + // ѯźID + String selectSQL = String.format(pro.getProperty("CONTROLPLANOPERATIONSELECT"), meprocess.getUid()); + rs = SqlUtilT.read(selectSQL); + Map itemIdMap = new HashMap(); + while (rs.next()) { + itemIdMap.put(rs.getString("rb3_gybh"), rs.getString("RB3_MEOPID")); + } + + // ɾ + String deleteSQL = pro.getProperty("CONTROLPLANDELETE").replace("'%s'", "?"); // ַƴӸΪѯ + pstmtDelete = connection.prepareStatement(deleteSQL); + System.out.print(deleteSQL); + System.out.print(deleteRows); + for (String deleteRow : deleteRows) { + pstmtDelete.setString(1, deleteRow); + System.out.print("-----------------------------tesdt"); + System.out.print(pstmtDelete); + pstmtDelete.addBatch(); + } + pstmtDelete.executeBatch(); + + // ׼ºͲ + String updateSQL = pro.getProperty("CONTROLPLANUPDATE") + .replace("'%s'", "?") // ַƴӸΪѯ + .replace("'%s'", "?"); + String insertSQL = pro.getProperty("INSERTSQL"); + + pstmtUpdate = connection.prepareStatement(updateSQL); + pstmtInsert = connection.prepareStatement(insertSQL); + + // + for (List rowList : dataValueList) { + if (rowList.get(0) != null && !rowList.get(0).isEmpty()) { + if (plmeidList.contains(rowList.get(0))) { + // + setUpdateParameters(pstmtUpdate, rowList, UID); + pstmtUpdate.addBatch(); + } else { + // + setInsertParameters(pstmtInsert, rowList, meprocess, itemIdMap, UID); + pstmtInsert.addBatch(); + } + } + } + + // ִ + pstmtUpdate.executeBatch(); + pstmtInsert.executeBatch(); + + // ύ + connection.commit(); + wait.setBool(true); + wait.interrupt(); + } catch (Exception e) { + // ع + if (connection != null) { + try { + connection.rollback(); + } catch (SQLException ex) { + ex.printStackTrace(); + } + } + MessageBox.post(e.toString(), "", MessageBox.ERROR); + throw e; + } finally { + // رԴ + if (rs != null) SqlUtilT.free(rs); + if (pstmtUpdate != null) pstmtUpdate.close(); + if (pstmtInsert != null) pstmtInsert.close(); + if (pstmtDelete != null) pstmtDelete.close(); + if (input != null) input.close(); + if (connection != null) { + try { + connection.setAutoCommit(true); // ָԶύģʽ + SqlUtilT.freeAll(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + + private void setUpdateParameters(PreparedStatement pstmt, List rowList, String UID) throws SQLException { + // ø² + pstmt.setString(1, rowList.get(1)); // RB3_GYBH + pstmt.setString(2, rowList.get(2)); // RB3_GCMC + pstmt.setString(3, rowList.get(3)); // RB3_JQSB + pstmt.setString(4, rowList.get(4)); // RB3_QPTBH + pstmt.setString(5, rowList.get(5)); // RB3_CP + pstmt.setString(6, rowList.get(6)); // RB3_GC + pstmt.setString(7, rowList.get(7)); // RB3_TSTX + pstmt.setString(8, rowList.get(8)); // RB3_CPGC + pstmt.setString(9, rowList.get(9)); // RB3_CLFF + pstmt.setString(10, rowList.get(10)); // RB3_RL + pstmt.setString(11, rowList.get(11)); // RB3_PL + pstmt.setString(12, rowList.get(12)); // RB3_KZFF + pstmt.setString(13, rowList.get(13)); // RB3_FYJH + pstmt.setString(14, rowList.get(16)); // RB3_HH + pstmt.setString(15, rowList.get(17)); // RB3_HBDYG + pstmt.setString(16, rowList.get(0)); // plmeid + pstmt.setString(17, UID); // revisionuid + } + + private void setInsertParameters(PreparedStatement pstmt, List rowList, + TCComponent meprocess, Map itemIdMap, + String UID) throws SQLException { + // ò + pstmt.setString(1, rowList.get(0)); + pstmt.setString(2, meprocess.getUid()); + pstmt.setString(3, itemIdMap.get(rowList.get(1))); + pstmt.setString(4, rowList.get(1)); + pstmt.setString(5, rowList.get(2)); + pstmt.setString(6, rowList.get(3)); + pstmt.setString(7, ""); + pstmt.setString(8, rowList.get(4)); + pstmt.setString(9, ""); + pstmt.setString(10, rowList.get(5)); + pstmt.setString(11, rowList.get(6)); + pstmt.setString(12, rowList.get(7)); + pstmt.setString(13, rowList.get(8)); + pstmt.setString(14, rowList.get(9)); + pstmt.setString(15, rowList.get(10)); + pstmt.setString(16, rowList.get(11)); + pstmt.setString(17, ""); + pstmt.setString(18, ""); + pstmt.setString(19, ""); + pstmt.setString(20, ""); + pstmt.setString(21, rowList.get(12)); + pstmt.setString(22, ""); + pstmt.setString(23, rowList.get(13)); + pstmt.setString(24, rowList.get(16)); + pstmt.setString(25, rowList.get(17)); + pstmt.setString(26, ""); + pstmt.setString(27, rowList.get(18)); + pstmt.setString(28, ""); + pstmt.setString(29, rowList.get(19)); + pstmt.setString(30, ""); + pstmt.setString(31, ""); + pstmt.setString(32, ""); + pstmt.setString(33, ""); + pstmt.setString(34, UID); + pstmt.setString(35, rowList.get(rowList.size()-1)); + } +} + + + diff --git a/src/com/connor/renben/process/plm/tmom004/TableCellCheckboxRenderer.java b/src/com/connor/renben/process/plm/tmom004/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..dd3398c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TableCellCheckboxRenderer.java @@ -0,0 +1,121 @@ +package com.connor.renben.process.plm.tmom004; + +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.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 CTMap tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(""); + // 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("")) { + 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 +// if(value != null) +// { +// String valueStr = (boolean)value ? "true" : "false"; +// //System.out.println(valueStr); +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected((boolean)value); +// } +// else +// { +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected(false); +// } +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ + 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/tmom004/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/tmom004/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..26a914a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TableCellTextAreaRenderer.java @@ -0,0 +1,220 @@ +package com.connor.renben.process.plm.tmom004; + +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ַֿ˳ʹDocumentinsertString + 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/renben/process/plm/tmom004/TableCellTextAreaRenderer2.java b/src/com/connor/renben/process/plm/tmom004/TableCellTextAreaRenderer2.java new file mode 100644 index 0000000..cb0a2c6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TableCellTextAreaRenderer2.java @@ -0,0 +1,203 @@ +package com.connor.renben.process.plm.tmom004; + +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, 5) == null ? "0" : table + .getValueAt(row, 5).toString(); + String pds = table.getValueAt(row, 9) == null ? "0" : table + .getValueAt(row, 9).toString(); + String tcd = table.getValueAt(row, 11) == null ? "0" : table + .getValueAt(row, 11).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 (row > 0 && table.getColumnName(column).equals("RPN") + && value != null && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } +// else if (row == table.getSelectedRow()) { +// setBackground(Color.GRAY); +// 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ַֿ˳ʹDocumentinsertString + 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/renben/process/plm/tmom004/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/tmom004/TextAreaCellEditor.java new file mode 100644 index 0000000..8fdb24c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom004/TextAreaCellEditor.java @@ -0,0 +1,193 @@ +package com.connor.renben.process.plm.tmom004; + +import java.awt.Component; +import java.util.EventObject; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +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.classClass󣩣 + // ŵһCellEditorListenerʵ + listener = (CellEditorListener) listeners[i + 1]; + // changeEventȥ֪ͨ༭Ѿ༭ + // editingStoppedУJTablegetCellEditorValue()ȡصԪֵ + // Ұֵݸ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ַֿ˳ʹDocumentinsertString + 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/tmom005/TMom005CreateOPByModuleCommand.java b/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleCommand.java new file mode 100644 index 0000000..692236e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleCommand.java @@ -0,0 +1,69 @@ +package com.connor.renben.process.plm.tmom005; + +import com.connor.renben.process.plm.util.DDInClassDialog; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom005CreateOPByModuleCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private String commandId; + + public TMom005CreateOPByModuleCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + this.app = app; + this.session = session; + this.commandId = commandId; + } + + @Override + public void executeModal() throws Exception { + final InterfaceAIFComponent targetComponent = app.getTargetComponent(); +// if (targetComponent.getType().indexOf("MEProcess") < 0) { +// MessageBox.post("ѡն", "", MessageBox.ERROR); +// return; +// } +// if (!(targetComponent instanceof TCComponentItem)) { +// MessageBox.post("ѡйն", "", MessageBox.ERROR); +// return; +// } +// if (targetComponent instanceof TCComponentBOMLine) { +// if (targetComponent.getProperty("object_type").indexOf("MEProcess") >= 0) { +// MessageBox.post("ڽṹѡйBOM󴴽", "", MessageBox.ERROR); +// return; +// } +// } +// else +// { +// MessageBox.post("ڽṹѡйBOM󴴽", "", MessageBox.ERROR); +// return; +// } + +// Activator.getDefault().openPerspective( +// "com.teamcenter.rac.pse.PSEPerspective"); +// Activator.getDefault().openComponents( +// "com.teamcenter.rac.pse.PSEPerspective", +// new InterfaceAIFComponent[] { targetComponent }); + final AbstractAIFUIApplication localAbstractAIFUIApplication = AIFDesktop + .getActiveDesktop().getCurrentApplication(); + new Thread() { + @Override + public void run() { + DDInClassDialog localDDInClassDialog = new DDInClassDialog( + localAbstractAIFUIApplication, targetComponent, 2, + commandId); + localDDInClassDialog.setVisible(true); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleHandler.java b/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleHandler.java new file mode 100644 index 0000000..b296c39 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleHandler.java @@ -0,0 +1,57 @@ +package com.connor.renben.process.plm.tmom005; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom005CreateOPByModuleHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(targetComponent==null) { + MessageBox.post(rb.getString("wxzdx05_display.TITLE"), "", MessageBox.ERROR); + }else { + if(!(targetComponent instanceof TCComponentBOMLine)) { + MessageBox.post(rb.getString("xzgyBOM05_display.TITLE"), "", MessageBox.ERROR); + }else { + try { + if(((TCComponentBOMLine)targetComponent).getItem().getStringProperty("object_type").equals("MEProcess")) { + TMom005CreateOPByModuleCommand command = new TMom005CreateOPByModuleCommand( + app, session, commandId); + command.executeModal(); + }else { + MessageBox.post(rb.getString("qxzgyBOMhcj05_display.TITLE"), "", MessageBox.ERROR); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + } + + + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleOperation.java b/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleOperation.java new file mode 100644 index 0000000..d5dcc13 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom005/TMom005CreateOPByModuleOperation.java @@ -0,0 +1,252 @@ +package com.connor.renben.process.plm.tmom005; + +import java.awt.print.Printable; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Date; +import java.util.Locale; +import java.util.ResourceBundle; + +import com.connor.renben.process.plm.tmom002.TMom002AbtractDialog; +import com.connor.renben.process.plm.util.SavePermissions; +import com.connor.renben.process.plm.util.ServiceUtil; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom005CreateOPByModuleOperation extends AbstractAIFOperation { + private InterfaceAIFComponent targets;// ѡж + private String selectItems;// ѡ + private TCSession session; + + public TMom005CreateOPByModuleOperation(TCSession session, + InterfaceAIFComponent targets, String selectItems) { + this.session = session; + this.targets = targets; + this.selectItems = selectItems; + } + + @Override + public void executeOperation() throws Exception { + System.out.println(new Date() + "============ʼִ"); + ArrayList itemlists = new ArrayList(); + TCComponentItem item = null; + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (this.targets instanceof TCComponentBOMLine) { + item = ((TCComponentBOMLine) this.targets).getItem(); + } + // ȡItemId + String[] itemID = null; + if (selectItems.indexOf(" | ") > -1) { + //itemID = selectItems.split(" | "); + MessageBox.post(rb.getString("znxzyggx05_display.TITLE"),"",MessageBox.ERROR); + return; + } else { + itemID = new String[] { selectItems }; + // + } + // ȡѡеĶ + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItemType gxType = (TCComponentItemType) session + .getTypeComponent("MEOP"); + String classID=""; + if (itemID != null && itemID.length > 0) { + for (int i = 0; i < itemID.length; i++) { + TCComponentItem childrenItem = itemType.find(itemID[i] + .substring(0, itemID[i].length() - 1)); + //ͨString͵ϺźͶҶ+++ + if (itemID[i].indexOf("/") >= 0) { + childrenItem = itemType.find(itemID[i].split("/")[0]); + classID=(childrenItem.getLatestItemRevision()).getClassificationClass(); + } + if (!childrenItem.getType().equals("MEOP")) { + MessageBox.post(rb.getString("qxzgxdx05_display.TITLE"), "", MessageBox.ERROR); + return; + } + TCComponent[] mepComponents = item.getLatestItemRevision() + .getRelatedComponents("ps_children"); + int mepCount = 0; + for (int j = 0; j < mepComponents.length; j++) { + if (mepComponents[j].getType().indexOf("MEOP") >= 0) { + mepCount++; + } + } + TCComponentItem newItem = saveAsItem(item, mepCount + 1, + childrenItem); + // BOM + TCComponent[] childrenComponents = newItem + .getLatestItemRevision().getRelatedComponents( + "ps_children"); + if (childrenComponents.length > 0) { + ArrayList childrenItemlists = new ArrayList(); + for (int k = 0; k < childrenComponents.length; k++) { + if (childrenComponents[k].getStringProperty( + "object_type").indexOf("mould") < 0) { + if (childrenComponents[k] instanceof TCComponentItemRevision) { + childrenItemlists + .add(((TCComponentItemRevision) childrenComponents[k]) + .getItem()); + } + } + } + if (newItem != null && childrenItemlists != null + && childrenItemlists.size() > 0) { + recreateBom(newItem, childrenItemlists, true,classID); + } + } + // µĹװ + TCComponent[] gzComponents = newItem.getLatestItemRevision() + .getRelatedComponents("RB3_gongzhuang"); + if (gzComponents.length > 0) { + newItem.getLatestItemRevision().remove("RB3_gongzhuang", + gzComponents); + } + itemlists.add(newItem); + } + } + if (item != null && itemlists != null && itemlists.size() > 0) { + + recreateBom(item, itemlists, false,classID); + + MessageBox.post(rb.getString("gjmbcjgxcg05_display.TITLE"), "ɹ", MessageBox.WARNING); + } + } + + /** + * Ϊ + * + * @param item + */ + public TCComponentItem saveAsItem(TCComponentItem processItem, + int itemCount, TCComponentItem item) { + TCComponentItem newItem = null; + try { + String itemID = ""; + if (item.getType().equals("MEOP")) { + itemID = TMomMethodUtil.getRuleItemID(session, + processItem.getStringProperty("item_id"), null, + TMomFinalUtil.GX_CODE); + } else { + itemID = item.getTypeComponent().getNewID(); + } + String name = item.getProperty("object_name"); + newItem = saveItemByJar(itemID,name,item,item.getLatestItemRevision().getStringProperty("item_revision_id")); + TCComponent[] datas = item + .getReferenceListProperty("IMAN_reference"); + if (datas.length > 0) { + newItem.remove("IMAN_reference", datas); + } + for (int j = 0; j < datas.length; j++) { + if (datas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) datas[j]; + TCComponentItemRevision latestItemRevision = dataItem.getLatestItemRevision(); + String revId = latestItemRevision.getStringProperty("item_revision_id"); + String objName = latestItemRevision.getProperty("object_name"); + TCComponentItem newDataItem = dataItem + .getLatestItemRevision().saveAsItem( + dataItem.getTypeComponent().getNewID(), + revId); + newItem.add("IMAN_reference", newDataItem); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + public TCComponentItem saveItemByJar(String itemId,String itemName,TCComponentItem item,String revId) { + try { + TCPreferenceService preService = session.getPreferenceService(); + TCComponentUser user = session.getUser(); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + String userUid = user.getUid(); + String groupUid = group.getUid(); + ServiceUtil.sendRequest(itemId,itemName,item.getLatestItemRevision().getUid(),revId,"","","",userUid,groupUid,"uid"); + + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent(item.getType()); + TCComponentItem itemNew = ccomponentitemtype.find(itemId); + System.out.println(itemNew); + return itemNew; + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem item, + ArrayList itemlists, boolean isDelete,String classID) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + //+++++ + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + //Ѱӵbomline + String[] itemflagString= n_item.toString().split("-"); + String[] bomflagString= children.toString().split("/"); + + if(itemflagString[0].equals(bomflagString[0])) { + //ȡIDǰ桰BZGXֶβҪ + ((TCComponentBOMLine) children.getComponent()).setStringProperty("RB3_GXH", + classID.substring(classID.indexOf("X")+1,classID.length())); + } + } + //++++++ + } + bomWindow.unlock(); + bomWindow.save(); + //+++򱣴浽permissionsݿ + SavePermissions permissions = new SavePermissions(session, topline.getItem()); + + permissions.insertData(); + //+++ + } + +} diff --git a/src/com/connor/renben/process/plm/tmom006/BomImportBean.java b/src/com/connor/renben/process/plm/tmom006/BomImportBean.java new file mode 100644 index 0000000..934de7c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/BomImportBean.java @@ -0,0 +1,89 @@ +package com.connor.renben.process.plm.tmom006; + +import java.util.HashMap; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +/** + * @ClassName: BomImportBean + * @Description: TODO(һ仰) + * @author admin + * @date 20241125 + * + */ +public class BomImportBean { + private TCComponentItem item; + + private TCComponentItemRevision itemRevision; + + private Map itemProperties = new HashMap(); + + private Map revProperties = new HashMap(); + + private Map itemFromProperties = new HashMap(); + + private Map revFromProperties = new HashMap(); + + private Map bomProperties = new HashMap(); + + public TCComponentItem getItem() { + return item; + } + + public void setItem(TCComponentItem item) { + this.item = item; + } + + public TCComponentItemRevision getItemRevision() { + return itemRevision; + } + + public void setItemRevision(TCComponentItemRevision itemRevision) { + this.itemRevision = itemRevision; + } + + public Map getItemProperties() { + return itemProperties; + } + + public void setItemProperties(Map itemProperties) { + this.itemProperties = itemProperties; + } + + public Map getRevProperties() { + return revProperties; + } + + public void setRevProperties(Map revProperties) { + this.revProperties = revProperties; + } + + public Map getItemFromProperties() { + return itemFromProperties; + } + + public void setItemFromProperties(Map itemFromProperties) { + this.itemFromProperties = itemFromProperties; + } + + public Map getRevFromProperties() { + return revFromProperties; + } + + public void setRevFromProperties(Map revFromProperties) { + this.revFromProperties = revFromProperties; + } + + public Map getBomProperties() { + return bomProperties; + } + + public void setBomProperties(Map bomProperties) { + this.bomProperties = bomProperties; + } + + +} + diff --git a/src/com/connor/renben/process/plm/tmom006/CopyOfTMom006CreateProcessByModuleOperation.java b/src/com/connor/renben/process/plm/tmom006/CopyOfTMom006CreateProcessByModuleOperation.java new file mode 100644 index 0000000..63d0175 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/CopyOfTMom006CreateProcessByModuleOperation.java @@ -0,0 +1,673 @@ +package com.connor.renben.process.plm.tmom006; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.TreeMap; +import java.util.UUID; + +import com.connor.renben.process.plm.bean.PFMEADataBean; +import com.connor.renben.process.plm.bean.ProcessBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.Activator; +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.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CopyOfTMom006CreateProcessByModuleOperation extends AbstractAIFOperation { + + private InterfaceAIFComponent targets; + private String selectItems; + private TCSession session; + private Map itemIdMap = new HashMap();// ItemId + private Map noMap = new HashMap();// Ųұ + + public CopyOfTMom006CreateProcessByModuleOperation(InterfaceAIFComponent targets, + String selectItems, TCSession session) { + super(); + this.targets = targets; + this.selectItems = selectItems; + this.session = session; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + TreeMap itemlists = new TreeMap(); + ArrayList childrenItemlists = new ArrayList(); + TCComponentItem item = null; + //ջȡƷ + AIFComponentContext[] componentContexts = item.whereReferenced(); + for (int i = 0; i < componentContexts.length; i++) { + if(componentContexts[i].getComponent().getType().indexOf("Product") >=0 && componentContexts[i].getComponent() instanceof TCComponentItem) + { + TCComponentItem product = (TCComponentItem)componentContexts[i].getComponent(); + //ȡƷ + product.getStringProperty(""); + //ȡ汾 + product.getLatestItemRevision(); + //ȡ汾 + TCComponent form = form = product.getLatestItemRevision() + .getRelatedComponent("IMAN_master_form_rev"); + + } + } + if (this.targets instanceof TCComponentItem) { + item = (TCComponentItem) this.targets; + } + // ȡItemId + String[] itemID = null; + if (selectItems.indexOf(" | ") > -1) { + itemID = selectItems.split(" | "); + + } else { + itemID = new String[] { selectItems }; + } + // ȡѡеĶ + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItemType gyType = (TCComponentItemType) session + .getTypeComponent("MEProcess"); + TCComponentItem newTopItem = null; + if (itemID != null && itemID.length > 0) { + for (int i = 0; i < itemID.length; i++) { + TCComponentItem oldTopItem = itemType.find(itemID[i].substring( + 0, itemID[i].length() - 1)); + if (itemID[i].indexOf("/") >= 0) { + oldTopItem = itemType.find(itemID[i].split("/")[0]); + } else { + oldTopItem = itemType.find(itemID[i]); + } + if (!oldTopItem.getType().equals("MEProcess")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzgydx06_display.TITLE"), "", MessageBox.ERROR); + return; + } + TCComponentItemRevision oldTopItemRevision = oldTopItem + .getLatestItemRevision(); + TCComponent[] mepComponents = item + .getRelatedComponents("IMAN_reference"); + int mepCount = 0; + for (int j = 0; j < mepComponents.length; j++) { + if (mepComponents[j].getType().indexOf("MEProcess") >= 0) { + mepCount++; + } + } + Map oldMeopIdMap = new HashMap(); + ResultSet rs = null; + try { + //ȡӦIJұ + SqlUtilT.getTCConnection(); + String sql = String.format( + "select rb3_meopid,rb3_gybh from rb3_pfmea where processpuid = \'%s\' group by rb3_meopid,rb3_gybh", + oldTopItem.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + oldMeopIdMap.put(rs.getString("rb3_meopid"), rs.getString("rb3_gybh")); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + newTopItem = saveAsItem(item, mepCount + 1, oldTopItem); + // IMAN_METargetϵ + newTopItem.getLatestItemRevision().add("IMAN_METarget", + item.getLatestItemRevision()); + // oldTopItem.getLatestItemRevision().saveAsItem(gyType.getNewID(), + // oldTopItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // TCComponent[] datas = + // oldTopItem.getReferenceListProperty("IMAN_reference"); + // if(datas.length > 0) + // { + // newTopItem.remove("IMAN_reference", datas); + // } + // for (int j = 0; j < datas.length; j++) { + // if(datas[j] instanceof TCComponentItem) + // { + // TCComponentItem dataItem = (TCComponentItem)datas[j]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + // TCComponentItem newDataItem = + // dataItem.getLatestItemRevision().saveAsItem(dataType.getNewID(), + // dataItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // newTopItem.add("IMAN_reference", newDataItem); + // } + // } + // յBOM + TCComponent[] components = newTopItem.getLatestItemRevision() + .getRelatedComponents("ps_children"); + for (int j = 0; j < components.length; j++) { + if (components[j] instanceof TCComponentItemRevision) { + TCComponentItem oldMeop = ((TCComponentItemRevision) components[j]).getItem(); + TCComponentItem newItem = saveAsItem(item, j + 1,oldMeop); + + // BOM + TCComponent[] childrenComponents = newItem + .getLatestItemRevision().getRelatedComponents( + "ps_children"); + if (childrenComponents.length > 0) { + for (int k = 0; k < childrenComponents.length; k++) { + String mould = childrenComponents[k] + .getStringProperty("object_type"); + if (childrenComponents[k].getStringProperty( + "object_type").indexOf("mould") < 0) { + if (childrenComponents[k] instanceof TCComponentItemRevision) { + childrenItemlists + .add(((TCComponentItemRevision) childrenComponents[k]) + .getItem()); + } + } + // if(childrenComponents[k] instanceof + // TCComponentItemRevision) + // { + // TCComponentItem newChildrenItem = + // saveAsItem(((TCComponentItemRevision)childrenComponents[k]).getItem()); + // childrenItemlists.add(newChildrenItem); + // } + } + // if(((TCComponentItemRevision)components[j]) != + // null && childrenItemlists != null && + // childrenItemlists.size() > 0) + // { + // recreateBom(((TCComponentItemRevision)components[j]).getItem(),childrenItemlists); + // } + if (newItem != null && childrenItemlists != null + && childrenItemlists.size() > 0) { + recreateBom(newItem, childrenItemlists, true); + } + } + // µĹװ + TCComponent[] gzComponents = newItem + .getLatestItemRevision().getRelatedComponents( + "RB3_gongzhuang"); + if (gzComponents.length > 0) { + newItem.getLatestItemRevision().remove( + "RB3_gongzhuang", gzComponents); + } + // for (int k = 0; k < gzComponents.length; k++) { + // if(gzComponents[k] instanceof TCComponentItem) + // { + // TCComponentItem dataItem = + // (TCComponentItem)gzComponents[k]; + // //TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + // TCComponentItem newDataItem = + // dataItem.getLatestItemRevision().saveAsItem(dataItem.getTypeComponent().getNewID(), + // dataItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // ((TCComponentItemRevision)components[j]).add("RB3_gognzhuang", + // newDataItem); + // } + // } + // µҵָ + TCComponent[] workInstructionComponents = newItem + .getLatestItemRevision().getRelatedComponents( + "RB3_zuoyezhidaoshu"); + if (workInstructionComponents.length > 0) { + newItem.getLatestItemRevision().remove( + "RB3_zuoyezhidaoshu", + workInstructionComponents); + } + for (int k = 0; k < workInstructionComponents.length; k++) { + if (workInstructionComponents[k] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) workInstructionComponents[k]; + // TCComponentItemType + // dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + TCComponentItem newDataItem = dataItem + .getLatestItemRevision() + .saveAsItem( + dataItem.getTypeComponent() + .getNewID(), + dataItem.getLatestItemRevision() + .getStringProperty( + "item_revision_id")); + newItem.getLatestItemRevision().add( + "RB3_zuoyezhidaoshu", newDataItem); + } + } + + // ((TCComponentItemRevision)components[j]).saveAsItem(gxType.getNewID(), + // ((TCComponentItemRevision)components[j]).getStringProperty( + // "item_revision_id")); + // TCComponent[] childrenDatas = + // newChildrenItem.getReferenceListProperty("IMAN_reference"); + // if(childrenDatas.length > 0) + // { + // newChildrenItem.remove("IMAN_reference", + // childrenDatas); + // } + // for (int k = 0; k < childrenDatas.length; k++) { + // if(childrenDatas[k] instanceof TCComponentItem) + // { + // TCComponentItem dataItem = + // (TCComponentItem)childrenDatas[k]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + // TCComponentItem newDataItem = + // dataItem.getLatestItemRevision().saveAsItem(dataType.getNewID(), + // dataItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // newChildrenItem.add("IMAN_reference", newDataItem); + // } + // } + System.out.println(oldMeop.getStringProperty("item_id").toString()); + String index = oldMeopIdMap.get(oldMeop.getStringProperty("item_id").toString()); + System.out.println(index); + itemlists.put(Integer.parseInt(index),newItem);; + } + } + if (newTopItem != null && itemlists != null + && itemlists.size() > 0) { + + recreateMeopBom(newTopItem, itemlists, true); + item.add("IMAN_reference", newTopItem); + copyDataValue(oldTopItem, newTopItem); + Activator.getDefault().openPerspective( + "com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents( + "com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { newTopItem }); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("gjmbcjgycg06_display.TITLE"), "ɹ", MessageBox.WARNING); + } + } + } + + } + + /** + * Ϊ + * + * @param item + */ + public TCComponentItem saveAsItem(TCComponentItem productItem, + int itemCount, TCComponentItem item) { + TCComponentItem newItem = null; + try { + String itemID = ""; + if (item.getType().equals("MEProcess")) { + itemID = TMomMethodUtil.getRuleItemID(session, + productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GY_CODE); + } else if (item.getType().equals("MEOP")) { + itemID = TMomMethodUtil.getRuleItemID(session, + productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GX_CODE); + itemIdMap.put(item.getStringProperty("item_id"), itemID); + } else { + itemID = item.getTypeComponent().getNewID(); + } + newItem = item.getLatestItemRevision().saveAsItem( + itemID, + item.getLatestItemRevision().getStringProperty( + "item_revision_id")); + if (item.getType().equals("MEProcess")) { + TCComponent[] target = newItem.getLatestItemRevision() + .getReferenceListProperty("IMAN_METarget"); + if (target.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_METarget", + target); + } + } + TCComponent[] itemDatas = item + .getReferenceListProperty("IMAN_reference"); + TCComponent[] newItemDatas = newItem + .getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.remove("IMAN_reference", newItemDatas); + } + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + TCComponentItem newDataItem = dataItem + .getLatestItemRevision().saveAsItem( + dataItem.getTypeComponent().getNewID(), + dataItem.getLatestItemRevision() + .getStringProperty( + "item_revision_id")); + newItem.add("IMAN_reference", newDataItem); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + /** + * ݿеĿƼƻ + * + * @param oldItem + * ն + * @param newDataItem + * ¹ն + */ + private void copyDataValue(TCComponentItem oldItem, TCComponentItem newItem) { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet pfmeaRs = null; + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + List processBeans = new ArrayList(); + // ѯϹյĿƼƻ + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format( + "select * from rb3_controlplan where processpuid = \'%s\'", + oldItem.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + ProcessBean processBean = new ProcessBean(); + processBean.setMeopId(rs.getString("RB3_MEOPID")); + processBean.setGybh(rs.getString("RB3_GYBH")); + processBean.setGcmc(rs.getString("RB3_GCMC")); + processBean.setJqsb(rs.getString("RB3_JQSB")); + processBean.setSmjy(rs.getString("RB3_SMJY")); + processBean.setQptbh(rs.getString("RB3_QPTBH")); + processBean.setCc(rs.getString("RB3_CC")); + processBean.setCp(rs.getString("RB3_CP")); + processBean.setGc(rs.getString("RB3_GC")); + processBean.setTstx(rs.getString("RB3_TSTX")); + processBean.setCpgc(rs.getString("RB3_CPGC")); + processBean.setPgclff(rs.getString("RB3_CLFF")); + processBean.setRl(rs.getString("RB3_RL")); + processBean.setPl(rs.getString("RB3_PL")); + processBean.setSjsj(rs.getString("RB3_SJSJ")); + processBean.setGcsj(rs.getString("RB3_GCSJ")); + processBean.setMjsj(rs.getString("RB3_MJSJ")); + processBean.setFzr(rs.getString("RB3_FZR")); + processBean.setKzff(rs.getString("RB3_KZFF")); + processBean.setCzgf(rs.getString("RB3_CZGF")); + processBean.setFyjh(rs.getString("RB3_FYJH")); + processBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + processBean.setHbdyg(rs.getString("RB3_HBDYG")); + processBean.setSfwc(String.valueOf(rs.getInt("RB3_SFWC"))); + processBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + processBean.setSpecial(rs.getString("RB3_SPECIAL")); + processBean.setType(rs.getString("TYPE")); + processBeans.add(processBean); + } + noMap = getNomMap(newItem); + // + for (int i = 0; i < processBeans.size(); i++) { + // itemidȡϢ + ProcessBean process = processBeans.get(i); + String insertSQL = pro.getProperty("INSERTSQL"); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString().replace("-", ""), + newItem.getUid(), + itemIdMap.get(process.getMeopId()), + process.getGybh(), process.getGcmc(), + process.getJqsb(), process.getSmjy(), + process.getQptbh(), process.getCc(), + process.getCp(), process.getGc(), + process.getTstx(), process.getCpgc(), + process.getPgclff(), process.getRl(), + process.getPl(), process.getSjsj(), + process.getGcsj(), process.getMjsj(), + process.getFzr(), process.getKzff(), + process.getCzgf(), process.getFyjh(), + process.getHh(), process.getHbdyg(), + process.getSfwc(), process.getHhc(), + process.getSpecial(), process.getType() }, + insertSQL); + } + // Ȩޱ + List> meopList = new ArrayList>(); + String selectSQL = String + .format("select processpuid,rb3_meopid,rb3_gybh,rb3_gcmc from rb3_controlplan where processpuid = \'%s\' and rb3_gcmc not like \'%s\' group by processpuid,rb3_meopid,rb3_gybh,rb3_gcmc", + newItem.getUid(), "飨%");//飨 + System.out.println(selectSQL); + rs2 = SqlUtilT.read(selectSQL); + while (rs2.next()) { + List list = new ArrayList(); + list.add(rs2.getString("processpuid")); + list.add(rs2.getString("rb3_meopid")); + list.add(rs2.getString("rb3_gybh")); + list.add(rs2.getString("rb3_gcmc")); + meopList.add(list); + } + for (int i = 0; i < meopList.size(); i++) { + String insertSQL = pro.getProperty("INSERTPERMISSIONS"); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + meopList.get(i).get(0), meopList.get(i).get(1), + meopList.get(i).get(2), meopList.get(i).get(3), "", "", + "", "", }, insertSQL); + } + // ӵPFMEAе + List pfmeaDataBeans = new ArrayList(); + // ѯϹյPFMEA + String pfmeaSql = String.format(pro.getProperty("SETPFMEASELECT"), + oldItem.getUid()); + pfmeaRs = SqlUtilT.read(pfmeaSql); + while (pfmeaRs.next()) { + PFMEADataBean pfmeaDataBean = new PFMEADataBean(); + pfmeaDataBean.setMeopId(pfmeaRs.getString("RB3_MEOPID")); + pfmeaDataBean.setGybh(pfmeaRs.getString("RB3_GYBH")); + pfmeaDataBean.setGcmc(pfmeaRs.getString("RB3_GCMC")); + pfmeaDataBean.setStation(pfmeaRs.getString("RB3_STATION")); + pfmeaDataBean.setRequirement(pfmeaRs + .getString("RB3_REQUIREMENT")); + pfmeaDataBean.setQzsxms(pfmeaRs.getString("RB3_QZSXMS")); + pfmeaDataBean.setQzsxhg(pfmeaRs.getString("RB3_QZSXHG")); + pfmeaDataBean.setYzd(pfmeaRs.getString("RB3_YZD")); + pfmeaDataBean.setJb(pfmeaRs.getString("RB3_JB")); + pfmeaDataBean.setQzsxqy(pfmeaRs.getString("RB3_QZSXQY")); + pfmeaDataBean.setXxgckzyf(pfmeaRs.getString("RB3_XXGCKZYF")); + pfmeaDataBean.setPds(pfmeaRs.getString("RB3_PDS")); + pfmeaDataBean.setXxgckztc(pfmeaRs.getString("RB3_XXGCKZTC")); + pfmeaDataBean.setTcd(pfmeaRs.getString("RB3_TCD")); + pfmeaDataBean.setTm2Rpn(pfmeaRs.getString("RB3_RPN")); + pfmeaDataBean.setJycs(pfmeaRs.getString("RB3_JYCS")); + pfmeaDataBean.setZrr(pfmeaRs.getString("RB3_ZZR")); + pfmeaDataBean.setJhwcrq(pfmeaRs.getString("RB3_JHWCRQ")); + pfmeaDataBean.setCqdcs(pfmeaRs.getString("RB3_CQDCS")); + pfmeaDataBean.setNewSev(pfmeaRs.getString("RB3_NEW_SEV")); + pfmeaDataBean.setNewOcc(pfmeaRs.getString("RB3_NEW_OCC")); + pfmeaDataBean.setNewDel(pfmeaRs.getString("RB3_NEW_DET")); + pfmeaDataBean.setNewRpn(pfmeaRs.getString("RB3_NEW_RPN")); + pfmeaDataBean.setIdealState(pfmeaRs + .getString("RB3_IDEAL_STATE")); + pfmeaDataBean.setHh(String.valueOf(pfmeaRs.getInt("RB3_HH"))); + pfmeaDataBean.setHbdyg(pfmeaRs.getString("RB3_HBDYG")); + pfmeaDataBean.setHhc(String.valueOf(pfmeaRs.getInt("RB3_HHC"))); + pfmeaDataBean.setSpecial(pfmeaRs.getString("RB3_SPECIAL")); + pfmeaDataBean.setType(pfmeaRs.getString("TYPE")); + pfmeaDataBean.setBak(pfmeaRs.getString("BAK")); + pfmeaDataBeans.add(pfmeaDataBean); + } + // + for (int i = 0; i < pfmeaDataBeans.size(); i++) { + PFMEADataBean pfmeaData = pfmeaDataBeans.get(i); + String insertSQL = pro.getProperty("INSERTPFMEA"); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString().replace("-", ""), + newItem.getUid(), + itemIdMap.get(pfmeaData.getMeopId()), + noMap.get(itemIdMap.get(pfmeaData.getMeopId())), + pfmeaData.getGcmc(), pfmeaData.getStation(), + pfmeaData.getRequirement(), + pfmeaData.getQzsxms(), pfmeaData.getQzsxhg(), + pfmeaData.getYzd(), pfmeaData.getJb(), + pfmeaData.getQzsxqy(), pfmeaData.getXxgckzyf(), + pfmeaData.getPds(), pfmeaData.getXxgckztc(), + pfmeaData.getTcd(), pfmeaData.getTm2Rpn(), + pfmeaData.getJycs(), pfmeaData.getZrr(), + pfmeaData.getJhwcrq(), pfmeaData.getCqdcs(), + pfmeaData.getNewSev(), pfmeaData.getNewOcc(), + pfmeaData.getNewDel(), pfmeaData.getNewRpn(), + pfmeaData.getIdealState(), pfmeaData.getHh(), + pfmeaData.getHbdyg(), pfmeaData.getHhc(), + pfmeaData.getSpecial(), pfmeaData.getType(), + pfmeaData.getBak(),"","","" }, insertSQL); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (pfmeaRs != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private Map getNomMap(TCComponentItem item) { + Map resultMap = new HashMap(); + try { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline = ((TCComponentBOMLine) children + .getComponent()); + resultMap.put( + subline.getStringProperty("bl_indented_title") + .split("/")[0], subline + .getStringProperty("bl_sequence_no")); + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return resultMap; + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateMeopBom(TCComponentItem topItem, + TreeMap itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, + topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + Iterator it = itemlists.keySet().iterator(); + while (it.hasNext()) { + TCComponentItem meopItem = itemlists.get(it.next()); + TCComponentItemRevision revision = meopItem.getLatestItemRevision(); + topline.add(meopItem, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem topItem, + ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, + topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleCommand.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleCommand.java new file mode 100644 index 0000000..f6c5a9d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleCommand.java @@ -0,0 +1,48 @@ +package com.connor.renben.process.plm.tmom006; + +import com.connor.renben.process.plm.util.DDInClassDialog; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.kernel.TCSession; + +public class TMom006CreateProcessByModuleCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private String commandId; + + public TMom006CreateProcessByModuleCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.commandId = commandId; + } + + @Override + public void executeModal() throws Exception { + final InterfaceAIFComponent targetComponent = app.getTargetComponent(); + Activator.getDefault().openPerspective( + "com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents( + "com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { targetComponent }); + final AbstractAIFUIApplication localAbstractAIFUIApplication = AIFDesktop + .getActiveDesktop().getCurrentApplication(); + new Thread() { + @Override + public void run() { + + DDInClassDialog localDDInClassDialog = new DDInClassDialog( + localAbstractAIFUIApplication, targetComponent, 2, + commandId); + localDDInClassDialog.setVisible(true); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleHandler.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleHandler.java new file mode 100644 index 0000000..9fdb215 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleHandler.java @@ -0,0 +1,37 @@ +package com.connor.renben.process.plm.tmom006; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom006CreateProcessByModuleHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String commandId = arg0.getCommand().getId(); + TMom006CreateProcessByModuleCommand command = new TMom006CreateProcessByModuleCommand( + app, session, commandId); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("gjmbcjgysb06_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleOperation.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleOperation.java new file mode 100644 index 0000000..877d50d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByModuleOperation.java @@ -0,0 +1,597 @@ +package com.connor.renben.process.plm.tmom006; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.TreeMap; +import java.util.UUID; + +import com.connor.renben.process.plm.bean.PFMEADataBean; +import com.connor.renben.process.plm.bean.ProcessBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.Activator; +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.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom006CreateProcessByModuleOperation extends AbstractAIFOperation { + + private InterfaceAIFComponent targets; + private String selectItems; + private TCSession session; + private String productId;// ƷID + private Map itemIdMap = new HashMap();// ItemId + private Map noMap = new HashMap();// Ųұ + + public TMom006CreateProcessByModuleOperation(InterfaceAIFComponent targets, String selectItems, TCSession session) { + this.targets = targets; + this.selectItems = selectItems; + this.session = session; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + TreeMap itemlists = new TreeMap(); + TCComponentItem item = null; + if (this.targets instanceof TCComponentItem) { + item = (TCComponentItem) this.targets; + } + this.productId = item.getStringProperty("item_id"); + // ȡItemId + String[] itemID = null; + if (selectItems.indexOf(" | ") > -1) { + itemID = selectItems.split(" | "); + } else { + itemID = new String[] { selectItems }; + } + // ȡѡеĶ + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + TCComponentItemType gyType = (TCComponentItemType) session.getTypeComponent("MEProcess"); + TCComponentItem newTopItem = null; + if (itemID != null && itemID.length > 0) { + for (int i = 0; i < itemID.length; i++) { + TCComponentItem oldTopItem = itemType.find(itemID[i].substring(0, itemID[i].length() - 1)); + if (itemID[i].indexOf("/") >= 0) { + oldTopItem = itemType.find(itemID[i].split("/")[0]); + } else { + oldTopItem = itemType.find(itemID[i]); + } + if (!oldTopItem.getType().equals("MEProcess")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzgydx06_display.TITLE"), "", MessageBox.ERROR); + return; + } + TCComponentItemRevision oldTopItemRevision = oldTopItem.getLatestItemRevision(); + TCComponent[] mepComponents = item.getRelatedComponents("IMAN_reference"); + int mepCount = 0; + for (int j = 0; j < mepComponents.length; j++) { + if (mepComponents[j].getType().indexOf("MEProcess") >= 0) { + mepCount++; + } + } + Map oldMeopIdMap = new HashMap(); + ResultSet rs = null; + try { + // ȡӦIJұ + SqlUtilT.getTCConnection(); + String sql = String.format( + "select rb3_meopid,rb3_gybh from rb3_pfmea where processpuid = \'%s\' group by rb3_meopid,rb3_gybh", + oldTopItem.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + oldMeopIdMap.put(rs.getString("rb3_meopid"), rs.getString("rb3_gybh")); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + newTopItem = saveAsItem(item, mepCount + 1, oldTopItem); + // IMAN_METargetϵ + newTopItem.getLatestItemRevision().add("IMAN_METarget", item.getLatestItemRevision()); + // oldTopItem.getLatestItemRevision().saveAsItem(gyType.getNewID(), + // oldTopItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // TCComponent[] datas = + // oldTopItem.getReferenceListProperty("IMAN_reference"); + // if(datas.length > 0) + // { + // newTopItem.remove("IMAN_reference", datas); + // } + // for (int j = 0; j < datas.length; j++) { + // if(datas[j] instanceof TCComponentItem) + // { + // TCComponentItem dataItem = (TCComponentItem)datas[j]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + // TCComponentItem newDataItem = + // dataItem.getLatestItemRevision().saveAsItem(dataType.getNewID(), + // dataItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // newTopItem.add("IMAN_reference", newDataItem); + // } + // } + // յBOM + TCComponent[] components = newTopItem.getLatestItemRevision().getRelatedComponents("ps_children"); + for (int j = 0; j < components.length; j++) { + if (components[j] instanceof TCComponentItemRevision) { + TCComponentItem oldMeop = ((TCComponentItemRevision) components[j]).getItem(); + TCComponentItem newItem = saveAsItem(item, j + 1, oldMeop); + + // BOM + TCComponent[] childrenComponents = newItem.getLatestItemRevision() + .getRelatedComponents("ps_children"); + if (childrenComponents.length > 0) { + ArrayList childrenItemlists = new ArrayList(); + for (int k = 0; k < childrenComponents.length; k++) { + String mould = childrenComponents[k].getStringProperty("object_type"); + if (childrenComponents[k].getStringProperty("object_type").indexOf("mould") < 0) { + if (childrenComponents[k] instanceof TCComponentItemRevision) { + childrenItemlists + .add(((TCComponentItemRevision) childrenComponents[k]).getItem()); + } + } + // if(childrenComponents[k] instanceof + // TCComponentItemRevision) + // { + // TCComponentItem newChildrenItem = + // saveAsItem(((TCComponentItemRevision)childrenComponents[k]).getItem()); + // childrenItemlists.add(newChildrenItem); + // } + } + // if(((TCComponentItemRevision)components[j]) != + // null && childrenItemlists != null && + // childrenItemlists.size() > 0) + // { + // recreateBom(((TCComponentItemRevision)components[j]).getItem(),childrenItemlists); + // } + if (newItem != null && childrenItemlists != null && childrenItemlists.size() > 0) { + recreateBom(newItem, childrenItemlists, true); + } + } + // µĹװ + TCComponent[] gzComponents = newItem.getLatestItemRevision() + .getRelatedComponents("RB3_gongzhuang"); + if (gzComponents.length > 0) { + newItem.getLatestItemRevision().remove("RB3_gongzhuang", gzComponents); + } + // for (int k = 0; k < gzComponents.length; k++) { + // if(gzComponents[k] instanceof TCComponentItem) + // { + // TCComponentItem dataItem = + // (TCComponentItem)gzComponents[k]; + // //TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + // TCComponentItem newDataItem = + // dataItem.getLatestItemRevision().saveAsItem(dataItem.getTypeComponent().getNewID(), + // dataItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // ((TCComponentItemRevision)components[j]).add("RB3_gognzhuang", + // newDataItem); + // } + // } + // µҵָ + TCComponent[] workInstructionComponents = newItem.getLatestItemRevision() + .getRelatedComponents("RB3_zuoyezhidaoshu"); + if (workInstructionComponents.length > 0) { + newItem.getLatestItemRevision().remove("RB3_zuoyezhidaoshu", workInstructionComponents); + } +// for (int k = 0; k < workInstructionComponents.length; k++) { +// if (workInstructionComponents[k] instanceof TCComponentItem) { +// TCComponentItem dataItem = (TCComponentItem) workInstructionComponents[k]; +// // TCComponentItemType +// // dataType=(TCComponentItemType) +// // session.getTypeComponent(dataItem.getStringProperty("object_type")); +// TCComponentItem newDataItem = dataItem +// .getLatestItemRevision() +// .saveAsItem( +// dataItem.getTypeComponent() +// .getNewID(),"00"); +// newItem.getLatestItemRevision().add( +// "RB3_zuoyezhidaoshu", newDataItem); +// } +// } + + // ((TCComponentItemRevision)components[j]).saveAsItem(gxType.getNewID(), + // ((TCComponentItemRevision)components[j]).getStringProperty( + // "item_revision_id")); + // TCComponent[] childrenDatas = + // newChildrenItem.getReferenceListProperty("IMAN_reference"); + // if(childrenDatas.length > 0) + // { + // newChildrenItem.remove("IMAN_reference", + // childrenDatas); + // } + // for (int k = 0; k < childrenDatas.length; k++) { + // if(childrenDatas[k] instanceof TCComponentItem) + // { + // TCComponentItem dataItem = + // (TCComponentItem)childrenDatas[k]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + // TCComponentItem newDataItem = + // dataItem.getLatestItemRevision().saveAsItem(dataType.getNewID(), + // dataItem.getLatestItemRevision().getStringProperty( + // "item_revision_id")); + // newChildrenItem.add("IMAN_reference", newDataItem); + // } + // } + System.out.println(oldMeop.getStringProperty("item_id").toString()); + String index = oldMeopIdMap.get(oldMeop.getStringProperty("item_id").toString()); + System.out.println(index); + itemlists.put(Integer.parseInt(index), newItem); + } + } + if (newTopItem != null && itemlists != null && itemlists.size() > 0) { + + recreateMeopBom(newTopItem, itemlists, true); + item.add("IMAN_reference", newTopItem); + copyDataValue(oldTopItem, newTopItem); + Activator.getDefault().openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents("com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { newTopItem }); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("gjgycjgycg06_display.TITLE"), "ɹ", MessageBox.WARNING); + } + } + } + + } + + /** + * Ϊ + * + * @param item + */ + public TCComponentItem saveAsItem(TCComponentItem productItem, int itemCount, TCComponentItem item) { + TCComponentItem newItem = null; + try { + String itemID = ""; + if (item.getType().equals("MEProcess")) { + itemID = TMomMethodUtil.getRuleItemID(session, productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GY_CODE); + } else if (item.getType().equals("MEOP")) { + itemID = TMomMethodUtil.getRuleItemID(session, productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GX_CODE); + itemIdMap.put(item.getStringProperty("item_id"), itemID); + } else { + itemID = item.getTypeComponent().getNewID(); + } +// String itemName = ""; +// if(item.getStringProperty("object_name").indexOf("/") >= 0) +// { +// itemName = this.productId+"/"+item.getStringProperty("object_name").split("/")[1]; +// } +// else +// { +// itemName = this.productId+"/"+item.getStringProperty("object_name"); +// } + newItem = item.getLatestItemRevision().saveAsItem(itemID, "00"); + if (item.getType().equals("MEProcess")) { + TCComponent[] target = newItem.getLatestItemRevision().getReferenceListProperty("IMAN_METarget"); + if (target.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_METarget", target); + } + } + TCComponent[] itemDatas = item.getReferenceListProperty("IMAN_reference"); + TCComponent[] newItemDatas = newItem.getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.remove("IMAN_reference", newItemDatas); + } + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + String dataItemName = ""; + if (dataItem.getStringProperty("object_name").indexOf("/") >= 0) { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name").split("/")[1]; + } else { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name"); + } + // = this.productId+dataItem.getStringProperty("object_name"); + TCComponentItem newDataItem = dataItem.getLatestItemRevision() + .saveAsItem(dataItem.getTypeComponent().getNewID(), "00", dataItemName, "", false, null); + newItem.add("IMAN_reference", newDataItem); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + /** + * ݿеĿƼƻ + * + * @param oldItem ն + * @param newDataItem ¹ն + */ + private void copyDataValue(TCComponentItem oldItem, TCComponentItem newItem) { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet pfmeaRs = null; + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + List processBeans = new ArrayList(); + // ѯϹյĿƼƻ + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format("select * from rb3_controlplan where processpuid = \'%s\'", oldItem.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + ProcessBean processBean = new ProcessBean(); + processBean.setMeopId(rs.getString("RB3_MEOPID")); + processBean.setGybh(rs.getString("RB3_GYBH")); + processBean.setGcmc(rs.getString("RB3_GCMC")); + processBean.setJqsb(rs.getString("RB3_JQSB")); + processBean.setSmjy(rs.getString("RB3_SMJY")); + processBean.setQptbh(rs.getString("RB3_QPTBH")); + processBean.setCc(rs.getString("RB3_CC")); + processBean.setNo(rs.getString("RB3_NO")); + processBean.setCp(rs.getString("RB3_CP")); + processBean.setGc(rs.getString("RB3_GC")); + processBean.setTstx(rs.getString("RB3_TSTX")); + processBean.setCpgc(rs.getString("RB3_CPGC")); + processBean.setPgclff(rs.getString("RB3_CLFF")); + processBean.setRl(rs.getString("RB3_RL")); + processBean.setPl(rs.getString("RB3_PL")); + processBean.setSjsj(rs.getString("RB3_SJSJ")); + processBean.setGcsj(rs.getString("RB3_GCSJ")); + processBean.setMjsj(rs.getString("RB3_MJSJ")); + processBean.setFzr(rs.getString("RB3_FZR")); + processBean.setKzff(rs.getString("RB3_KZFF")); + processBean.setCzgf(rs.getString("RB3_CZGF")); + processBean.setFyjh(rs.getString("RB3_FYJH")); + processBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + processBean.setHbdyg(rs.getString("RB3_HBDYG")); + processBean.setSfwc(String.valueOf(rs.getInt("RB3_SFWC"))); + processBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + processBean.setSpecial(rs.getString("RB3_SPECIAL")); + processBean.setType(rs.getString("TYPE")); + processBeans.add(processBean); + } + noMap = getNomMap(newItem); + // + for (int i = 0; i < processBeans.size(); i++) { + // itemidȡϢ + ProcessBean process = processBeans.get(i); + String insertSQL = pro.getProperty("INSERTSQL"); + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), + itemIdMap.get(process.getMeopId()), process.getGybh(), process.getGcmc(), process.getJqsb(), + process.getSmjy(), process.getQptbh(), process.getCc(), process.getCp(), process.getGc(), + process.getTstx(), process.getCpgc(), process.getPgclff(), process.getRl(), process.getPl(), + process.getSjsj(), process.getGcsj(), process.getMjsj(), process.getFzr(), process.getKzff(), + process.getCzgf(), process.getFyjh(), process.getHh(), process.getHbdyg(), "0", + process.getHhc(), process.getSpecial(), process.getType(), "0", "0", process.getNo(), "0" }, + insertSQL); + } + // Ȩޱ + List> meopList = new ArrayList>(); + String selectSQL = String.format( + "select processpuid,rb3_meopid,rb3_gybh,rb3_gcmc from RB3_PERMISSIONS where processpuid = \'%s\' and rb3_gcmc not like \'%s\' and rb3_meopid is not null group by processpuid,rb3_meopid,rb3_gybh,rb3_gcmc", + oldItem.getUid(), "飨%");// 飨 + System.out.println(selectSQL); + rs2 = SqlUtilT.read(selectSQL); + while (rs2.next()) { + List list = new ArrayList(); + list.add(rs2.getString("processpuid")); + list.add(rs2.getString("rb3_meopid")); + list.add(rs2.getString("rb3_gybh")); + list.add(rs2.getString("rb3_gcmc")); + meopList.add(list); + } + for (int i = 0; i < meopList.size(); i++) { + String insertSQL = pro.getProperty("INSERTPERMISSIONS"); + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), + itemIdMap.get(meopList.get(i).get(1)), meopList.get(i).get(2), meopList.get(i).get(3), "", "", + "", "" }, insertSQL); + } + // ӵPFMEAе + List pfmeaDataBeans = new ArrayList(); + // ѯϹյPFMEA + String pfmeaSql = String.format(pro.getProperty("SETPFMEASELECT"), oldItem.getUid()); + pfmeaRs = SqlUtilT.read(pfmeaSql); + while (pfmeaRs.next()) { + PFMEADataBean pfmeaDataBean = new PFMEADataBean(); + pfmeaDataBean.setMeopId(pfmeaRs.getString("RB3_MEOPID")); + pfmeaDataBean.setGybh(pfmeaRs.getString("RB3_GYBH")); + pfmeaDataBean.setGcmc(pfmeaRs.getString("RB3_GCMC")); + pfmeaDataBean.setStation(pfmeaRs.getString("RB3_STATION")); + pfmeaDataBean.setRequirement(pfmeaRs.getString("RB3_REQUIREMENT")); + pfmeaDataBean.setQzsxms(pfmeaRs.getString("RB3_QZSXMS")); + pfmeaDataBean.setQzsxhg(pfmeaRs.getString("RB3_QZSXHG")); + pfmeaDataBean.setYzd(pfmeaRs.getString("RB3_YZD")); + pfmeaDataBean.setJb(pfmeaRs.getString("RB3_JB")); + pfmeaDataBean.setQzsxqy(pfmeaRs.getString("RB3_QZSXQY")); + pfmeaDataBean.setXxgckzyf(pfmeaRs.getString("RB3_XXGCKZYF")); + pfmeaDataBean.setPds(pfmeaRs.getString("RB3_PDS")); + pfmeaDataBean.setXxgckztc(pfmeaRs.getString("RB3_XXGCKZTC")); + pfmeaDataBean.setTcd(pfmeaRs.getString("RB3_TCD")); + pfmeaDataBean.setTm2Rpn(pfmeaRs.getString("RB3_RPN")); + pfmeaDataBean.setJycs(pfmeaRs.getString("RB3_JYCS")); + pfmeaDataBean.setZrr(pfmeaRs.getString("RB3_ZZR")); + pfmeaDataBean.setJhwcrq(pfmeaRs.getString("RB3_JHWCRQ")); + pfmeaDataBean.setCqdcs(pfmeaRs.getString("RB3_CQDCS")); + pfmeaDataBean.setNewSev(pfmeaRs.getString("RB3_NEW_SEV")); + pfmeaDataBean.setNewOcc(pfmeaRs.getString("RB3_NEW_OCC")); + pfmeaDataBean.setNewDel(pfmeaRs.getString("RB3_NEW_DET")); + pfmeaDataBean.setNewRpn(pfmeaRs.getString("RB3_NEW_RPN")); + pfmeaDataBean.setIdealState(pfmeaRs.getString("RB3_IDEAL_STATE")); + pfmeaDataBean.setHh(String.valueOf(pfmeaRs.getInt("RB3_HH"))); + pfmeaDataBean.setHbdyg(pfmeaRs.getString("RB3_HBDYG")); + pfmeaDataBean.setHhc(String.valueOf(pfmeaRs.getInt("RB3_HHC"))); + pfmeaDataBean.setSpecial(pfmeaRs.getString("RB3_SPECIAL")); + pfmeaDataBean.setType(pfmeaRs.getString("TYPE")); + pfmeaDataBean.setBak(pfmeaRs.getString("BAK")); + pfmeaDataBean.setP1(pfmeaRs.getString("P1")); + pfmeaDataBean.setP2(pfmeaRs.getString("P2")); + pfmeaDataBean.setP3(pfmeaRs.getString("P3")); + pfmeaDataBean.setP4(pfmeaRs.getString("P4")); + pfmeaDataBean.setP5(pfmeaRs.getString("P5")); + pfmeaDataBeans.add(pfmeaDataBean); + } + // + for (int i = 0; i < pfmeaDataBeans.size(); i++) { + PFMEADataBean pfmeaData = pfmeaDataBeans.get(i); + String insertSQL = pro.getProperty("INSERTPFMEA"); + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), + itemIdMap.get(pfmeaData.getMeopId()), noMap.get(itemIdMap.get(pfmeaData.getMeopId())), + pfmeaData.getGcmc(), pfmeaData.getStation(), pfmeaData.getRequirement(), pfmeaData.getQzsxms(), + pfmeaData.getQzsxhg(), pfmeaData.getYzd(), pfmeaData.getJb(), pfmeaData.getQzsxqy(), + pfmeaData.getXxgckzyf(), pfmeaData.getPds(), pfmeaData.getXxgckztc(), pfmeaData.getTcd(), + pfmeaData.getTm2Rpn(), pfmeaData.getJycs(), pfmeaData.getZrr(), pfmeaData.getJhwcrq(), + pfmeaData.getCqdcs(), pfmeaData.getNewSev(), pfmeaData.getNewOcc(), pfmeaData.getNewDel(), + pfmeaData.getNewRpn(), pfmeaData.getIdealState(), pfmeaData.getHh(), pfmeaData.getHbdyg(), + pfmeaData.getHhc(), pfmeaData.getSpecial(), pfmeaData.getType(), pfmeaData.getBak(), "", "", "", + pfmeaData.getP1(), pfmeaData.getP2(), pfmeaData.getP3(), pfmeaData.getP4(), pfmeaData.getP5() }, + insertSQL); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (pfmeaRs != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private Map getNomMap(TCComponentItem item) { + Map resultMap = new HashMap(); + try { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline = ((TCComponentBOMLine) children.getComponent()); + resultMap.put(subline.getStringProperty("bl_indented_title").split("/")[0], + subline.getStringProperty("bl_sequence_no")); + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return resultMap; + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateMeopBom(TCComponentItem topItem, TreeMap itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + Iterator it = itemlists.keySet().iterator(); + while (it.hasNext()) { + TCComponentItem meopItem = itemlists.get(it.next()); + TCComponentItemRevision revision = meopItem.getLatestItemRevision(); + topline.add(meopItem, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem topItem, ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessCommand.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessCommand.java new file mode 100644 index 0000000..f161919 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessCommand.java @@ -0,0 +1,51 @@ +package com.connor.renben.process.plm.tmom006; + +import java.util.Locale; +import java.util.ResourceBundle; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom006CreateProcessByProcessCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private String commandId; + + public TMom006CreateProcessByProcessCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.commandId = commandId; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + final InterfaceAIFComponent targetComponent = app.getTargetComponent(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (targetComponent instanceof TCComponentItem) { + if (targetComponent.getType().toUpperCase().indexOf("RB3_ZC") < 0 && targetComponent.getType().toUpperCase().indexOf("RB3_LBJ") < 0 && targetComponent.getType().toUpperCase().indexOf("RB3_GZ") < 0 && targetComponent.getType().toUpperCase().indexOf("RB3_GQ") < 0 && targetComponent.getType().toUpperCase().indexOf("RB3_BZJ") < 0 && targetComponent.getType().toUpperCase().indexOf("RB3_GZBJ") < 0 && targetComponent.getType().toUpperCase().indexOf("RB3_GQBJ") < 0 && targetComponent.getType().toUpperCase().indexOf("RB3_BZJBJ") < 0) { + MessageBox.post(rb.getString("qxzcpdx06_display.TITLE"), "", MessageBox.ERROR); + return; + } + } else { + MessageBox.post(rb.getString("qxzcpdx06_display.TITLE"), "", MessageBox.ERROR); + return; + } + new Thread() { + @Override + public void run() { + TMom006CreateProcessByProcessDialog lDialog = new TMom006CreateProcessByProcessDialog( + app, session, targetComponent); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessDialog.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessDialog.java new file mode 100644 index 0000000..719ab98 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessDialog.java @@ -0,0 +1,384 @@ +package com.connor.renben.process.plm.tmom006; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.RowSorter; +import javax.swing.border.TitledBorder; +import javax.swing.plaf.metal.MetalProgressBarUI; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.connor.renben.process.plm.util.MyTableModel; +import com.connor.renben.process.plm.util.ProcessBarDialog; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom006CreateProcessByProcessDialog extends AbstractAIFDialog + implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent targetComponent; + private SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + private String[] queryName;//ѯ + private String[] queryValue;//ֵ + private Vector cellData;// + private String groupName;//ǰıʶ + private Map groupMap= new HashMap();//RB3_GROUPʵֵʾֵ + private Vector header=new Vector(); + //{"Ʒ","ձ",""}; + + + // ҳؼ + private JPanel mainPanel; + private JLabel IDLabel;//ID + private JTextField IDTextField; + private JLabel NameLabel;// + private JTextField NameTextField; + private JLabel CPHLabel;//Ʒ + private JTextField CPHTextField; + private JLabel THLabel;//ͼ + private JTextField THTextField; + + //ʾ + private JPanel tablePanel; + private JTable showTable; + + private JPanel rootPanel; + private JButton selectButton;//ȷ + + public TMom006CreateProcessByProcessDialog(AbstractAIFApplication app, + TCSession session, InterfaceAIFComponent targetComponent) { + // TODO Auto-generated constructor stub + super(false); + this.app = app; + this.session = session; + this.targetComponent = targetComponent; + String currentGroupName = null; + try { + currentGroupName = this.session.getCurrentGroup().getFullName(); + } catch (TCException e) { + e.printStackTrace(); + } + int indexx = currentGroupName.lastIndexOf("."); + // ȡǰʶ + this.groupName = currentGroupName.substring(indexx + 1, currentGroupName.length()); + init(); + } + + //ȡвѯĶ + public List getItem(String[] queryName,String[] queryValue) + { + List components=new ArrayList(); + if(queryName.length==0 && queryValue.length==0) + { + queryName=new String[]{"ͺ"}; + queryValue=new String[]{"*"}; + } + //ȡѯ + // ȡѯ + try { + TCComponentQueryType queryType = (TCComponentQueryType) this.session + .getTypeComponent("ImanQuery"); + //ȡƷͳƲѯ + TCComponentQuery cptjQuery=(TCComponentQuery)queryType.find("RBSearchZC_ID_NAME_CPH_TH"); + if(cptjQuery==null){ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("wzdzcdx06_display.TITLE"), "", ERROR); + return null; + } + TCComponent[] cptjComponents = cptjQuery.execute(queryName, queryValue); + for (TCComponent tcComponent : cptjComponents) { + components.add(tcComponent); + } + return components; + } catch (TCException e) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("cxdxcc06_display.TITLE"), "", MessageBox.ERROR); + e.printStackTrace(); + } + return null; + } + + 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("cjgy_display.TITLE")); + this.mainPanel = new JPanel(new PropertyLayout()); + this.mainPanel = new JPanel(new PropertyLayout()); + this.IDLabel = new JLabel("ID");// + this.IDTextField = new JTextField(20); + this.NameLabel = new JLabel("");// + this.NameTextField = new JTextField(20); + this.CPHLabel = new JLabel("Ʒ");//Ʒ + this.CPHTextField = new JTextField(20); + this.THLabel = new JLabel("ͼ");//ͼ + this.THTextField = new JTextField(20); + this.selectButton=new JButton(rb.getString("cx06_display.TITLE")); + + //ʾ + this.mainPanel=new JPanel(new PropertyLayout()); + this.mainPanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black),"ѯ")); + this.mainPanel.add("1.1.left.top", this.IDLabel); + this.mainPanel.add("1.2.left.top", this.IDTextField); + this.mainPanel.add("2.1.left.top", this.NameLabel); + this.mainPanel.add("2.2.left.top", this.NameTextField); + this.mainPanel.add("3.1.left.top", this.CPHLabel); + this.mainPanel.add("3.2.left.top", this.CPHTextField); + this.mainPanel.add("4.1.left.top", this.THLabel); + this.mainPanel.add("4.2.left.top", this.THTextField); + this.mainPanel.add("5.1.left.top", this.selectButton); + + //ʼJTable + header.add(rb.getString("cph06_display.TITLE")); + header.add(rb.getString("gybh06_display.TITLE")); + header.add(rb.getString("mc06_display.TITLE")); + this.showTable=getjTable(showTable, null, header, cellData); + this.tablePanel=new JPanel(new BorderLayout()); + //this.tablePanel.setPreferredSize(new Dimension(200, 300)); + this.tablePanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black),"ѯ")); + this.tablePanel.add(new JScrollPane(this.showTable),BorderLayout.CENTER); + + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.CENTER); + //this.add(rootPanel, BorderLayout.SOUTH); + + this.setLayout(new BorderLayout()); + this.add(this.mainPanel,BorderLayout.NORTH); + this.add(this.tablePanel,BorderLayout.CENTER); + //this.add(this.rootPanel,BorderLayout.SOUTH); + this.createActionEvent(); + + this.pack(); + this.showDialog(); + } + + //Ӱť + public void createActionEvent() { + this.selectButton.addActionListener(this); +// this.okButton.addActionListener(this); +// this.celButton.addActionListener(this); + this.showTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + if (arg0.getClickCount() == 2) { + try { + + int row = showTable.getSelectedRow(); + if(row < 0) + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzh06_display.TITLE"), "", MessageBox.ERROR); + return; + } + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + if (!itemType.find(showTable.getValueAt(row, 1).toString()).getType() + .equals("MEProcess")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzzqdgy06_display.TITLE"), "", MessageBox.ERROR); + return; + } + String itemId = showTable.getValueAt(row, 1).toString(); + System.out.println("itemId"+itemId); + TMom006CreateProcessByProcessOperation2 operation = new TMom006CreateProcessByProcessOperation2( + targetComponent, itemId, session); +// operation.executeOperation(); + session.queueOperation(operation); + TMom006CreateProcessByProcessDialog.this.disposeDialog(); + TMom006CreateProcessByProcessDialog.this.dispose(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } +// // TODO Auto-generated method stub +// super.mouseClicked(arg0); + } + }); + } + +// //ȡlovֵ +// public String[] getGroupLov() +// { +// try { +// //ȡlov +// TCComponentListOfValues rtlistOfValues = TCLOVUtil.findLOVByName(this.session, "RB3_GROUP"); +// ListOfValuesInfo rtlistOfValuesInfo = rtlistOfValues.getListOfValues(); +// String[] groupName=rtlistOfValuesInfo.getStringListOfValues(); +// String[] groupDisplayName=rtlistOfValuesInfo.getLOVDisplayValues(); +// for (int i = 0; i < groupName.length; i++) { +// this.groupMap.put(groupDisplayName[i],groupName[i]); +// } +// return rtlistOfValuesInfo.getLOVDisplayValues();//rtlistOfValuesInfo.getLOVDisplayValues(); +// } catch (TCException e) { +// MessageBox.post("ȡLOVϵϵͳԱ", "", MessageBox.ERROR); +// e.printStackTrace(); +// } +// return null; +// } + // Jtableͨ÷ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Vector titleNames, Vector values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + if (simpleLen * titleNames.size() >= totleLen) { + for (int i = 0; i < titleNames.size(); i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + // ± + public void addData(Vector cellData2) { + DefaultTableModel tableModel = (DefaultTableModel) this.showTable + .getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter(this.getTableModel(null, this.header, cellData2)); + this.showTable.setRowSorter(sorter); + for (int i = 0; i < cellData2.size(); i++) { + tableModel.addRow(cellData2.get(i)); + } + // ݲ޸ + showTable.setEnabled(true); + // ± + showTable.invalidate(); + } + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Vector titleNames, Vector 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.selectButton)) + { + try { + //· + TCUtils.openLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, true); + List queryNameList = new ArrayList<>(); + List queryValueList = new ArrayList<>(); + if(IDTextField.getText() != null && !IDTextField.getText().equals("")) + { + queryNameList.add("ID"); + queryValueList.add(IDTextField.getText()); + + } if(NameTextField.getText() != null && !NameTextField.getText().equals("")) + { + queryNameList.add(""); + queryValueList.add(NameTextField.getText()); + + } if(CPHTextField.getText() != null && !CPHTextField.getText().equals("")) + { + queryNameList.add("rb3_cph"); + queryValueList.add(CPHTextField.getText()); + }if(THTextField.getText() != null && !THTextField.getText().equals("")) + { + queryNameList.add("rb3_th"); + queryValueList.add(THTextField.getText()); + } +// final int size = list.size(); +// String[] arr = (String[])list.toArray(new String[size]); + for (int i = 0; i < queryNameList.size(); i++) { + System.out.println(queryNameList.get(i)); + System.out.println(queryValueList.get(i)); + } + + List components=getItem((String[])queryNameList.toArray(new String[queryNameList.size()]),(String[])queryValueList.toArray(new String[queryValueList.size()])); + if(components != null && components.size() > 0) + { + Vector dataValue = new Vector(); + for (int i = 0; i < components.size(); i++) { + TCComponent[] processItems = components.get(i).getReferenceListProperty("IMAN_reference"); + if(processItems != null && processItems.length > 0) + { + for (int j = 0; j < processItems.length; j++) { + if(processItems[j].getType().indexOf("MEProcess") >= 0 && processItems[j] instanceof TCComponentItem) + { + Vector rowValue = new Vector<>(); + rowValue.add(components.get(i).getStringProperty("object_string")); + rowValue.add(processItems[j].getStringProperty("item_id")); + rowValue.add(processItems[j].getStringProperty("object_name")); + dataValue.add(rowValue); + } + } + } + } + addData(dataValue); + + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + }finally { + try { + TCUtils.closeLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, false); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessHandler.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessHandler.java new file mode 100644 index 0000000..e8cce16 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessHandler.java @@ -0,0 +1,38 @@ +package com.connor.renben.process.plm.tmom006; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom006CreateProcessByProcessHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String commandId = arg0.getCommand().getId(); + TMom006CreateProcessByProcessCommand command = new TMom006CreateProcessByProcessCommand( + app, session, commandId); + try { +// session. + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("gjgycjgysb06_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessOperation.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessOperation.java new file mode 100644 index 0000000..2976466 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessOperation.java @@ -0,0 +1,2050 @@ +package com.connor.renben.process.plm.tmom006; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.TreeMap; +import java.util.UUID; + +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.alibaba.fastjson.JSON; +//import org.jacorb.idl.runtime.int_token; +import com.connor.renben.process.plm.bean.PFMEADataBean; +import com.connor.renben.process.plm.bean.ProcessBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.ServiceUtil; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.common.Activator; +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.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.loose.core.DataManagementService; +import com.teamcenter.services.loose.core._2008_06.DataManagement.SaveAsNewItemInfo; +import com.teamcenter.services.loose.core._2008_06.DataManagement.SaveAsNewItemResponse2; +import com.teamcenter.services.rac.cad.StructureManagementService; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelOccInfo; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelativeStructureChildInfo; +import com.teamcenter.services.rac.cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructureInfo2; +import com.teamcenter.services.rac.cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructurePref2; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class TMom006CreateProcessByProcessOperation extends AbstractAIFOperation { + + private InterfaceAIFComponent targets; + private String selectItems; + private TCSession session; + private String productId;// ƷID + private String productName;// Ʒ + private Map itemIdMap = new HashMap();// ItemId + private Map noMap = new HashMap();// Ųұ + private JFrame frame = new JFrame("ڸ...");// + private JProgressBar progressBar = new JProgressBar() { + public void setValue(int n) { + super.setValue(n); + System.out.println("ǰȣ"+n); + }; + };// + private String updateUID; + + public TMom006CreateProcessByProcessOperation(InterfaceAIFComponent targets, String selectItems, + TCSession session) { + this.targets = targets; + this.selectItems = selectItems; + this.session = session; + } + + private TCComponentItem item = null; + private TCComponentItem newTopItem = null; + private TCComponentItem oldTopItem; + private TreeMap itemlists = new TreeMap(); + + @Override + public void executeOperation() throws Exception { + try { + TCUtils.openLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, true); + // +++ӽ + 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);// ؽ + // +++ + // TODO Auto-generated method stub + + if (this.targets instanceof TCComponentItem) { + item = (TCComponentItem) this.targets; + } + this.productId = item.getStringProperty("item_id"); + this.productName = item.getStringProperty("object_name"); + // ȡItemId + String[] itemID = null; + if (selectItems.indexOf(" | ") > -1) { + itemID = selectItems.split(" | "); + } else { + itemID = new String[] { selectItems }; + } + progressBar.setValue(10);// ؽ + // ȡѡеĶ + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + TCComponentItemType gyType = (TCComponentItemType) session.getTypeComponent("MEProcess"); + + if (itemID != null && itemID.length > 0) { + for (int i = 0; i < itemID.length; i++) { + oldTopItem = itemType.find(itemID[i].substring(0, itemID[i].length() - 1)); + if (itemID[i].indexOf("/") >= 0) { + oldTopItem = itemType.find(itemID[i].split("/")[0]); + } else { + oldTopItem = itemType.find(itemID[i]); + } + if (!oldTopItem.getType().equals("MEProcess")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzgydx06_display.TITLE"), "", MessageBox.ERROR); + return; + } + + TCComponentItemRevision oldTopItemRevision = oldTopItem.getLatestItemRevision(); + + TCComponent[] mepComponents = item.getRelatedComponents("IMAN_reference"); + int mepCount = 0; + for (int j = 0; j < mepComponents.length; j++) { + if (mepComponents[j].getType().indexOf("MEProcess") >= 0) { + mepCount++; + } + } + Map oldMeopIdMap = new HashMap(); + ResultSet rs = null; + try { + // ȡӦIJұoldTopItem.getUid() + SqlUtilT.getTCConnection(); + String sql = String.format( + "select rb3_meopid,rb3_gybh from rb3_permissions where processpuid = \'%s\' group by rb3_meopid,rb3_gybh order by rb3_gybh", + oldTopItem.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + System.out.println("rb3_meopid:"+rs.getString("rb3_meopid")); + System.out.println("rb3_gybh:"+rs.getString("rb3_gybh")); + oldMeopIdMap.put(rs.getString("rb3_meopid"), rs.getString("rb3_gybh")); + } + + progressBar.setValue(20);// ؽ + this.updateUID = this.item.getLatestItemRevision().getUid(); + newTopItem = saveAsItem(item, mepCount + 1, oldTopItem); + + progressBar.setValue(40);// ؽ + + TCComponent[] components = newTopItem.getLatestItemRevision() + .getRelatedComponents("ps_children"); + // +++Իȡľɹ + int[] IDlist = new int[components.length]; + Map MEOPmap = new HashMap();// ע + for (int a = 0; a < components.length; a++) { + IDlist[a] = Integer.valueOf(components[a].toString().split("/")[0].substring(2)); + MEOPmap.put(IDlist[a], components[a]); + } + Arrays.sort(IDlist); + for (int b = 0; b < IDlist.length; b++) { + components[b] = MEOPmap.get(IDlist[b]); + } + progressBar.setValue(50);// ؽ + // +++ + TCComponentItemType ccomponentitemtype = null; +// Map valMap = new HashMap(); + List> opList = new ArrayList>(); + for (int j = 0; j < components.length; j++) { + if (components[j] instanceof TCComponentItemRevision) { + TCComponentItem oldMeop = ((TCComponentItemRevision) components[j]).getItem(); + String itemName = oldMeop.getStringProperty("object_name"); + if (ccomponentitemtype == null) { + ccomponentitemtype = (TCComponentItemType) session + .getTypeComponent(oldMeop.getType()); + } + String newOpId = TMomMethodUtil.getRuleItemID(session, + item.getStringProperty("item_id"), null, TMomFinalUtil.GX_CODE); + itemIdMap.put(oldMeop.getStringProperty("item_id"), newOpId); + Map opMap = new HashMap(); + opMap.put("revUid", oldMeop.getLatestItemRevision().getUid()); + opMap.put("itemId", newOpId); + opMap.put("name", itemName); + opMap.put("revId", "00"); + opList.add(opMap); + } + } + System.out.println("ʼ湤"); + if(opList.size() > 0) { + String jsonString = JSON.toJSONString(opList); + System.out.println("jsonString:"+jsonString); + saveItemByJar2(jsonString); + } + System.out.println("湤"); + System.out.println("ʼѭcomponents"); + //TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + List> oldData1 = new ArrayList>(); + List> oldData2 = new ArrayList>(); + List> oldData3 = new ArrayList>(); + Map> bomReplMap = new HashMap>(); + LinkedHashMap saveAsIteMap = new LinkedHashMap(); + + for (int j = 0; j < components.length; j++) { + if (components[j] instanceof TCComponentItemRevision) { + TCComponentItem oldMeop = ((TCComponentItemRevision) components[j]).getItem(); + String string = itemIdMap.get(oldMeop.getStringProperty("item_id")); + TCComponentItem newItem = ccomponentitemtype.find(string); +// 1 + System.out.println("ʼ"); + saveAsItem2222(saveAsIteMap,oldMeop, newItem); +// TCComponentItem newItem = saveAsItem(item, j + 1, oldMeop); + // BOM + TCComponent[] childrenComponents = newItem.getLatestItemRevision() + .getRelatedComponents("ps_children"); + if (childrenComponents.length > 0) { + ArrayList childrenItemlists = new ArrayList(); + System.out.println("ѭӼ"); + for (int k = 0; k < childrenComponents.length; k++) { + String mould = childrenComponents[k].getStringProperty("object_type"); + if (childrenComponents[k].getStringProperty("object_type") + .indexOf("mould") < 0) { + if (childrenComponents[k] instanceof TCComponentItemRevision) { + if (((TCComponentItemRevision) childrenComponents[k]) + .getItem() != null) { + childrenItemlists + .add(((TCComponentItemRevision) childrenComponents[k]) + .getItem()); + + } + } + } + } + if (newItem != null && childrenItemlists != null && childrenItemlists.size() > 0) { + bomReplMap.put(newItem, childrenItemlists); + //recreateBom(bomWindowType,newItem, childrenItemlists, true);// +++µĹ + } + } + // µĹװ + TCComponent[] gzComponents = newItem.getLatestItemRevision() + .getRelatedComponents("RB3_gongzhuang"); + if (gzComponents.length > 0) { + newItem.getLatestItemRevision().remove("RB3_gongzhuang", gzComponents); + } + // µҵָ + TCComponent[] workInstructionComponents = newItem.getLatestItemRevision() + .getRelatedComponents("RB3_zuoyezhidaoshu"); + if (workInstructionComponents.length > 0) { + newItem.getLatestItemRevision().remove("RB3_zuoyezhidaoshu", + workInstructionComponents); + } + + System.out.println(oldMeop.getStringProperty("item_id").toString()); + String index = oldMeopIdMap.get(oldMeop.getStringProperty("item_id").toString()); + System.out.println(index); + itemlists.put(Integer.parseInt(index), newItem); + } + + } + // + batchSaveAsItem(saveAsIteMap, oldData1, oldData2, oldData3); + //BOM + System.out.println("bom"); + batchBOM(bomReplMap); + System.out.println("bom"); + // + if(oldData1.size() > 0) { + batchAdd1(oldData1); + } + if(oldData2.size() > 0) { + batchAdd2(oldData2); + } + if(oldData3.size() > 0) { + batchAdd3(oldData3); + } + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + System.out.println("ѭ"); + progressBar.setValue(60);// ؽ + new Thread() { + @Override + public void run() { + if (newTopItem != null && itemlists != null && itemlists.size() > 0) { + + // recreateMeopBom(newTopItem, itemlists, true); + try { + item.add("IMAN_reference", newTopItem); + + copyDataValue(oldTopItem, newTopItem); + progressBar.setValue(80);// ؽ + recreateMeopBom(newTopItem, itemlists, true); + progressBar.setValue(90);// ؽ + progressBar.setValue(100);// ؽ + frame.dispose(); + new Thread() { + @Override + public void run() { + Activator.getDefault() + .openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents( + "com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { newTopItem }); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle( + "com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("gjgycjgycg06_display.TITLE"), "ɹ", + MessageBox.WARNING); + } + }.start(); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + progressBar.setValue(0);// ؽ + frame.setTitle("ʧ"); + } + } + }.start(); + + } + } + } catch (Exception e) { + // TODO: handle exception + } finally { + TCUtils.closeLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, false); + } + + } + + /** + * bom + * @param bomReplMap + * @throws Exception + */ + private void batchBOM(Map> bomReplMap) throws Exception { + // TODO Auto-generated method stub + Map> updateBoms = new LinkedHashMap>(); + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + for(Entry> entry : bomReplMap.entrySet()) { + //bom + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(entry.getKey(), entry.getKey().getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + topline.save(); + topline.unlock(); + bomWindow.save(); + bomWindow.unlock(); + ArrayList beans = new ArrayList(); + for(TCComponentItem item : entry.getValue()) { + BomImportBean bean = new BomImportBean(); + bean.setItem(item); + bean.setItemRevision(item.getLatestItemRevision()); + } + updateBoms.put(entry.getKey(),beans); +// CreateOrUpdateBom(entry.getKey(),beans); + } + CreateOrUpdateBom2(updateBoms); + } + private void CreateOrUpdateBom2(Map> updateBoms) throws Exception { + long time = System.nanoTime(); + CreateOrUpdateRelativeStructureInfo2[] structInfos = new CreateOrUpdateRelativeStructureInfo2[updateBoms.size()]; + int n = 0; + for(Entry> entry : updateBoms.entrySet()) { + TCComponentItem parent = entry.getKey(); + ArrayList beans = entry.getValue(); + CreateOrUpdateRelativeStructureInfo2 structInfo = new CreateOrUpdateRelativeStructureInfo2(); + List childInfoVec = new ArrayList(); + + for (int i = 0; i < beans.size(); i++) {//Ӽ + long t = System.nanoTime(); + RelativeStructureChildInfo childInfo = new RelativeStructureChildInfo(); + RelOccInfo occInfo = new RelOccInfo(); + childInfo.child = beans.get(i).getItemRevision();//Ӽ汾 + childInfo.occInfo = occInfo; + childInfoVec.add(childInfo); + System.out.println((i+1)+". Add Child: "+beans.get(i).getItem()+"=="+(t-time)/1000000); + } + RelativeStructureChildInfo[] relats = new RelativeStructureChildInfo[childInfoVec.size()]; + for(int j=0; j0) { +// view = (TCComponent) rev.getChildren("structure_revisions")[0].getComponent(); +// } +// if(view != null) { +// session.getReservationService().reserve(view); +// } +// if(view != null) { +// session.getReservationService().unreserve(view); +// } + n++; + } + CreateOrUpdateRelativeStructurePref2 sPref = new CreateOrUpdateRelativeStructurePref2(); + sPref.cadOccIdAttrName = null; + sPref.itemTypes = new String[] {}; + sPref.overwriteForLastModDate = true; + +// TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + + StructureManagementService structureManagementService = StructureManagementService.getService(session); + + structureManagementService.createOrUpdateRelativeStructure(structInfos, "view", false, sPref); + + System.out.println("time1: "+(System.nanoTime()-time)/1000000); + } + private void CreateOrUpdateBom(TCComponentItem parent, ArrayList beans) throws Exception { + long time = System.nanoTime(); + CreateOrUpdateRelativeStructureInfo2 structInfo = new CreateOrUpdateRelativeStructureInfo2(); + List childInfoVec = new ArrayList(); + CreateOrUpdateRelativeStructurePref2 sPref = new CreateOrUpdateRelativeStructurePref2(); + sPref.cadOccIdAttrName = null; + sPref.itemTypes = new String[] {}; + sPref.overwriteForLastModDate = true; + for (int i = 0; i < beans.size(); i++) {//Ӽ + long t = System.nanoTime(); + RelativeStructureChildInfo childInfo = new RelativeStructureChildInfo(); + RelOccInfo occInfo = new RelOccInfo(); + childInfo.child = beans.get(i).getItemRevision();//Ӽ汾 + childInfo.occInfo = occInfo; + childInfoVec.add(childInfo); + System.out.println((i+1)+". Add Child: "+beans.get(i).getItem()+"=="+(t-time)/1000000); + } + RelativeStructureChildInfo[] relats = new RelativeStructureChildInfo[childInfoVec.size()]; + for(int j=0; j0) { + view = (TCComponent) rev.getChildren("structure_revisions")[0].getComponent(); + } + if(view != null) { + session.getReservationService().reserve(view); + } + structureManagementService.createOrUpdateRelativeStructure(structInfoVec, "view", false, sPref); + if(view != null) { + session.getReservationService().unreserve(view); + } + System.out.println("time1: "+(System.nanoTime()-time)/1000000); + } + + + public void saveItemByJar2(String json) { + try { + TCPreferenceService preService = session.getPreferenceService(); +// String notifies[] = preService.getStringValues("RB_loginUrl"); + TCComponentUser user = session.getUser(); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + String userUid = user.getUid(); + String groupUid = group.getUid(); +// String path1 = "C:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// File file = new File(path1); +// if (!file.exists()) { +// path1 = "D:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// } +// System.out.println("updateUID:" + this.updateUID); +// String cmd = "java -jar " + path1 + " \"" + notifies[0] + "\" \"" + notifies[1] + "\" \"" + notifies[2] +// + "\" \"" + userUid + "\" \"" + groupUid + "\"" + " \"" + updateUID + "\" \"saveOp\" " + "\"" +// + json.replaceAll("\"", "\\\\\"") + "\""; +// System.out.println(cmd); +// Process process = Runtime.getRuntime().exec(cmd); +// InputStream inputStream = process.getInputStream(); +// InputStreamReader reader = new InputStreamReader(inputStream); +// BufferedReader bufferedReader = new BufferedReader(reader); +// String line = null; +// while ((line = bufferedReader.readLine()) != null) { +// System.out.println(line); +// } +// System.out.println("cmd̨"); + ServiceUtil.sendRequest("","","",userUid,groupUid,updateUID,"saveOp",json); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + public TCComponentItem saveItemByJar(String itemId, String itemName, TCComponentItem item, String revId, + String updateUID) { + try { + TCPreferenceService preService = session.getPreferenceService(); +// String notifies[] = preService.getStringValues("RB_loginUrl"); + TCComponentUser user = session.getUser(); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + String userUid = user.getUid(); + String groupUid = group.getUid(); +// String path1 = "C:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// File file = new File(path1); +// if (!file.exists()) { +// path1 = "D:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// } + System.out.println("updateUID:" + this.updateUID); +// String cmd = "java -jar " + path1 + " \"" + itemId +//// String cmd = "java -jar C:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar \""+itemId +// + "\" \"" + itemName + "\" \"" + item.getLatestItemRevision().getUid() + "\" \"" + revId + "\" \"" +// + notifies[0] + "\" \"" + notifies[1] + "\" \"" + notifies[2] + "\" \"" + userUid + "\" \"" +// + groupUid + "\"" + " \"" + updateUID + "\""; +// System.out.println(cmd); +// Process process = Runtime.getRuntime().exec(cmd); +// InputStream inputStream = process.getInputStream(); +// InputStreamReader reader = new InputStreamReader(inputStream); +// BufferedReader bufferedReader = new BufferedReader(reader); +// String line = null; +// while ((line = bufferedReader.readLine()) != null) { +// System.out.println(line); +// } +// Class.forName("com.connor.renben.process.plm.util.ServiceUtil"); + ServiceUtil.sendRequest(itemId,itemName,item.getLatestItemRevision().getUid(),revId,"","","",userUid,groupUid,updateUID); + + TCComponentItemType ccomponentitemtype = (TCComponentItemType) session.getTypeComponent(item.getType()); + TCComponentItem itemNew = null; + try { + TCUtils.openLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, true); + itemNew = ccomponentitemtype.find(itemId); + } catch (Exception e) { + // TODO: handle exception + } finally { + TCUtils.closeLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, false); + } + +// TCComponentUser user = session.getUser(); +// TMomMethodUtil.setByPass(session, true); +// TMom002AbtractDialog.changeOwner(itemNew, user); +// TMom002AbtractDialog.changeOwner(itemNew.getLatestItemRevision(), user); +// TMomMethodUtil.setByPass(session, false); + System.out.println(itemNew); + return itemNew; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * Ϊ + * + * @param item + */ + public TCComponentItem saveAsItem(TCComponentItem productItem, int itemCount, TCComponentItem item) { + TCComponentItem newItem = null; + try { + boolean isMEOP = false; + String itemID = ""; + String itemName = item.getStringProperty("object_name"); + System.out.println("ʼ"); + if (item.getType().equals("MEProcess")) { + itemID = TMomMethodUtil.getRuleItemID(session, productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GY_CODE); + itemName = this.productName; + newItem = saveItemByJar(itemID, itemName, item, "00", this.updateUID); + } else if (item.getType().equals("MEOP")) { + itemID = TMomMethodUtil.getRuleItemID(session, productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GX_CODE); + itemIdMap.put(item.getStringProperty("item_id"), itemID); + newItem = saveItemByJar(itemID, itemName, item, "00", "uid"); + } else { + newItem = item.getLatestItemRevision().saveAsItem(itemID, "00", itemName, "", true, null);// ӹ + } + System.out.println(""); + TCComponent[] itemDatas = null; + TCComponent[] newItemDatas = null; + if (item.getType().equals("MEProcess")) { + itemDatas = item.getReferenceListProperty("IMAN_reference"); + newItemDatas = newItem.getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.remove("IMAN_reference", newItemDatas); + } + } else if (item.getType().equals("MEOP")) { + isMEOP = true; + itemDatas = item.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + newItemDatas = newItem.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_reference", newItemDatas); + } + } + + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + String dataItemName = ""; + if (dataItem.getStringProperty("object_name").indexOf("/") >= 0) { + // ʱ֣this.productId DzƷID + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name").split("/")[1]; + } else { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name"); + } + + TCComponentItem newDataItem = dataItem.getLatestItemRevision() + .saveAsItem(dataItem.getTypeComponent().getNewID(), "00", dataItemName, "", true, null);// Ӱ汾 + TCComponentDataset dataSet = null; + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), "TC_Attaches", + "MSExcel"); + if (dataSet == null) { + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), + "TC_Attaches", "MSExcelX"); + } + if (dataSet != null) { + dataSet.setStringProperty("object_name", dataItemName); + dataSet.save(); + dataSet.refresh(); + } + if (newDataItem.getType().indexOf("KZJH") >= 0) { + + } else if (newDataItem.getType().indexOf("PFMEA") >= 0) { + + } else if (newDataItem.getType().indexOf("GCLCT") >= 0) { + + } + // +++ǹͣͰĹտ׼ݸƵݿ + if (isMEOP) { + String oldItmeUid = dataItem.getLatestItemRevision().getUid(); + String NewItmeUid = newDataItem.getLatestItemRevision().getUid(); + switch (dataItem.getType()) { + case "RB3_ZYGYK": + copyToolingDetailData2(oldItmeUid, NewItmeUid); + copyMachiningParameterData2(oldItmeUid, NewItmeUid); + copyControlRequirementData2(oldItmeUid, NewItmeUid); + break; + case "RB3_ZPGYK": + copyToolingDetailData2(oldItmeUid, NewItmeUid); + copyMachiningParameterData2(oldItmeUid, NewItmeUid); + copyControlRequirementData2(oldItmeUid, NewItmeUid); + break; + case "RB3_ZYJZS": + copyControlRequirementData2(oldItmeUid, NewItmeUid); + break; + default: + break; + } + // ҵĻڰ汾 + newItem.getLatestItemRevision().add("IMAN_reference", newDataItem); + } else { + // ǿƼƻPFMEAItem + newItem.add("IMAN_reference", newDataItem); + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + + public void batchSaveAsItem(LinkedHashMap saveAsIteMap,List> oldData1, List> oldData2, List> oldData3) throws TCException, NotLoadedException{ + System.out.println("ʼ"); + + SaveAsNewItemInfo[] infos = new SaveAsNewItemInfo[saveAsIteMap.size()]; + DataManagementService service = DataManagementService.getService(session.getSoaConnection()); + String[] uids = new String[saveAsIteMap.size()]; + int i = 0; + + // saveAsIteMap ļȡ UIDs + for (TCComponentItemRevision revision : saveAsIteMap.keySet()) { + System.out.println(": " + revision.getUid()); + uids[i] = revision.getUid(); + ++i; + } + + System.out.println("ض..."); + ServiceData loadObjects = service.loadObjects(uids); + + i = 0; + List oldItemUids = new ArrayList<>(); + List newItemIDList = new ArrayList(); + for (Entry entry : saveAsIteMap.entrySet()) { + System.out.println("׼¶Ϣ..."); + String newID = entry.getKey().getItem().getTypeComponent().getNewID(); + newItemIDList.add(newID); + SaveAsNewItemInfo info = new SaveAsNewItemInfo(); + ModelObject plainObject = loadObjects.getPlainObject(i); + info.baseItemRevision = plainObject; + info.newItemId = newID; + info.name = (String)(entry.getValue()[0]); + info.newRevId = "00"; + infos[i] = info; + oldItemUids.add(entry.getKey().getUid()); + System.out.println("ɶ UID: " + entry.getKey().getUid()); + ++i; + } + System.out.println(" saveAsNewItem2 ..."); + SaveAsNewItemResponse2 saveAsNewItem = service.saveAsNewItem2(infos); + int sizeOfCreatedObjects = saveAsNewItem.serviceData.sizeOfCreatedObjects(); + System.out.println("" + sizeOfCreatedObjects); + + List modjs = new ArrayList(); + // ض + System.out.println("ȡUID"); + List idList = new ArrayList(); + List modelObjects = new ArrayList(); + for (int t = 0; t < sizeOfCreatedObjects; t++) { + ModelObject modj = saveAsNewItem.serviceData.getCreatedObject(t); + idList.add(modj.getUid()); + modelObjects.add(modj); + + } + TCComponent[] stringToComponent2 = session.stringToComponent(idList.toArray(new String[0])); + for (TCComponent component : stringToComponent2) { + if(component instanceof TCComponentItem) { + modjs.add((TCComponentItem)component); + } + } + System.out.println("ɸѡ"); + + List items = sortModjsByNewItemIDList(modjs,newItemIDList); + + System.out.println("ɸѡ"); + if(items.size() != newItemIDList.size()) { + System.out.println("000000000c80w8"); + } + + for (TCComponentItem item : modjs) { + + TCComponent[] referenceListProperty = item.getLatestItemRevision().getReferenceListProperty("TC_Attaches"); + for (TCComponent zyzdsChildren : referenceListProperty) { + String type = zyzdsChildren.getType(); + if ("MSExcel".equals(type) || "MSExcelX".equals(type)) { + zyzdsChildren.setProperty("object_name", item.getProperty("object_name")); + } + } + } + + System.out.println("ùϵ..."); + i = 0; + for (Entry entry : saveAsIteMap.entrySet()) { + switch (entry.getKey().getItem().getType()) { + case "RB3_ZYGYK": + System.out.println(" RB3_ZYGYK..."); + copyToolingDetailData(oldItemUids.get(i), items.get(i).getUid(), oldData1); + copyMachiningParameterData(oldItemUids.get(i), items.get(i).getUid(), oldData2); + copyControlRequirementData(oldItemUids.get(i), items.get(i).getUid(), oldData3); + break; + case "RB3_ZPGYK": + System.out.println(" RB3_ZPGYK..."); + copyToolingDetailData(oldItemUids.get(i), items.get(i).getUid(), oldData1); + copyMachiningParameterData(oldItemUids.get(i), items.get(i).getUid(), oldData2); + copyControlRequirementData(oldItemUids.get(i), items.get(i).getUid(), oldData3); + break; + case "RB3_ZYJZS": + System.out.println(" RB3_ZYJZS..."); + copyControlRequirementData(oldItemUids.get(i), items.get(i).getUid(), oldData3); + break; + default: + System.out.println("δ: " + entry.getKey().getType()); + break; + } + System.out.println("ʼ¶" + ((TCComponentItemRevision)(entry.getValue()[1])) + "IMAN_referenceϵ" + items.get(i)); + ((TCComponentItemRevision)(entry.getValue()[1])).add("IMAN_reference", items.get(i)); + System.out.println(" IMAN_reference "); + ++i; + } + + } + + /** + * newItemIDList ˳ modjs + * + * @param modjs ԭʼ󼯺 + * @param newItemIDList ˳ ID + * @return ˳еĶ󼯺 + * @throws TCException + */ + public static List sortModjsByNewItemIDList(List modjs, List newItemIDList) throws TCException { + // һ Mapڿٲ ID ӦĶ + Map idToItemMap = new HashMap<>(); + for (TCComponentItem item : modjs) { + idToItemMap.put(item.getProperty("item_id"), item); + } + + // newItemIDList ˳򹹽µб + List sortedList = new ArrayList<>(); + for (String id : newItemIDList) { + TCComponentItem item = idToItemMap.get(id); + if (item != null) { + sortedList.add(item); + } else { + System.out.println(": newItemIDList е ID " + id + " modjs δҵ"); + } + } + + return sortedList; + } + + + + /** + * Ϊ + * + * @param item + * @param oldData3 + * @param oldData2 + * @param oldData1 + */ + public TCComponentItem saveAsItem2222(LinkedHashMap saveAsIteMap, TCComponentItem item, TCComponentItem newItem) { + try { + Boolean isMEOP = true; + TCComponent[] itemDatas = item.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + TCComponent[] newItemDatas = newItem.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_reference", newItemDatas); + } + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + Object[] obj = new Object[2]; + String dataItemName = ""; + if (dataItem.getStringProperty("object_name").indexOf("/") >= 0) { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name").split("/")[1]; + } else { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name"); + } + obj[0] = dataItemName; + obj[1] = newItem.getLatestItemRevision(); + saveAsIteMap.put(dataItem.getLatestItemRevision(), obj); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + /** + * Ϊ + * + * @param item + * @param oldData3 + * @param oldData2 + * @param oldData1 + */ + public TCComponentItem saveAsItem222(TCComponentItem item, TCComponentItem newItem, List> oldData1, List> oldData2, List> oldData3) { + try { + Boolean isMEOP = true; + TCComponent[] itemDatas = item.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + TCComponent[] newItemDatas = newItem.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_reference", newItemDatas); + } + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + String dataItemName = ""; + if (dataItem.getStringProperty("object_name").indexOf("/") >= 0) { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name").split("/")[1]; + } else { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name"); + } + + System.out.println("ʼ"); + TCComponentItem newDataItem = dataItem.getLatestItemRevision() + .saveAsItem(dataItem.getTypeComponent().getNewID(), "00", dataItemName, "", true, null);// Ӱ汾 + System.out.println(""); + + System.out.println("ʼض"); + TCComponentDataset dataSet = null; + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), "TC_Attaches", + "MSExcel"); + if (dataSet == null) { + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), + "TC_Attaches", "MSExcelX"); + } + if (dataSet != null) { + dataSet.setStringProperty("object_name", dataItemName); + dataSet.save(); + dataSet.refresh(); + } + System.out.println("ض"); + if (newDataItem.getType().indexOf("KZJH") >= 0) { + } else if (newDataItem.getType().indexOf("PFMEA") >= 0) { + + } else if (newDataItem.getType().indexOf("GCLCT") >= 0) { + + } + // +++ǹͣͰĹտ׼ݸƵݿ + if (isMEOP) { + String oldItmeUid = dataItem.getLatestItemRevision().getUid(); + String NewItmeUid = newDataItem.getLatestItemRevision().getUid(); + switch (dataItem.getType()) { + case "RB3_ZYGYK": + copyToolingDetailData(oldItmeUid, NewItmeUid,oldData1); + copyMachiningParameterData(oldItmeUid, NewItmeUid,oldData2); + copyControlRequirementData(oldItmeUid, NewItmeUid,oldData3); + break; + case "RB3_ZPGYK": + copyToolingDetailData(oldItmeUid, NewItmeUid,oldData1); + copyMachiningParameterData(oldItmeUid, NewItmeUid,oldData2); + copyControlRequirementData(oldItmeUid, NewItmeUid,oldData3); + break; + case "RB3_ZYJZS": + copyControlRequirementData(oldItmeUid, NewItmeUid,oldData3); + break; + default: + break; + } + // ҵĻڰ汾 + newItem.getLatestItemRevision().add("IMAN_reference", newDataItem); + } else { + // ǿƼƻPFMEAItem + newItem.add("IMAN_reference", newDataItem); + } + + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + private void copyToolingDetailData2(String oldItmeUid,String NewItmeUid) { + // ȡݿ + + InputStream input = null; + ResultSet Old = null; + List> oldData = new ArrayList>(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + //ȡģ + pro.load(input); + String OldSelect = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"),oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIFICATION")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("P1")); + oldData.add(rowList); + } + //ݸƸ½Item + String insertNew = pro.getProperty("RB3_TOOLINGDETAILINSERT"); + for(int i=0;i rowList = new ArrayList(); + rowList=oldData.get(i); + SqlUtilT.write2(new String[] { rowList.get(0),rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),rowList.get(5), rowList.get(6) }, insertNew); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * Ƽӹ + */ +private void copyMachiningParameterData2(String oldItmeUid,String NewItmeUid) { + // ȡݿ + InputStream input = null; + ResultSet Old = null; + List> oldData = new ArrayList>(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + //ȡģ + pro.load(input); + String OldSelect = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"),oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("VALUE")); + rowList.add(Old.getString("P1")); + oldData.add(rowList); + } + //ݸƸ½Item + String insertNew = pro.getProperty("RB3_MACHININGPARAMETERINSERT"); + for(int i=0;i rowList = new ArrayList(); + rowList=oldData.get(i); + SqlUtilT.write2(new String[] { rowList.get(0),rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),rowList.get(5), rowList.get(6) }, insertNew); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +/** + * ƿҪ + */ +private void copyControlRequirementData2(String oldItmeUid,String NewItmeUid) { + + System.out.println("ʼƻ׼"); + System.out.println("oldItmeUid:"+oldItmeUid); + System.out.println("NewItmeUid:"+NewItmeUid); + + + // ȡݿ + InputStream input = null; + ResultSet Old = null; + List> oldData = new ArrayList>(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + //ȡģ + pro.load(input); + String OldSelect = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"),oldItmeUid); + System.out.println("oldsql:"+OldSelect); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("PROJECT")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(Old.getString("CHECK_METHOD")); + rowList.add(Old.getString("FIRST_INSPECTION")); + rowList.add(Old.getString("SELF_INSPECTION")); + rowList.add(Old.getString("ROUTING_INSPECTION")); + rowList.add(Old.getString("REACTION_PLAN")); + rowList.add(Old.getString("REMARKS")); + oldData.add(rowList); + } + //ݸƸ½Item + String insertNew = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT"); + System.out.println("newsql:"+insertNew); + for(int i=0;i rowList = new ArrayList(); + rowList=oldData.get(i); + SqlUtilT.write2(new String[] { rowList.get(0),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)}, insertNew); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +} + + /** + * ƹװϸ + * @param oldData1 + */ + private void copyToolingDetailData(String oldItmeUid, String NewItmeUid, List> oldData1) { + // ȡݿ + System.out.println("ƹװϸ"); + InputStream input = null; + ResultSet Old = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); +// SqlUtilT.getTCConnection(); + String OldSelect = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIFICATION")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("P1")); + oldData1.add(rowList); + } + + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// SqlUtilT.freeAll(); + } + + private void batchAdd1(List> oldData) { + if(oldData.size() > 0) { + PreparedStatement pstmtInsert = null; + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + pstmtInsert = SqlUtilT.connection.prepareStatement(pro.getProperty("RB3_TOOLINGDETAILINSERT")); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + pstmtInsert.setString(1, rowList.get(0)); + pstmtInsert.setString(2, rowList.get(1)); + pstmtInsert.setString(3, rowList.get(2)); + pstmtInsert.setString(4, rowList.get(3)); + pstmtInsert.setString(5, rowList.get(4)); + pstmtInsert.setString(6, rowList.get(5)); + pstmtInsert.setString(7, rowList.get(6)); + pstmtInsert.addBatch(); + } + pstmtInsert.executeBatch(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * Ƽӹ + * @param oldData2 + */ + private void copyMachiningParameterData(String oldItmeUid, String NewItmeUid, List> oldData2) { + // ȡݿ + System.out.println("Ƽӹ"); +// SqlUtilT.getTCConnection(); + InputStream input = null; + ResultSet Old = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); +// SqlUtilT.getTCConnection(); + String OldSelect = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("VALUE")); + rowList.add(Old.getString("P1")); + oldData2.add(rowList); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// SqlUtilT.freeAll(); + } + + private void batchAdd2(List> oldData) { + if(oldData.size() > 0) { + PreparedStatement pstmtInsert = null; + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + pstmtInsert = SqlUtilT.connection.prepareStatement(pro.getProperty("RB3_MACHININGPARAMETERINSERT")); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + pstmtInsert.setString(1, rowList.get(0)); + pstmtInsert.setString(2, rowList.get(1)); + pstmtInsert.setString(3, rowList.get(2)); + pstmtInsert.setString(4, rowList.get(3)); + pstmtInsert.setString(5, rowList.get(4)); + pstmtInsert.setString(6, rowList.get(5)); + pstmtInsert.setString(7, rowList.get(6)); + pstmtInsert.addBatch(); + } + pstmtInsert.executeBatch(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ƿҪ + * @param oldData3 + */ + private void copyControlRequirementData(String oldItmeUid, String NewItmeUid, List> oldData3) { + + System.out.println("ʼƻ׼"); + System.out.println("oldItmeUid:" + oldItmeUid); + System.out.println("NewItmeUid:" + NewItmeUid); + + // ȡݿ +// SqlUtilT.getTCConnection(); + InputStream input = null; + ResultSet Old = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); +// SqlUtilT.getTCConnection(); + String OldSelect = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), oldItmeUid); + System.out.println("oldsql:" + OldSelect); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("PROJECT")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(Old.getString("CHECK_METHOD")); + rowList.add(Old.getString("FIRST_INSPECTION")); + rowList.add(Old.getString("SELF_INSPECTION")); + rowList.add(Old.getString("ROUTING_INSPECTION")); + rowList.add(Old.getString("REACTION_PLAN")); + rowList.add(Old.getString("REMARKS")); + oldData3.add(rowList); + } + // ݸƸ½Item +// String insertNew = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT"); +// System.out.println("newsql:" + insertNew); +// for (int i = 0; i < oldData.size(); i++) { +// List rowList = new ArrayList(); +// rowList = oldData.get(i); +// SqlUtilT.write2(new String[] { rowList.get(0), 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) }, insertNew); +// } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// SqlUtilT.freeAll(); + } + + private void batchAdd3(List> oldData) { + if(oldData.size() > 0) { + PreparedStatement pstmtInsert = null; + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + pstmtInsert = SqlUtilT.connection.prepareStatement(pro.getProperty("RB3_CONTROLREQUIREMENTINSERT")); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + pstmtInsert.setString(1, rowList.get(0)); + pstmtInsert.setString(2, rowList.get(1)); + pstmtInsert.setString(3, rowList.get(2)); + pstmtInsert.setString(4, rowList.get(3)); + pstmtInsert.setString(5, rowList.get(4)); + pstmtInsert.setString(6, rowList.get(5)); + pstmtInsert.setString(7, rowList.get(6)); + pstmtInsert.setString(8, rowList.get(7)); + pstmtInsert.setString(9, rowList.get(8)); + pstmtInsert.setString(10, rowList.get(9)); + pstmtInsert.setString(11, rowList.get(10)); + pstmtInsert.setString(12, rowList.get(11)); + + pstmtInsert.addBatch(); + } + pstmtInsert.executeBatch(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ݿеĿƼƻPFMEA + * + * @param oldItem նL + * @param newDataItem ¹ն + */ + private void copyDataValue(TCComponentItem oldItem, TCComponentItem newItem) { + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet pfmeaRs = null; + InputStream input = null; + + Connection connection = null; + try { + Properties pro = new Properties(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro.load(input); + + // ȡĿб + TCComponent[] oldItemComponents = oldItem.getReferenceListProperty("IMAN_reference"); + String controlUid = ""; + String PFMEAUid = ""; + + for (int i = 0; i < oldItemComponents.length; i++) { + if (oldItemComponents[i].getType().indexOf("RB3_SSCKZJH") >= 0) { + TCComponent[] oldItemControlRevisions = oldItemComponents[i] + .getReferenceListProperty("revision_list"); + controlUid = oldItemControlRevisions[oldItemControlRevisions.length - 1].getUid(); + } + if (oldItemComponents[i].getType().indexOf("RB3_PFMEA") >= 0) { + TCComponent[] oldItemPFMEARevisions = oldItemComponents[i] + .getReferenceListProperty("revision_list"); + PFMEAUid = oldItemPFMEARevisions[oldItemPFMEARevisions.length - 1].getUid(); + } + } + + // ȡĿб + TCComponent[] newItemComponents = newItem.getReferenceListProperty("IMAN_reference"); + String newcontrolUid = ""; + String newPFMEAUid = ""; + + for (int i = 0; i < newItemComponents.length; i++) { + if (newItemComponents[i].getType().indexOf("RB3_SSCKZJH") >= 0) { + TCComponent[] newItemControlRevisions = newItemComponents[i] + .getReferenceListProperty("revision_list"); + newcontrolUid = newItemControlRevisions[0].getUid(); + } + if (newItemComponents[i].getType().indexOf("RB3_PFMEA") >= 0) { + TCComponent[] newItemPFMEARevisions = newItemComponents[i] + .getReferenceListProperty("revision_list"); + newPFMEAUid = newItemPFMEARevisions[0].getUid(); + } + } + + // ʹӳػȡݿ + //connection = SqlUtilT.getConnection(); + connection = SqlUtilT.getTCConnection(); + // ѯControl Plan + List processBeans = queryAndCopyControlPlan(connection, oldItem, newItem, controlUid, + newcontrolUid, pro); + + // Ȩ + copyPermissions(connection, oldItem, newItem, pro); + + // ѯPFMEA + List pfmeaDataBeans = queryAndCopyPFMEA(connection, oldItem, newItem, PFMEAUid, newPFMEAUid, + pro); + + // PFMEA + insertPFMEAData(connection, newItem, pfmeaDataBeans, pro); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + // رResultSet + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (pfmeaRs != null) { + SqlUtilT.free(pfmeaRs); + } + // ر + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + } + + private List queryAndCopyControlPlan(Connection connection, TCComponentItem oldItem, + TCComponentItem newItem, String controlUid, String newcontrolUid, Properties pro) throws SQLException { + List processBeans = new ArrayList<>(); + String sql = "select * from rb3_controlplan where processpuid = ? and revisionuid=?"; + PreparedStatement pstmt = connection.prepareStatement(sql); + pstmt.setString(1, oldItem.getUid()); + pstmt.setString(2, controlUid); + ResultSet rs = pstmt.executeQuery(); + + while (rs.next()) { + ProcessBean processBean = new ProcessBean(); + processBean.setMeopId(rs.getString("RB3_MEOPID")); + processBean.setGybh(rs.getString("RB3_GYBH")); + processBean.setGcmc(rs.getString("RB3_GCMC")); + processBean.setJqsb(rs.getString("RB3_JQSB")); + processBean.setSmjy(rs.getString("RB3_SMJY")); + processBean.setQptbh(rs.getString("RB3_QPTBH")); + processBean.setCc(rs.getString("RB3_CC")); + processBean.setCp(rs.getString("RB3_CP")); + processBean.setGc(rs.getString("RB3_GC")); + processBean.setTstx(rs.getString("RB3_TSTX")); + processBean.setCpgc(rs.getString("RB3_CPGC")); + processBean.setPgclff(rs.getString("RB3_CLFF")); + processBean.setRl(rs.getString("RB3_RL")); + processBean.setPl(rs.getString("RB3_PL")); + processBean.setSjsj(rs.getString("RB3_SJSJ")); + processBean.setGcsj(rs.getString("RB3_GCSJ")); + processBean.setMjsj(rs.getString("RB3_MJSJ")); + processBean.setFzr(rs.getString("RB3_FZR")); + processBean.setKzff(rs.getString("RB3_KZFF")); + processBean.setCzgf(rs.getString("RB3_CZGF")); + processBean.setFyjh(rs.getString("RB3_FYJH")); + processBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + processBean.setHbdyg(rs.getString("RB3_HBDYG")); + processBean.setSfwc(String.valueOf(rs.getInt("RB3_SFWC"))); + processBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + processBean.setSpecial(rs.getString("RB3_SPECIAL")); + processBean.setType(rs.getString("TYPE")); + processBean.setRevisionuid(newcontrolUid); + processBean.setNO(rs.getString("NO")); // + processBeans.add(processBean); + } + + // µĿƼƻ + String insertSQL = pro.getProperty("INSERTSQL"); + PreparedStatement insertPstmt = connection.prepareStatement(insertSQL); + for (ProcessBean process : processBeans) { + insertPstmt.setString(1, UUID.randomUUID().toString().replace("-", "")); + insertPstmt.setString(2, newItem.getUid()); + insertPstmt.setString(3, itemIdMap.get(process.getMeopId())); + insertPstmt.setString(4, process.getGybh()); + insertPstmt.setString(5, process.getGcmc()); + insertPstmt.setString(6, process.getJqsb()); + insertPstmt.setString(7, process.getSmjy()); + insertPstmt.setString(8, process.getQptbh()); + insertPstmt.setString(9, process.getCc()); + insertPstmt.setString(10, process.getCp()); + insertPstmt.setString(11, process.getGc()); + insertPstmt.setString(12, process.getTstx()); + insertPstmt.setString(13, process.getCpgc()); + insertPstmt.setString(14, process.getPgclff()); + insertPstmt.setString(15, process.getRl()); + insertPstmt.setString(16, process.getPl()); + insertPstmt.setString(17, process.getSjsj()); + insertPstmt.setString(18, process.getGcsj()); + insertPstmt.setString(19, process.getMjsj()); + insertPstmt.setString(20, process.getFzr()); + insertPstmt.setString(21, process.getKzff()); + insertPstmt.setString(22, process.getCzgf()); + insertPstmt.setString(23, process.getFyjh()); + insertPstmt.setString(24, process.getHh()); + insertPstmt.setString(25, process.getHbdyg()); + insertPstmt.setString(26, "0"); + insertPstmt.setString(27, process.getHhc()); + insertPstmt.setString(28, process.getSpecial()); + insertPstmt.setString(29, process.getType()); + insertPstmt.setString(30, "0"); + insertPstmt.setString(31, "0"); + insertPstmt.setString(32, process.getNo()); + insertPstmt.setString(33, "0"); + insertPstmt.setString(34, process.getRevisionuid()); + insertPstmt.setString(35, process.getNO()); + insertPstmt.addBatch(); + } + insertPstmt.executeBatch(); + return processBeans; + } + + private void copyPermissions(Connection connection, TCComponentItem oldItem, TCComponentItem newItem, + Properties pro) throws SQLException { + String selectSQL = "select processpuid, rb3_meopid, rb3_gybh, rb3_gcmc, rb3_gxh " + "from RB3_PERMISSIONS " + + "where processpuid = ? and rb3_gcmc not like ? and rb3_meopid is not null " + + "group by processpuid, rb3_meopid, rb3_gybh, rb3_gcmc, rb3_gxh"; + + PreparedStatement pstmt = connection.prepareStatement(selectSQL); + pstmt.setString(1, oldItem.getUid()); + pstmt.setString(2, "飨%"); + ResultSet rs = pstmt.executeQuery(); + + List> meopList = new ArrayList<>(); + while (rs.next()) { + List list = new ArrayList<>(); + list.add(rs.getString("processpuid")); + list.add(rs.getString("rb3_meopid")); + list.add(rs.getString("rb3_gybh")); + list.add(rs.getString("rb3_gcmc")); + list.add(rs.getString("rb3_gxh")); + meopList.add(list); + } + + String insertSQL = pro.getProperty("INSERTPERMISSIONS"); + PreparedStatement insertPstmt = connection.prepareStatement(insertSQL); + for (List meop : meopList) { + insertPstmt.setString(1, UUID.randomUUID().toString().replace("-", "")); + insertPstmt.setString(2, newItem.getUid()); + insertPstmt.setString(3, itemIdMap.get(meop.get(1))); + insertPstmt.setString(4, meop.get(2)); + insertPstmt.setString(5, meop.get(3)); + insertPstmt.setString(6, ""); + insertPstmt.setString(7, ""); + insertPstmt.setString(8, ""); + insertPstmt.setString(9, ""); + insertPstmt.setString(10, meop.get(4)); + insertPstmt.addBatch(); + } + insertPstmt.executeBatch(); + } + + private List queryAndCopyPFMEA(Connection connection, TCComponentItem oldItem, + TCComponentItem newItem, String PFMEAUid, String newPFMEAUid, Properties pro) throws SQLException { + List pfmeaDataBeans = new ArrayList<>(); + + // ѯĿPFMEA + String pfmeaSql = String.format(pro.getProperty("SETPFMEASELECT"), oldItem.getUid(), PFMEAUid); + PreparedStatement pstmt = connection.prepareStatement(pfmeaSql); + ResultSet rs = pstmt.executeQuery(); + + while (rs.next()) { + PFMEADataBean pfmeaDataBean = new PFMEADataBean(); + pfmeaDataBean.setMeopId(rs.getString("RB3_MEOPID")); + pfmeaDataBean.setGybh(rs.getString("RB3_GYBH")); + pfmeaDataBean.setGcmc(rs.getString("RB3_GCMC")); + pfmeaDataBean.setStation(rs.getString("RB3_STATION")); + pfmeaDataBean.setRequirement(rs.getString("RB3_REQUIREMENT")); + pfmeaDataBean.setQzsxms(rs.getString("RB3_QZSXMS")); + pfmeaDataBean.setQzsxhg(rs.getString("RB3_QZSXHG")); + pfmeaDataBean.setYzd(rs.getString("RB3_YZD")); + pfmeaDataBean.setJb(rs.getString("RB3_JB")); + pfmeaDataBean.setQzsxqy(rs.getString("RB3_QZSXQY")); + pfmeaDataBean.setXxgckzyf(rs.getString("RB3_XXGCKZYF")); + pfmeaDataBean.setPds(rs.getString("RB3_PDS")); + pfmeaDataBean.setXxgckztc(rs.getString("RB3_XXGCKZTC")); + pfmeaDataBean.setTcd(rs.getString("RB3_TCD")); + pfmeaDataBean.setTm2Rpn(rs.getString("RB3_RPN")); + pfmeaDataBean.setJycs(rs.getString("RB3_JYCS")); + pfmeaDataBean.setZrr(rs.getString("RB3_ZZR")); + pfmeaDataBean.setJhwcrq(rs.getString("RB3_JHWCRQ")); + pfmeaDataBean.setCqdcs(rs.getString("RB3_CQDCS")); + pfmeaDataBean.setNewSev(rs.getString("RB3_NEW_SEV")); + pfmeaDataBean.setNewOcc(rs.getString("RB3_NEW_OCC")); + pfmeaDataBean.setNewDel(rs.getString("RB3_NEW_DET")); + pfmeaDataBean.setNewRpn(rs.getString("RB3_NEW_RPN")); + pfmeaDataBean.setIdealState(rs.getString("RB3_IDEAL_STATE")); + pfmeaDataBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + pfmeaDataBean.setHbdyg(rs.getString("RB3_HBDYG")); + pfmeaDataBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + pfmeaDataBean.setSpecial(rs.getString("RB3_SPECIAL")); + pfmeaDataBean.setType(rs.getString("TYPE")); + pfmeaDataBean.setBak(rs.getString("BAK")); + pfmeaDataBean.setOccurrence(rs.getString("OCCURRRENCE")); + pfmeaDataBean.setDetection(rs.getString("DETECTION")); + pfmeaDataBean.setPriority(rs.getString("PRIORITY")); + pfmeaDataBean.setP1(rs.getString("P1")); + pfmeaDataBean.setP2(rs.getString("P2")); + pfmeaDataBean.setP3(rs.getString("P3")); + pfmeaDataBean.setP4(rs.getString("P4")); + pfmeaDataBean.setP5(rs.getString("P5")); + pfmeaDataBean.setRevisionid(newPFMEAUid); + pfmeaDataBean.setNO(rs.getString("NO")); + + pfmeaDataBeans.add(pfmeaDataBean); + } + + return pfmeaDataBeans; + } + + private void insertPFMEAData(Connection connection, TCComponentItem newItem, List pfmeaDataBeans, + Properties pro) throws SQLException { + String insertSQL = pro.getProperty("INSERTPFMEA"); + PreparedStatement insertPstmt = connection.prepareStatement(insertSQL); + for (PFMEADataBean pfmeaData : pfmeaDataBeans) { + insertPstmt.setString(1, UUID.randomUUID().toString().replace("-", "")); // ID + insertPstmt.setString(2, newItem.getUid()); // ĿUID + insertPstmt.setString(3, itemIdMap.get(pfmeaData.getMeopId())); // MEOPIDӳֵ + insertPstmt.setString(4, noMap.get(itemIdMap.get(pfmeaData.getMeopId()))); // NOӳֵ + insertPstmt.setString(5, pfmeaData.getGcmc()); // + insertPstmt.setString(6, pfmeaData.getStation()); // λ + insertPstmt.setString(7, pfmeaData.getRequirement()); // Ҫ + insertPstmt.setString(8, pfmeaData.getQzsxms()); // ǿ + insertPstmt.setString(9, pfmeaData.getQzsxhg()); // ǿԺϸ + insertPstmt.setString(10, pfmeaData.getYzd()); // ԭӵ + insertPstmt.setString(11, pfmeaData.getJb()); // + insertPstmt.setString(12, pfmeaData.getQzsxqy()); // ǿ + insertPstmt.setString(13, pfmeaData.getXxgckzyf()); // ߹οҵ + insertPstmt.setString(14, pfmeaData.getPds()); // PDS + insertPstmt.setString(15, pfmeaData.getXxgckztc()); // ߹ο + insertPstmt.setString(16, pfmeaData.getTcd()); // + insertPstmt.setString(17, pfmeaData.getTm2Rpn()); // RPN + insertPstmt.setString(18, pfmeaData.getJycs()); // + insertPstmt.setString(19, pfmeaData.getZrr()); // + insertPstmt.setString(20, pfmeaData.getJhwcrq()); // ƻ + insertPstmt.setString(21, pfmeaData.getCqdcs()); // + insertPstmt.setString(22, pfmeaData.getNewSev()); // ض + insertPstmt.setString(23, pfmeaData.getNewOcc()); // ·Ƶ + insertPstmt.setString(24, pfmeaData.getNewDel()); // ¼Ѷ + insertPstmt.setString(25, pfmeaData.getNewRpn()); // RPN + insertPstmt.setString(26, pfmeaData.getIdealState()); // ״̬ + insertPstmt.setString(27, pfmeaData.getHh()); // к + insertPstmt.setString(28, pfmeaData.getHbdyg()); // ϲԪ + insertPstmt.setString(29, pfmeaData.getHhc()); // ϲ + insertPstmt.setString(30, pfmeaData.getSpecial()); // + insertPstmt.setString(31, pfmeaData.getType()); // + insertPstmt.setString(32, pfmeaData.getBak()); // ע + insertPstmt.setString(33, pfmeaData.getOccurrence()); // + insertPstmt.setString(34, pfmeaData.getDetection()); // + insertPstmt.setString(35, pfmeaData.getPriority()); // ȼ + insertPstmt.setString(36, pfmeaData.getP1()); // 1 + insertPstmt.setString(37, pfmeaData.getP2()); // 2 + insertPstmt.setString(38, pfmeaData.getP3()); // 3 + insertPstmt.setString(39, pfmeaData.getP4()); // 4 + insertPstmt.setString(40, pfmeaData.getP5()); // 5 + insertPstmt.setString(41, pfmeaData.getRevisionid()); // ޶汾ID + insertPstmt.setString(42, pfmeaData.getNO()); // + insertPstmt.addBatch(); + } + insertPstmt.executeBatch(); + } + + private void copyDataValue2(TCComponentItem oldItem, TCComponentItem newItem) { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet pfmeaRs = null; + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + List processBeans = new ArrayList(); + // ѯϹյĿƼƻ + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // +++ȡģ幤 + TCComponent[] oldItemComponents = oldItem.getReferenceListProperty("IMAN_reference"); + String controlUid = ""; + String PFMEAUid = ""; + for (int i = 0; i < oldItemComponents.length; i++) { + if (oldItemComponents[i].getType().indexOf("RB3_SSCKZJH") >= 0) { + TCComponent[] oldItemControlRevisions = oldItemComponents[i] + .getReferenceListProperty("revision_list"); + controlUid = oldItemControlRevisions[oldItemControlRevisions.length - 1].getUid();// ѡ°汾UID + } + if (oldItemComponents[i].getType().indexOf("RB3_PFMEA") >= 0) { + TCComponent[] oldItemPFMEARevisions = oldItemComponents[i] + .getReferenceListProperty("revision_list"); + PFMEAUid = oldItemPFMEARevisions[oldItemPFMEARevisions.length - 1].getUid();// ѡUID + } + } + // ++++ + + // +++ȡ½ + TCComponent[] newItemComponents = newItem.getReferenceListProperty("IMAN_reference"); + String newcontrolUid = ""; + String newPFMEAUid = ""; + for (int i = 0; i < newItemComponents.length; i++) { + if (newItemComponents[i].getType().indexOf("RB3_SSCKZJH") >= 0) { + TCComponent[] newItemControlRevisions = newItemComponents[i] + .getReferenceListProperty("revision_list"); + newcontrolUid = newItemControlRevisions[0].getUid();// ѡһ汾UID + } + if (newItemComponents[i].getType().indexOf("RB3_PFMEA") >= 0) { + TCComponent[] newItemPFMEARevisions = newItemComponents[i] + .getReferenceListProperty("revision_list"); + newPFMEAUid = newItemPFMEARevisions[0].getUid();// ѡһ汾UID + } + } + // ++++ + + SqlUtilT.getTCConnection(); + String sql = String.format( + "select * from rb3_controlplan where processpuid = \'%s\' and revisionuid=\'%s\'", oldItem.getUid(), + controlUid); + rs = SqlUtilT.read(sql); + while (rs.next()) { + ProcessBean processBean = new ProcessBean(); + processBean.setMeopId(rs.getString("RB3_MEOPID")); + processBean.setGybh(rs.getString("RB3_GYBH")); + processBean.setGcmc(rs.getString("RB3_GCMC")); + processBean.setJqsb(rs.getString("RB3_JQSB")); + processBean.setSmjy(rs.getString("RB3_SMJY")); + processBean.setQptbh(rs.getString("RB3_QPTBH")); + processBean.setCc(rs.getString("RB3_CC")); + processBean.setNo(rs.getString("RB3_NO")); + processBean.setCp(rs.getString("RB3_CP")); + processBean.setGc(rs.getString("RB3_GC")); + processBean.setTstx(rs.getString("RB3_TSTX")); + processBean.setCpgc(rs.getString("RB3_CPGC")); + processBean.setPgclff(rs.getString("RB3_CLFF")); + processBean.setRl(rs.getString("RB3_RL")); + processBean.setPl(rs.getString("RB3_PL")); + processBean.setSjsj(rs.getString("RB3_SJSJ")); + processBean.setGcsj(rs.getString("RB3_GCSJ")); + processBean.setMjsj(rs.getString("RB3_MJSJ")); + processBean.setFzr(rs.getString("RB3_FZR")); + processBean.setKzff(rs.getString("RB3_KZFF")); + processBean.setCzgf(rs.getString("RB3_CZGF")); + processBean.setFyjh(rs.getString("RB3_FYJH")); + processBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + processBean.setHbdyg(rs.getString("RB3_HBDYG")); + processBean.setSfwc(String.valueOf(rs.getInt("RB3_SFWC"))); + processBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + processBean.setSpecial(rs.getString("RB3_SPECIAL")); + processBean.setType(rs.getString("TYPE")); + processBean.setRevisionuid(newcontrolUid); + processBean.setNO(rs.getString("NO"));// ұ + processBeans.add(processBean); + } + noMap = getNomMap(newItem); + // + for (int i = 0; i < processBeans.size(); i++) { + // itemidȡϢ + + ProcessBean process = processBeans.get(i); + String insertSQL = pro.getProperty("INSERTSQL"); + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), + itemIdMap.get(process.getMeopId()), process.getGybh(), process.getGcmc(), process.getJqsb(), + process.getSmjy(), process.getQptbh(), process.getCc(), process.getCp(), process.getGc(), + process.getTstx(), process.getCpgc(), process.getPgclff(), process.getRl(), process.getPl(), + process.getSjsj(), process.getGcsj(), process.getMjsj(), process.getFzr(), process.getKzff(), + process.getCzgf(), process.getFyjh(), process.getHh(), process.getHbdyg(), "0", + process.getHhc(), process.getSpecial(), process.getType(), "0", "0", process.getNo(), "0", + process.getRevisionuid(), process.getNO() }, insertSQL); + } + // Ȩޱ + List> meopList = new ArrayList>(); + + String selectSQL = String.format( + "select processpuid,rb3_meopid,rb3_gybh,rb3_gcmc,rb3_gxh from RB3_PERMISSIONS where processpuid = \'%s\' and rb3_gcmc not like \'%s\' and rb3_meopid is not null group by processpuid,rb3_meopid,rb3_gybh,rb3_gcmc,rb3_gxh", + oldItem.getUid(), "飨%");// 飨 + System.out.println(selectSQL); + SqlUtilT.getTCConnection(); + rs2 = SqlUtilT.read(selectSQL); + // ģpermissionsݸƵ½ȥ + while (rs2.next()) { + List list = new ArrayList(); + list.add(rs2.getString("processpuid")); + list.add(rs2.getString("rb3_meopid")); + list.add(rs2.getString("rb3_gybh")); + list.add(rs2.getString("rb3_gcmc")); + list.add(rs2.getString("rb3_gxh")); + meopList.add(list); + } + for (int i = 0; i < meopList.size(); i++) { + String insertSQL = pro.getProperty("INSERTPERMISSIONS"); + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), + itemIdMap.get(meopList.get(i).get(1)), meopList.get(i).get(2), meopList.get(i).get(3), "", "", + "", "", meopList.get(i).get(4) }, insertSQL); + } + // ӵPFMEAе + List pfmeaDataBeans = new ArrayList(); + // ѯϹյPFMEA + SqlUtilT.getTCConnection(); + String pfmeaSql = String.format(pro.getProperty("SETPFMEASELECT"), oldItem.getUid(), PFMEAUid); + pfmeaRs = SqlUtilT.read(pfmeaSql); + while (pfmeaRs.next()) { + PFMEADataBean pfmeaDataBean = new PFMEADataBean(); + pfmeaDataBean.setMeopId(pfmeaRs.getString("RB3_MEOPID")); + pfmeaDataBean.setGybh(pfmeaRs.getString("RB3_GYBH")); + pfmeaDataBean.setGcmc(pfmeaRs.getString("RB3_GCMC")); + pfmeaDataBean.setStation(pfmeaRs.getString("RB3_STATION")); + pfmeaDataBean.setRequirement(pfmeaRs.getString("RB3_REQUIREMENT")); + pfmeaDataBean.setQzsxms(pfmeaRs.getString("RB3_QZSXMS")); + pfmeaDataBean.setQzsxhg(pfmeaRs.getString("RB3_QZSXHG")); + pfmeaDataBean.setYzd(pfmeaRs.getString("RB3_YZD")); + pfmeaDataBean.setJb(pfmeaRs.getString("RB3_JB")); + pfmeaDataBean.setQzsxqy(pfmeaRs.getString("RB3_QZSXQY")); + pfmeaDataBean.setXxgckzyf(pfmeaRs.getString("RB3_XXGCKZYF")); + pfmeaDataBean.setPds(pfmeaRs.getString("RB3_PDS")); + pfmeaDataBean.setXxgckztc(pfmeaRs.getString("RB3_XXGCKZTC")); + pfmeaDataBean.setTcd(pfmeaRs.getString("RB3_TCD")); + pfmeaDataBean.setTm2Rpn(pfmeaRs.getString("RB3_RPN")); + pfmeaDataBean.setJycs(pfmeaRs.getString("RB3_JYCS")); + pfmeaDataBean.setZrr(pfmeaRs.getString("RB3_ZZR")); + pfmeaDataBean.setJhwcrq(pfmeaRs.getString("RB3_JHWCRQ")); + pfmeaDataBean.setCqdcs(pfmeaRs.getString("RB3_CQDCS")); + pfmeaDataBean.setNewSev(pfmeaRs.getString("RB3_NEW_SEV")); + pfmeaDataBean.setNewOcc(pfmeaRs.getString("RB3_NEW_OCC")); + pfmeaDataBean.setNewDel(pfmeaRs.getString("RB3_NEW_DET")); + pfmeaDataBean.setNewRpn(pfmeaRs.getString("RB3_NEW_RPN")); + pfmeaDataBean.setIdealState(pfmeaRs.getString("RB3_IDEAL_STATE")); + pfmeaDataBean.setHh(String.valueOf(pfmeaRs.getInt("RB3_HH"))); + pfmeaDataBean.setHbdyg(pfmeaRs.getString("RB3_HBDYG")); + pfmeaDataBean.setHhc(String.valueOf(pfmeaRs.getInt("RB3_HHC"))); + pfmeaDataBean.setSpecial(pfmeaRs.getString("RB3_SPECIAL")); + pfmeaDataBean.setType(pfmeaRs.getString("TYPE")); + pfmeaDataBean.setBak(pfmeaRs.getString("BAK")); + pfmeaDataBean.setOccurrence(pfmeaRs.getString("OCCURRRENCE")); + pfmeaDataBean.setDetection(pfmeaRs.getString("DETECTION")); + pfmeaDataBean.setPriority(pfmeaRs.getString("PRIORITY")); + pfmeaDataBean.setP1(pfmeaRs.getString("P1")); + pfmeaDataBean.setP2(pfmeaRs.getString("P2")); + pfmeaDataBean.setP3(pfmeaRs.getString("P3")); + pfmeaDataBean.setP4(pfmeaRs.getString("P4")); + pfmeaDataBean.setP5(pfmeaRs.getString("P5")); + pfmeaDataBean.setRevisionid(newPFMEAUid); + pfmeaDataBean.setNO(pfmeaRs.getString("NO")); + pfmeaDataBeans.add(pfmeaDataBean); + } + // + for (int i = 0; i < pfmeaDataBeans.size(); i++) { + SqlUtilT.getTCConnection(); + PFMEADataBean pfmeaData = pfmeaDataBeans.get(i); + String insertSQL = pro.getProperty("INSERTPFMEA"); + SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), + itemIdMap.get(pfmeaData.getMeopId()), noMap.get(itemIdMap.get(pfmeaData.getMeopId())), + pfmeaData.getGcmc(), pfmeaData.getStation(), pfmeaData.getRequirement(), pfmeaData.getQzsxms(), + pfmeaData.getQzsxhg(), pfmeaData.getYzd(), pfmeaData.getJb(), pfmeaData.getQzsxqy(), + pfmeaData.getXxgckzyf(), pfmeaData.getPds(), pfmeaData.getXxgckztc(), pfmeaData.getTcd(), + pfmeaData.getTm2Rpn(), pfmeaData.getJycs(), pfmeaData.getZrr(), pfmeaData.getJhwcrq(), + pfmeaData.getCqdcs(), pfmeaData.getNewSev(), pfmeaData.getNewOcc(), pfmeaData.getNewDel(), + pfmeaData.getNewRpn(), pfmeaData.getIdealState(), pfmeaData.getHh(), pfmeaData.getHbdyg(), + pfmeaData.getHhc(), pfmeaData.getSpecial(), pfmeaData.getType(), pfmeaData.getBak(), + pfmeaData.getOccurrence(), pfmeaData.getDetection(), pfmeaData.getPriority(), pfmeaData.getP1(), + pfmeaData.getP2(), pfmeaData.getP3(), pfmeaData.getP4(), pfmeaData.getP5(), + pfmeaData.getRevisionid(), pfmeaData.getNO() }, insertSQL); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (pfmeaRs != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private Map getNomMap(TCComponentItem item) { + Map resultMap = new HashMap(); + try { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline = ((TCComponentBOMLine) children.getComponent()); + resultMap.put(subline.getStringProperty("bl_indented_title").split("/")[0], + subline.getStringProperty("bl_sequence_no")); + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return resultMap; + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + * @throws SQLException + */ + public void recreateMeopBom(TCComponentItem topItem, TreeMap itemlists, boolean isDelete) + throws TCException, SQLException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + topline.refresh(); + Iterator it = itemlists.keySet().iterator(); + while (it.hasNext()) { + TCComponentItem meopItem = itemlists.get(it.next()); + TCComponentItemRevision revision = meopItem.getLatestItemRevision(); + topline.add(meopItem, revision, null, false, ""); + } + // +++++дBOM + // topline.updateCacheOnEvent(null); + topline.refresh(); + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + // +++ͨpermissions½IDĹţдbom + ResultSet rs = null; + String classID = ""; + String sql = String.format("select RB3_GXH from RB3_PERMISSIONS where RB3_MEOPID=\'%s\'", + ((TCComponentBOMLine) children.getComponent()).getStringProperty("bl_item_item_id")); + SqlUtilT.getTCConnection(); + rs = SqlUtilT.read(sql); + System.out.println("=====>" + sql); + while (rs.next()) { + classID = rs.getString("RB3_GXH"); + } + System.out.println("+++++++++ţ" + classID); + ((TCComponentBOMLine) children.getComponent()).setStringProperty("RB3_GXH", classID); + } + SqlUtilT.freeAll(); + // ++++++ + bomWindow.unlock(); + bomWindow.save(); + } + + /** + * ´BOM µĹ + * @param bomWindowType + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentBOMWindowType bomWindowType, TCComponentItem topItem, ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessOperation2.java b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessOperation2.java new file mode 100644 index 0000000..ca3356a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/TMom006CreateProcessByProcessOperation2.java @@ -0,0 +1,2379 @@ +package com.connor.renben.process.plm.tmom006; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.TreeMap; +import java.util.UUID; + +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.alibaba.fastjson.JSON; +//import org.jacorb.idl.runtime.int_token; +import com.connor.renben.process.plm.bean.PFMEADataBean; +import com.connor.renben.process.plm.bean.ProcessBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.ServiceUtil; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.common.Activator; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMView; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.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.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.loose.bom._2008_06.StructureManagement.RemoveChildrenFromParentLineResponse; +import com.teamcenter.services.loose.core.DataManagementService; +import com.teamcenter.services.loose.core._2008_06.DataManagement.SaveAsNewItemInfo; +import com.teamcenter.services.loose.core._2008_06.DataManagement.SaveAsNewItemResponse2; +import com.teamcenter.services.rac.cad.StructureManagementService; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateBOMWindowsInfo; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateBOMWindowsOutput; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateBOMWindowsResponse; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelOccInfo; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelativeStructureChildInfo; +import com.teamcenter.services.rac.cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructureInfo2; +import com.teamcenter.services.rac.cad._2007_12.StructureManagement.CreateOrUpdateRelativeStructurePref2; +import com.teamcenter.soa.client.model.ModelObject; +import com.teamcenter.soa.client.model.ServiceData; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class TMom006CreateProcessByProcessOperation2 extends AbstractAIFOperation { + + private InterfaceAIFComponent targets; + private String selectItems; + private TCSession session; + private String productId;// ƷID + private String productName;// Ʒ + private Map itemIdMap = new HashMap();// ItemId + private Map noMap = new HashMap();// Ųұ + private JFrame frame = new JFrame("ڸ...");// + private JProgressBar progressBar = new JProgressBar() { + public void setValue(int n) { + super.setValue(n); + System.out.println("ǰȣ" + n); + }; + };// + private String updateUID; + + public TMom006CreateProcessByProcessOperation2(InterfaceAIFComponent targets, String selectItems, + TCSession session) { + this.targets = targets; + this.selectItems = selectItems; + this.session = session; + } + + private TCComponentItem item = null; + private TCComponentItem newTopItem = null; + private TCComponentItem oldTopItem; + private TreeMap itemlists = new TreeMap(); + + @Override + public void executeOperation() throws Exception { + try { + TCUtils.openLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, true); + // +++ӽ + 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);// ؽ + // +++ + // TODO Auto-generated method stub + + if (this.targets instanceof TCComponentItem) { + item = (TCComponentItem) this.targets; + } + + String[] itemPops = new String[] { "item_id", "object_name" }; + TCProperty[][] itemPropers = TCComponentType + .getTCPropertiesSet(Arrays.asList(new TCComponentItem[] { item }), itemPops); + + this.productId = itemPropers[0][0].getDisplayableValue(); + this.productName = itemPropers[0][1].getDisplayableValue(); + // ȡItemId + String[] itemID = null; + if (selectItems.indexOf(" | ") > -1) { + itemID = selectItems.split(" | "); + } else { + itemID = new String[] { selectItems }; + } + + // ȡѡеĶ + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + + if (itemID != null && itemID.length > 0) { + for (int i = 0; i < itemID.length; i++) { + oldTopItem = itemType.find(itemID[i].substring(0, itemID[i].length() - 1)); + if (itemID[i].indexOf("/") >= 0) { + oldTopItem = itemType.find(itemID[i].split("/")[0]); + } else { + oldTopItem = itemType.find(itemID[i]); + } + if (!oldTopItem.getType().equals("MEProcess")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzgydx06_display.TITLE"), "", MessageBox.ERROR); + return; + } + + Map oldMeopIdMap = new HashMap(); + ResultSet rs = null; + try { + // ȡӦIJұoldTopItem.getUid() + SqlUtilT.getTCConnection(); + String sql = String.format( + "select rb3_meopid,rb3_gybh from rb3_permissions where processpuid = \'%s\' group by rb3_meopid,rb3_gybh order by rb3_gybh", + oldTopItem.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + String rb3_meopid = rs.getString("rb3_meopid"); + String rb3_gybh = rs.getString("rb3_gybh"); + System.out.println("rb3_meopid:" + rb3_meopid + "rb3_gybh:" + rb3_gybh); + oldMeopIdMap.put(rb3_meopid, rb3_gybh); + } + + this.updateUID = this.item.getLatestItemRevision().getUid(); + newTopItem = saveAsItem(item, oldTopItem); + + progressBar.setValue(10);// ؽ + + TCComponent[] components = newTopItem.getLatestItemRevision() + .getRelatedComponents("ps_children"); +// TCComponent[] components = getBomObj(newTopItem); + // +++Իȡľɹ + int[] IDlist = new int[components.length]; + Map MEOPmap = new HashMap();// ע + for (int a = 0; a < components.length; a++) { + IDlist[a] = Integer.valueOf(components[a].toString().split("/")[0].substring(2)); + MEOPmap.put(IDlist[a], components[a]); + } + Arrays.sort(IDlist); + for (int b = 0; b < IDlist.length; b++) { + components[b] = MEOPmap.get(IDlist[b]); + } + progressBar.setValue(15);// ؽ + + List> opList = new ArrayList>(); + String[] oldMeopProps = new String[] { "object_name", "item_id" }; + TCComponentItemType tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("MEOP")); + + for (int j = 0; j < components.length; j++) { + if (components[j] instanceof TCComponentItemRevision) { + TCComponentItem oldMeop = ((TCComponentItemRevision) components[j]).getItem(); + String[] properties2 = oldMeop.getProperties(oldMeopProps); + String newOpId = tccomponentitemtype.getNewID(); + itemIdMap.put(properties2[1], newOpId); + Map opMap = new HashMap(); + opMap.put("revUid", oldMeop.getLatestItemRevision().getUid()); + opMap.put("itemId", newOpId); + opMap.put("name", properties2[0]); + opMap.put("revId", "00"); + opList.add(opMap); + } + } + progressBar.setValue(20);// ؽ + System.out.println("ʼ湤"); + if (opList.size() > 0) { + String jsonString = JSON.toJSONString(opList); + System.out.println("jsonString:" + jsonString); + saveItemByJar2(jsonString); + } + progressBar.setValue(35);// ؽ + System.out.println("湤,ʼѭcomponents"); + + Map> bomReplMap = new HashMap>(); + LinkedHashMap saveAsIteMap = new LinkedHashMap(); + + // ռTCComponentItemRevisionʵ + List oldRevs = new ArrayList<>(); + for (TCComponent component : components) { + if (component instanceof TCComponentItemRevision) { + oldRevs.add((TCComponentItemRevision) component); + } + } + System.out.println("ɹ" + oldRevs.size()); + // ȡɶ + String[] itemRevProps = new String[] { "item_id", "IMAN_reference" }; + TCProperty[][] itemProps = TCComponentType.getTCPropertiesSet(oldRevs, itemRevProps); + + // ȡItem + List newItemIds = new ArrayList<>(); + for (int j = 0; j < itemProps.length; j++) { + newItemIds.add(itemIdMap.get(itemProps[j][0].getDisplayableValue())); + } + + // ȡid + String result = String.join(";", newItemIds); + // ȡµĹ + TCComponent[] newItemRev = session.search("...", new String[] { " ID" }, + new String[] { result }); + System.out.println("¹" + newItemRev.length); + // ȡ¶ + String[] newItemRevProps = new String[] { "revision_list" }; + TCProperty[][] newItemProps = TCComponentType.getTCPropertiesSet(Arrays.asList(newItemRev), + newItemRevProps); + List newItemRevs = new ArrayList(); + + for (int j = 0; j < newItemProps.length; j++) { + + TCComponent[] rList = newItemProps[j][0].getReferenceValueArray(); + newItemRevs.add(((TCComponentItemRevision) rList[rList.length - 1])); + } + System.out.println("¹汾" + newItemRevs.size()); + + // BOM + List gxBoms = new ArrayList(); + String[] gxRevProps = new String[] {"ps_children","IMAN_reference" }; + TCProperty[][] gxRevPropy = TCComponentType.getTCPropertiesSet(newItemRevs, gxRevProps); + for (int j = 0; j < gxRevPropy.length; j++) { +// TCComponent[] referenceValueArray = getBomObj(newItemRevs.get(j).getItem()); + TCComponent[] referenceValueArray = gxRevPropy[j][0].getReferenceValueArray(); + System.out.println("children:" + referenceValueArray.length); + gxBoms.add(referenceValueArray); + + TCComponent[] referenceValueArray1 = gxRevPropy[j][1].getReferenceValueArray(); + if (referenceValueArray1 != null && referenceValueArray1.length > 0) { + ((TCComponentItem) newItemRev[j]).getLatestItemRevision().remove("IMAN_reference", + referenceValueArray1); + } + + TCComponent[] gzComponents = newItemRevs.get(j).getRelatedComponents("RB3_gongzhuang"); + if (gzComponents.length > 0) { + newItemRevs.get(j).remove("RB3_gongzhuang", gzComponents); + } + // µҵָ + TCComponent[] workInstructionComponents = newItemRevs.get(j) + .getRelatedComponents("RB3_zuoyezhidaoshu"); + if (workInstructionComponents.length > 0) { + newItemRevs.get(j).remove("RB3_zuoyezhidaoshu", workInstructionComponents); + } + } + System.out.println("BOM" + gxBoms.size()); + + // 湤µ + for (int j = 0; j < itemProps.length; j++) { + TCComponent[] referenceValueArray = itemProps[j][1].getReferenceValueArray(); + if (referenceValueArray != null && referenceValueArray.length > 0) { + List wlComps = new ArrayList(); + for (int j1 = 0; j1 < referenceValueArray.length; j1++) { + if (referenceValueArray[j1] instanceof TCComponentItem) { + wlComps.add((TCComponentItem) referenceValueArray[j1]); + } + } + System.out.println("1:" + wlComps); + // ȡ + String[] wlProps = new String[] { "object_name" }; + TCProperty[][] wlItemProps = TCComponentType.getTCPropertiesSet(wlComps, wlProps); + for (int n = 0; n < wlItemProps.length; n++) { + String name = wlItemProps[n][0].getDisplayableValue(); + String dataItemName = ""; + if (name.indexOf("/") >= 0) { + dataItemName = this.productId + "/" + name.split("/")[1]; + } else { + dataItemName = this.productId + "/" + name; + } + Object[] obj = new Object[2]; + obj[0] = dataItemName; + obj[1] = ((TCComponentItem) newItemRev[j]).getLatestItemRevision(); + saveAsIteMap.put(wlComps.get(n).getLatestItemRevision(), obj); + } + } + // ȡBOM + ArrayList childrenItemlists = new ArrayList(); + if (gxBoms.size() > 0 && gxBoms.get(j) != null && gxBoms.get(j).length > 0) { + // ȡӼ + String[] wlBomProps = new String[] { "object_type" }; + System.out.println(gxBoms.get(j)[0].getProperty("object_string")); + List asList = Arrays.asList(gxBoms.get(j)); + System.out.println(asList); + TCProperty[][] wlBomPropy = TCComponentType + .getTCPropertiesSet(asList, wlBomProps); + for (int n = 0; n < wlBomPropy.length; n++) { + String type = wlBomPropy[n][0].getStringValue(); + if (type.indexOf("mould") < 0 + && gxBoms.get(j)[n] instanceof TCComponentItemRevision) { + childrenItemlists.add(((TCComponentItemRevision) gxBoms.get(j)[n]).getItem()); + } + } + } + bomReplMap.put((TCComponentItem) newItemRev[j], childrenItemlists); + + String index = oldMeopIdMap.get(itemProps[j][0].getDisplayableValue()); + System.out.println(index); + itemlists.put(Integer.parseInt(index), ((TCComponentItem) newItemRev[j])); + } + progressBar.setValue(40);// ؽ + + List> oldData1 = new ArrayList>(); + List> oldData2 = new ArrayList>(); + List> oldData3 = new ArrayList>(); + // + batchSaveAsItem(saveAsIteMap, oldData1, oldData2, oldData3); + progressBar.setValue(60);// ؽ + // BOM + System.out.println("bom"); + batchBOM(bomReplMap); + System.out.println("bom"); + progressBar.setValue(70);// ؽ + // + if (oldData1.size() > 0) { + batchAdd1(oldData1); + } + if (oldData2.size() > 0) { + batchAdd2(oldData2); + } + if (oldData3.size() > 0) { + batchAdd3(oldData3); + } + progressBar.setValue(75);// ؽ + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + System.out.println("ѭ"); + new Thread() { + @Override + public void run() { + if (newTopItem != null && itemlists != null && itemlists.size() > 0) { + + // recreateMeopBom(newTopItem, itemlists, true); + try { + item.add("IMAN_reference", newTopItem); + copyDataValue2(oldTopItem, newTopItem); + progressBar.setValue(80);// ؽ + recreateMeopBom(newTopItem, itemlists, true); + progressBar.setValue(90);// ؽ + progressBar.setValue(100);// ؽ + frame.dispose(); + new Thread() { + @Override + public void run() { + Activator.getDefault() + .openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + Activator.getDefault().openComponents( + "com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { newTopItem }); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle( + "com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("gjgycjgycg06_display.TITLE"), "ɹ", + MessageBox.WARNING); + } + }.start(); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + progressBar.setValue(0);// ؽ + frame.setTitle("ʧ"); + } + } + }.start(); + + } + } + } catch (Exception e) { + // TODO: handle exception + } finally { + TCUtils.closeLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, false); + } + + } + + /** + * bom + * + * @param bomReplMap + * @throws Exception + */ + private void batchBOM(Map> bomReplMap) throws Exception { + // TODO Auto-generated method stub + Map> updateBoms = new LinkedHashMap>(); +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + List itemRevs = new ArrayList(); + List items = new ArrayList(); + for (Entry> entry : bomReplMap.entrySet()) { + items.add(entry.getKey()); + itemRevs.add(entry.getKey().getLatestItemRevision()); + ArrayList beans = new ArrayList(); + for (TCComponentItem item : entry.getValue()) { + BomImportBean bean = new BomImportBean(); + bean.setItem(item); + bean.setItemRevision(item.getLatestItemRevision()); + beans.add(bean); + } + updateBoms.put(entry.getKey(), beans); + } + + // BomӼ + System.out.println("BOMӼ"); + //ɾBOMͼ +// removeBomViewsByItemForService(itemRevs); + removeBomsViewByRevs(itemRevs); + //clearBomsChild(items, itemRevs); + System.out.println("BOM"); + CreateOrUpdateBom2(updateBoms); + } + + private void removeBomViewsByItemForService(List itemRevs) { + // TODO Auto-generated method stub + //֯ + try { + List> opList = new ArrayList>(); + String[] props = new String[] { "structure_revisions" }; + TCProperty[][] gxRevPropy = TCComponentType.getTCPropertiesSet(itemRevs, props); + for(int i = 0;i< gxRevPropy.length;i++) { + TCComponent[] referenceValueArray = gxRevPropy[i][0].getReferenceValueArray(); + if(referenceValueArray != null && referenceValueArray.length > 0) { + Map opMap = new HashMap(); + opMap.put("viewUid", referenceValueArray[0].getUid()); + opList.add(opMap); + } + } + if(opList.size() > 0) { + String jsonString = JSON.toJSONString(opList); + System.out.println("jsonString:" + jsonString); + saveItemByJar3(jsonString); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void removeBomsViewByRevs(List itemRevs) { + // TODO Auto-generated method stub + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = session.getUserService(); + try { + TCUtils.openLogByPass(session, "ݹոƹ"); + userservice.call("Connor_set_bypass", obj); +// String[] props = new String[] { "structure_revisions" }; +// TCProperty[][] gxRevPropy = TCComponentType.getTCPropertiesSet(itemRevs, props); +// List comps = new ArrayList(); +// for(int i = 0;i< gxRevPropy.length;i++) { +// TCComponent[] referenceValueArray = gxRevPropy[i][0].getReferenceValueArray(); +// +// if(referenceValueArray != null && referenceValueArray.length > 0) { +// referenceValueArray[0].delete(); +// } +// } + for (int i = 0; i < itemRevs.size(); i++) { + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine topLine = view.setWindowTopLine(itemRevs.get(i).getItem(), itemRevs.get(i), null, null); + topLine.lock(); + AIFComponentContext[] childrens = topLine.getChildren(); + System.out.println("childrens==="+childrens.length); + for (int k = 0; k < childrens.length; k++) { + InterfaceAIFComponent comp = childrens[k].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; + topLine.remove("", line); + } + } + topLine.save(); + topLine.unlock(); + view.save(); + view.close(); + } + + + + + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, "ݹոƹ"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + @SuppressWarnings("deprecation") + private void clearBomsChild(List items2, List itemRevs2) + throws TCException { + // TODO Auto-generated method stub + String[] props = new String[] { "bom_view_tags" }; + TCProperty[][] gxRevPropy = TCComponentType.getTCPropertiesSet(items2, props); + List itemRevs = new ArrayList(); + List items = new ArrayList(); + List bomViews = new ArrayList(); + for (int i = 0; i < gxRevPropy.length; i++) { + TCComponent[] referenceValueArray = gxRevPropy[i][0].getReferenceValueArray(); + if (referenceValueArray != null && referenceValueArray.length > 0) { + items.add(items2.get(i)); + itemRevs.add(itemRevs2.get(i)); + bomViews.add(referenceValueArray[referenceValueArray.length - 1]); + } + } + com.teamcenter.services.loose.bom.StructureManagementService service2 = com.teamcenter.services.loose.bom.StructureManagementService + .getService(session.getSoaConnection()); + + StructureManagementService service = StructureManagementService.getService(session); + CreateBOMWindowsInfo[] bomWinInfos = new CreateBOMWindowsInfo[items.size()]; + for (int i = 0; i < items.size(); i++) { + CreateBOMWindowsInfo bomWinInfo = new CreateBOMWindowsInfo(); + bomWinInfo.item = items.get(i); + bomWinInfo.itemRev = itemRevs.get(i); + bomWinInfo.bomView = (TCComponentBOMView) bomViews.get(i); + bomWinInfos[i] = bomWinInfo; + } + CreateBOMWindowsResponse bomResp = service.createBOMWindows(bomWinInfos); + if (bomResp == null || bomResp.serviceData.sizeOfPartialErrors() > 0) { + System.out.println(""); + System.out.println("clear bom failed"); + for (int i = 0; i < bomResp.serviceData.sizeOfPartialErrors(); i++) { + String[] messages = bomResp.serviceData.getPartialError(i).getMessages(); + for (int j = 0; j < messages.length; j++) { + System.out.println(bomResp.serviceData.getPartialError(i).getErrorValues()[j].getMessage()); + } + } + return; + } + + CreateBOMWindowsOutput[] outputs = bomResp.output; + List bomLines = new ArrayList(); + Set bomWindows = new HashSet(); + for (int k = 0; k < outputs.length; k++) { + TCComponentBOMLine bomLine = outputs[k].bomLine; + TCComponentBOMWindow bomWindow = outputs[k].bomWindow; + bomLines.add(bomLine); + bomWindows.add(bomWindow); + } + String[] bomlineProp = new String[] { "bl_child_lines" }; + System.out.println(bomLines); + TCProperty[][] bomPropy = TCComponentType.getTCPropertiesSet(bomLines, bomlineProp); + List comList = new ArrayList(); + for (int i = 0; i < bomPropy.length; i++) { + TCComponent[] boms = bomPropy[i][0].getReferenceValueArray(); + if (boms != null || boms.length > 0) { + comList.addAll(Arrays.asList(boms)); + } + } + RemoveChildrenFromParentLineResponse removeResp = service2 + .removeChildrenFromParentLine(comList.toArray(new TCComponent[0])); + System.out.println("ɾɹ"); + TCComponentBOMWindow[] array = bomWindows.toArray(new TCComponentBOMWindow[0]); + System.out.println("BOMͼ"); + service.saveBOMWindows(array); + System.out.println("رBOMͼ"); + service.closeBOMWindows(array); + } + + private void CreateOrUpdateBom2(Map> updateBoms) throws Exception { + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = session.getUserService(); + try { + TCUtils.openLogByPass(session, "ݹոƹ"); + userservice.call("Connor_set_bypass", obj); + long time = System.nanoTime(); + CreateOrUpdateRelativeStructureInfo2[] structInfos = new CreateOrUpdateRelativeStructureInfo2[updateBoms + .size()]; + int n = 0; + List views = new ArrayList(); + for (Entry> entry : updateBoms.entrySet()) { + TCComponentItem parent = entry.getKey(); + ArrayList beans = entry.getValue(); + CreateOrUpdateRelativeStructureInfo2 structInfo = new CreateOrUpdateRelativeStructureInfo2(); + List childInfoVec = new ArrayList(); + + for (int i = 0; i < beans.size(); i++) {// Ӽ + long t = System.nanoTime(); + RelativeStructureChildInfo childInfo = new RelativeStructureChildInfo(); + RelOccInfo occInfo = new RelOccInfo(); + childInfo.child = beans.get(i).getItemRevision();// Ӽ汾 + childInfo.occInfo = occInfo; + childInfoVec.add(childInfo); + System.out.println((i + 1) + ". Add Child: " + beans.get(i).getItem() + "==" + (t - time) / 1000000); + } + RelativeStructureChildInfo[] relats = new RelativeStructureChildInfo[childInfoVec.size()]; + for (int j = 0; j < childInfoVec.size(); j++) { + relats[j] = childInfoVec.get(j); + } + structInfo.childInfo = relats; + TCComponentItemRevision rev = parent.getLatestItemRevision(); + structInfo.parent = rev; + structInfo.precise = false; + structInfos[n] = structInfo; + + AIFComponentContext[] children = rev.getChildren("structure_revisions"); + TCComponent view = null; + if (children != null && children.length > 0) { + view = (TCComponent) rev.getChildren("structure_revisions")[0].getComponent(); + } + if (view != null) { + session.getReservationService().reserve(view); + views.add(view); + } + n++; + } + CreateOrUpdateRelativeStructurePref2 sPref = new CreateOrUpdateRelativeStructurePref2(); + sPref.cadOccIdAttrName = null; + sPref.itemTypes = new String[] {}; + sPref.overwriteForLastModDate = true; + + StructureManagementService structureManagementService = StructureManagementService.getService(session); + + structureManagementService.createOrUpdateRelativeStructure(structInfos, "view", false, sPref); + for (TCComponent view : views) { + if (view != null) { + session.getReservationService().unreserve(view); + } + } + System.out.println("time1: " + (System.nanoTime() - time) / 1000000); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + try { + TCUtils.closeLogByPass(session, "ݹոƹ"); + userservice.call("Connor_close_bypass", obj); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + private void CreateOrUpdateBom(TCComponentItem parent, ArrayList beans) throws Exception { + long time = System.nanoTime(); + CreateOrUpdateRelativeStructureInfo2 structInfo = new CreateOrUpdateRelativeStructureInfo2(); + List childInfoVec = new ArrayList(); + CreateOrUpdateRelativeStructurePref2 sPref = new CreateOrUpdateRelativeStructurePref2(); + sPref.cadOccIdAttrName = null; + sPref.itemTypes = new String[] {}; + sPref.overwriteForLastModDate = true; + for (int i = 0; i < beans.size(); i++) {// Ӽ + long t = System.nanoTime(); + RelativeStructureChildInfo childInfo = new RelativeStructureChildInfo(); + RelOccInfo occInfo = new RelOccInfo(); + childInfo.child = beans.get(i).getItemRevision();// Ӽ汾 + childInfo.occInfo = occInfo; + childInfoVec.add(childInfo); + System.out.println((i + 1) + ". Add Child: " + beans.get(i).getItem() + "==" + (t - time) / 1000000); + } + RelativeStructureChildInfo[] relats = new RelativeStructureChildInfo[childInfoVec.size()]; + for (int j = 0; j < childInfoVec.size(); j++) { + relats[j] = childInfoVec.get(j); + } + structInfo.childInfo = relats; + TCComponentItemRevision rev = parent.getLatestItemRevision(); + structInfo.parent = rev; + structInfo.precise = false; + CreateOrUpdateRelativeStructureInfo2[] structInfoVec = new CreateOrUpdateRelativeStructureInfo2[] { + structInfo }; + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + StructureManagementService structureManagementService = StructureManagementService.getService(session); + int i = 0; + while (i < 5) { + rev.refresh(); + i++; + } + + // TCComponent view = (TCComponent) + // rev.getChildren("structure_revisions")[0].getComponent(); + // session.getReservationService().reserve(view); +// CreateOrUpdateRelativeStructureResponse bomResp = + AIFComponentContext[] children = rev.getChildren("structure_revisions"); + TCComponent view = null; + if (children != null && children.length > 0) { + view = (TCComponent) rev.getChildren("structure_revisions")[0].getComponent(); + } + if (view != null) { + session.getReservationService().reserve(view); + } + structureManagementService.createOrUpdateRelativeStructure(structInfoVec, "view", false, sPref); + if (view != null) { + session.getReservationService().unreserve(view); + } + System.out.println("time1: " + (System.nanoTime() - time) / 1000000); + } + + public void saveItemByJar2(String json) { + try { + TCComponentUser user = session.getUser(); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + String userUid = user.getUid(); + String groupUid = group.getUid(); + ServiceUtil.sendRequest("", "", "", userUid, groupUid, updateUID, "saveOp", json); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + public void saveItemByJar3(String json) { + try { + ServiceUtil.sendRequest("", "", "", "", "", "", "removeView", json); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + public TCComponentItem saveItemByJar(String itemId, String itemName, TCComponentItem item, String revId, + String updateUID) { + try { + TCPreferenceService preService = session.getPreferenceService(); +// String notifies[] = preService.getStringValues("RB_loginUrl"); + TCComponentUser user = session.getUser(); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + String userUid = user.getUid(); + String groupUid = group.getUid(); +// String path1 = "C:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// File file = new File(path1); +// if (!file.exists()) { +// path1 = "D:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar"; +// } + System.out.println("updateUID:" + this.updateUID); +// String cmd = "java -jar " + path1 + " \"" + itemId +//// String cmd = "java -jar C:\\Siemens\\Teamcenter12\\portal\\plugins\\saveAsTest.jar \""+itemId +// + "\" \"" + itemName + "\" \"" + item.getLatestItemRevision().getUid() + "\" \"" + revId + "\" \"" +// + notifies[0] + "\" \"" + notifies[1] + "\" \"" + notifies[2] + "\" \"" + userUid + "\" \"" +// + groupUid + "\"" + " \"" + updateUID + "\""; +// System.out.println(cmd); +// Process process = Runtime.getRuntime().exec(cmd); +// InputStream inputStream = process.getInputStream(); +// InputStreamReader reader = new InputStreamReader(inputStream); +// BufferedReader bufferedReader = new BufferedReader(reader); +// String line = null; +// while ((line = bufferedReader.readLine()) != null) { +// System.out.println(line); +// } +// Class.forName("com.connor.renben.process.plm.util.ServiceUtil"); + ServiceUtil.sendRequest(itemId, itemName, item.getLatestItemRevision().getUid(), revId, "", "", "", userUid, + groupUid, updateUID); + + TCComponentItemType ccomponentitemtype = (TCComponentItemType) session.getTypeComponent(item.getType()); + TCComponentItem itemNew = null; + try { + TCUtils.openLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, true); + itemNew = ccomponentitemtype.find(itemId); + } catch (Exception e) { + // TODO: handle exception + } finally { + TCUtils.closeLogByPass(session, "ݹմ"); + TMomMethodUtil.setByPass(session, false); + } + +// TCComponentUser user = session.getUser(); +// TMomMethodUtil.setByPass(session, true); +// TMom002AbtractDialog.changeOwner(itemNew, user); +// TMom002AbtractDialog.changeOwner(itemNew.getLatestItemRevision(), user); +// TMomMethodUtil.setByPass(session, false); + System.out.println(itemNew); + return itemNew; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * Ϊ + * + * @param item + */ + public TCComponentItem saveAsItem(TCComponentItem productItem, TCComponentItem item) { + TCComponentItem newItem = null; + try { + boolean isMEOP = false; + String itemID = ""; + String itemName = item.getStringProperty("object_name"); + System.out.println("ʼ"); + String type = item.getType(); + if (type.equals("MEProcess")) { + itemID = TMomMethodUtil.getRuleItemID(session, productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GY_CODE); + itemName = this.productName; + newItem = saveItemByJar(itemID, itemName, item, "00", this.updateUID); + } else if (type.equals("MEOP")) { + itemID = TMomMethodUtil.getRuleItemID(session, productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GX_CODE); + itemIdMap.put(item.getStringProperty("item_id"), itemID); + newItem = saveItemByJar(itemID, itemName, item, "00", "uid"); + } else { + newItem = item.getLatestItemRevision().saveAsItem(itemID, "00", itemName, "", true, null);// ӹ + } + System.out.println(""); + TCComponent[] itemDatas = null; + TCComponent[] newItemDatas = null; + if (type.equals("MEProcess")) { + itemDatas = item.getReferenceListProperty("IMAN_reference"); + newItemDatas = newItem.getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.remove("IMAN_reference", newItemDatas); + } + } else if (type.equals("MEOP")) { + isMEOP = true; + itemDatas = item.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + newItemDatas = newItem.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_reference", newItemDatas); + } + } + + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + String dataItemName = ""; + if (dataItem.getStringProperty("object_name").indexOf("/") >= 0) { + // ʱ֣this.productId DzƷID + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name").split("/")[1]; + } else { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name"); + } + + TCComponentItem newDataItem = dataItem.getLatestItemRevision() + .saveAsItem(dataItem.getTypeComponent().getNewID(), "00", dataItemName, "", true, null);// Ӱ汾 + TCComponentDataset dataSet = null; + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), "TC_Attaches", + "MSExcel"); + if (dataSet == null) { + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), + "TC_Attaches", "MSExcelX"); + } + if (dataSet != null) { + dataSet.setStringProperty("object_name", dataItemName); + dataSet.save(); + dataSet.refresh(); + } + if (newDataItem.getType().indexOf("KZJH") >= 0) { + + } else if (newDataItem.getType().indexOf("PFMEA") >= 0) { + + } else if (newDataItem.getType().indexOf("GCLCT") >= 0) { + + } + // +++ǹͣͰĹտ׼ݸƵݿ + if (isMEOP) { + String oldItmeUid = dataItem.getLatestItemRevision().getUid(); + String NewItmeUid = newDataItem.getLatestItemRevision().getUid(); + switch (dataItem.getType()) { + case "RB3_ZYGYK": + copyToolingDetailData2(oldItmeUid, NewItmeUid); + copyMachiningParameterData2(oldItmeUid, NewItmeUid); + copyControlRequirementData2(oldItmeUid, NewItmeUid); + break; + case "RB3_ZPGYK": + copyToolingDetailData2(oldItmeUid, NewItmeUid); + copyMachiningParameterData2(oldItmeUid, NewItmeUid); + copyControlRequirementData2(oldItmeUid, NewItmeUid); + break; + case "RB3_ZYJZS": + copyControlRequirementData2(oldItmeUid, NewItmeUid); + break; + default: + break; + } + // ҵĻڰ汾 + newItem.getLatestItemRevision().add("IMAN_reference", newDataItem); + } else { + // ǿƼƻPFMEAItem + newItem.add("IMAN_reference", newDataItem); + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + public void batchSaveAsItem(LinkedHashMap saveAsIteMap, + List> oldData1, List> oldData2, List> oldData3) + throws TCException, NotLoadedException { + System.out.println("ʼ"); + + SaveAsNewItemInfo[] infos = new SaveAsNewItemInfo[saveAsIteMap.size()]; + DataManagementService service = DataManagementService.getService(session.getSoaConnection()); + String[] uids = new String[saveAsIteMap.size()]; + int i = 0; + + // saveAsIteMap ļȡ UIDs + for (TCComponentItemRevision revision : saveAsIteMap.keySet()) { + System.out.println(": " + revision.getUid()); + uids[i] = revision.getUid(); + ++i; + } + + System.out.println("ض..."); + ServiceData loadObjects = service.loadObjects(uids); + + i = 0; + List oldItemUids = new ArrayList<>(); + List newItemIDList = new ArrayList(); + for (Entry entry : saveAsIteMap.entrySet()) { + System.out.println("׼¶Ϣ..."); + String newID = entry.getKey().getItem().getTypeComponent().getNewID(); + newItemIDList.add(newID); + SaveAsNewItemInfo info = new SaveAsNewItemInfo(); + ModelObject plainObject = loadObjects.getPlainObject(i); + info.baseItemRevision = plainObject; + info.newItemId = newID; + info.name = (String) (entry.getValue()[0]); + info.newRevId = "00"; + infos[i] = info; + oldItemUids.add(entry.getKey().getUid()); + System.out.println("ɶ UID: " + entry.getKey().getUid()); + ++i; + } + System.out.println(" saveAsNewItem2 ..."); + SaveAsNewItemResponse2 saveAsNewItem = service.saveAsNewItem2(infos); + int sizeOfCreatedObjects = saveAsNewItem.serviceData.sizeOfCreatedObjects(); + System.out.println("" + sizeOfCreatedObjects); + + List modjs = new ArrayList(); + // ض + System.out.println("ȡUID"); + List idList = new ArrayList(); + List modelObjects = new ArrayList(); + for (int t = 0; t < sizeOfCreatedObjects; t++) { + ModelObject modj = saveAsNewItem.serviceData.getCreatedObject(t); + idList.add(modj.getUid()); + modelObjects.add(modj); + + } + TCComponent[] stringToComponent2 = session.stringToComponent(idList.toArray(new String[0])); + for (TCComponent component : stringToComponent2) { + if (component instanceof TCComponentItem) { + modjs.add((TCComponentItem) component); + } + } + System.out.println("ɸѡ"); + + List items = sortModjsByNewItemIDList(modjs, newItemIDList); + + System.out.println("ɸѡ"); + if (items.size() != newItemIDList.size()) { + System.out.println("000000000c80w8"); + } + + String property = item.getProperty("object_name"); + for (TCComponentItem item : modjs) { + TCComponent[] referenceListProperty = item.getLatestItemRevision().getReferenceListProperty("TC_Attaches"); + for (TCComponent zyzdsChildren : referenceListProperty) { + String type = zyzdsChildren.getType(); + if ("MSExcel".equals(type) || "MSExcelX".equals(type)) { + zyzdsChildren.setProperty("object_name", property); + } + } + } + + System.out.println("ùϵ..."); + // · + Object[] obj = new Object[1]; + obj[0] = ""; + TCUserService userservice = session.getUserService(); + try { + TCUtils.openLogByPass(session, "ݹոƹ"); + userservice.call("Connor_set_bypass", obj); + i = 0; + for (Entry entry : saveAsIteMap.entrySet()) { + switch (entry.getKey().getItem().getType()) { + case "RB3_ZYGYK": + System.out.println(" RB3_ZYGYK..."); + copyToolingDetailData(oldItemUids.get(i), items.get(i).getUid(), oldData1); + copyMachiningParameterData(oldItemUids.get(i), items.get(i).getUid(), oldData2); + copyControlRequirementData(oldItemUids.get(i), items.get(i).getUid(), oldData3); + break; + case "RB3_ZPGYK": + System.out.println(" RB3_ZPGYK..."); + copyToolingDetailData(oldItemUids.get(i), items.get(i).getUid(), oldData1); + copyMachiningParameterData(oldItemUids.get(i), items.get(i).getUid(), oldData2); + copyControlRequirementData(oldItemUids.get(i), items.get(i).getUid(), oldData3); + break; + case "RB3_ZYJZS": + System.out.println(" RB3_ZYJZS..."); + copyControlRequirementData(oldItemUids.get(i), items.get(i).getUid(), oldData3); + break; + default: + System.out.println("δ: " + entry.getKey().getType()); + break; + } + System.out.println("ʼ¶" + ((TCComponentItemRevision) (entry.getValue()[1])) + "IMAN_referenceϵ" + + items.get(i)); + ((TCComponentItemRevision) (entry.getValue()[1])).add("IMAN_reference", items.get(i)); + System.out.println(" IMAN_reference "); + ++i; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + TCUtils.closeLogByPass(session, "ݹոƹ"); + userservice.call("Connor_close_bypass", obj); + } + + } + + /** + * newItemIDList ˳ modjs + * + * @param modjs ԭʼ󼯺 + * @param newItemIDList ˳ ID + * @return ˳еĶ󼯺 + * @throws TCException + */ + public static List sortModjsByNewItemIDList(List modjs, + List newItemIDList) throws TCException { + // һ Mapڿٲ ID ӦĶ + Map idToItemMap = new HashMap<>(); + for (TCComponentItem item : modjs) { + idToItemMap.put(item.getProperty("item_id"), item); + } + + // newItemIDList ˳򹹽µб + List sortedList = new ArrayList<>(); + for (String id : newItemIDList) { + TCComponentItem item = idToItemMap.get(id); + if (item != null) { + sortedList.add(item); + } else { + System.out.println(": newItemIDList е ID " + id + " modjs δҵ"); + } + } + + return sortedList; + } + + /** + * Ϊ + * + * @param item + * @param oldData3 + * @param oldData2 + * @param oldData1 + */ + public TCComponentItem saveAsItem222(TCComponentItem item, TCComponentItem newItem, List> oldData1, + List> oldData2, List> oldData3) { + try { + Boolean isMEOP = true; + TCComponent[] itemDatas = item.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + TCComponent[] newItemDatas = newItem.getLatestItemRevision().getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_reference", newItemDatas); + } + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + String dataItemName = ""; + if (dataItem.getStringProperty("object_name").indexOf("/") >= 0) { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name").split("/")[1]; + } else { + dataItemName = this.productId + "/" + dataItem.getStringProperty("object_name"); + } + + System.out.println("ʼ"); + TCComponentItem newDataItem = dataItem.getLatestItemRevision() + .saveAsItem(dataItem.getTypeComponent().getNewID(), "00", dataItemName, "", true, null);// Ӱ汾 + System.out.println(""); + + System.out.println("ʼض"); + TCComponentDataset dataSet = null; + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), "TC_Attaches", + "MSExcel"); + if (dataSet == null) { + dataSet = ExcelUtil07.getExcelToDataset(session, newDataItem.getLatestItemRevision(), + "TC_Attaches", "MSExcelX"); + } + if (dataSet != null) { + dataSet.setStringProperty("object_name", dataItemName); + dataSet.save(); + dataSet.refresh(); + } + System.out.println("ض"); + if (newDataItem.getType().indexOf("KZJH") >= 0) { + } else if (newDataItem.getType().indexOf("PFMEA") >= 0) { + + } else if (newDataItem.getType().indexOf("GCLCT") >= 0) { + + } + // +++ǹͣͰĹտ׼ݸƵݿ + if (isMEOP) { + String oldItmeUid = dataItem.getLatestItemRevision().getUid(); + String NewItmeUid = newDataItem.getLatestItemRevision().getUid(); + switch (dataItem.getType()) { + case "RB3_ZYGYK": + copyToolingDetailData(oldItmeUid, NewItmeUid, oldData1); + copyMachiningParameterData(oldItmeUid, NewItmeUid, oldData2); + copyControlRequirementData(oldItmeUid, NewItmeUid, oldData3); + break; + case "RB3_ZPGYK": + copyToolingDetailData(oldItmeUid, NewItmeUid, oldData1); + copyMachiningParameterData(oldItmeUid, NewItmeUid, oldData2); + copyControlRequirementData(oldItmeUid, NewItmeUid, oldData3); + break; + case "RB3_ZYJZS": + copyControlRequirementData(oldItmeUid, NewItmeUid, oldData3); + break; + default: + break; + } + // ҵĻڰ汾 + newItem.getLatestItemRevision().add("IMAN_reference", newDataItem); + } else { + // ǿƼƻPFMEAItem + newItem.add("IMAN_reference", newDataItem); + } + + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + private void copyToolingDetailData2(String oldItmeUid, String NewItmeUid) { + // ȡݿ + + InputStream input = null; + ResultSet Old = null; + List> oldData = new ArrayList>(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); + String OldSelect = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIFICATION")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("P1")); + oldData.add(rowList); + } + // ݸƸ½Item + String insertNew = pro.getProperty("RB3_TOOLINGDETAILINSERT"); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + SqlUtilT.write2(new String[] { rowList.get(0), rowList.get(1), rowList.get(2), rowList.get(3), + rowList.get(4), rowList.get(5), rowList.get(6) }, insertNew); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * Ƽӹ + */ + private void copyMachiningParameterData2(String oldItmeUid, String NewItmeUid) { + // ȡݿ + InputStream input = null; + ResultSet Old = null; + List> oldData = new ArrayList>(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); + String OldSelect = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("VALUE")); + rowList.add(Old.getString("P1")); + oldData.add(rowList); + } + // ݸƸ½Item + String insertNew = pro.getProperty("RB3_MACHININGPARAMETERINSERT"); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + SqlUtilT.write2(new String[] { rowList.get(0), rowList.get(1), rowList.get(2), rowList.get(3), + rowList.get(4), rowList.get(5), rowList.get(6) }, insertNew); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ƿҪ + */ + private void copyControlRequirementData2(String oldItmeUid, String NewItmeUid) { + + System.out.println("ʼƻ׼"); + System.out.println("oldItmeUid:" + oldItmeUid); + System.out.println("NewItmeUid:" + NewItmeUid); + + // ȡݿ + InputStream input = null; + ResultSet Old = null; + List> oldData = new ArrayList>(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); + String OldSelect = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), oldItmeUid); + System.out.println("oldsql:" + OldSelect); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("PROJECT")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(Old.getString("CHECK_METHOD")); + rowList.add(Old.getString("FIRST_INSPECTION")); + rowList.add(Old.getString("SELF_INSPECTION")); + rowList.add(Old.getString("ROUTING_INSPECTION")); + rowList.add(Old.getString("REACTION_PLAN")); + rowList.add(Old.getString("REMARKS")); + oldData.add(rowList); + } + // ݸƸ½Item + String insertNew = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT"); + System.out.println("newsql:" + insertNew); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + SqlUtilT.write2(new String[] { rowList.get(0), 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) }, insertNew); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ƹװϸ + * + * @param oldData1 + */ + private void copyToolingDetailData(String oldItmeUid, String NewItmeUid, List> oldData1) { + // ȡݿ + System.out.println("ƹװϸ"); + InputStream input = null; + ResultSet Old = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); +// SqlUtilT.getTCConnection(); + String OldSelect = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIFICATION")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("P1")); + oldData1.add(rowList); + } + + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// SqlUtilT.freeAll(); + } + + private void batchAdd1(List> oldData) { + if (oldData.size() > 0) { + PreparedStatement pstmtInsert = null; + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + pstmtInsert = SqlUtilT.connection.prepareStatement(pro.getProperty("RB3_TOOLINGDETAILINSERT")); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + pstmtInsert.setString(1, rowList.get(0)); + pstmtInsert.setString(2, rowList.get(1)); + pstmtInsert.setString(3, rowList.get(2)); + pstmtInsert.setString(4, rowList.get(3)); + pstmtInsert.setString(5, rowList.get(4)); + pstmtInsert.setString(6, rowList.get(5)); + pstmtInsert.setString(7, rowList.get(6)); + pstmtInsert.addBatch(); + } + pstmtInsert.executeBatch(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * Ƽӹ + * + * @param oldData2 + */ + private void copyMachiningParameterData(String oldItmeUid, String NewItmeUid, List> oldData2) { + // ȡݿ + System.out.println("Ƽӹ"); +// SqlUtilT.getTCConnection(); + InputStream input = null; + ResultSet Old = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); +// SqlUtilT.getTCConnection(); + String OldSelect = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), oldItmeUid); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("NAME")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("VALUE")); + rowList.add(Old.getString("P1")); + oldData2.add(rowList); + } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// SqlUtilT.freeAll(); + } + + private void batchAdd2(List> oldData) { + if (oldData.size() > 0) { + PreparedStatement pstmtInsert = null; + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + pstmtInsert = SqlUtilT.connection.prepareStatement(pro.getProperty("RB3_MACHININGPARAMETERINSERT")); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + pstmtInsert.setString(1, rowList.get(0)); + pstmtInsert.setString(2, rowList.get(1)); + pstmtInsert.setString(3, rowList.get(2)); + pstmtInsert.setString(4, rowList.get(3)); + pstmtInsert.setString(5, rowList.get(4)); + pstmtInsert.setString(6, rowList.get(5)); + pstmtInsert.setString(7, rowList.get(6)); + pstmtInsert.addBatch(); + } + pstmtInsert.executeBatch(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ƿҪ + * + * @param oldData3 + */ + private void copyControlRequirementData(String oldItmeUid, String NewItmeUid, List> oldData3) { + + System.out.println("ʼƻ׼"); + System.out.println("oldItmeUid:" + oldItmeUid); + System.out.println("NewItmeUid:" + NewItmeUid); + + // ȡݿ +// SqlUtilT.getTCConnection(); + InputStream input = null; + ResultSet Old = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + // ȡģ + pro.load(input); +// SqlUtilT.getTCConnection(); + String OldSelect = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), oldItmeUid); + System.out.println("oldsql:" + OldSelect); + Old = SqlUtilT.read(OldSelect); + while (Old.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(NewItmeUid); + rowList.add(Old.getString("ID")); + rowList.add(Old.getString("PROJECT")); + rowList.add(Old.getString("SPECIALITY")); + rowList.add(Old.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(Old.getString("CHECK_METHOD")); + rowList.add(Old.getString("FIRST_INSPECTION")); + rowList.add(Old.getString("SELF_INSPECTION")); + rowList.add(Old.getString("ROUTING_INSPECTION")); + rowList.add(Old.getString("REACTION_PLAN")); + rowList.add(Old.getString("REMARKS")); + oldData3.add(rowList); + } + // ݸƸ½Item +// String insertNew = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT"); +// System.out.println("newsql:" + insertNew); +// for (int i = 0; i < oldData.size(); i++) { +// List rowList = new ArrayList(); +// rowList = oldData.get(i); +// SqlUtilT.write2(new String[] { rowList.get(0), 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) }, insertNew); +// } + } catch (IOException | SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// SqlUtilT.freeAll(); + } + + private void batchAdd3(List> oldData) { + if (oldData.size() > 0) { + PreparedStatement pstmtInsert = null; + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + pstmtInsert = SqlUtilT.connection.prepareStatement(pro.getProperty("RB3_CONTROLREQUIREMENTINSERT")); + for (int i = 0; i < oldData.size(); i++) { + List rowList = new ArrayList(); + rowList = oldData.get(i); + pstmtInsert.setString(1, rowList.get(0)); + pstmtInsert.setString(2, rowList.get(1)); + pstmtInsert.setString(3, rowList.get(2)); + pstmtInsert.setString(4, rowList.get(3)); + pstmtInsert.setString(5, rowList.get(4)); + pstmtInsert.setString(6, rowList.get(5)); + pstmtInsert.setString(7, rowList.get(6)); + pstmtInsert.setString(8, rowList.get(7)); + pstmtInsert.setString(9, rowList.get(8)); + pstmtInsert.setString(10, rowList.get(9)); + pstmtInsert.setString(11, rowList.get(10)); + pstmtInsert.setString(12, rowList.get(11)); + + pstmtInsert.addBatch(); + } + pstmtInsert.executeBatch(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + /** + * ݿеĿƼƻPFMEA + * + * @param oldItem նL + * @param newDataItem ¹ն + */ + private void copyDataValue(TCComponentItem oldItem, TCComponentItem newItem) { + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet pfmeaRs = null; + InputStream input = null; + + Connection connection = null; + try { + Properties pro = new Properties(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro.load(input); + + // ȡĿб + TCComponent[] oldItemComponents = oldItem.getReferenceListProperty("IMAN_reference"); + String controlUid = ""; + String PFMEAUid = ""; + + for (int i = 0; i < oldItemComponents.length; i++) { + if (oldItemComponents[i].getType().indexOf("RB3_SSCKZJH") >= 0) { + TCComponent[] oldItemControlRevisions = oldItemComponents[i] + .getReferenceListProperty("revision_list"); + controlUid = oldItemControlRevisions[oldItemControlRevisions.length - 1].getUid(); + } + if (oldItemComponents[i].getType().indexOf("RB3_PFMEA") >= 0) { + TCComponent[] oldItemPFMEARevisions = oldItemComponents[i] + .getReferenceListProperty("revision_list"); + PFMEAUid = oldItemPFMEARevisions[oldItemPFMEARevisions.length - 1].getUid(); + } + } + + // ȡĿб + TCComponent[] newItemComponents = newItem.getReferenceListProperty("IMAN_reference"); + String newcontrolUid = ""; + String newPFMEAUid = ""; + + for (int i = 0; i < newItemComponents.length; i++) { + if (newItemComponents[i].getType().indexOf("RB3_SSCKZJH") >= 0) { + TCComponent[] newItemControlRevisions = newItemComponents[i] + .getReferenceListProperty("revision_list"); + newcontrolUid = newItemControlRevisions[0].getUid(); + } + if (newItemComponents[i].getType().indexOf("RB3_PFMEA") >= 0) { + TCComponent[] newItemPFMEARevisions = newItemComponents[i] + .getReferenceListProperty("revision_list"); + newPFMEAUid = newItemPFMEARevisions[0].getUid(); + } + } + + // ʹӳػȡݿ + // connection = SqlUtilT.getConnection(); + connection = SqlUtilT.getTCConnection(); + // ѯControl Plan + List processBeans = queryAndCopyControlPlan(connection, oldItem, newItem, controlUid, + newcontrolUid, pro); + + // Ȩ + copyPermissions(connection, oldItem, newItem, pro); + + // ѯPFMEA + List pfmeaDataBeans = queryAndCopyPFMEA(connection, oldItem, newItem, PFMEAUid, newPFMEAUid, + pro); + + // PFMEA + insertPFMEAData(connection, newItem, pfmeaDataBeans, pro); + + } catch (Exception e) { + e.printStackTrace(); + } finally { + // رResultSet + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (pfmeaRs != null) { + SqlUtilT.free(pfmeaRs); + } + // ر + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } + } + + private List queryAndCopyControlPlan(Connection connection, TCComponentItem oldItem, + TCComponentItem newItem, String controlUid, String newcontrolUid, Properties pro) throws SQLException { + List processBeans = new ArrayList<>(); + String sql = "select * from rb3_controlplan where processpuid = ? and revisionuid=?"; + PreparedStatement pstmt = connection.prepareStatement(sql); + pstmt.setString(1, oldItem.getUid()); + pstmt.setString(2, controlUid); + ResultSet rs = pstmt.executeQuery(); + + while (rs.next()) { + ProcessBean processBean = new ProcessBean(); + processBean.setMeopId(rs.getString("RB3_MEOPID")); + processBean.setGybh(rs.getString("RB3_GYBH")); + processBean.setGcmc(rs.getString("RB3_GCMC")); + processBean.setJqsb(rs.getString("RB3_JQSB")); + processBean.setSmjy(rs.getString("RB3_SMJY")); + processBean.setQptbh(rs.getString("RB3_QPTBH")); + processBean.setCc(rs.getString("RB3_CC")); + processBean.setCp(rs.getString("RB3_CP")); + processBean.setGc(rs.getString("RB3_GC")); + processBean.setTstx(rs.getString("RB3_TSTX")); + processBean.setCpgc(rs.getString("RB3_CPGC")); + processBean.setPgclff(rs.getString("RB3_CLFF")); + processBean.setRl(rs.getString("RB3_RL")); + processBean.setPl(rs.getString("RB3_PL")); + processBean.setSjsj(rs.getString("RB3_SJSJ")); + processBean.setGcsj(rs.getString("RB3_GCSJ")); + processBean.setMjsj(rs.getString("RB3_MJSJ")); + processBean.setFzr(rs.getString("RB3_FZR")); + processBean.setKzff(rs.getString("RB3_KZFF")); + processBean.setCzgf(rs.getString("RB3_CZGF")); + processBean.setFyjh(rs.getString("RB3_FYJH")); + processBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + processBean.setHbdyg(rs.getString("RB3_HBDYG")); + processBean.setSfwc(String.valueOf(rs.getInt("RB3_SFWC"))); + processBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + processBean.setSpecial(rs.getString("RB3_SPECIAL")); + processBean.setType(rs.getString("TYPE")); + processBean.setRevisionuid(newcontrolUid); + processBean.setNO(rs.getString("NO")); // + processBeans.add(processBean); + } + + // µĿƼƻ + String insertSQL = pro.getProperty("INSERTSQL"); + PreparedStatement insertPstmt = connection.prepareStatement(insertSQL); + for (ProcessBean process : processBeans) { + insertPstmt.setString(1, UUID.randomUUID().toString().replace("-", "")); + insertPstmt.setString(2, newItem.getUid()); + insertPstmt.setString(3, itemIdMap.get(process.getMeopId())); + insertPstmt.setString(4, process.getGybh()); + insertPstmt.setString(5, process.getGcmc()); + insertPstmt.setString(6, process.getJqsb()); + insertPstmt.setString(7, process.getSmjy()); + insertPstmt.setString(8, process.getQptbh()); + insertPstmt.setString(9, process.getCc()); + insertPstmt.setString(10, process.getCp()); + insertPstmt.setString(11, process.getGc()); + insertPstmt.setString(12, process.getTstx()); + insertPstmt.setString(13, process.getCpgc()); + insertPstmt.setString(14, process.getPgclff()); + insertPstmt.setString(15, process.getRl()); + insertPstmt.setString(16, process.getPl()); + insertPstmt.setString(17, process.getSjsj()); + insertPstmt.setString(18, process.getGcsj()); + insertPstmt.setString(19, process.getMjsj()); + insertPstmt.setString(20, process.getFzr()); + insertPstmt.setString(21, process.getKzff()); + insertPstmt.setString(22, process.getCzgf()); + insertPstmt.setString(23, process.getFyjh()); + insertPstmt.setString(24, process.getHh()); + insertPstmt.setString(25, process.getHbdyg()); + insertPstmt.setString(26, "0"); + insertPstmt.setString(27, process.getHhc()); + insertPstmt.setString(28, process.getSpecial()); + insertPstmt.setString(29, process.getType()); + insertPstmt.setString(30, "0"); + insertPstmt.setString(31, "0"); + insertPstmt.setString(32, process.getNo()); + insertPstmt.setString(33, "0"); + insertPstmt.setString(34, process.getRevisionuid()); + insertPstmt.setString(35, process.getNO()); + insertPstmt.addBatch(); + } + insertPstmt.executeBatch(); + return processBeans; + } + + private void copyPermissions(Connection connection, TCComponentItem oldItem, TCComponentItem newItem, + Properties pro) throws SQLException { + String selectSQL = "select processpuid, rb3_meopid, rb3_gybh, rb3_gcmc, rb3_gxh " + "from RB3_PERMISSIONS " + + "where processpuid = ? and rb3_gcmc not like ? and rb3_meopid is not null " + + "group by processpuid, rb3_meopid, rb3_gybh, rb3_gcmc, rb3_gxh"; + + PreparedStatement pstmt = connection.prepareStatement(selectSQL); + pstmt.setString(1, oldItem.getUid()); + pstmt.setString(2, "飨%"); + ResultSet rs = pstmt.executeQuery(); + + List> meopList = new ArrayList<>(); + while (rs.next()) { + List list = new ArrayList<>(); + list.add(rs.getString("processpuid")); + list.add(rs.getString("rb3_meopid")); + list.add(rs.getString("rb3_gybh")); + list.add(rs.getString("rb3_gcmc")); + list.add(rs.getString("rb3_gxh")); + meopList.add(list); + } + + String insertSQL = pro.getProperty("INSERTPERMISSIONS"); + PreparedStatement insertPstmt = connection.prepareStatement(insertSQL); + for (List meop : meopList) { + insertPstmt.setString(1, UUID.randomUUID().toString().replace("-", "")); + insertPstmt.setString(2, newItem.getUid()); + insertPstmt.setString(3, itemIdMap.get(meop.get(1))); + insertPstmt.setString(4, meop.get(2)); + insertPstmt.setString(5, meop.get(3)); + insertPstmt.setString(6, ""); + insertPstmt.setString(7, ""); + insertPstmt.setString(8, ""); + insertPstmt.setString(9, ""); + insertPstmt.setString(10, meop.get(4)); + insertPstmt.addBatch(); + } + insertPstmt.executeBatch(); + } + + private List queryAndCopyPFMEA(Connection connection, TCComponentItem oldItem, + TCComponentItem newItem, String PFMEAUid, String newPFMEAUid, Properties pro) throws SQLException { + List pfmeaDataBeans = new ArrayList<>(); + + // ѯĿPFMEA + String pfmeaSql = String.format(pro.getProperty("SETPFMEASELECT"), oldItem.getUid(), PFMEAUid); + PreparedStatement pstmt = connection.prepareStatement(pfmeaSql); + ResultSet rs = pstmt.executeQuery(); + + while (rs.next()) { + PFMEADataBean pfmeaDataBean = new PFMEADataBean(); + pfmeaDataBean.setMeopId(rs.getString("RB3_MEOPID")); + pfmeaDataBean.setGybh(rs.getString("RB3_GYBH")); + pfmeaDataBean.setGcmc(rs.getString("RB3_GCMC")); + pfmeaDataBean.setStation(rs.getString("RB3_STATION")); + pfmeaDataBean.setRequirement(rs.getString("RB3_REQUIREMENT")); + pfmeaDataBean.setQzsxms(rs.getString("RB3_QZSXMS")); + pfmeaDataBean.setQzsxhg(rs.getString("RB3_QZSXHG")); + pfmeaDataBean.setYzd(rs.getString("RB3_YZD")); + pfmeaDataBean.setJb(rs.getString("RB3_JB")); + pfmeaDataBean.setQzsxqy(rs.getString("RB3_QZSXQY")); + pfmeaDataBean.setXxgckzyf(rs.getString("RB3_XXGCKZYF")); + pfmeaDataBean.setPds(rs.getString("RB3_PDS")); + pfmeaDataBean.setXxgckztc(rs.getString("RB3_XXGCKZTC")); + pfmeaDataBean.setTcd(rs.getString("RB3_TCD")); + pfmeaDataBean.setTm2Rpn(rs.getString("RB3_RPN")); + pfmeaDataBean.setJycs(rs.getString("RB3_JYCS")); + pfmeaDataBean.setZrr(rs.getString("RB3_ZZR")); + pfmeaDataBean.setJhwcrq(rs.getString("RB3_JHWCRQ")); + pfmeaDataBean.setCqdcs(rs.getString("RB3_CQDCS")); + pfmeaDataBean.setNewSev(rs.getString("RB3_NEW_SEV")); + pfmeaDataBean.setNewOcc(rs.getString("RB3_NEW_OCC")); + pfmeaDataBean.setNewDel(rs.getString("RB3_NEW_DET")); + pfmeaDataBean.setNewRpn(rs.getString("RB3_NEW_RPN")); + pfmeaDataBean.setIdealState(rs.getString("RB3_IDEAL_STATE")); + pfmeaDataBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + pfmeaDataBean.setHbdyg(rs.getString("RB3_HBDYG")); + pfmeaDataBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + pfmeaDataBean.setSpecial(rs.getString("RB3_SPECIAL")); + pfmeaDataBean.setType(rs.getString("TYPE")); + pfmeaDataBean.setBak(rs.getString("BAK")); + pfmeaDataBean.setOccurrence(rs.getString("OCCURRRENCE")); + pfmeaDataBean.setDetection(rs.getString("DETECTION")); + pfmeaDataBean.setPriority(rs.getString("PRIORITY")); + pfmeaDataBean.setP1(rs.getString("P1")); + pfmeaDataBean.setP2(rs.getString("P2")); + pfmeaDataBean.setP3(rs.getString("P3")); + pfmeaDataBean.setP4(rs.getString("P4")); + pfmeaDataBean.setP5(rs.getString("P5")); + pfmeaDataBean.setRevisionid(newPFMEAUid); + pfmeaDataBean.setNO(rs.getString("NO")); + + pfmeaDataBeans.add(pfmeaDataBean); + } + + return pfmeaDataBeans; + } + + private void insertPFMEAData(Connection connection, TCComponentItem newItem, List pfmeaDataBeans, + Properties pro) throws SQLException { + String insertSQL = pro.getProperty("INSERTPFMEA"); + PreparedStatement insertPstmt = connection.prepareStatement(insertSQL); + for (PFMEADataBean pfmeaData : pfmeaDataBeans) { + insertPstmt.setString(1, UUID.randomUUID().toString().replace("-", "")); // ID + insertPstmt.setString(2, newItem.getUid()); // ĿUID + insertPstmt.setString(3, itemIdMap.get(pfmeaData.getMeopId())); // MEOPIDӳֵ + insertPstmt.setString(4, noMap.get(itemIdMap.get(pfmeaData.getMeopId()))); // NOӳֵ + insertPstmt.setString(5, pfmeaData.getGcmc()); // + insertPstmt.setString(6, pfmeaData.getStation()); // λ + insertPstmt.setString(7, pfmeaData.getRequirement()); // Ҫ + insertPstmt.setString(8, pfmeaData.getQzsxms()); // ǿ + insertPstmt.setString(9, pfmeaData.getQzsxhg()); // ǿԺϸ + insertPstmt.setString(10, pfmeaData.getYzd()); // ԭӵ + insertPstmt.setString(11, pfmeaData.getJb()); // + insertPstmt.setString(12, pfmeaData.getQzsxqy()); // ǿ + insertPstmt.setString(13, pfmeaData.getXxgckzyf()); // ߹οҵ + insertPstmt.setString(14, pfmeaData.getPds()); // PDS + insertPstmt.setString(15, pfmeaData.getXxgckztc()); // ߹ο + insertPstmt.setString(16, pfmeaData.getTcd()); // + insertPstmt.setString(17, pfmeaData.getTm2Rpn()); // RPN + insertPstmt.setString(18, pfmeaData.getJycs()); // + insertPstmt.setString(19, pfmeaData.getZrr()); // + insertPstmt.setString(20, pfmeaData.getJhwcrq()); // ƻ + insertPstmt.setString(21, pfmeaData.getCqdcs()); // + insertPstmt.setString(22, pfmeaData.getNewSev()); // ض + insertPstmt.setString(23, pfmeaData.getNewOcc()); // ·Ƶ + insertPstmt.setString(24, pfmeaData.getNewDel()); // ¼Ѷ + insertPstmt.setString(25, pfmeaData.getNewRpn()); // RPN + insertPstmt.setString(26, pfmeaData.getIdealState()); // ״̬ + insertPstmt.setString(27, pfmeaData.getHh()); // к + insertPstmt.setString(28, pfmeaData.getHbdyg()); // ϲԪ + insertPstmt.setString(29, pfmeaData.getHhc()); // ϲ + insertPstmt.setString(30, pfmeaData.getSpecial()); // + insertPstmt.setString(31, pfmeaData.getType()); // + insertPstmt.setString(32, pfmeaData.getBak()); // ע + insertPstmt.setString(33, pfmeaData.getOccurrence()); // + insertPstmt.setString(34, pfmeaData.getDetection()); // + insertPstmt.setString(35, pfmeaData.getPriority()); // ȼ + insertPstmt.setString(36, pfmeaData.getP1()); // 1 + insertPstmt.setString(37, pfmeaData.getP2()); // 2 + insertPstmt.setString(38, pfmeaData.getP3()); // 3 + insertPstmt.setString(39, pfmeaData.getP4()); // 4 + insertPstmt.setString(40, pfmeaData.getP5()); // 5 + insertPstmt.setString(41, pfmeaData.getRevisionid()); // ޶汾ID + insertPstmt.setString(42, pfmeaData.getNO()); // + insertPstmt.addBatch(); + } + insertPstmt.executeBatch(); + } + + private void copyDataValue2(TCComponentItem oldItem, TCComponentItem newItem) { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet pfmeaRs = null; + InputStream input = null; + Connection conn = null; + try { + SqlUtilT.getTCConnection(); + List processBeans = new ArrayList(); + // ѯϹյĿƼƻ + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // +++ȡģ幤 + TCComponent[] oldItemComponents = oldItem.getReferenceListProperty("IMAN_reference"); + String controlUid = ""; + String PFMEAUid = ""; + for (int i = 0; i < oldItemComponents.length; i++) { + String type = oldItemComponents[i].getType(); + if (type.indexOf("RB3_SSCKZJH") >= 0) { + controlUid = ((TCComponentItem) oldItemComponents[i]).getLatestItemRevision().getUid(); + } + if (type.indexOf("RB3_PFMEA") >= 0) { + PFMEAUid = ((TCComponentItem) oldItemComponents[i]).getLatestItemRevision().getUid(); + } + } + // ++++ + + // +++ȡ½ + TCComponent[] newItemComponents = newItem.getReferenceListProperty("IMAN_reference"); + String newcontrolUid = ""; + String newPFMEAUid = ""; + for (int i = 0; i < newItemComponents.length; i++) { + String type = newItemComponents[i].getType(); + if (type.indexOf("RB3_SSCKZJH") >= 0) { + newcontrolUid = ((TCComponentItem) newItemComponents[i]).getLatestItemRevision().getUid(); + } + if (type.indexOf("RB3_PFMEA") >= 0) { + newPFMEAUid = ((TCComponentItem) newItemComponents[i]).getLatestItemRevision().getUid(); + } + } + // ++++ + + conn = SqlUtilT.getTCConnection(); + + String sql = String.format( + "select * from rb3_controlplan where processpuid = \'%s\' and revisionuid=\'%s\'", oldItem.getUid(), + controlUid); + rs = SqlUtilT.read(sql); + while (rs.next()) { + ProcessBean processBean = new ProcessBean(); + processBean.setMeopId(rs.getString("RB3_MEOPID")); + processBean.setGybh(rs.getString("RB3_GYBH")); + processBean.setGcmc(rs.getString("RB3_GCMC")); + processBean.setJqsb(rs.getString("RB3_JQSB")); + processBean.setSmjy(rs.getString("RB3_SMJY")); + processBean.setQptbh(rs.getString("RB3_QPTBH")); + processBean.setCc(rs.getString("RB3_CC")); + processBean.setNo(rs.getString("RB3_NO")); + processBean.setCp(rs.getString("RB3_CP")); + processBean.setGc(rs.getString("RB3_GC")); + processBean.setTstx(rs.getString("RB3_TSTX")); + processBean.setCpgc(rs.getString("RB3_CPGC")); + processBean.setPgclff(rs.getString("RB3_CLFF")); + processBean.setRl(rs.getString("RB3_RL")); + processBean.setPl(rs.getString("RB3_PL")); + processBean.setSjsj(rs.getString("RB3_SJSJ")); + processBean.setGcsj(rs.getString("RB3_GCSJ")); + processBean.setMjsj(rs.getString("RB3_MJSJ")); + processBean.setFzr(rs.getString("RB3_FZR")); + processBean.setKzff(rs.getString("RB3_KZFF")); + processBean.setCzgf(rs.getString("RB3_CZGF")); + processBean.setFyjh(rs.getString("RB3_FYJH")); + processBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + processBean.setHbdyg(rs.getString("RB3_HBDYG")); + processBean.setSfwc(String.valueOf(rs.getInt("RB3_SFWC"))); + processBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + processBean.setSpecial(rs.getString("RB3_SPECIAL")); + processBean.setType(rs.getString("TYPE")); + processBean.setRevisionuid(newcontrolUid); + processBean.setNO(rs.getString("NO"));// ұ + processBeans.add(processBean); + } + noMap = getNomMap(newItem); + // SQL + String insertSQL = pro.getProperty("INSERTSQL"); + + PreparedStatement ps = null; + ps = conn.prepareStatement(insertSQL); + + for (ProcessBean process : processBeans) { + // 飬˳ INSERT SQL ? ռλһ + ps.setString(1, UUID.randomUUID().toString().replace("-", "")); + ps.setString(2, newItem.getUid()); + ps.setString(3, itemIdMap.get(process.getMeopId())); + ps.setString(4, process.getGybh()); + ps.setString(5, process.getGcmc()); + ps.setString(6, process.getJqsb()); + ps.setString(7, process.getSmjy()); + ps.setString(8, process.getQptbh()); + ps.setString(9, process.getCc()); + ps.setString(10, process.getCp()); + ps.setString(11, process.getGc()); + ps.setString(12, process.getTstx()); + ps.setString(13, process.getCpgc()); + ps.setString(14, process.getPgclff()); + ps.setString(15, process.getRl()); + ps.setString(16, process.getPl()); + ps.setString(17, process.getSjsj()); + ps.setString(18, process.getGcsj()); + ps.setString(19, process.getMjsj()); + ps.setString(20, process.getFzr()); + ps.setString(21, process.getKzff()); + ps.setString(22, process.getCzgf()); + ps.setString(23, process.getFyjh()); + ps.setString(24, process.getHh()); + ps.setString(25, process.getHbdyg()); + ps.setString(26, "0"); + ps.setString(27, process.getHhc()); + ps.setString(28, process.getSpecial()); + ps.setString(29, process.getType()); + ps.setString(30, "0"); + ps.setString(31, "0"); + ps.setString(32, process.getNo()); + ps.setString(33, "0"); + ps.setString(34, process.getRevisionuid()); + ps.setString(35, process.getNO()); + + ps.addBatch(); // ӵ + } + + ps.executeBatch(); // ִ + conn.commit(); // ύ +// // +// for (int i = 0; i < processBeans.size(); i++) { +// // itemidȡϢ +// +// ProcessBean process = processBeans.get(i); +// String insertSQL = pro.getProperty("INSERTSQL"); +// SqlUtilT.getTCConnection(); +// SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), +// itemIdMap.get(process.getMeopId()), process.getGybh(), process.getGcmc(), process.getJqsb(), +// process.getSmjy(), process.getQptbh(), process.getCc(), process.getCp(), process.getGc(), +// process.getTstx(), process.getCpgc(), process.getPgclff(), process.getRl(), process.getPl(), +// process.getSjsj(), process.getGcsj(), process.getMjsj(), process.getFzr(), process.getKzff(), +// process.getCzgf(), process.getFyjh(), process.getHh(), process.getHbdyg(), "0", +// process.getHhc(), process.getSpecial(), process.getType(), "0", "0", process.getNo(), "0", +// process.getRevisionuid(), process.getNO() }, insertSQL); +// } + // Ȩޱ + List> meopList = new ArrayList>(); + + String selectSQL = String.format( + "select processpuid,rb3_meopid,rb3_gybh,rb3_gcmc,rb3_gxh from RB3_PERMISSIONS where processpuid = \'%s\' and rb3_gcmc not like \'%s\' and rb3_meopid is not null group by processpuid,rb3_meopid,rb3_gybh,rb3_gcmc,rb3_gxh", + oldItem.getUid(), "飨%");// 飨 + System.out.println(selectSQL); + rs2 = SqlUtilT.read(selectSQL); + // ģpermissionsݸƵ½ȥ + while (rs2.next()) { + List list = new ArrayList(); + list.add(rs2.getString("processpuid")); + list.add(rs2.getString("rb3_meopid")); + list.add(rs2.getString("rb3_gybh")); + list.add(rs2.getString("rb3_gcmc")); + list.add(rs2.getString("rb3_gxh")); + meopList.add(list); + } + String insertSQL1 = pro.getProperty("INSERTPERMISSIONS"); // INSERT SQL ģ壬Ӧ ? ռλ + ps = conn.prepareStatement(insertSQL1); + + for (int i = 0; i < meopList.size(); i++) { + List row = meopList.get(i); + String meopId = row.get(1); + String targetMeopId = itemIdMap.get(meopId); // ӳµ MEOP ID + ps.setString(1, UUID.randomUUID().toString().replace("-", "")); // id + ps.setString(2, newItem.getUid()); // µ processpuid + ps.setString(3, targetMeopId); // rb3_meopid + ps.setString(4, row.get(2)); // rb3_gybh + ps.setString(5, row.get(3)); // rb3_gcmc + ps.setString(6, ""); // ֶ + ps.setString(7, ""); // ֶ + ps.setString(8, ""); // ֶ + ps.setString(9, ""); // ֶ + ps.setString(10, row.get(4)); // rb3_gxh + ps.addBatch(); // ӵ + } + + ps.executeBatch(); // ִ + conn.commit(); // ύ +// for (int i = 0; i < meopList.size(); i++) { +// String insertSQL = pro.getProperty("INSERTPERMISSIONS"); +// SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), +// itemIdMap.get(meopList.get(i).get(1)), meopList.get(i).get(2), meopList.get(i).get(3), "", "", +// "", "", meopList.get(i).get(4) }, insertSQL); +// } + // ӵPFMEAе + List pfmeaDataBeans = new ArrayList(); + // ѯϹյPFMEA + SqlUtilT.getTCConnection(); + String pfmeaSql = String.format(pro.getProperty("SETPFMEASELECT"), oldItem.getUid(), PFMEAUid); + pfmeaRs = SqlUtilT.read(pfmeaSql); + while (pfmeaRs.next()) { + PFMEADataBean pfmeaDataBean = new PFMEADataBean(); + pfmeaDataBean.setMeopId(pfmeaRs.getString("RB3_MEOPID")); + pfmeaDataBean.setGybh(pfmeaRs.getString("RB3_GYBH")); + pfmeaDataBean.setGcmc(pfmeaRs.getString("RB3_GCMC")); + pfmeaDataBean.setStation(pfmeaRs.getString("RB3_STATION")); + pfmeaDataBean.setRequirement(pfmeaRs.getString("RB3_REQUIREMENT")); + pfmeaDataBean.setQzsxms(pfmeaRs.getString("RB3_QZSXMS")); + pfmeaDataBean.setQzsxhg(pfmeaRs.getString("RB3_QZSXHG")); + pfmeaDataBean.setYzd(pfmeaRs.getString("RB3_YZD")); + pfmeaDataBean.setJb(pfmeaRs.getString("RB3_JB")); + pfmeaDataBean.setQzsxqy(pfmeaRs.getString("RB3_QZSXQY")); + pfmeaDataBean.setXxgckzyf(pfmeaRs.getString("RB3_XXGCKZYF")); + pfmeaDataBean.setPds(pfmeaRs.getString("RB3_PDS")); + pfmeaDataBean.setXxgckztc(pfmeaRs.getString("RB3_XXGCKZTC")); + pfmeaDataBean.setTcd(pfmeaRs.getString("RB3_TCD")); + pfmeaDataBean.setTm2Rpn(pfmeaRs.getString("RB3_RPN")); + pfmeaDataBean.setJycs(pfmeaRs.getString("RB3_JYCS")); + pfmeaDataBean.setZrr(pfmeaRs.getString("RB3_ZZR")); + pfmeaDataBean.setJhwcrq(pfmeaRs.getString("RB3_JHWCRQ")); + pfmeaDataBean.setCqdcs(pfmeaRs.getString("RB3_CQDCS")); + pfmeaDataBean.setNewSev(pfmeaRs.getString("RB3_NEW_SEV")); + pfmeaDataBean.setNewOcc(pfmeaRs.getString("RB3_NEW_OCC")); + pfmeaDataBean.setNewDel(pfmeaRs.getString("RB3_NEW_DET")); + pfmeaDataBean.setNewRpn(pfmeaRs.getString("RB3_NEW_RPN")); + pfmeaDataBean.setIdealState(pfmeaRs.getString("RB3_IDEAL_STATE")); + pfmeaDataBean.setHh(String.valueOf(pfmeaRs.getInt("RB3_HH"))); + pfmeaDataBean.setHbdyg(pfmeaRs.getString("RB3_HBDYG")); + pfmeaDataBean.setHhc(String.valueOf(pfmeaRs.getInt("RB3_HHC"))); + pfmeaDataBean.setSpecial(pfmeaRs.getString("RB3_SPECIAL")); + pfmeaDataBean.setType(pfmeaRs.getString("TYPE")); + pfmeaDataBean.setBak(pfmeaRs.getString("BAK")); + pfmeaDataBean.setOccurrence(pfmeaRs.getString("OCCURRRENCE")); + pfmeaDataBean.setDetection(pfmeaRs.getString("DETECTION")); + pfmeaDataBean.setPriority(pfmeaRs.getString("PRIORITY")); + pfmeaDataBean.setP1(pfmeaRs.getString("P1")); + pfmeaDataBean.setP2(pfmeaRs.getString("P2")); + pfmeaDataBean.setP3(pfmeaRs.getString("P3")); + pfmeaDataBean.setP4(pfmeaRs.getString("P4")); + pfmeaDataBean.setP5(pfmeaRs.getString("P5")); + pfmeaDataBean.setRevisionid(newPFMEAUid); + pfmeaDataBean.setNO(pfmeaRs.getString("NO")); + pfmeaDataBeans.add(pfmeaDataBean); + } + + String insertSQL2 = pro.getProperty("INSERTPFMEA"); + ps = conn.prepareStatement(insertSQL2); + + for (PFMEADataBean data : pfmeaDataBeans) { + String meopId = data.getMeopId(); + String targetMeopId = itemIdMap.get(meopId); // ӳµ MEOP ID + String no = noMap.get(targetMeopId); // ȡ NO + + ps.setString(1, UUID.randomUUID().toString().replace("-", "")); // ID + ps.setString(2, newItem.getUid()); // PROCESSPUID + ps.setString(3, targetMeopId); // RB3_MEOPID + ps.setString(4, no); // NO + ps.setString(5, data.getGcmc()); // RB3_GCMC + ps.setString(6, data.getStation()); // RB3_STATION + ps.setString(7, data.getRequirement()); // RB3_REQUIREMENT + ps.setString(8, data.getQzsxms()); // RB3_QZSXMS + ps.setString(9, data.getQzsxhg()); // RB3_QZSXHG + ps.setString(10, data.getYzd()); // RB3_YZD + ps.setString(11, data.getJb()); // RB3_JB + ps.setString(12, data.getQzsxqy()); // RB3_QZSXQY + ps.setString(13, data.getXxgckzyf()); // RB3_XXGCKZYF + ps.setString(14, data.getPds()); // RB3_PDS + ps.setString(15, data.getXxgckztc()); // RB3_XXGCKZTC + ps.setString(16, data.getTcd()); // RB3_TCD + ps.setString(17, data.getTm2Rpn()); // RB3_RPN + ps.setString(18, data.getJycs()); // RB3_JYCS + ps.setString(19, data.getZrr()); // RB3_ZZR + ps.setString(20, data.getJhwcrq()); // RB3_JHWCRQ + ps.setString(21, data.getCqdcs()); // RB3_CQDCS + ps.setString(22, data.getNewSev()); // RB3_NEW_SEV + ps.setString(23, data.getNewOcc()); // RB3_NEW_OCC + ps.setString(24, data.getNewDel()); // RB3_NEW_DET + ps.setString(25, data.getNewRpn()); // RB3_NEW_RPN + ps.setString(26, data.getIdealState()); // RB3_IDEAL_STATE + ps.setString(27, data.getHh()); // RB3_HH + ps.setString(28, data.getHbdyg()); // RB3_HBDYG + ps.setString(29, data.getHhc()); // RB3_HHC + ps.setString(30, data.getSpecial()); // RB3_SPECIAL + ps.setString(31, data.getType()); // TYPE + ps.setString(32, data.getBak()); // BAK + ps.setString(33, data.getOccurrence()); // OCCURRRENCE + ps.setString(34, data.getDetection()); // DETECTION + ps.setString(35, data.getPriority()); // PRIORITY + ps.setString(36, data.getP1()); // P1 + ps.setString(37, data.getP2()); // P2 + ps.setString(38, data.getP3()); // P3 + ps.setString(39, data.getP4()); // P4 + ps.setString(40, data.getP5()); // P5 + ps.setString(41, data.getRevisionid()); // REVISIONID + ps.setString(42, data.getNO()); // NO + + ps.addBatch(); // + } + ps.executeBatch(); // ִ + conn.commit(); // ύ + +// // +// for (int i = 0; i < pfmeaDataBeans.size(); i++) { +// SqlUtilT.getTCConnection(); +// PFMEADataBean pfmeaData = pfmeaDataBeans.get(i); +// String insertSQL = pro.getProperty("INSERTPFMEA"); +// SqlUtilT.write(new String[] { UUID.randomUUID().toString().replace("-", ""), newItem.getUid(), +// itemIdMap.get(pfmeaData.getMeopId()), noMap.get(itemIdMap.get(pfmeaData.getMeopId())), +// pfmeaData.getGcmc(), pfmeaData.getStation(), pfmeaData.getRequirement(), pfmeaData.getQzsxms(), +// pfmeaData.getQzsxhg(), pfmeaData.getYzd(), pfmeaData.getJb(), pfmeaData.getQzsxqy(), +// pfmeaData.getXxgckzyf(), pfmeaData.getPds(), pfmeaData.getXxgckztc(), pfmeaData.getTcd(), +// pfmeaData.getTm2Rpn(), pfmeaData.getJycs(), pfmeaData.getZrr(), pfmeaData.getJhwcrq(), +// pfmeaData.getCqdcs(), pfmeaData.getNewSev(), pfmeaData.getNewOcc(), pfmeaData.getNewDel(), +// pfmeaData.getNewRpn(), pfmeaData.getIdealState(), pfmeaData.getHh(), pfmeaData.getHbdyg(), +// pfmeaData.getHhc(), pfmeaData.getSpecial(), pfmeaData.getType(), pfmeaData.getBak(), +// pfmeaData.getOccurrence(), pfmeaData.getDetection(), pfmeaData.getPriority(), pfmeaData.getP1(), +// pfmeaData.getP2(), pfmeaData.getP3(), pfmeaData.getP4(), pfmeaData.getP5(), +// pfmeaData.getRevisionid(), pfmeaData.getNO() }, insertSQL); +// } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (pfmeaRs != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private Map getNomMap(TCComponentItem item) { + Map resultMap = new HashMap(); + TCComponentBOMWindow bomWindow = null; + try { + + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null, null); + + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline = ((TCComponentBOMLine) children.getComponent()); + resultMap.put(subline.getStringProperty("bl_indented_title").split("/")[0], + subline.getStringProperty("bl_sequence_no")); + } + } + + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + }finally { + try { + if(bomWindow != null) { + bomWindow.close(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return resultMap; + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + * @throws SQLException + */ + public void recreateMeopBom(TCComponentItem topItem, TreeMap itemlists, boolean isDelete) + throws TCException, SQLException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + topline.refresh(); + Iterator it = itemlists.keySet().iterator(); + List meopItems = new ArrayList(); + while (it.hasNext()) { + TCComponentItem meopItem = itemlists.get(it.next()); + meopItems.add(meopItem); +// TCComponentItemRevision revision = meopItem.getLatestItemRevision(); +// topline.add(meopItem, revision, null, false, ""); + } + // ȡ¶ + String[] newItemRevProps = new String[] { "revision_list" }; + TCProperty[][] newItemProps = TCComponentType.getTCPropertiesSet(meopItems, newItemRevProps); + List newItemRevs = new ArrayList(); + for (int j = 0; j < newItemProps.length; j++) { + TCComponent[] rList = newItemProps[j][0].getReferenceValueArray(); + newItemRevs.add(((TCComponentItemRevision) rList[rList.length - 1])); + } + Map> updateBoms = new LinkedHashMap>(); + ArrayList beans = new ArrayList(); + for (int j = 0; j < meopItems.size(); j++) { + BomImportBean bean = new BomImportBean(); + bean.setItem(meopItems.get(j)); + bean.setItemRevision(newItemRevs.get(j)); + beans.add(bean); + } + updateBoms.put(topItem, beans); + + try { + CreateOrUpdateBom2(updateBoms); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // +++++дBOM + // topline.updateCacheOnEvent(null); + topline.refresh(); + AIFComponentContext[] childrens = topline.getChildren(); + List boLines = new ArrayList<>(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bom = (TCComponentBOMLine) children.getComponent(); + boLines.add(bom); + } + String[] Props = new String[] { "bl_item_item_id" }; + TCProperty[][] Propy = TCComponentType.getTCPropertiesSet(boLines, Props); + SqlUtilT.getTCConnection(); + for (int j = 0; j < Propy.length; j++) { + // +++ͨpermissions½IDĹţдbom + ResultSet rs = null; + String classID = ""; + String sql = String.format("select RB3_GXH from RB3_PERMISSIONS where RB3_MEOPID=\'%s\'", Propy[j][0]); + rs = SqlUtilT.read(sql); + System.out.println("=====>" + sql); + while (rs.next()) { + classID = rs.getString("RB3_GXH"); + } + System.out.println("+++++++++ţ" + classID); + boLines.get(j).setStringProperty("RB3_GXH", classID); + } + SqlUtilT.freeAll(); + // ++++++ + bomWindow.unlock(); + bomWindow.save(); + bomWindow.close(); + } + + + + public TCComponent[] getBomObj(TCComponentItem topItem) throws TCException { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + List comps = new ArrayList(); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null); + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + comps.add(((TCComponentBOMLine)children.getComponent()).getItemRevision()); + } + } + bomWindow.close(); + return comps.toArray(new TCComponent[0]); + } +} diff --git a/src/com/connor/renben/process/plm/tmom006/Test.java b/src/com/connor/renben/process/plm/tmom006/Test.java new file mode 100644 index 0000000..70d75da --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom006/Test.java @@ -0,0 +1,36 @@ +package com.connor.renben.process.plm.tmom006; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; + +public class Test { + + public static void main(String[] args) { + List> opList = new ArrayList>(); + + Map opMap = new HashMap(); + opMap.put("revUid", "12332131"); + opMap.put("itemId", "opId"); + opMap.put("name", "opName"); + opMap.put("revId", "00"); + + Map opMap2 = new HashMap(); + opMap2.put("revUid", "12332131"); + opMap2.put("itemId", "opId1"); + opMap2.put("name", "opName2"); + opMap2.put("revId", "00"); + + opList.add(opMap); + opList.add(opMap2); + String jsonString = JSON.toJSONString(opList); + JSONArray parseArray = JSON.parseArray(jsonString); + + System.out.println("parseArray==>"+parseArray.size()); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedCommand.java b/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedCommand.java new file mode 100644 index 0000000..03962d5 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedCommand.java @@ -0,0 +1,41 @@ +package com.connor.renben.process.plm.tmom007; + +import com.connor.renben.process.plm.util.DDInClassDialog; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class TMom007ResourcesAssignedCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + private String commandId; + + public TMom007ResourcesAssignedCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.commandId = commandId; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + final InterfaceAIFComponent targetComponent = app.getTargetComponent(); + final AbstractAIFUIApplication localAbstractAIFUIApplication = AIFDesktop + .getActiveDesktop().getCurrentApplication(); + new Thread() { + @Override + public void run() { + DDInClassDialog localDDInClassDialog = new DDInClassDialog( + localAbstractAIFUIApplication, targetComponent, 2, + commandId); + localDDInClassDialog.setVisible(true); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedHandler.java b/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedHandler.java new file mode 100644 index 0000000..6d9422c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedHandler.java @@ -0,0 +1,59 @@ +package com.connor.renben.process.plm.tmom007; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom005.TMom005CreateOPByModuleCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom007ResourcesAssignedHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String commandId = arg0.getCommand().getId(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(targetComponent==null) { + MessageBox.post(rb.getString("wxzdx05_display.TITLE"), "", MessageBox.ERROR); + }else { + if(!(targetComponent instanceof TCComponentBOMLine)) { + MessageBox.post(rb.getString("xzgxBOM_display.TITLE"), "", MessageBox.ERROR); + }else { + try { + if(((TCComponentBOMLine)targetComponent).getItem().getStringProperty("object_type").equals("MEOP")) { + TMom007ResourcesAssignedCommand command = new TMom007ResourcesAssignedCommand( + app, session, commandId); + command.executeModal(); + + }else { + MessageBox.post(rb.getString("qxzgxbomhcj07_display.TITLE"), "", MessageBox.ERROR); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + } + + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedOperation.java b/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedOperation.java new file mode 100644 index 0000000..2bfdbf1 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom007/TMom007ResourcesAssignedOperation.java @@ -0,0 +1,192 @@ +package com.connor.renben.process.plm.tmom007; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Map.Entry; + +import com.alibaba.fastjson.JSON; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom006.BomImportBean; +import com.connor.renben.process.plm.util.ServiceUtil; +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.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.util.MessageBox; + + +public class TMom007ResourcesAssignedOperation extends AbstractAIFOperation { + + private InterfaceAIFComponent targets; + private String selectItems; + private TCSession session; + + public TMom007ResourcesAssignedOperation(InterfaceAIFComponent targets, + String selectItems, TCSession session) { + // TODO Auto-generated constructor stub + this.targets = targets; + this.selectItems = selectItems; + this.session = session; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + ArrayList itemlists = new ArrayList(); + TCComponentItem item = null; + if (this.targets instanceof TCComponentBOMLine) { + item = ((TCComponentBOMLine) this.targets).getItem(); + } else if (this.targets instanceof TCComponentItem) { + item = (TCComponentItem) this.targets; + } + // ȡItemId + String[] itemID = null; + if (selectItems.indexOf(" | ") > -1) { + itemID = selectItems.split(" | "); + } else { + itemID = new String[] { selectItems }; + } + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + for (int i = 0; i < itemID.length; i++) { + TCComponentItem resultItem = itemType.find(itemID[i].substring(0, + itemID[i].length() - 1)); + if (itemID[i].indexOf("/") >= 0) { + resultItem = itemType.find(itemID[i].split("/")[0]); + } + itemlists.add(resultItem); + } + if (item != null && itemlists != null && itemlists.size() > 0) { + recreateBom(item, itemlists, false); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("zyzpcg07_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } + + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem topItem, + ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, + topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + + + //÷ + List uidsList = new ArrayList(); + for(TCComponentItem item: itemlists) { + String uid = item.getLatestItemRevision().getUid(); + uidsList.add(uid); + } + Map valMap = new HashMap(); + valMap.put("childUid", uidsList); + valMap.put("pUid", topItem.getLatestItemRevision().getUid()); + String jsonString = JSON.toJSONString(valMap); + + TCComponentUser user = session.getUser(); + TCComponentGroup group = (TCComponentGroup) user.getRelatedComponent("default_group"); + String userUid = user.getUid(); + String groupUid = group.getUid(); + + ServiceUtil.sendRequest(jsonString,"","","",userUid,groupUid); + + + // ȡ + TCComponentBOMLine subline = topline; + //ȡն + TCComponentItem meopItem = subline.getItem(); + //ȡµ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()); + } + } + } + } + } + } + String value = ""; + if(equipmentNameList.size() > 0) + { + value = equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1); + } + // + SqlUtilT.getTCConnection(); + String updateSql = String.format("update RB3_CONTROLPLAN set RB3_JQSB = ? where RB3_MEOPID = \'%s\' and RB3_GCMC not like (\'飨%%\')", meopItem.getStringProperty("item_id"));//飨 + System.out.println(updateSql+"===="+value); + SqlUtilT.update(new String[] { value }, updateSql); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + bomWindow.unlock(); + bomWindow.save(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionCommand.java b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionCommand.java new file mode 100644 index 0000000..f3a415d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionCommand.java @@ -0,0 +1,120 @@ +package com.connor.renben.process.plm.tmom008; + +import java.io.BufferedInputStream; +import java.io.File; +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.SavePermissions; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom008OPDivisionCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private String commandId; + private InterfaceAIFComponent targetComponent; + private List> dataList = new ArrayList>(); + private String[] titleNames = new String[] { "PLMEID", "ID", "", + "", "Լû", "Ѳû", "ԼûID", "ѲûID" }; + + public TMom008OPDivisionCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.commandId = commandId; + } + + /** + * ȡй + */ + private void getDataList() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // ȡѡй°汾 + TCComponentItem process = (TCComponentItem) this.targetComponent; + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String + .format(pro.getProperty("OPDIVISIONDIALOGSELECT"), + process.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PROCESSPUID")); + list.add(rs.getString("RB3_MEOPID")); + list.add(rs.getString("RB3_GYBH")); + list.add(rs.getString("RB3_GCMC")); + list.add(rs.getString("RB3_USER_NAME")); + list.add(rs.getString("RB3_INSPECTIONUSER_NAME")); + list.add(rs.getString("RB3_USER")); + list.add(rs.getString("RB3_INSPECTIONUSER")); + this.dataList.add(list); + } + } catch (Exception e) { + // TODO Auto-generated catch block + 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(); + } + } + + @Override + public void executeModal() throws Exception { + this.targetComponent = app.getTargetComponent(); + if (this.targetComponent.getType().indexOf("MEProcess") < 0 || !(this.targetComponent instanceof TCComponentItem)) { + MessageBox.post("ѡն", "", MessageBox.ERROR); + return; + } + String userName = ((TCComponentItem)this.targetComponent).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + if (!session.getUser().getUserId().equals(userName) && !session.getUser().getUserId().equals("admin")) { + MessageBox.post("޹շֹȨ", "", MessageBox.ERROR); + return; + } + SavePermissions savePermissions = new SavePermissions(session, (TCComponentItem)this.targetComponent); + savePermissions.insertData(); + getDataList(); + new Thread() { + private InterfaceAIFComponent targetComponent; + + @Override + public void run() { + TMom008OPDivisionDialog dialog = new TMom008OPDivisionDialog( + session, commandId, this.targetComponent, dataList, + titleNames); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionDialog.java b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionDialog.java new file mode 100644 index 0000000..a798f7d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionDialog.java @@ -0,0 +1,566 @@ +package com.connor.renben.process.plm.tmom008; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.image.ColorModel; +import java.io.File; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +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.connor.renben.process.plm.tmom009.TMom009ControlSynergyOperation; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TCGroupDialogTree; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentRole; +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 TMom008OPDivisionDialog extends AbstractAIFDialog implements + ActionListener { + + private TCSession session; + private String commandId; + private InterfaceAIFComponent targetComponent; + private List> dataList = new ArrayList>(); + private List> meopTable_dataList = new ArrayList>(); + private JComponent setValueText; + private Map componentMap = new HashMap(); + private Map buttonMap = new HashMap(); + private String[] titleNames; + private List changRow = new ArrayList(); + // ؼ + private JPanel tablePanel; + private JPanel rootPanel; + private CTMap map; + private CTable table; + private AddUserDialog userDialog; + private JButton okButton; + private JButton celButton; + private JButton deleteButton; + private List indexList;//ɱ༭ĵԪ + //private JButton selectUser; + + public TMom008OPDivisionDialog(TCSession session, String commandId, + InterfaceAIFComponent targetComponent, List> dataList, + String[] titleNames) { + // TODO Auto-generated constructor stub + this.session = session; + this.commandId = commandId; + this.targetComponent = targetComponent; + this.dataList = dataList; + this.titleNames = titleNames; + getValues(); + init(); + } + private void getValues() + { + //ȡExcelϢ + File file = TMomMethodUtil.getFile(session, "","MSExcelX"); + try { + meopTable_dataList = ExcelUtil07.readExcel(file); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + // 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); + map.setEditable(false); + setJTable(); + partsTable = new CTable(map); + // partsTable.setRowHeight(1, 50); + partsTable.HiddenCell(0); + partsTable.HiddenCell(6); + partsTable.HiddenCell(7); + int count1 = partsTable.getModel().getRowCount(); + indexList = new ArrayList<>(); + for(List list :meopTable_dataList){ + String meopType = list.get(4).toString(); + if(meopType!="" || meopType!=null) + for(int i = 0 ; i < count1 ; i++){ + if(partsTable.getModel().getValueAt(i, 3).equals(list.get(2))){ + if(list.get(4).equals("1")) + { + indexList.add(new String[]{i+"","5"}); + } + if(list.get(4).equals("2")) + { + indexList.add(new String[]{i+"","4"}); + } + } + } + } + partsTable.setDefaultRenderer(Object.class, new TableRenderer(indexList)); + 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 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + for (int j = 0; j < rowList.size(); j++) { + map.setValueAt(rowList.get(j), i, j); + } + } + } + + private void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("gyfg08_display.TITLE")); + this.tablePanel = new JPanel(new BorderLayout()); + table = getjTable(null, null, titleNames, null); + table.setRowHeight(30); + table.getTableHeader().setVisible(true); + this.tablePanel.add(new JScrollPane(this.table), BorderLayout.CENTER); + // for (int i = 0; i < meopName.size(); i++) { + // JComponent valueComp = null; + // JComponent buttonComp = null; + // JLabel disNameLabel = new JLabel(); + // disNameLabel.setText(meopName.get(i)); + // JTextField valueText = new JTextField(20); + // valueComp = valueText; + // JButton button = new JButton("ѡԱ..."); + // button.addActionListener(this); + // buttonComp = button; + // itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", + // disNameLabel); + // itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", + // valueComp); + // itemPorpPanel.add((i + 1) + ".3.left.top.preferred.preferred", + // button); + // componentMap.put(meopName.get(i), valueComp); + // buttonMap.put(buttonComp,meopName.get(i)); + // } + + //setValueText = componentMap.get(buttonMap.get(source)); + userDialog = new AddUserDialog(); + + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(tablePanel); + splitPane.setRightComponent(userDialog); + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + okButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); + deleteButton = new JButton(rb.getString("sc08_display.TITLE")); + deleteButton.addActionListener(this); + //this.selectUser = new JButton("ѡԱ"); + //this.selectUser.addActionListener(this); + + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + //this.rootPanel.add(this.selectUser); + this.rootPanel.add(this.deleteButton); + + this.setLayout(new BorderLayout()); + this.add(splitPane, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + Object source = arg0.getSource(); + if (source.equals(this.okButton)) { + try { + List> dataValueList = new ArrayList>(); + for (int i = 0; i < table.getRowCount(); i++) { + if (!this.changRow.contains(i)) { + continue; + } + List rowValue = new ArrayList(); + for (int j = 0; j < table.getColumnCount(); j++) { + rowValue.add(table.getValueAt(i, j) == null ? "" + : table.getValueAt(i, j).toString()); + } + dataValueList.add(rowValue); + } + switch (commandId) { + + case "com.connor.renben.process.plm.commands.OPDivision": + TMom008OPDivisionOperation operation = new TMom008OPDivisionOperation( + session, dataValueList); + session.queueOperation(operation); + break; + case "com.connor.renben.process.plm.commands.ControlSynergy": + TMom009ControlSynergyOperation ontrolSynergyOperation = new TMom009ControlSynergyOperation( + session, dataValueList); + session.queueOperation(ontrolSynergyOperation); + break; + default: + break; + } + this.disposeDialog(); + this.dispose(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.disposeDialog(); + this.dispose(); + } else if (source.equals(deleteButton)) { + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() > 3) { + if (!changRow.contains(table.getSelectedRow())) { + changRow.add(table.getSelectedRow()); + } + table.setValueAt("", table.getSelectedRow(), + table.getSelectedColumn()); + table.setValueAt("", table.getSelectedRow(), + table.getSelectedColumn() + 2); + } + } + } + + /** + * + * + * @author hub + * + */ + private class AddUserDialog extends JPanel { + + private JPanel panel; + private JPanel panel3; + private JLabel lable; + private JLabel searchLable; + private JTextField searchField; + private JButton okButton; + private JButton searchButton; + // private MyTable table; + private JTree userTree; + private DefaultMutableTreeNode node; + private DefaultTreeModel m_model; + private String value; + //private String meopName; + private List nameList = new ArrayList(); + TCGroupDialogTree treeDialog; + + public AddUserDialog() { + super(false); + //this.meopName = meopName; + init(); + } + + public void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + System.out.println("ʼ"); + //this.setTitle("֯ṹ"); + this.setPreferredSize(new Dimension(400, 300)); + + this.lable = new JLabel(rb.getString("xzz08_display.TITLE")); + + this.panel = new JPanel(new BorderLayout()); + this.panel3 = new JPanel(new FlowLayout()); + + this.searchLable = new JLabel(rb.getString("yhm08_display.TITLE")); + this.searchField = new JTextField(20); + + this.searchButton = new JButton(rb.getString("ss08_display.TITLE")); + this.searchButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + if (value != null && !value.equals(searchField.getText())) { + nameList.clear(); + value = searchField.getText(); + } else { + value = searchField.getText(); + } + DefaultMutableTreeNode node = searchNode( + searchField.getText(), nameList); + if (node != null) { + TCComponent user = ((TMomUserBean) node.getUserObject()) + .getUser(); + try { + nameList.add(user.getStringProperty("user_id")); + } catch (TCException e) { + e.printStackTrace(); + } + TreeNode[] nodes = m_model.getPathToRoot(node); + TreePath path = new TreePath(nodes); + userTree.scrollPathToVisible(path); + userTree.setSelectionPath(path); + } else { + MessageBox.post("δҵԱ", "", MessageBox.ERROR); + nameList.clear(); + } + } + }); +// this.okButton = new JButton("ȷ"); +// this.okButton.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// okAction(e); +// } +// }); + // JPanel orgPanel = new JPanel(new BorderLayout()); + + if (treeDialog == null) { + treeDialog = new TCGroupDialogTree(); + } + if (this.userTree == null) { + + TCSession session = (TCSession) AIFUtility + .getCurrentApplication().getSession(); + 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); + this.node = node1; + m_model = new DefaultTreeModel(node); + userTree = new JTree(m_model); + userTree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 2) { + okAction(); + } + } + }); + userTree.setRowHeight(20); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) userTree + .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(); + } + // this.userTree = treeDialog.getTcOrgTree(session, "NBTM"); + } + // orgPanel.add(BorderLayout.CENTER, this.userTree); + // panel2.add(lable); + // panel2.add(BorderLayout.CENTER, ); + panel3.add(searchField); + panel3.add(searchButton); + //panel3.add(okButton); + panel.add(panel3, BorderLayout.SOUTH); + panel.add(new JScrollPane(this.userTree), BorderLayout.CENTER); + this.add(panel, "Center"); + // this.setAlwaysOnTop(true); + //this.pack(); + //this.centerToScreen(); + //this.showDialog(); + } + + 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 DefaultMutableTreeNode searchNode(String nodeStr, + List nameList) { + DefaultMutableTreeNode node = null; + Enumeration e = this.node.breadthFirstEnumeration(); + while (e.hasMoreElements()) { + node = (DefaultMutableTreeNode) e.nextElement(); + if (node.getUserObject() instanceof TMomUserBean) { + TCComponent user = ((TMomUserBean) node.getUserObject()) + .getUser(); + try { + String userName = user.getStringProperty("user_name"); + String userId = user.getStringProperty("user_id"); + if (userName != null) { + if ((userName.indexOf(nodeStr) >= 0 || userId.indexOf(nodeStr) >= 0) + && !nameList.contains(userId)) { + return node; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + return null; + } + + private void okAction() { + + Object selectObj = userTree.getLastSelectedPathComponent(); + if (selectObj instanceof DefaultMutableTreeNode) { + Object userObj = ((DefaultMutableTreeNode) selectObj) + .getUserObject(); + if (userObj instanceof TMomUserBean) { + if (((TMomUserBean) userObj).getUser() instanceof TCComponentUser) { + try { + TCComponentUser user = (TCComponentUser) ((TMomUserBean) userObj) + .getUser(); + // ȡ޸ĵ + String userId = table.getValueAt( + table.getSelectedRow(), + table.getSelectedColumn()) == null ? "" + : table.getValueAt(table.getSelectedRow(), + table.getSelectedColumn()) + .toString(); + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() > 3) { + if ((userId == null || userId.equals("") || !user + .getStringProperty("user_id") + .equals(userId)) + && !changRow.contains(table + .getSelectedRow())) { + changRow.add(table.getSelectedRow()); + } + System.out.println(table.getSelectedRow() + + "======" + table.getSelectedColumn()); + //жѡĵԪǷDzɱ༭ + boolean flag = false; + for(String[] index : indexList){ + if(index[0].equals(String.valueOf(table.getSelectedRow()))&&index[1].equals(String.valueOf(table.getSelectedColumn()))){ + flag = true; + } + } + if(!flag){ + table.setValueAt( + user.getStringProperty("user_name"), + table.getSelectedRow(), + table.getSelectedColumn()); + table.setValueAt(user.getStringProperty("user_id"), + table.getSelectedRow(), + table.getSelectedColumn() + 2); + System.out.println("get user = " + user); + } + // ((JTextField)setValueText).setText(user + // .getStringProperty("user_name")); + // userMap.put(meopName, user); + // this.disposeDialog(); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + MessageBox.post(e1.toString(), "", + MessageBox.ERROR); + e1.printStackTrace(); + // user = null; + // personName.setText(""); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + // user = null; + // personName.setText(""); + } + + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + // user = null; + // personName.setText(""); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + // user = null; + // personName.setText(""); + } + } + + } +} diff --git a/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionHandler.java b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionHandler.java new file mode 100644 index 0000000..0338e67 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionHandler.java @@ -0,0 +1,32 @@ +package com.connor.renben.process.plm.tmom008; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class TMom008OPDivisionHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String commandId = arg0.getCommand().getId(); + TMom008OPDivisionCommand command = new TMom008OPDivisionCommand(app, + session, commandId); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("շֹʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionOperation.java b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionOperation.java new file mode 100644 index 0000000..4bbb848 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom008/TMom008OPDivisionOperation.java @@ -0,0 +1,226 @@ +package com.connor.renben.process.plm.tmom008; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom008OPDivisionOperation extends AbstractAIFOperation { + private TCSession session; + private List> dataValue; + + public TMom008OPDivisionOperation(TCSession session, + List> dataValue) { + // TODO Auto-generated constructor stub + this.session = session; + this.dataValue = dataValue; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + // Уе + CheckData(); + // ±е + updateDate(); + MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + // TCComponentProcessType tccomponentprocesstype = + // (TCComponentProcessType)session.getTypeComponent("Job"); + // TCComponentTaskTemplateType tccomponenttasktemplatetype + // =(TCComponentTaskTemplateType)session.getTypeComponent("EPMTaskTemplate"); + // TCComponentTaskTemplate atccomponenttasktemplate = + // tccomponenttasktemplatetype.find("֪ͨ", + // TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + // if(atccomponenttasktemplate == null) + // { + // MessageBox.post("δҵģ壡", "", MessageBox.ERROR); + // return; + // } + // for (int i = 0; i < dataValue.size(); i++) { + // //ȡԱ + // TCComponentUserType type = + // (TCComponentUserType)session.getTypeComponent("User"); + // TCComponentUser[] user; + // if(dataValue.get(i).get(4) == null || + // dataValue.get(i).get(4).equals("")) + // { + // continue; + // } + // if(dataValue.get(i).get(5) == null || + // dataValue.get(i).get(5).equals("") || + // dataValue.get(i).get(4).equals(dataValue.get(i).get(5))) + // { + // user = new TCComponentUser[]{ type.find(dataValue.get(i).get(4)) + // };//2135 + // } + // else + // { + // user = new TCComponentUser[]{ + // type.find(dataValue.get(i).get(4)),type.find(dataValue.get(i).get(5)) + // };//2135 + // } + // //ȡĿ + // // ȡѡеĶ + // TCComponentItemType itemType = (TCComponentItemType) + // this.session.getTypeComponent("Item"); + // TCComponentItem item = itemType.find(dataValue.get(i).get(1)); + // //Ȩ + // // TMomMethodUtil.setByPass(session, true); + // // TCAccessControlService + // acs=session.getTCAccessControlService(); + // // String[] as=new + // String[]{TCAccessControlService.WRITE,TCAccessControlService.CHANGE}; + // TMomMethodUtil.setByPass(session, true); + // // + // item.changeOwner(type.find(dataValue.get(i).get(4)), + // type.find(dataValue.get(i).get(4)).getGroups()[0]); + // //Աrb3_meop_user + // // item.lock(); + // // item.setRelated("rb3_meop_user", user); + // // item.save(); + // // item.unlock(); + // TMomMethodUtil.setByPass(session, false); + // //item.save(); + // if(user != null && user.length > 0) + // { + // for (int j = 0; j < user.length; j++) { + // //һ ơģ塢Ŀ󡢸 + // TCComponentProcess + // newProcess=(TCComponentProcess)tccomponentprocesstype + // .create(item.getLatestItemRevision().getStringProperty("object_string")+"-", + // item.getLatestItemRevision().getStringProperty("object_string"),atccomponenttasktemplate, + // new TCComponent[]{ item.getLatestItemRevision() },new + // int[]{TCAttachmentType.TARGET}); + // TMomMethodUtil.setProcess(session, newProcess, user[j]); + // } + // } + // //ResourceMember resourceMember = new + // ResourceMember(atccomponenttasktemplate[i], new TCComponent[]{}, + // new TCComponent[]{ session.getUser() }, new int[]{ 3 }, 1, 1, 1); + // // TCComponentTask task = newProcess.getRootTask(); + // // TCComponent[] tasks = + // task.getReferenceListProperty("child_tasks"); + // // for (int j1 = 0; j1 < tasks.length; j1++) { + // // if(tasks[j1] instanceof TCComponentTask) + // // { + // // TCComponent[] tasks2 = + // ((TCComponentTask)tasks[j1]).getReferenceListProperty("child_tasks"); + // // for (int k = 0; k < tasks2.length; k++) { + // // //System.out.println(((TCComponentTask)tasks2[k]).getName()); + // // + // if(((TCComponentTask)tasks2[k]).getName().equals("select-signoff-team")) + // // { + // // TCComponentTask task1 = (TCComponentTask)tasks2[k]; + // // } + // // else + // // { + // // TCComponentTask task1 = (TCComponentTask)tasks2[k]; + // // task1.setResponsibleParty(user[j]); + // // } + // // } + // // } + // // } + // //} + // } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + private void CheckData() { + + //ȡ + TCPreferenceService service = session.getPreferenceService(); + + //ȡѡϢ + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "RB3_Process_Control_Check"); + if (array != null) + { + for (int i = 0; i < dataValue.size(); i++) { + + for (String str : array) { + + if ( str.trim() == dataValue.get(i).get(3).toString().trim()) + { + if ((dataValue.get(i).get(6)== null)&&(dataValue.get(i).get(7)== null)&&(dataValue.get(i).get(4)== null)&&(dataValue.get(i).get(5)== null)) + { + + MessageBox.post("ùDZַĹûָˣдлл","",0); + return; + } + + + + + } + + } + + } + + } + + + } + private void updateDate() { + // TODO Auto-generated method stub + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + for (int i = 0; i < dataValue.size(); i++) { + String updateSQL = String.format(pro + .getProperty("OPDIVISIONDIALOGUPDATE"), dataValue + .get(i).get(0), dataValue.get(i).get(1)); +// if (dataValue.get(i).get(5) == null +// || dataValue.get(i).get(5).equals("") +// || dataValue.get(i).get(7) == null +// || dataValue.get(i).get(7).equals("")) { +// if (dataValue.get(i).get(4) != null +// && dataValue.get(i).get(6) != null) { +// SqlUtilT.update(new String[] { dataValue.get(i).get(6), +// dataValue.get(i).get(6), +// dataValue.get(i).get(4), +// dataValue.get(i).get(4) }, updateSQL); +// } else { +// SqlUtilT.update(new String[] { "", "", "", "" }, +// updateSQL); +// } +// } else { + SqlUtilT.update(new String[] { dataValue.get(i).get(6), + dataValue.get(i).get(7), dataValue.get(i).get(4), + dataValue.get(i).get(5) }, updateSQL); + //} + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + 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/tmom008/TableRenderer.java b/src/com/connor/renben/process/plm/tmom008/TableRenderer.java new file mode 100644 index 0000000..b83c878 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom008/TableRenderer.java @@ -0,0 +1,98 @@ +package com.connor.renben.process.plm.tmom008; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellRenderer; + +public class TableRenderer extends DefaultTableCellRenderer{ + private static final long serialVersionUID = 1L; + private List positioins; + + public TableRenderer(List _positioins){ + this.positioins = _positioins; + } + + public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, + int row, int col) { + int maxPreferredHeight = 0; + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(col).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + for(int i=0; i> indexList; +// public static final DefaultTableCellRenderer DEFAULT_RENDERER = new DefaultTableCellRenderer(); +// public TableRenderer(List> indexList) { +// // TODO Auto-generated constructor stub +// this.indexList = indexList; +// } +// public TableRenderer(){}; +// public Component getTableCellRendererComponent(JTable table, +// +// Object value,boolean isSelected, boolean hasFocus, int row, int column) { +// +// Component renderer = DEFAULT_RENDERER.getTableCellRendererComponent(table, +// +// value,isSelected, hasFocus, row, column); +// for(List list : indexList){ +// +// rowIndex = (int) list.get(0); +// columnIndex = (int) list.get(1); +// if(row==rowIndex&&column==columnIndex){ +// +// background = Color.GRAY; +// +// }else{ +// +// foreground = Color.BLACK; +// +// background = Color.WHITE; +// +// } +// +// renderer.setForeground(foreground); +// +// renderer.setBackground(background); +// } +// +// return renderer; +// } + +} diff --git a/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyCommand.java b/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyCommand.java new file mode 100644 index 0000000..099a2b3 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyCommand.java @@ -0,0 +1,245 @@ +package com.connor.renben.process.plm.tmom009; + +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCAttachmentType; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom009ControlSynergyCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent targetComponent; + private TCComponent process = null; + private TCComponent product = null; + private List> dataList = new ArrayList>(); + + public TMom009ControlSynergyCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.targetComponent = app.getTargetComponent(); + } + + /** + * ȡй + */ + private void getDataList() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + TCComponentItemRevision itemRevision = null; + // ȡƼƻ汾 + if (this.targetComponent instanceof TCComponentItem) { + //item = (TCComponentItem) this.targetComponent; + MessageBox.post("ѡƼƻ汾", "", MessageBox.ERROR); + return; + } else if (this.targetComponent instanceof TCComponentItemRevision) { + itemRevision = ((TCComponentItemRevision) this.targetComponent); + } + if (itemRevision == null) { + MessageBox.post("ѡ", "", MessageBox.ERROR); + return; + } else { + AIFComponentContext[] context = itemRevision.getItem().whereReferenced(); + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("MEProcess")) { + process = (TCComponent) context[i].getComponent(); + } + } + //ݹջȡƷ + AIFComponentContext[] productItems = process.whereReferenced(); + for (int i = 0; i < productItems.length; i++) { + if(productItems[i].getComponent().getType().indexOf("Product") >= 0 && productItems[i].getComponent() instanceof TCComponentItem) + { + product = (TCComponent) productItems[i].getComponent(); + } + } + } + String userName = ((TCComponentItemRevision)this.targetComponent).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + if (!session.getUser().getUserId().equals(userName) && !session.getUser().getUserId().equals("admin")) { + MessageBox.post("޿ƼƻַȨ", "", MessageBox.ERROR); + return; + } + + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("CONTROLSYNERGYSELECT"), + process.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List list = new ArrayList(); + //list.add(rs.getString("PLMEID")); + list.add(rs.getString("RB3_MEOPID")); + //list.add(rs.getString("RB3_GYBH")); + //list.add(rs.getString("RB3_GCMC")); + list.add(rs.getString("RB3_USER_ID")); + this.dataList.add(list); + } + } catch (Exception e) { + // TODO Auto-generated catch block + 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(); + } + } + + @Override + public void executeModal() throws Exception { + this.targetComponent = app.getTargetComponent(); + if (this.targetComponent.getType().toUpperCase().indexOf("KZJH") < 0 || !(this.targetComponent instanceof TCComponentItemRevision)) { + MessageBox.post("ѡƼƻ汾", "", MessageBox.ERROR); + return; + } + getDataList(); + TCComponentProcessType tccomponentprocesstype = (TCComponentProcessType) session + .getTypeComponent("Job"); + TCComponentTaskTemplateType tccomponenttasktemplatetype = (TCComponentTaskTemplateType) session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate atccomponenttasktemplate = tccomponenttasktemplatetype + .find("WF_61շֹ", TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (atccomponenttasktemplate == null) { + MessageBox.post("δҵģ壡", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < dataList.size(); i++) { + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + TCComponentUser[] user = null; +// if (dataList.get(i).get(1) == null +// || dataList.get(i).get(1).equals("")) { +// continue; +// } +// if (dataList.get(i).get(2) == null +// || dataList.get(i).get(2).equals("") || dataList.get(i).get(2).equals(" ") +// || dataList.get(i).get(1).equals(dataList.get(i).get(2))) { + user = new TCComponentUser[] { type.find(dataList.get(i).get(1) + .toString()) };// 2135 +// } else if (dataList.get(i).get(1) == null +// || dataList.get(i).get(1).equals("") || dataList.get(i).get(1).equals(" ")) { +// if(dataList.get(i).get(2) != null +// && !dataList.get(i).get(2).equals("") && !dataList.get(i).get(2).equals(" ")) +// { +// user = new TCComponentUser[] { type.find(dataList.get(i).get(2) +// .toString()) };// 2135 +// } +// } else { +// user = new TCComponentUser[] { +// type.find(dataList.get(i).get(1).toString()), +// type.find(dataList.get(i).get(2).toString()) };// 2135 +// } + // ȡĿ + // ȡѡеĶ + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem[] meopItems = null; + if(dataList.get(i).get(0).toString().indexOf(",") >= 0) + { + String[] meopId = dataList.get(i).get(0).toString().split(","); + meopItems = new TCComponentItem[meopId.length]; + for (int j = 0; j < meopId.length; j++) { + meopItems[j] = itemType.find(meopId[j]); + } + } + else + { + meopItems = new TCComponentItem[]{itemType.find(dataList.get(i).get(0).toString())}; + } + TCComponent[] components = null; + int[] componentType = null; + if(meopItems != null) + { + components = new TCComponent[meopItems.length+1]; + componentType = new int[meopItems.length+1]; + components[0] = ((TCComponentItemRevision)this.targetComponent); + componentType[0] = TCAttachmentType.TARGET; + for (int j = 1; j <= meopItems.length; j++) { + components[j] = meopItems[j-1]; + componentType[j] = TCAttachmentType.REFERENCE; + } + } + else + { + continue; + } +// TCComponentItem item = itemType.find(dataList.get(i).get(1) +// .toString()); +// //ȡհ汾 +// TCComponent[] components = item.whereUsed(TCComponent.WHERE_USED_PRECISE); +// if(components[0] instanceof TCComponentItemRevision) +// { +// //ȡն +// TCComponentItem meprocessItem = ((TCComponentItemRevision)components[0]).getItem(); +// AIFComponentContext[] prodectRevs = meprocessItem.whereReferenced(); +// for (int j = 0; j < prodectRevs.length; j++) { +// +// } +// } +// // Ȩ +// TMomMethodUtil.setByPass(session, true); +// // +// item.changeOwner(type.find(dataList.get(i).get(4).toString()), type +// .find(dataList.get(i).get(4).toString()).getGroups()[0]); +// TMomMethodUtil.setByPass(session, false); + if (user != null && user.length > 0) { + for (int j = 0; j < user.length; j++) { + // һ ơģ塢Ŀ󡢸 + TCComponentProcess newProcess = (TCComponentProcess) tccomponentprocesstype + .create(product + .getStringProperty("item_id") + + "-Ƽƻ", this.targetComponent + .getProperty("object_name"), + atccomponenttasktemplate, + components, + componentType); + TMomMethodUtil.setProcess(session, newProcess, user[j]); + } + } + } + MessageBox.post("Ƽƻַɹ", "ɹ", MessageBox.INFORMATION); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyHandler.java b/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyHandler.java new file mode 100644 index 0000000..0263249 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyHandler.java @@ -0,0 +1,32 @@ +package com.connor.renben.process.plm.tmom009; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class TMom009ControlSynergyHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String commandId = arg0.getCommand().getId(); + TMom009ControlSynergyCommand command = new TMom009ControlSynergyCommand( + app, session, commandId); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ƼƻЭʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyOperation.java b/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyOperation.java new file mode 100644 index 0000000..86a88b3 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom009/TMom009ControlSynergyOperation.java @@ -0,0 +1,133 @@ +package com.connor.renben.process.plm.tmom009; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCAttachmentType; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom009ControlSynergyOperation extends AbstractAIFOperation { + + private TCSession session; + private List> dataValue; + + public TMom009ControlSynergyOperation(TCSession session, + List> dataValue) { + // TODO Auto-generated constructor stub + this.session = session; + this.dataValue = dataValue; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + // ±е + updateDate(); + TCComponentProcessType tccomponentprocesstype = (TCComponentProcessType) session + .getTypeComponent("Job"); + TCComponentTaskTemplateType tccomponenttasktemplatetype = (TCComponentTaskTemplateType) session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate atccomponenttasktemplate = tccomponenttasktemplatetype + .find("֪ͨ", TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (atccomponenttasktemplate == null) { + MessageBox.post("δҵģ壡", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < dataValue.size(); i++) { + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + TCComponentUser[] user; + if (dataValue.get(i).get(4) == null + || dataValue.get(i).get(4).equals("")) { + continue; + } else { + user = new TCComponentUser[] { type.find(dataValue.get(i) + .get(4)) };// 2135 + } + // ȡĿ + // ȡѡеĶ + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem item = itemType.find(dataValue.get(i).get(1)); + if (user != null && user.length > 0) { + for (int j = 0; j < user.length; j++) { + // һ ơģ塢Ŀ󡢸 + TCComponentProcess newProcess = (TCComponentProcess) tccomponentprocesstype + .create(item.getLatestItemRevision() + .getStringProperty("object_string") + + "-Ƽƻ", item + .getLatestItemRevision() + .getStringProperty("object_string"), + atccomponenttasktemplate, + new TCComponent[] { item + .getLatestItemRevision() }, + new int[] { TCAttachmentType.TARGET }); + TMomMethodUtil.setProcess(session, newProcess, user[j]); + } + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + + private void updateDate() { + // TODO Auto-generated method stub + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + for (int i = 0; i < dataValue.size(); i++) { + String updateSQL = String.format( + pro.getProperty("CONTROLSYNERGYUPDATE"), + dataValue.get(i).get(0)); + if (dataValue.get(i).get(4) == null + || dataValue.get(i).get(4).equals("")) { + continue; + } else { + SqlUtilT.update(new String[] { dataValue.get(i).get(4) }, + updateSQL); + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + 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/tmom010/CTMap.java b/src/com/connor/renben/process/plm/tmom010/CTMap.java new file mode 100644 index 0000000..21db2d2 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/CTMap.java @@ -0,0 +1,328 @@ +package com.connor.renben.process.plm.tmom010; + +import java.awt.Dimension; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + + private List processRowList; + + 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; + } + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (processRowList != null && processRowList.size() > 0) { + if (!processRowList.contains(arg0) || arg1 == 1 || arg1 == 2) { + return false; + } else { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + } else { + return false; + } + } + + @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 void combine(int[] rows, int[] columns) { + // TODO Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if ((span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1) + || (span[startRow + i][startColumn + j][CellSpan.ROW] != 1)) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) + || (columnSize <= column)) { + return true; + } + return false; + } + + public void addRow() { + + Vector newData = new Vector(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, + getRowCount() - 1, TableModelEvent.ALL_COLUMNS, + TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + public void insertRow(int row) { + Vector rowData = new Vector(getColumnCount()); + 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); + } + } + + // if (processRowList.contains(row)) { + // for (int i = 0; i < processRowList.size(); i++) { + // 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+1) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + // else + // { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == + // row-1) + // { + // index = i+1; + // processRowList.add(i+1, row); + // } + // 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/tmom010/CTUI.java b/src/com/connor/renben/process/plm/tmom010/CTUI.java new file mode 100644 index 0000000..124f530 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom010; + +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/tmom010/CTable.java b/src/com/connor/renben/process/plm/tmom010/CTable.java new file mode 100644 index 0000000..bf858f8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/CTable.java @@ -0,0 +1,251 @@ +package com.connor.renben.process.plm.tmom010; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class CTable extends JTable { + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor( + new Object[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + + public CTable(TableModel model) { + super(model); + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + +// Dimension size = this.getTableHeader().getPreferredSize(); +// System.out.println("Table Header Size:"+size); +// size.height = 200;//µıͷ߶40 +// this.getTableHeader().setPreferredSize(size); + // Ӽ̼ + this.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + if(arg0.getKeyChar() == KeyEvent.VK_DELETE) + { + int[] selectRows = CTable.this.getSelectedRows(); + int[] selectColumns = CTable.this.getSelectedColumns(); + for (int i = 0; i < selectRows.length; i++) { + for (int j = 0; j < selectColumns.length; j++) { + CTable.this.setValueAt("", selectRows[i], selectColumns[j]); + } + } + } + super.keyPressed(arg0); + } + }); + 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("New_SEV") + || this.getColumnName(column).equals("New_OCC") + || this.getColumnName(column).equals("New_DET")) { + return comboBoxCellEditor; + } else { + return cellEditor; + } + // Point point = new Point(row,column); + // if(map.containsKey(point)){ + // return map.get(point); + // }else{ + // return super.getCellEditor(row, column); + // } + } + + // @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 + // { + // return renderer; + // } + // + // } + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + // @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/tmom010/CellSpan.java b/src/com/connor/renben/process/plm/tmom010/CellSpan.java new file mode 100644 index 0000000..21e7e47 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.tmom010; + +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/tmom010/ComboBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom010/ComboBoxCellEditor.java new file mode 100644 index 0000000..237eb90 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/ComboBoxCellEditor.java @@ -0,0 +1,88 @@ +package com.connor.renben.process.plm.tmom010; + +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/tmom010/CopyOfTMom010SetPFMEADialog.java b/src/com/connor/renben/process/plm/tmom010/CopyOfTMom010SetPFMEADialog.java new file mode 100644 index 0000000..0fd0d45 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/CopyOfTMom010SetPFMEADialog.java @@ -0,0 +1,1494 @@ +package com.connor.renben.process.plm.tmom010; +//package com.connor.renben.process.plm.tmom010; +// +//import java.awt.BorderLayout; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Font; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//import java.io.BufferedInputStream; +//import java.io.File; +//import java.io.FileOutputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.sql.ResultSet; +//import java.util.ArrayList; +//import java.util.Arrays; +//import java.util.HashMap; +//import java.util.Iterator; +//import java.util.List; +//import java.util.Map; +//import java.util.Properties; +// +//import javax.swing.JButton; +//import javax.swing.JLabel; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JSplitPane; +//import javax.swing.JTabbedPane; +//import javax.swing.JTable; +//import javax.swing.JTree; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.DefaultTreeCellRenderer; +// +//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 com.connor.renben.process.plm.bean.ControlPlanTreeBean; +//import com.connor.renben.process.plm.bean.PFMEABean; +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.connor.renben.process.plm.util.CTextField; +//import com.connor.renben.process.plm.util.CTreeNode; +//import com.connor.renben.process.plm.util.ExcelUtil; +//import com.connor.renben.process.plm.util.MyTableModel; +//import com.connor.renben.process.plm.util.TreeTableCellEditor; +//import com.connor.renben.process.plm.util.TreeTableCellRenderer; +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.AbstractAIFDialog; +//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; +//import com.teamcenter.rac.util.PropertyLayout; +// +//public class CopyOfTMom010SetPFMEADialog extends AbstractAIFDialog implements +// ActionListener { +// private AbstractAIFApplication app; +// private TCSession session; +// private TCProperty[] properties; +// private TCProperty[] itemProperties; +// private CTMap map; +// static JScrollPane scrollPane; +// private String[] header = new String[] { "PLMEID", "", "Station", +// "̹", "Ҫ", "DZʧЧģʽ", "DZʧЧ", "ضS", "", "DZʧЧ/", +// "й̿Ԥ", "ƵO", "й̿̽", "̽D", "RPN", "ʩ", "", +// "ƻ", "ȡĴʩ", "New_SEV", "New_OCC", "New_DET", "New_RPN", +// "Ideal_State", "λ" }; +// private String[] pfmeaHeader = new String[] { "PLMEID", "Station", "Ҫ", +// "DZʧЧģʽ", "DZʧЧ", "ضS", "", "DZʧЧ/", "й̿Ԥ", "ƵO", +// "й̿̽", "̽D", "RPN", "ʩ", "", "ƻ", "ȡĴʩ", +// "New_SEV", "New_OCC", "New_DET", "New_RPN", "Ideal_State", "ڵID", +// "λ" }; +// private String[] recordHeader = new String[] { "", "", "ǰ", +// "ĺ", "ʱ", "ԭ", "" }; +// private Map combineMap;// źϲԪ +// private TCComponentItemRevision itemRevision;// ѡжİ汾 +// private TCComponent meprocess;// ѡڵĹ +// // private List> processRowList;//ǰû޸ĵк +// private List processRows;// ǰû޸ĵк +// private List> dataList; +// private List deleteRows = new ArrayList(); +// private SpecialDialog specialDialog; +// private ControlPlanTreeBean bean; +// private Properties pro = new Properties(); +// private boolean isComplete = false; +// private boolean isOwning; +// +// // ؼ +// private JPanel titlePanel;// +// private JLabel titleLabel; +// +// private JPanel mainPanel;// д +// +// private JLabel prjNameLabel;// Ŀ +// private CTextField prjNameField; +// private JLabel processLiabilityLabel;// +// private CTextField processLiabilityField; +// private JLabel drawupLabel;// +// private CTextField drawupField; +// +// private JLabel cotyLabel;// / +// private CTextField cotyField; +// private JLabel keydayLabel;// ؼ +// private CTextField keydayField; +// private JLabel drawupDateLabel;// +// private CTextField drawupDateField; +// +// private JLabel coreteamLabel;// С +// private CTextField coreteamField; +// private JLabel changeDateLabel;// +// private CTextField changeDateField; +// +// // ǩҳ +// private JTabbedPane tabbedPane; +// // һҳ +// private JPanel firstPanel;// ؼ +// private static CTable table; +// // ڶҳ +// private JPanel secondPanel;// ؼ +// private static CTable table2; +// +// // PFMEA +// private JPanel treePanel; +// private JTree tree; +// +// private JPanel rootPanel;// ť +// private JButton addButton;// +// private JButton remButton;// Ƴ +// private JButton comBinebutton;// ϲ +// private JButton splitButton;// +// private JButton saveButton;// +// private JButton completeButton;// +// private JButton addSpecialButton;// +// +// // PFMEA +// +// public CopyOfTMom010SetPFMEADialog(AbstractAIFApplication app, +// TCSession session, List processRows, +// TCComponentItemRevision itemRevision, TCComponent meprocess, +// TCProperty[] properties, TCProperty[] itemProperties, +// Map combineMap, List> dataList, +// boolean isOwning) { +// super(); +// // this.processRowList = processRowList; +// this.processRows = processRows; +// this.dataList = dataList; +// this.combineMap = combineMap; +// this.itemRevision = itemRevision; +// this.meprocess = meprocess; +// this.properties = properties; +// this.itemProperties = itemProperties; +// this.app = app; +// this.session = session; +// this.isOwning = isOwning; +// init(); +// this.processRows = processRows; +// // setProcessRows(this.processRowList); +// comBine(); +// } +// +// 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()); +// } +// } +// } +// +// // /** +// // * ̬ÿ޸ +// // */ +// // 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 void init() { +// this.setTitle("дPFMEA"); +// // this.setLocationRelativeTo(null); +// // this.setUndecorated(true); +// this.setPreferredSize(new Dimension(1280, 810)); +// // ʼⲿֿؼ +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel("DZʧЧģʽ"); +// this.titleLabel.setFont(new Font("", 1, 18)); +// this.titlePanel.add(titleLabel); +// // ʼ˵ֿؼ +// this.mainPanel = new JPanel(new PropertyLayout()); +// this.prjNameLabel = new JLabel("Ŀ"); +// this.prjNameField = new CTextField(this.properties[0].getStringValue()); +// this.prjNameField.setPreferredSize(new Dimension(160, 20)); +// this.processLiabilityLabel = new JLabel(""); +// this.processLiabilityField = new CTextField( +// this.properties[1].getStringValue()); +// this.processLiabilityField.setPreferredSize(new Dimension(160, 20)); +// this.drawupLabel = new JLabel(""); +// this.drawupField = new CTextField(this.properties[2].getStringValue()); +// this.drawupField.setPreferredSize(new Dimension(160, 20)); +// +// this.cotyLabel = new JLabel("/"); +// this.cotyField = new CTextField(this.properties[3].getStringValue()); +// this.cotyField.setPreferredSize(new Dimension(160, 20)); +// this.keydayLabel = new JLabel("ؼ"); +// this.keydayField = new CTextField(this.properties[4].getStringValue()); +// this.keydayField.setPreferredSize(new Dimension(160, 20)); +// this.drawupDateLabel = new JLabel(""); +// this.drawupDateField = new CTextField( +// this.properties[5].getStringValue()); +// this.drawupDateField.setPreferredSize(new Dimension(160, 20)); +// +// this.coreteamLabel = new JLabel("С"); +// this.coreteamField = new CTextField(this.properties[6].getStringValue()); +// this.coreteamField.setPreferredSize(new Dimension(160, 20)); +// this.changeDateLabel = new JLabel(""); +// this.changeDateField = new CTextField( +// this.properties[7].getStringValue()); +// this.changeDateField.setPreferredSize(new Dimension(160, 20)); +// +// this.mainPanel.add("1.1.left.top", this.prjNameLabel); +// this.mainPanel.add("1.2.left.top", this.prjNameField); +// this.mainPanel.add("1.3.left.top", this.processLiabilityLabel); +// this.mainPanel.add("1.4.left.top", this.processLiabilityField); +// this.mainPanel.add("1.5.left.top", this.drawupLabel); +// this.mainPanel.add("1.6.left.top", this.drawupField); +// +// this.mainPanel.add("2.1.left.top", this.cotyLabel); +// this.mainPanel.add("2.2.left.top", this.cotyField); +// this.mainPanel.add("2.3.left.top", this.keydayLabel); +// this.mainPanel.add("2.4.left.top", this.keydayField); +// this.mainPanel.add("2.5.left.top", this.drawupDateLabel); +// this.mainPanel.add("2.6.left.top", this.drawupDateField); +// +// this.mainPanel.add("3.1.left.top", this.coreteamLabel); +// this.mainPanel.add("3.2.left.top", this.coreteamField); +// this.mainPanel.add("3.3.left.top", this.changeDateLabel); +// this.mainPanel.add("3.4.left.top", this.changeDateField); +// +// this.firstPanel = new JPanel(new BorderLayout()); +// this.table = getjTable(null, null, header, null); +// // ӹ +// this.firstPanel.add(new JScrollPane(this.table), BorderLayout.CENTER); +// +// this.secondPanel = new JPanel(new BorderLayout()); +// if (itemProperties[0].getStringValueArray().length == 0) { +// this.table2 = getNewjTable(null, null, recordHeader, +// itemProperties[0].getStringValueArray().length + 1, true); +// } else { +// this.table2 = getNewjTable(null, null, recordHeader, +// itemProperties[0].getStringValueArray().length, true); +// } +// // +// for (int i = 0; i < this.table2.getColumnCount(); i++) { +// String[] rowValue = this.itemProperties[i].getStringValueArray(); +// for (int j = 0; j < rowValue.length; j++) { +// this.table2.setValueAt(rowValue[j], j, i); +// } +// } +// this.secondPanel.add(new JScrollPane(this.table2), BorderLayout.CENTER); +// +// this.tabbedPane = new JTabbedPane(); +// this.tabbedPane.add("PFMEA", new JScrollPane(this.firstPanel)); +// this.tabbedPane.add("", new JScrollPane(this.secondPanel)); +// +// // ȡݿ +// SqlUtilT.getConnectionTC10(); +// // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10","tc10", +// // "infodba"); +// getData(); +// CTreeNode node = createNodes(null, bean); +// // رݿ +// SqlUtilT.freeAll(); +// this.treePanel = new JPanel(new BorderLayout()); +// this.tree = new JTree(node); +// this.tree.setRowHeight(0); +// this.tree.setCellRenderer(new TreeTableCellRenderer()); +// this.tree.setCellEditor(new TreeTableCellEditor(this.tree, +// new DefaultTreeCellRenderer())); +// this.tree.setEditable(true); +// // this.table = getjTable(null, null, header, null); +// // ӹ +// this.treePanel.add(new JScrollPane(this.tree), BorderLayout.CENTER); +// +// 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(""); +// this.completeButton = new JButton(""); +// this.addSpecialButton = 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); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(completeButton); +// this.rootPanel.add(addSpecialButton); +// // this.rootPanel.add(sendbutton); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// centerPanel.add(mainPanel, BorderLayout.CENTER); +// +// 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.showDialog(); +// } +// +// // Ӽ +// public void createActionEvent() { +// this.addButton.addActionListener(this); +// this.remButton.addActionListener(this); +// this.comBinebutton.addActionListener(this); +// this.splitButton.addActionListener(this); +// this.saveButton.addActionListener(this); +// this.addSpecialButton.addActionListener(this); +// this.completeButton.addActionListener(this); +// } +// +// /** +// * дݵJtable +// */ +// private void setJTable() { +// for (int i = 0; i < dataList.size(); i++) { +// List rowList = dataList.get(i); +// for (int j = 0; j < header.length; j++) { +// map.setValueAt(rowList.get(j), i, j); +// } +// } +// } +// +// // ȡPFMEA +// /** +// * ȡݿе +// */ +// private void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // ȡSQL +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// pro.load(input); +// // ȡݿ +// SqlUtilT.getConnectionTC10(); +// // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +// // "tc10", "infodba"); +// String sql = String +// .format("select * from RB3_PFMEA_TREE where PARENT_ID is null"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// bean = getChidren(beans.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 ControlPlanTreeBean getChidren( +// ControlPlanTreeBean controlPlanTreeBean) { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// try { +// // ѯȨ޿ +// String sql = String.format( +// "select * from RB3_PFMEA_TREE where PARENT_ID = \'%s\'", +// controlPlanTreeBean.getId()); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// if (beans.size() > 0) { +// controlPlanTreeBean.setChidrenBeans(beans); +// for (ControlPlanTreeBean controlPlanTreeBean2 : beans) { +// getChidren(controlPlanTreeBean2); +// } +// } +// return controlPlanTreeBean; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return controlPlanTreeBean; +// } +// +// public CTreeNode createNodes(DefaultMutableTreeNode node, +// ControlPlanTreeBean bean) { +// CTreeNode root = null; +// System.out.println(bean.getName()); +// root = new CTreeNode(bean); +// try { +// if (bean != null) { +// ResultSet rs = null; +// // ѯȨ޿ +// String sql = String.format( +// pro.getProperty("PFMEALIBRARYSELECT"), bean.getId()); +// rs = SqlUtilT.read(sql); +// List> beans = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// list.add(rs.getString("RB3_STATION")); +// list.add(rs.getString("RB3_REQUIREMENT")); +// list.add(rs.getString("RB3_QZSXMS")); +// list.add(rs.getString("RB3_QZSXHG")); +// list.add(rs.getString("RB3_YZD")); +// list.add(rs.getString("RB3_JB")); +// list.add(rs.getString("RB3_QZSXQY")); +// list.add(rs.getString("RB3_XXGCKZYF")); +// list.add(rs.getString("RB3_PDS")); +// list.add(rs.getString("RB3_XXGCKZTC")); +// list.add(rs.getString("RB3_TCD")); +// list.add(rs.getString("RB3_RPN")); +// list.add(rs.getString("RB3_JYCS")); +// list.add(rs.getString("RB3_ZZR")); +// list.add(rs.getString("RB3_JHWCRQ")); +// list.add(rs.getString("RB3_CQDCS")); +// list.add(rs.getString("RB3_NEW_SEV")); +// list.add(rs.getString("RB3_NEW_OCC")); +// list.add(rs.getString("RB3_NEW_DET")); +// list.add(rs.getString("RB3_NEW_RPN")); +// list.add(rs.getString("RB3_IDEAL_STATE")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("RB3_SPECIAL")); +// beans.add(list); +// } +// if (beans.size() > 0) { +// final CTable jtable = getNewjTable(null, null, pfmeaHeader, +// beans.size() + 1, false); +// // +// jtable.HiddenCell(0); +// jtable.HiddenCell(pfmeaHeader.length - 1); +// jtable.HiddenCell(pfmeaHeader.length - 2); +// for (int i = 0; i < beans.size() + 1; i++) { +// if (i == 0) { +// for (int j = 0; j < pfmeaHeader.length; j++) { +// jtable.setValueAt(pfmeaHeader[j], i, j); +// } +// } else { +// for (int j = 0; j < beans.get(i - 1).size(); j++) { +// jtable.setValueAt(beans.get(i - 1).get(j), i, j); +// } +// } +// } +// +// // Ӽ +// jtable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 2) { +// if (table.getSelectedRow() >= 0) { +// table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn()) +// .stopCellEditing(); +// for (int i = 1; i < jtable.getColumnCount(); i++) { +// if (i == jtable.getColumnCount() - 2) { +// continue; +// } else if (i == 1 +// || i == jtable.getColumnCount() - 1) { +// table.setValueAt( +// jtable.getValueAt(jtable +// .getSelectedRow(), +// i), table +// .getSelectedRow(), +// i + 1); +// } else { +// table.setValueAt( +// jtable.getValueAt(jtable +// .getSelectedRow(), +// i), table +// .getSelectedRow(), +// i + 2); +// } +// } +// } +// } +// } +// }); +// +// DefaultMutableTreeNode child = new DefaultMutableTreeNode( +// jtable); +// root.add(child); +// node.add(root); +// if (bean.getChidrenBeans() != null) { +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root, bean.getChidrenBeans().get(i)); +// } +// } +// } else if (bean.getChidrenBeans() == null +// || bean.getChidrenBeans().size() == 0) { +// if (node != null) { +// node.add(root); +// } +// } else { +// if (node != null) { +// node.add(root); +// } +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root, bean.getChidrenBeans().get(i)); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// +// return root; +// } +// +// // Jtableͨ÷ +// public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, +// Object[] titleNames, int rows, boolean isEditable) { +// int simpleLen = 100; +// int totleLen = 1000; +// if (partsTable == null) { +// final CTMap map = new CTMap(rows, titleNames.length); +// map.setColumnIdentifiers(titleNames); +// map.setEditable(isEditable); +// partsTable = new CTable(map); +// partsTable.setRowHeight(50); +// // ʾȾ +// TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); +// partsTable.setDefaultRenderer(Object.class, renderer); +// // Ӽ +// partsTable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 1) { +// map.setRow(table.getSelectedRow()); +// map.setColumn(table.getSelectedColumn()); +// } +// } +// }); +// // 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; +// } +// +// // 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); +// setJTable(); +// partsTable.setRowHeight(50); +// // +// partsTable.HiddenCell(0); +// partsTable.HiddenCell(header.length - 1); +// // //ʾȾ +// TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); +// partsTable.setDefaultRenderer(Object.class, renderer); +// // Ӽ +// partsTable.addMouseListener(new MouseListener() { +// +// @Override +// public void mouseReleased(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mousePressed(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseExited(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseEntered(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// +// } +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 1) { +// map.setRow(table.getSelectedRow()); +// map.setColumn(table.getSelectedColumn()); +// } +// } +// }); +// // //ñ༭Ⱦ +// // 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); +// } +// } +// return partsTable; +// } +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// Object source = arg0.getSource(); +// if (source.equals(this.addButton)) { +// if (this.tabbedPane.getSelectedIndex() == 1) { +// CTMap map = ((CTMap) 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); +// 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(); +// } +// } else if (source.equals(this.remButton)) { +// if (this.tabbedPane.getSelectedIndex() == 1) { +// if (table2.getSelectedRow() > 0 +// && table2.getSelectedColumn() > 0) { +// (table2.getCellEditor(table2.getSelectedRow(), +// table2.getSelectedColumn())).stopCellEditing(); +// } +// CTMap map = ((CTMap) this.table2.getModel()); +// map.removeRow(table2.getSelectedRow()); +// } else { +// if (table.getSelectedRow() > 0 && table.getSelectedColumn() > 0) { +// (table.getCellEditor(table.getSelectedRow(), +// table.getSelectedColumn())).stopCellEditing(); +// } +// 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]); +// } +// if (i < newKey.length) { +// newKey[i] = entry.getKey()[i]; +// } +// } +// it.remove(); +// 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++) { +// 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(); +// map.combine(entry.getKey(), entry.getValue()); +// combineMap.put(entry.getKey(), entry.getValue()); +// } +// table.revalidate(); +// table.repaint(); +// } +// } else if (source.equals(this.comBinebutton)) { +// // table.setRowHeight(2, 50); +// int[] rows = table.getSelectedRows(); +// int[] columns = table.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()); +// table.revalidate(); +// table.repaint(); +// } else if (source.equals(this.splitButton)) { +// 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(); +// } else if (source.equals(this.saveButton)) { +// okEvent(true); +// } else if (source.equals(addSpecialButton)) { +// if (this.specialDialog == null) { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } else { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } else if (source.equals(completeButton)) { +// isComplete = true; +// okEvent(false); +// this.disposeDialog(); +// this.dispose(); +// } else { +// this.disposeDialog(); +// this.dispose(); +// } +// } +// +// private void okEvent(boolean isSave) { +// // TODO Auto-generated method stub +// // ݱ浽 +// try { +// 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.setPrjName(this.prjNameField.getText()); +// pfmeaBean.setProcessLiability(this.processLiabilityField.getText()); +// pfmeaBean.setDrawup(this.drawupField.getText()); +// pfmeaBean.setCoty(this.cotyField.getText()); +// pfmeaBean.setKeyDay(this.keydayField.getText()); +// pfmeaBean.setDrawupDate(this.drawupDateField.getText()); +// pfmeaBean.setCoreTeam(this.coreteamField.getText()); +// pfmeaBean.setChangeDate(this.changeDateField.getText()); +// String[][] dataValue = new String[this.table2.getColumnCount()][this.table2 +// .getRowCount()]; +// for (int i = 0; i < this.table2.getColumnCount(); i++) { +// for (int j = 0; j < this.table2.getRowCount(); j++) { +// dataValue[i][j] = this.table2.getValueAt(j, i) == null ? "" +// : this.table2.getValueAt(j, i).toString(); +// } +// } +// // if(isOwning) +// // { +// // } +// // ȡJTableе +// List> dataValeList = getTableValue(); +// TMom010SetPFMEAOperation operation = new TMom010SetPFMEAOperation( +// this.itemRevision, this.meprocess, this.session, +// properties, this.itemProperties, pfmeaBean, dataValue, +// dataValeList, deleteRows, isOwning); +// session.queueOperation(operation); +// if (!isSave) { +// outPutExcel(pfmeaBean, dataValeList, dataValue); +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// MessageBox.post(e.toString(), "", MessageBox.ERROR); +// e.printStackTrace(); +// } +// } +// +// /** +// * PFMEA +// * +// * @param pfmeaBean +// * @param dataValeList +// */ +// private void outPutExcel(PFMEABean pfmeaBean, +// List> dataValeList, String[][] dataValue) { +// // TODO Auto-generated method stub +// InputStream input = null; +// try { +// input = CopyOfTMom010SetPFMEADialog.class +// .getResourceAsStream("PFMEA.xls"); +// String outFilePath = "C:\\PFMEA.xls"; +// FileOutputStream output = new FileOutputStream( +// new File(outFilePath)); // +// HSSFWorkbook wb = new HSSFWorkbook(input);// ( +// outPutSheet1(wb, dataValue); +// HSSFSheet sheet = wb.getSheetAt(1); +// int startRow = 10; +// for (int i = 0; i < dataValeList.size(); i++) { +// List rowValeue = dataValeList.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; +// } +// // ȡַλ +// String[] columnNames = null; +// Map indexMap = new HashMap(); +// if (rowValeue.get(24) != null && !rowValeue.get(24).equals("")) { +// try { +// if (rowValeue.get(24).indexOf("|") >= 0) { +// columnNames = rowValeue.get(24).split("\\|"); +// } else { +// columnNames = new String[] { rowValeue.get(24) }; +// } +// 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 = ExcelUtil +// .getNamedColumnIndex( +// wb, +// columnName[0] +// .replaceAll( +// ",", "")); +// } else if (columnName[0].indexOf("/") >= 0) { +// cellindex = ExcelUtil +// .getNamedColumnIndex( +// wb, +// columnName[0] +// .replaceAll( +// "/", "")); +// } else { +// cellindex = ExcelUtil +// .getNamedColumnIndex(wb, +// columnName[0]); +// } +// if (cellindex > -1) { +// indexMap.put(cellindex, +// Integer.parseInt(columnName[1])); +// } +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// MessageBox.post(e.toString(), "", MessageBox.ERROR); +// e.printStackTrace(); +// } +// } +// for (int cols = 0; cols < 24; 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);// ıʽ +// if (cols == 0) { +// cell.setCellValue(i + 1); +// } else { +// if (indexMap.get(cols) != null) { +// cell.setCellValue(ExcelUtil.setCellFont(wb, +// rowValeue.get(cols), indexMap.get(cols), +// indexMap.get(cols) + 1, 10, "Y14.5M")); +// } else { +// cell.setCellValue(rowValeue.get(cols)); +// } +// } +// } +// } +// // ϲԪ +// if (combineMap != null && combineMap.size() > 0) { +// Iterator> it = combineMap.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] + 10; +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// column[k] = entry.getValue()[k]; +// } +// ExcelUtil.combine(sheet, row, column); +// } +// } +// wb.write(output); +// output.close(); +// input.close(); +// ExcelUtil.setExcelToItem(session, +// (TCComponentItemRevision) app.getTargetComponent(), +// outFilePath, "PFMEA", false); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } catch (Exception e) { +// // TODO: handle exception +// MessageBox.post(e.toString(), "", MessageBox.ERROR); +// e.printStackTrace(); +// } finally { +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// } +// } +// +// private void outPutSheet1(HSSFWorkbook wb, String[][] dataValue) { +// // TODO Auto-generated method stub +// HSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 0; i < dataValue[0].length; i++) { +// HSSFRow row = null; +// Boolean isCreat = false; +// if ((i + 1) > 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(HSSFCell.CELL_TYPE_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(); +// for (int j2 = 0; j2 < this.map.getColumnCount(); j2++) { +// rowValue.add(getCellValue(processRows.get(j), j2)); +// } +// rowValue.add(processRows.get(j).toString()); +// // rowValue.add("1"); +// if (combineMap.size() > 0) { +// Iterator> it = combineMap.entrySet() +// .iterator(); +// 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] == processRows.get(j)) { +// if (rowValue.size() == 27) { +// rowValue.set( +// 26, +// rowValue.get(26) +// + "-" +// + rowSb.substring(0, +// rowSb.length() - 1) +// + "/" +// + columnSb.substring(0, +// columnSb.length() - 1)); +// } else { +// rowValue.add(rowSb.substring(0, rowSb.length() - 1) +// + "/" +// + columnSb.substring(0, +// columnSb.length() - 1)); +// } +// } +// // else +// // { +// // rowValue.add(""); +// // } +// } +// } +// if (rowValue.size() == 26) { +// rowValue.add(""); +// } +// if (isComplete) { +// rowValue.add("1"); +// } else { +// rowValue.add("0"); +// } +// rowValue.add("1"); +// rowValue.add(""); +// 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 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 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(); +// this.init(); +// } +// +// private void init() { +// // TODO Auto-generated method stub +// this.setTitle("ѡ"); +// 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("ȷ"); +// this.okButton.addActionListener(this); +// this.celButton = new JButton("ȡ"); +// 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 = CopyOfTMom010SetPFMEADialog.table.getSelectedRow(); +// int column = CopyOfTMom010SetPFMEADialog.table +// .getSelectedColumn(); +// // λ +// String columnName = CopyOfTMom010SetPFMEADialog.table +// .getColumnName(CopyOfTMom010SetPFMEADialog.table +// .getSelectedColumn()); +// +// int cursorIndex = ((TextAreaCellEditor) (CopyOfTMom010SetPFMEADialog.table +// .getCellEditor(row, column))).getIndex(); +// System.out.println("index+" + cursorIndex); +// (CopyOfTMom010SetPFMEADialog.table.getCellEditor(row, column)) +// .stopCellEditing(); +// // TMom010SetPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); +// StringBuilder sb = new StringBuilder( +// CopyOfTMom010SetPFMEADialog.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 = CopyOfTMom010SetPFMEADialog.table.getValueAt( +// row, +// CopyOfTMom010SetPFMEADialog.table.getColumnCount() - 1); +// if (special == null || special.toString() == "") { +// CopyOfTMom010SetPFMEADialog.table +// .setValueAt(columnName + "-" + cursorIndex, row, +// CopyOfTMom010SetPFMEADialog.table +// .getColumnCount() - 1); +// } else { +// CopyOfTMom010SetPFMEADialog.table +// .setValueAt(special + "|" + columnName + "-" +// + cursorIndex, row, +// CopyOfTMom010SetPFMEADialog.table +// .getColumnCount() - 1); +// } +// System.out.println(sb.length()); +// String s = sb.insert( +// cursorIndex, +// this.table.getValueAt(this.table.getSelectedRow(), +// this.table.getSelectedColumn()).toString()) +// .toString(); +// CopyOfTMom010SetPFMEADialog.table.setValueAt(s, +// CopyOfTMom010SetPFMEADialog.table.getSelectedRow(), +// CopyOfTMom010SetPFMEADialog.table.getSelectedColumn()); +// System.out.println(CopyOfTMom010SetPFMEADialog.table +// .getValueAt(row, column).toString()); +// } else { +// this.dispose(); +// } +// } +// } +// +//} diff --git a/src/com/connor/renben/process/plm/tmom010/PFMEA.xls b/src/com/connor/renben/process/plm/tmom010/PFMEA.xls new file mode 100644 index 0000000..7ac28fa Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom010/PFMEA.xls differ diff --git a/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEACommand.java b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEACommand.java new file mode 100644 index 0000000..087aedf --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEACommand.java @@ -0,0 +1,742 @@ +package com.connor.renben.process.plm.tmom010; + +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.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +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.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.PFMEABean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.connor.renben.process.plm.util.CollectControlPlan; +import com.connor.renben.process.plm.util.SaveControlPlan; +import com.connor.renben.process.plm.util.SavePfmea; +import com.sun.mail.handlers.message_rfc822; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentRole; +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; + +public class TMom010SetPFMEACommand extends AbstractAIFCommand { + + private TCSession session; + private AbstractAIFApplication app; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCComponentItem meprocess; + private TCComponentItem item; + private boolean isOwning = false; + private JFrame frame = new JFrame("ڼ...");// + private JProgressBar progressBar = new JProgressBar();// + private String[] properName = new String[] { + "rb3_companyName",//˾ + "rb3_project", // Ŀ + "rb3_address",// ַ + "rb3_pfmeaStart_date",// PFMEAʼ + "rb3_pfmeaUpdate_date",// PFMEA޶ + "rb3_processDuty",// ְ + "rb3_customerName",// ˿ + "rb3_securityClassification",// ܼ + "rb3_modelPlatform",// /ƽ̨ + "rb3_functionalTeams"}; // ְŶ + private String[] itemProperName = new String[] { "rb3_No",// + "rb3_meop",// + "rb3_new",// ޸ĺֵ + "rb3_old",// ޸ǰֵ + "rb3_alter_date",// ޸ʱ + "rb3_modify_reason",// ޸ĵ + "rb3_change_user" };// ޸ + private Map combineMap = 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 TMom010SetPFMEACommand() { + super(); + } + + public TMom010SetPFMEACommand(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 getAuthority() { + // ResultSet rs = null; + // try { + // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", + // "tc10", "infodba"); + // InputStream input = new + // BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + // Properties pro = new Properties(); + // pro.load(input); + // //յ + // String userName = form.getReferenceProperty("owning_user") + // .getStringProperty("user_id"); + // String sql; + // if(user.getUserId().equals(userName)) + // { + // sql = String.format(pro.getProperty("CONTROLPLANSELECT3"),form.getUid()); + // } + // else + // { + // sql = + // String.format(pro.getProperty("CONTROLPLANSELECT2"),form.getUid(),user.getUserId()); + // } + // rs = SqlUtilT.read(sql); + // while (rs.next()) { + // List rowList = new ArrayList(); + // rowList.add(rs.getString("RB3_MEOPID")); + // } + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + + /** + * ȡݿе + */ + private void getData() { + // TODO Auto-generated method stub + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + 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 + while (rs.next()) { + //+++ + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("RB3_GYBH"));//RB3_GYBHš⡱ + rowList.add(rs.getString("RB3_GCMC"));//RB3_GCMCʷȨ + rowList.add(rs.getString("RB3_STATION")); + rowList.add(rs.getString("RB3_REQUIREMENT")); + rowList.add(rs.getString("RB3_QZSXMS")); + rowList.add(rs.getString("RB3_QZSXHG")); + rowList.add(rs.getString("RB3_YZD")); + rowList.add(rs.getString("RB3_JB")); + rowList.add(rs.getString("RB3_QZSXQY")); + rowList.add(rs.getString("RB3_XXGCKZYF")); + rowList.add(rs.getString("RB3_PDS")); + rowList.add(rs.getString("RB3_XXGCKZTC")); + rowList.add(rs.getString("RB3_TCD")); + rowList.add(rs.getString("RB3_RPN")); + rowList.add(rs.getString("RB3_JYCS")); + rowList.add(rs.getString("RB3_ZZR")); + rowList.add(rs.getString("RB3_JHWCRQ")); + rowList.add(rs.getString("RB3_CQDCS")); + rowList.add(rs.getString("RB3_NEW_SEV")); + rowList.add(rs.getString("RB3_NEW_OCC")); + rowList.add(rs.getString("RB3_NEW_DET")); + rowList.add(rs.getString("RB3_NEW_RPN")); + rowList.add(rs.getString("RB3_IDEAL_STATE")); + rowList.add(rs.getString("RB3_SPECIAL")); + rowList.add(rs.getInt("RB3_HH"));//25 + rowList.add(rs.getString("RB3_HBDYG"));//26 + rowList.add(rs.getInt("RB3_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); + } +// if(dataList.size()==0) { +// List rowList = new ArrayList(); +// rowList.add(UUID.randomUUID().toString().replace("-", "")); +// for(int i=0;i<35;i++) { +// rowList.add(""); +// } +// 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")); + dataList2.add(rowList2); + } + 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 RB3_PFMEALIBRARY values(?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] {uid,comp.getUid(),dateFormat.format(now),null,null,null,null,null,null,time} + ,insert); + List rowList2=new ArrayList(); + rowList2.add(uid); + rowList2.add(time); + rowList2.add(dateFormat.format(now)); + 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") != ""; + + //+++ + boolean bool1 = user.getGroups()[0].getGroupName().equals("dba"); + boolean bool2 = isRelease && !user.getGroups()[0].getGroupName().equals("dba"); + boolean bool3 = user.getUserId().equals(userName); + for (int i = 0; i < dataList.size(); i++) { + // кŲ + dataList.get(i).set(27,i- Integer.parseInt(dataList.get(i).get(25).toString())); + if(bool1) + { + isOwning = true; + processRows.add(i); + plmeidList.add(dataList.get(i).get(0).toString()); + continue; + } + else if (bool2) + { + continue; + } + if (bool3) { + 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 (rs2 != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + // /** + // * ȡPFMEAģеݿе + // */ + // private void getPFMEALibraryData() { + // // TODO Auto-generated method stub + // ResultSet rs = null; + // InputStream input = null; + // try { + // // ȡݿ + // // SqlUtilT.getConnectionTC10(); + // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", + // "tc10", "infodba"); + // input = new + // BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + // Properties pro = new Properties(); + // pro.load(input); + // String sql = String + // .format(pro.getProperty("PFMEALIBRARYSELECT")); + // rs = SqlUtilT.read(sql); + // while (rs.next()) { + // List rowList = new ArrayList(); + // rowList.add(rs.getInt("RB3_NO")); + // rowList.add(rs.getString("RB3_STATION")); + // rowList.add(rs.getString("RB3_REQUIREMENT")); + // rowList.add(rs.getString("RB3_QZSXMS")); + // rowList.add(rs.getString("RB3_QZSXHG")); + // rowList.add(rs.getString("RB3_YZD")); + // rowList.add(rs.getString("RB3_JB")); + // rowList.add(rs.getString("RB3_QZSXQY")); + // rowList.add(rs.getString("RB3_XXGCKZYF")); + // rowList.add(rs.getString("RB3_PDS")); + // rowList.add(rs.getString("RB3_XXGCKZTC")); + // rowList.add(rs.getString("RB3_TCD")); + // rowList.add(rs.getString("RB3_RPN")); + // rowList.add(rs.getString("RB3_JYCS")); + // rowList.add(rs.getString("RB3_ZZR")); + // rowList.add(rs.getString("RB3_JHWCRQ")); + // rowList.add(rs.getString("RB3_CQDCS")); + // rowList.add(rs.getString("RB3_NEW_SEV")); + // rowList.add(rs.getString("RB3_NEW_OCC")); + // rowList.add(rs.getString("RB3_NEW_DET")); + // rowList.add(rs.getString("RB3_NEW_RPN")); + // rowList.add(rs.getString("RB3_IDEAL_STATE")); + // rowList.add(rs.getString("RB3_SPECIAL")); + // pfmeaDataList.add(rowList); + // } + // } 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.getRelatedComponent("IMAN_master_form") + .getTCProperties(itemProperName); + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("MEProcess")) { + meprocess = (TCComponentItem) context[i].getComponent(); + } + } + //ȡ comp °汾İ汾 IMAN_master_form_rev + form = ((TCComponentItemRevision) comp) + .getRelatedComponent("IMAN_master_form_rev"); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzPFMEAbbdx10_display.TITLE"), "", 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()) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("PFMEAzzbj10_display.TITLE"), "", 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); + //+++ +// //ûİ汾Ҫͬ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(); + 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("00")&&!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("RB3_MEOPID")); + rowList.add(rs.getString("RB3_GYBH")); + rowList.add(rs.getString("RB3_GCMC")); + rowList.add(rs.getString("RB3_STATION")); + rowList.add(rs.getString("RB3_REQUIREMENT")); + rowList.add(rs.getString("RB3_QZSXMS")); + rowList.add(rs.getString("RB3_QZSXHG")); + rowList.add(rs.getString("RB3_YZD")); + rowList.add(rs.getString("RB3_JB")); + rowList.add(rs.getString("RB3_QZSXQY")); + rowList.add(rs.getString("RB3_XXGCKZYF")); + rowList.add(rs.getString("RB3_PDS")); + rowList.add(rs.getString("RB3_XXGCKZTC")); + rowList.add(rs.getString("RB3_TCD")); + rowList.add(rs.getString("RB3_RPN")); + rowList.add(rs.getString("RB3_JYCS")); + rowList.add(rs.getString("RB3_ZZR")); + rowList.add(rs.getString("RB3_JHWCRQ")); + rowList.add(rs.getString("RB3_CQDCS")); + rowList.add(rs.getString("RB3_NEW_SEV")); + rowList.add(rs.getString("RB3_NEW_OCC")); + rowList.add(rs.getString("RB3_NEW_DET")); + rowList.add(rs.getString("RB3_NEW_RPN")); + rowList.add(rs.getString("RB3_IDEAL_STATE")); + Integer ssInteger=rs.getInt("RB3_HH"); + rowList.add(ssInteger.toString());//rowList.add(rs.getInt("RB3_HH")); + rowList.add(rs.getString("RB3_HBDYG")); + Integer sscInteger=rs.getInt("RB3_HHc"); + rowList.add(sscInteger.toString());//rowList.add(rs.getInt("RB3_HHC")); + rowList.add(rs.getString("RB3_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); + } + } + if (rs0 != null) { + SqlUtilT.free(rs0); + } + progressBar.setValue(5); + //++++++++ + + //ûİ汾Ҫͬbom + if(comp.getProperty("release_status_list")==null||comp.getProperty("release_status_list").equals("")) { + SavePfmea savePfmea = new SavePfmea(session, meprocess,comp); + savePfmea.insertData(); + } + progressBar.setValue(10); + + //δӹ +// if(dataList.size()==0) { +// MessageBox.post("ӻ߱湤","",MessageBox.ERROR); +// return; +// } + // getPFMEALibraryData(); + getData(); + progressBar.setValue(40); + getCombineMap(); + progressBar.setValue(50); + 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; + } + progressBar.setValue(60); + 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); + //ݹȡƷ + 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ŶӦPFMEAitem_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(revMaster.getStringProperty("rb3_bianzhiriqi")); + changValue.add(revMaster.getStringProperty("rb3_bianzhi")); + changValue.add(revMaster.getStringProperty("rb3_drawup_date")); + changValueList.add(changValue); + } + } + progressBar.setValue(100); + new Thread() { + @Override + public void run() { + TMom010SetPFMEADialog dislog = new TMom010SetPFMEADialog( + 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(); + } + +}//rb3_drawup_date diff --git a/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEADialog.java b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEADialog.java new file mode 100644 index 0000000..eecec9b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEADialog.java @@ -0,0 +1,3572 @@ +package com.connor.renben.process.plm.tmom010; + +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.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.FileNotFoundException; +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.Calendar; +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.Timer; +import java.util.TimerTask; +import java.util.UUID; +import java.util.Vector; + +import javax.swing.JButton; +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.filechooser.FileNameExtensionFilter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableRowSorter; + +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.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.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.PFMEABean; +import com.connor.renben.process.plm.bean.TMomControlPlanBean; +import com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TableCellTextAreaRenderer; +import com.connor.renben.process.plm.tmom004.CTMap; +import com.connor.renben.process.plm.tmom004.CTable; +import com.connor.renben.process.plm.tmom028.TMom028JobProcessFormInputCommand; +import com.connor.renben.process.plm.util.Adapter; +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.SavePfmea; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +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; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +public class TMom010SetPFMEADialog 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 CTMap map2; + static JScrollPane scrollPane; + private Timer timer; + + // ȡʻԱ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + + private String[] header = new String[] { + "PLMEID", + rb.getString("issue"), + rb.getString("historyChangeAuthorization"), + rb.getString("processItemSystem"), + rb.getString("processStepWorkstation"), + rb.getString("processWorkElement4M"), + rb.getString("processItemFunction"), + rb.getString("processStepFunction"), + rb.getString("processWorkElementFunction"), + rb.getString("failureEffectHigherLevel"), + rb.getString("severityFailureEffect"), + rb.getString("failureModeFocusElement"), + rb.getString("failureCauseWorkElement"), + rb.getString("preventiveControlFailureCause"), + rb.getString("occurrenceFailureCause"), + rb.getString("detectionControlFailureCause"), + rb.getString("detectabilityFailureCause"), + rb.getString("pfmeaActionPriority"), + rb.getString("productCharacteristics"), + rb.getString("filterCode"), + rb.getString("preventiveMeasures"), + rb.getString("detectionMeasures"), + rb.getString("responsiblePersonName"), + rb.getString("targetCompletionDate"), + rb.getString("status"), + rb.getString("evidenceBasedActionsTaken"), + rb.getString("completionDate"), + rb.getString("severityValue"), + rb.getString("occurrenceValue"), + rb.getString("detectabilityValue"), + rb.getString("productCharacteristics"), + rb.getString("pfmeaActionPriority"), + rb.getString("remark"), + rb.getString("lookupNumber") + }; + + private String[] pfmeaHeader = new String[] { + "PLMEID", + "ID", + rb.getString("processItemSystem"), + rb.getString("processStepWorkstation"), + rb.getString("processWorkElement4M"), + rb.getString("processItemFunction"), + rb.getString("processStepFunction"), + rb.getString("processWorkElementFunction"), + rb.getString("failureEffectHigherLevel"), + rb.getString("severityFailureEffect"), + rb.getString("failureModeFocusElement"), + rb.getString("failureCauseWorkElement"), + rb.getString("preventiveControlFailureCause"), + rb.getString("occurrenceFailureCause"), + rb.getString("detectionControlFailureCause"), + rb.getString("detectabilityFailureCause"), + rb.getString("pfmeaActionPriority"), + rb.getString("productCharacteristics"), + rb.getString("filterCode"), + rb.getString("preventiveMeasures"), + rb.getString("detectionMeasures"), + rb.getString("responsiblePersonName"), + rb.getString("targetCompletionDate"), + rb.getString("status"), + rb.getString("evidenceBasedActionsTaken"), + rb.getString("completionDate"), + rb.getString("severityValue"), + rb.getString("occurrenceValue"), + rb.getString("detectabilityValue"), + rb.getString("productCharacteristics"), + rb.getString("pfmeaActionPriority"), + rb.getString("remark"), + rb.getString("parentNodeID") + }; + + private String[] recordHeader = new String[] { + rb.getString("plmid"), + rb.getString("serialNumber"), + rb.getString("date"), + rb.getString("chapter"), + rb.getString("revisionReason"), + rb.getString("revisionContent"), + rb.getString("revisedVersion"), + rb.getString("revisedBy"), + rb.getString("approvedBy") + }; + + private String[] leftHeader = new String[] { + "PLMEID", + "ID", + rb.getString("name"), + rb.getString("name") + }; + +// private String[] pfmeaHeader = new String[] { "PLMEID","ID", "Station", "Ҫ", +// "DZʧЧģʽ", "DZʧЧ", "ضS", "", "DZʧЧ/", "й̿Ԥ", "ƵO", +// "й̿̽", "̽D", "RPN", "ʩ", "", "ƻ", "ȡĴʩ", +// "New_SEV", "New_OCC", "New_DET", "New_RPN", "Ideal_State", "ڵID", +// "λ" };//,"Ƶ","Ƶ","ȼ"}; + + private Map combineMap;// źϲԪ + 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 Boolean isImpToExcel; + private JPanel mainPanel;// д + + private JLabel companyNameLabel;// ˾ + private CTextField 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 JTextField 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 JPanel secondPanel;// ؼ + private CTable table2; + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem addItem; + private JMenuItem addCombineRowsItem; + private JMenuItem remItem; + private JMenuItem comBineItem; + 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 impExcel; + private JButton completeButton;// + private JButton clearData;// + // private JButton addSpecialButton;// +// private JButton deleteSpecialButton;// Ƴ + private JButton libraryButton;// PFME + private JButton RefreshButton;// ɾݺˢ°ť + private String UID; + + public static String getUUID() { + UUID uuid = UUID.randomUUID(); + String str = uuid.toString(); + String uuidStr = str.replace("-", ""); + return uuidStr; + } + // PFMEA + + public TMom010SetPFMEADialog(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.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.isOwning = isOwning; + this.UID = UID; + // ȡѡж + this.comp = app.getTargetComponent(); + runTask(); + init(); + this.processRows = processRows; + // setProcessRows(this.processRowList); + comBine(); + } + + 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()); + } + } + } + + // /** + // * ̬ÿ޸ + // */ + // 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 void init() { + // ȡʻ + 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(1000, 800)); + this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + if (!isOwning) { + TMom010SetPFMEADialog.this.dispose(); + } else { + int i = JOptionPane.showConfirmDialog(null, "Ƿ񱣴棿", "", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + okEvent(true, true); + TMom010SetPFMEADialog.this.dispose(); + } else if (i == JOptionPane.NO_OPTION) { + TMom010SetPFMEADialog.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 CTextField(this.properties[0].getStringValue()); + this.companyNameField.setPreferredSize(new Dimension(160, 20)); + this.projectLabel = new JLabel(rb.getString("xm10_display.TITLE")); + 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 JTextField(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.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.expiryDateButton); + + 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); + + // Ӽ̼ + 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 < table.getColumnCount() - 1 && j != 4) { + table.setValueAt("", selectRows[i], selectColumns[j]); + } + } else { + table.setValueAt("", selectRows[i], selectColumns[j]); + } + } + } + + } + if (arg0.getKeyCode() == 16) {// shift16Ӽ + comBineCell(); + } + if (arg0.getKeyCode() == 20) {// caps_lock20Ӽ + splitCell(); + } + 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); +// if (changValueList.size() == 0) { +// this.table2 = getNewjTable(null, null, recordHeader, 1, true); +// } else { +// this.table2 = getNewjTable(null, null, recordHeader, itemProperties.length, true); +// } + // Ӽ + this.table2.addMouseListener(new MouseAdapter() { + + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) table2.getModel()).setRow(table2.getSelectedRow()); + if (table2.getSelectedColumn() > 2) { + ((CTMap) 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, mouseevent.getX(), mouseevent.getY()); + } + } + } + }); + // Ӽ̼ + this.table2.addKeyListener(new KeyAdapter() { + + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + // delete + if (arg0.getKeyChar() == 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++) { +// table.setValueAt("", selectRows[i], selectColumns[j]); +// } +// } + } + super.keyPressed(arg0); + } + }); + +// (֮ǰ)+++++++++++++++++++ +// if (changValueList.size() > 0) { +// for (int i = 0; i < this.table2.getColumnCount(); i++) { +// String[] rowValue = null; +// if (this.itemProperties != null) { +// rowValue = this.itemProperties[i].getStringValueArray(); +// } +// for (int j = 0; j < rowValue.length; j++) { +// if (j >= changValueList.size()) { +// if (i == 4) { +// this.table2.setValueAt("", j, i); +// } else if (i == 6) { +// this.table2.setValueAt("", j, i); +// } else { +// if (rowValue != null && rowValue[j] != null) { +// this.table2.setValueAt(rowValue[j], j, i); +// } +// } +// } else { +// List rowValues = changValueList.get(j); +// if (i == 4) { +// this.table2.setValueAt(rowValues.get(0), j, i); +// } else if (i == 6) { +// this.table2.setValueAt(rowValues.get(1), j, i); +// } else { +// if (rowValue != null && rowValue[j] != null) { +// this.table2.setValueAt(rowValue[j], j, i); +// } +// } +// } +// } +// } +// } +//++++++++++++++++++++++++++++++++++ + 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(rb.getString("ll10_display.TITLE"), 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")); + // 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); + } + + 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.impExcel = new JButton(rb.getString("drexcel_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.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(this.impExcel); + this.rootPanel.add(clearData); + this.rootPanel.add(completeButton); + this.rootPanel.add(libraryButton); + } else { + this.rootPanel.add(completeButton); + setPanelEnabled(mainPanel, false); + } + // ++++ + + 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.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.addCombineRowsItem.addActionListener(this); + this.addItem.addActionListener(this); + this.remItem.addActionListener(this); + this.comBineItem.addActionListener(this); + this.splitItem.addActionListener(this); + this.shrinkColumnItem.addActionListener(this); + this.celShrinkColumnItem.addActionListener(this); + this.saveButton.addActionListener(this); + this.impExcel.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); + } + + // ÿؼȨ + 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); + } + } + } + + // Jtableͨ÷ + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows, + boolean isEditable) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + final CTMap map = new CTMap(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; + } + + @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); + Adapter adapter = new Adapter(partsTable); + + partsTable.setRowHeight(50); + // + 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 CTable getjTable2(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + this.map2 = new CTMap(dataList2.size(), titleNames.length); + map2.setColumnIdentifiers(titleNames); + this.map2.setEditable(true); + + partsTable = new CTable(map2); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter adapter = new Adapter(partsTable); + setJTable2(); + partsTable.setRowHeight(50); + // + 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 < dataList2.size(); i2++) { + dataList2List.add(new Integer(i2)); + } + this.map2.setProcessRowList(dataList2List); + renderer.setProcessRows(dataList2List); + } + + partsTable.setDefaultRenderer(Object.class, renderer); + + // //ñ༭Ⱦ + // 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 rendererM = new MultiLineHeaderRenderer(); + Enumeration e = partsTable.getColumnModel().getColumns(); + while (e.hasMoreElements()) { + ((TableColumn) e.nextElement()).setHeaderRenderer(rendererM); + } + // ++ + return partsTable; + + } + + @Override + public void actionPerformed(ActionEvent arg0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + Object source = arg0.getSource(); + if (source.equals(this.addItem2)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxtjh10_display.TITLE"), "", MessageBox.ERROR); + return; + } + CTable table = this.table2; + if (table.getSelectedRow() > -1) { + ((CTMap) 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 RB3_PFMEALIBRARY values(?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write( + new String[] { uid, UID, dateFormat.format(now), null, null, null, null, null, null, time }, + insert); + } + + } else if (source.equals(this.remItem2)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxsch10_display.TITLE"), "", MessageBox.ERROR); + return; + } + int i = JOptionPane.showConfirmDialog(null, "ǷɾѡУ", "ɾ", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + return; + } + CTable table = this.table2; + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() > 1) { + (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); + if (((CTMap) table.getModel()).getValueAt(table.getSelectedRow(), 0) != null) { + // plmidɾݿѡеϢ + String delete = String.format("delete from RB3_PFMEALIBRARY where PLMID = \'%s\'", + table.getValueAt(table.getSelectedRow(), 0).toString()); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(delete); + } + ((CTMap) table.getModel()).removeRow(table.getSelectedRow()); + table.revalidate(); + table.repaint(); + // this.tabbedPane.updateUI(); + } + + } else if (source.equals(this.addRowItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxtjh10_display.TITLE"), "", MessageBox.ERROR); + return; + } + addRow(); + } else if (source.equals(this.addRowsItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxtjh10_display.TITLE"), "", 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(rb.getString("wqxtjh10_display.TITLE"), "", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } + } else if (source.equals(this.addCombineRowsItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxtjh10_display.TITLE"), "", 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(rb.getString("wqxtjh10_display.TITLE"), "", MessageBox.ERROR); + return; + } + AddRowsDialog addRowsDialog = new AddRowsDialog(source); + } + } else if (source.equals(this.addItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxtjh10_display.TITLE"), "", MessageBox.ERROR); + return; + } + addCombineRow(); + } else if (source.equals(this.remItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxsch10_display.TITLE"), "", 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(rb.getString("wqxhbh10_display.TITLE"), "", MessageBox.ERROR); + return; + } + comBineCell(); + } else if (source.equals(this.splitItem)) { + if (!isOwning) { + MessageBox.post(rb.getString("wqxczh10_display.TITLE"), "", MessageBox.ERROR); + return; + } + splitCell(); + } else if (source.equals(this.saveButton)) { + if(table.getRowCount()<1) { + isImpToExcel = false; + try { + itemRevision.setStringProperty("object_desc", ""); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(isImpToExcel!=null && isImpToExcel) { + try { + itemRevision.setStringProperty("object_desc", "IMPORT TO EXCEL"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (isOwning) { + okEvent(true, true); + // this.dispose(); + } else { + MessageBox.post(rb.getString("wqxbc10_display.TITLE"), "", MessageBox.ERROR); + } + + } else if (source.equals(this.impExcel)) { + // ȡJtableе + + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); + chooser.setFileFilter(new FileNameExtensionFilter("Excelļ", new String[] { "xls", "xlsx" })); + int returnVal = chooser.showOpenDialog(chooser); + File file = chooser.getSelectedFile(); + try { + String filepath = file.getPath(); + // ȡļ + String fileType = filepath.substring(filepath.lastIndexOf(".") + 1, filepath.length()); + InputStream is = new FileInputStream(new File(filepath)); + Workbook wb = null; + if (fileType.endsWith("xlsx")) { + // Excel 2007 + wb = new XSSFWorkbook(is); + } else if (fileType.endsWith("xls")) { + // Excel 2003 + wb = new HSSFWorkbook(is); + } else { + throw new Exception("ȡIJexcelļ"); + } + // ȡExcelĵһsheetҳ + Sheet sheet = wb.getSheetAt(1); + // ǰҳе, ȥ+1Ϊǰһек + int rowSize = sheet.getLastRowNum() + 1; + //ɾ + int rowCount1 = table.getRowCount(); + System.out.println("Ϊ:"+rowCount1); + for(int i=0;i rowList = new ArrayList(); + String uuid = getUUID(); + rowList.add(uuid); + // ȡExcelе j + Row row = sheet.getRow(j); + if (row == null) { + continue; + } + // ǻȡһΪյǵڼ,һб1 + int cellSize = row.getLastCellNum(); + // ȡÿһбͷֶζӦֵ,kΪڼ + int ok = 0; + for (int k = 0; k < 32; k++) { + Cell cell = row.getCell(k); + if (k == 3 && (cell.toString() == null || "".equals(cell.toString()))) { + System.out.println("⵽Ϊ,˳"+j); + ok = 1; + break; + } + String value = null; + try { + value = cell.getStringCellValue(); + } catch (Exception e) { + // TODO Auto-generated catch block + double numericCellValue = cell.getNumericCellValue(); + //value = String.valueOf(numericCellValue); + // ʹøʽַ + value = String.format("%.0f", numericCellValue); + } + rowList.add(value); + } + if (ok == 1) { + break; + } + int rowCount = table.getRowCount() * 10; + String valueOf = String.valueOf(rowCount); + rowList.add(valueOf); + System.out.println("excelе" + rowList.toString()); + int coln = 4; + List twoColb = new ArrayList(); + for (int i = 0; i < table.getRowCount(); i++) { + if (table.getValueAt(i, coln) == null) { + twoColb.add(""); + } else { + String onecell = table.getValueAt(i, coln).toString(); + twoColb.add(onecell); + } + } + System.out.println("ȡֵΪ" + twoColb.toString()); + map.addRow(); + for (int a = 0; a < table.getColumnCount(); a++) { + table.setValueAt(rowList.get(a), table.getRowCount() - 1, a); + } + processRows.add(table.getRowCount()-1); +// } + + } + // ͷԴ + is.close(); + } catch (Exception e) { + MessageBox.post(rb.getString("excel_display.TITLE"), "", MessageBox.ERROR); + e.printStackTrace(); + } + //excelеݺ󣬽ȫֱisImpToExcelΪtrue + isImpToExcel = true; + } 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(rb.getString("wqxck10_display.TITLE"), "", 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(this.companyNameField.getText()); + 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()); + 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(); + } + } + } + new selectExportPath(pfmeaBean, this.excelDataList, dataValue); + } + this.dispose(); + } else if (source.equals(RefreshButton)) { + + try { + isImpToExcel = false; + itemRevision.setStringProperty("object_desc", ""); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + this.dispose(); + TMom010SetPFMEACommand command = new TMom010SetPFMEACommand(app, session, UID); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + }else if(source.equals(clearData)) { + //ݰť + System.out.println("ûݰťʼִв"); + + } else { + // this.disposeDialog(); + this.dispose(); + } + } + + private void okEvent(boolean isSave, boolean isAuto) { + // TODO Auto-generated method stub + // ݱ浽 + 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(this.companyNameField.getText()); + 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")); + + // ȡJTableе + List> dataValeList = getTableValue(); + System.out.println("dataValeList:"+dataValeList); + TMom010SetPFMEAOperation operation = new TMom010SetPFMEAOperation(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 { + dataValue[i][j] = this.table2.getValueAt(i, j + 1) == null ? "" + : this.table2.getValueAt(i, j + 1).toString(); + } + } + } + for (int i = 0; i < dataValue.length; i++) { + String updateSql = String.format( + updateSql = "update RB3_PFMEALIBRARY set P2 = ?,P3 = ?,P4 = ?,P5 = ?,P6 = ?,P7 = ? where PLMID = \'%s\'", + dataValue[i][0]); + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { dataValue[i][2], dataValue[i][3], dataValue[i][4], dataValue[i][5], + dataValue[i][6], dataValue[i][7] }, updateSql); + } + + // + if (!isSave) { +// SavePfmea savePfmea = new SavePfmea(session, meprocess); +// savePfmea.insertData(); + getData(); + getCombineMap(); + // System.out.println(excelDataList); + outPutExcel(pfmeaBean, this.excelDataList, dataValue); + } + rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO Auto-generated catch block + rootPanel.setBackground(Color.RED); + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + + // ++ձ + private void clearDatas() { + for (int i = 0; i < table.getSelectedRows().length; i++) { + for (int j = 3; j < table.getColumnCount(); j++) { + table.setValueAt("", table.getSelectedRows()[i], j); + } + } + table.revalidate(); + table.repaint(); + } + // ++ + + /** + * ȡݿе + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // ȡݿ + // SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + if (meprocess != null) { + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("SETPFMEASELECT"), meprocess.getUid(), + comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("RB3_GYBH")); + rowList.add(rs.getString("RB3_GCMC")); + rowList.add(rs.getString("RB3_STATION")); + rowList.add(rs.getString("RB3_REQUIREMENT")); + rowList.add(rs.getString("RB3_QZSXMS")); + rowList.add(rs.getString("RB3_QZSXHG")); + rowList.add(rs.getString("RB3_YZD")); + rowList.add(rs.getString("RB3_JB")); + rowList.add(rs.getString("RB3_QZSXQY")); + rowList.add(rs.getString("RB3_XXGCKZYF")); + rowList.add(rs.getString("RB3_PDS")); + rowList.add(rs.getString("RB3_XXGCKZTC")); + rowList.add(rs.getString("RB3_TCD")); + rowList.add(rs.getString("RB3_RPN")); + rowList.add(rs.getString("RB3_JYCS")); + rowList.add(rs.getString("RB3_ZZR")); + rowList.add(rs.getString("RB3_JHWCRQ")); + rowList.add(rs.getString("RB3_CQDCS")); + rowList.add(rs.getString("RB3_NEW_SEV")); + rowList.add(rs.getString("RB3_NEW_OCC")); + rowList.add(rs.getString("RB3_NEW_DET")); + rowList.add(rs.getString("RB3_NEW_RPN")); + rowList.add(rs.getString("RB3_IDEAL_STATE")); + rowList.add(rs.getString("RB3_SPECIAL")); + rowList.add(rs.getInt("RB3_HH")); + rowList.add(rs.getString("RB3_HBDYG")); + rowList.add(rs.getInt("RB3_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) { + // TODO Auto-generated method stub + InputStream input = null; + try { + File pfmeaFile = TMomMethodUtil.getFile(session, "PFMEA", "MSExcel"); + if (pfmeaFile != null) { + input = new FileInputStream(pfmeaFile); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("wzdPFMEAmb10_display.TITLE"), "", 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); + 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; + 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); + for (int j = 0; j < 32; j++) { + XSSFCell oldCell = oldRow.getCell(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 (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, row21.getCell(0).getStringCellValue() + pfmeaBean.getProject()); + setCellValue(row21, 3, row21.getCell(0).getStringCellValue() + pfmeaBean.getProcessDuty()); + setCellValue(row21, 7, row21.getCell(7).getStringCellValue() + pfmeaBean.getPfmeaNumber()); + XSSFRow row22 = sheet2.getRow(3); + setCellValue(row22, 0, row22.getCell(0).getStringCellValue() + pfmeaBean.getPfmeaStartDate()); + + for (int i = 0; i < dataValue.length; i++) { + XSSFRow row = null; + Boolean 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); + for (int j = 0; j < 9; j++) { + XSSFCell oldCell = oldRow.getCell(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]); + } + } + } + // ++++++++++++++ + +// // ñͷϢ +//// ExcelUtil.setNamedCellValue(wb, this.clientChartNoLabel.getText(), clientChartNoField.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.keydayLabel.getText(), keydayButton.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.drawupDateLabel.getText(), drawupDateField.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.coreteamLabel.getText(), coreteamField.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.changeDateLabel.getText(), changeDateButton.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.drawupLabel.getText(), drawupField.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.pfmeaNumberLabel.getText(), pfmeaNumberField.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.cotyLabel.getText().replaceAll("/", ""), cotyField.getText()); +////// ExcelUtil.setNamedCellValue(wb, this.expiryDateLabel.getText(), expiryDateButton.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.processLiabilityLabel.getText(), processLiabilityField.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.prjNameLabel.getText(), prjNameField.getText()); +//// ExcelUtil.setNamedCellValue(wb, this.prjNumberLabel.getText(), prjNumberField.getText()); +//// int colAndValue[][] = {{2,3},{3,4},{4,5},{5,6},{6,7},{8,9},{9,10}, +//// {10,12},{11,11}, +//// {12,13},{13,14},{14,15},{15,16}, +//// {16,28},{17,29},{18,30}, +//// {19,17},{20,18},{21,19},{22,20},{23,21} +//// }; +// int colAndValues[] = { 0, 0, 1, 3, 4, 5, 6, 7, 8, 9, 11, 10, 12, 13, 14, 28, 29, 30, 15, 16, 17, 18, 19, 20, +// 21, 22 }; +// for (int i = 0; i < dataValeList.size(); i++) { +// List rowValeue = dataValeList.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; +// } +// // ȡַλ +// // String[] columnNames = null; +//// Map indexMap = new HashMap(); +//// if (rowValeue.get(24) != null && !rowValeue.get(24).equals("")) { +//// try { +//// if (rowValeue.get(24).toString().indexOf("|") >= 0) { +//// columnNames = rowValeue.get(24).toString().split("\\|"); +//// } else { +//// columnNames = new String[] { rowValeue.get(24).toString() }; +//// } +//// 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 = ExcelUtil +//// .getNamedColumnIndex( +//// wb, +//// columnName[0] +//// .replaceAll( +//// ",", "")); +//// } else if (columnName[0].indexOf("/") >= 0) { +//// cellindex = ExcelUtil +//// .getNamedColumnIndex( +//// wb, +//// columnName[0] +//// .replaceAll( +//// "/", "")); +//// } else { +//// cellindex = ExcelUtil +//// .getNamedColumnIndex(wb, +//// columnName[0]); +//// } +//// if (cellindex > -1) { +//// indexMap.put(cellindex, +//// Integer.parseInt(columnName[1])); +//// } +//// } +//// } +//// } +//// } catch (Exception e) { +//// // TODO: handle exception +//// MessageBox.post(e.toString(), "", MessageBox.ERROR); +//// e.printStackTrace(); +//// } +//// } +// for (int cols = 1; cols < 24; 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);// ıʽ +// if (cols == 1) { +// cell.setCellValue(i + 1); +// +// } else { +// cell.setCellValue(rowValeue.get(colAndValues[cols]) == null ? "" +// : rowValeue.get(colAndValues[cols]).toString()); +//// if (indexMap.get(cols) != null) { +//// cell.setCellValue(ExcelUtil.setCellFont(wb, +//// rowValeue.get(cols) == null ? "" : rowValeue.get(cols).toString(), indexMap.get(cols), +//// indexMap.get(cols) + 1, 10, "Y14.5M")); +//// } else { +//// //String str = rowValeue.get(cols).toString(); +//// +//// } +// } +// } +// } + // ϲԪ + 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(); + // ExcelUtil.setExcelToItem(session, itemRevision, outFilePath, "PFMEA", true); + if (ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision) app.getTargetComponent(), "TC_Attaches", + "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), "excel", + "MSExcelX", outFilePath); + new File(outFilePath).delete(); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "PFMEA", "TC_Attaches", "MSExcelX", + true); + } + System.out.println("-------WRITE EXCEL OVER-------"); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + + private void outPutSheet1(HSSFWorkbook wb, String[][] dataValue) { + // TODO Auto-generated method stub + HSSFSheet sheet = wb.getSheetAt(0); + for (int i = 0; i < dataValue[0].length; i++) { + HSSFRow row = null; + Boolean isCreat = false; + if ((i + 1) > 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(HSSFCell.CELL_TYPE_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(); + System.out.println("aLength:"+a); + System.out.println("table:"+this.table.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(int row) { + + // TODO Auto-generated method stub + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (this.tabbedPane.getSelectedIndex() == 1) { + CTMap map = ((CTMap) this.table2.getModel()); + map.insertRow(row + 1); + } else { + if (this.processRows != null && this.processRows.size() == 0 && !(this.processRows.contains(row))) { + MessageBox.post(rb.getString("wqxtjh10_display.TITLE"), "", 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 addRow() { + // TODO Auto-generated method stub + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (this.tabbedPane.getSelectedIndex() == 1) { + CTMap map = ((CTMap) 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(rb.getString("wqxtjh10_display.TITLE"), "", 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 + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (this.tabbedPane.getSelectedIndex() == 1) { + CTMap map = ((CTMap) 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(rb.getString("wqxtjh10_display.TITLE"), "", 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()))) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("wqxsch10_display.TITLE"), "", 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 remRow(int index) { + 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(index)) { + 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(index) + && Integer.parseInt(keysList.get(0).toString()) > index) { + 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(index, 0) != null + && plmeidList.contains(map.getValueAt(index, 0))) { + deleteRows.add(map.getValueAt(index, 0).toString()); + } + map.removeRow(index); + // 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 comBineCell() { + // TODO Auto-generated method stub + // table.setRowHeight(2, 50); + int[] rows = table.getSelectedRows(); + int[] columns = table.getSelectedColumns(); + if (rows.length <= 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzyhbddyg10_display.TITLE"), "", MessageBox.ERROR); + return; + } + for (int i = 0; i < rows.length; i++) { + if (this.processRows != null && this.processRows.size() > 0 && !(this.processRows.contains(rows[i]))) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("wqxhbdyg10_display.TITLE"), "", 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()); + table.revalidate(); + table.repaint(); + } + + /** + * ֵԪ + */ + private void splitCell() { + // TODO Auto-generated method stub + int row = table.getSelectedRow(); + int colmn = table.getSelectedColumn(); + if (row < 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("qxzycfddyg10_display.TITLE"), "", 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; + + public selectExportPath(PFMEABean pfmeaBean, List> dataValeList, String[][] dataValue) { + this.pfmeaBean = pfmeaBean; + this.dataValeList = dataValeList; + this.dataValue = dataValue; + 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:\\"));// ļѡijʼĿ¼Ϊ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.fleName.getText() + ".xlsx"; +//+++++++ + + InputStream input = null; + try { + File pfmeaFile = TMomMethodUtil.getFile(session, "PFMEA", "MSExcel"); + if (pfmeaFile != null) { + input = new FileInputStream(pfmeaFile); + } else { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("wzdPFMEAmb10_display.TITLE"), "", 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; + 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); + for (int j = 0; j < 32; j++) { + XSSFCell oldCell = oldRow.getCell(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 (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, row21.getCell(0).getStringCellValue() + pfmeaBean.getProject()); + setCellValue(row21, 3, row21.getCell(3).getStringCellValue() + pfmeaBean.getProcessDuty()); + setCellValue(row21, 7, row21.getCell(7).getStringCellValue() + pfmeaBean.getPfmeaNumber()); + XSSFRow row22 = sheet2.getRow(3); + setCellValue(row22, 0, row22.getCell(0).getStringCellValue() + pfmeaBean.getPfmeaStartDate()); + + for (int i = 0; i < dataValue.length; i++) { + XSSFRow row = null; + Boolean 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); + for (int j = 0; j < 9; j++) { + XSSFCell oldCell = oldRow.getCell(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(); + } + } + } +//+++++++ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + MessageBox.post(rb.getString("dcexcelcg04_display.TITLE"), "ɹ", 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 = TMom010SetPFMEADialog.table.getSelectedRow(); + int column = TMom010SetPFMEADialog.table.getSelectedColumn(); + // λ + String columnName = TMom010SetPFMEADialog.table + .getColumnName(TMom010SetPFMEADialog.table.getSelectedColumn()); + + int cursorIndex = ((TextAreaCellEditor) (TMom010SetPFMEADialog.table.getCellEditor(row, column))) + .getIndex(); + System.out.println("index+" + cursorIndex); + (TMom010SetPFMEADialog.table.getCellEditor(row, column)).stopCellEditing(); + // TMom010SetPFMEADialog.table.getDefaultEditor(Object.class).stopCellEditing(); + StringBuilder sb = new StringBuilder(TMom010SetPFMEADialog.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 = TMom010SetPFMEADialog.table.getValueAt(row, + TMom010SetPFMEADialog.table.getColumnCount() - 1); + if (special == null || special.toString() == "") { + TMom010SetPFMEADialog.table.setValueAt(columnName + "-" + cursorIndex, row, + TMom010SetPFMEADialog.table.getColumnCount() - 1); + } else { + TMom010SetPFMEADialog.table.setValueAt(special + "|" + columnName + "-" + cursorIndex, row, + TMom010SetPFMEADialog.table.getColumnCount() - 1); + } + System.out.println(sb.length()); + String s = sb + .insert(cursorIndex, this.table + .getValueAt(this.table.getSelectedRow(), this.table.getSelectedColumn()).toString()) + .toString(); + TMom010SetPFMEADialog.table.setValueAt(s, TMom010SetPFMEADialog.table.getSelectedRow(), + TMom010SetPFMEADialog.table.getSelectedColumn()); + System.out.println(TMom010SetPFMEADialog.table.getValueAt(row, column).toString()); + } else { + this.dispose(); + } + } + } + + private class LibraryDialog extends JFrame { + private List beans = new ArrayList(); + private int index = -1; + private TableRowSorter mainSorter; + // ѯ + private JTextField findLeftField; + private JButton findLeftButton; + // ѯ + private JTextField findMainField; + private JButton findMainButton; + // ؼ + private JTextPane selectCellValuePane; + private JPanel titlePanel;// + private JLabel titleLabel; + // + private CTable leftTable; + private CTable mainTable; + + // Ҽ˵ + private JPopupMenu libraryMenu; + // Ҽ˵ + private JMenuItem copyRowItem;// ƶ + + // ǩؼ + // private JTabbedPane tabbedPane; + + public LibraryDialog() { + // TODO Auto-generated constructor stub + super(); + // getData(); + getPFMEAData(); + 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("PFMEAc10_display.TITLE")); + this.setPreferredSize(new Dimension(850, 600)); + // ʼⲿֿؼ + 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); + 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); + } + final TableRowSorter sorter = new TableRowSorter(this.leftTable.getModel()); + this.leftTable.setRowSorter(sorter); // ΪJTable + + 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")); + findMainPanel.add("1.1.left.top", this.findMainField); + findMainPanel.add("1.2.left.top", this.findMainButton); + this.mainTable = getNewjTable(null, null, pfmeaHeader, 0, false); + // + mainTable.HiddenCell(0); + mainTable.HiddenCell(pfmeaHeader.length - 1); + mainTable.setRowHeight(40); + mainSorter = new TableRowSorter(this.mainTable.getModel()); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + + this.findMainButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (findMainField.getText().length() == 0) { + mainSorter.setRowFilter(null); + } else { + mainSorter.setRowFilter(RowFilter.regexFilter(findMainField.getText()));// ΪJTableûʽĹ + } + } + }); + // + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 2) { + if (TMom010SetPFMEADialog.table.getSelectedRow() >= 0) { + TMom010SetPFMEADialog.table.getCellEditor(TMom010SetPFMEADialog.table.getSelectedRow(), + TMom010SetPFMEADialog.table.getSelectedColumn()).stopCellEditing(); + for (int i = 2; i < mainTable.getColumnCount(); i++) { + if (i == mainTable.getColumnCount() - 1) { + continue; + } else { + TMom010SetPFMEADialog.table.setValueAt( + mainTable.getValueAt(mainTable.getSelectedRow(), i), + TMom010SetPFMEADialog.table.getSelectedRow(), i + 1); + } + } + } + } + if (mouseevent.getClickCount() == 1) { + if (mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) { + selectCellValuePane.setText(mainTable + .getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } else { + selectCellValuePane.setText(""); + } + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + libraryMenu.show(mainTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane = new JScrollPane(mainTable); + scrollPane.getVerticalScrollBar().setUnitIncrement(2); + JScrollPane scrollPane2 = new JScrollPane(leftTable); + scrollPane2.setPreferredSize(new Dimension(150, 600)); + scrollPane2.getVerticalScrollBar().setUnitIncrement(2); + + JSplitPane splitPane2 = new JSplitPane(); + splitPane2.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane2.setContinuousLayout(true);// ͷػͼ + splitPane2.setLeftComponent(scrollPane2); + splitPane2.setRightComponent(scrollPane); + + // Ҽ˵ + libraryMenu = new JPopupMenu(); + // + copyRowItem = new JMenuItem(rb.getString("fzdh10_display.TITLE")); + copyRowItem.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { + CTable jtable = mainTable; + for (int i = 0; i < jtable.getSelectedRows().length; i++) { + if (TMom010SetPFMEADialog.table.getSelectedRow() >= 0) { + TMom010SetPFMEADialog.table.getCellEditor(TMom010SetPFMEADialog.table.getSelectedRow(), + TMom010SetPFMEADialog.table.getSelectedColumn()).stopCellEditing(); + for (int j = 1; j < jtable.getColumnCount(); j++) { + if (j == jtable.getColumnCount() - 2 && j == 1) { + continue; + } else if (j == 2 || j == jtable.getColumnCount() - 1) { + TMom010SetPFMEADialog.table.setValueAt( + jtable.getValueAt(jtable.getSelectedRows()[i], j), + TMom010SetPFMEADialog.table.getSelectedRow() + i, j); + } else { + TMom010SetPFMEADialog.table.setValueAt( + jtable.getValueAt(jtable.getSelectedRows()[i], j), + TMom010SetPFMEADialog.table.getSelectedRow() + i, j + 1); + } + } + } + } + } +// } +// } + }); + libraryMenu.add(copyRowItem); + + selectCellValuePane = new JTextPane(); + selectCellValuePane.setPreferredSize(new Dimension(500, 40)); + + JPanel southPanel = new JPanel(new PropertyLayout()); + southPanel.add("1.1.left.top", findLeftPanel); + southPanel.add("1.2.left.top", new JScrollPane(selectCellValuePane)); + southPanel.add("1.3.left.top", findMainPanel); + + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane2, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(southPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /** + * ȡݿе + */ + 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 void refreshPFMEATable() { + // 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("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("RB3_STATION")); + list.add(rs.getString("RB3_REQUIREMENT")); + list.add(rs.getString("RB3_QZSXMS")); + list.add(rs.getString("RB3_QZSXHG")); + list.add(rs.getString("RB3_YZD")); + list.add(rs.getString("RB3_JB")); + list.add(rs.getString("RB3_QZSXQY")); + list.add(rs.getString("RB3_XXGCKZYF")); + list.add(rs.getString("RB3_PDS")); + list.add(rs.getString("RB3_XXGCKZTC")); + list.add(rs.getString("RB3_TCD")); + list.add(rs.getString("RB3_RPN")); + list.add(rs.getString("RB3_JYCS")); + list.add(rs.getString("RB3_ZZR")); + list.add(rs.getString("RB3_JHWCRQ")); + list.add(rs.getString("RB3_CQDCS")); + list.add(rs.getString("RB3_NEW_SEV")); + list.add(rs.getString("RB3_NEW_OCC")); + list.add(rs.getString("RB3_NEW_DET")); + list.add(rs.getString("RB3_NEW_RPN")); + list.add(rs.getString("RB3_IDEAL_STATE")); + list.add(rs.getString("RB3_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")); + rowList.add(list); + } + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(), pfmeaHeader.length); + map.setColumnIdentifiers(pfmeaHeader); + map.setEditable(true); + mainTable.setModel(map); + mainSorter = new TableRowSorter(map); + this.mainTable.setRowSorter(mainSorter); // ΪJTable + mainTable.HiddenCell(0); + mainTable.HiddenCell(pfmeaHeader.length - 1); + // mainTable.HiddenCell(pfmeaHeader.length - 2); + 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); + } + } + } else { + CTMap map = new CTMap(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); + } + 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(); + } + } + } + + 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 + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", + defaultLocale); + if (this.source.equals(addRowsItem)) { + if (!isStr2Num(textField.getText())) { + MessageBox.post(rb.getString("qsrzqdsz04_display.TITLE"), "!", 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(rb.getString("qsrzqdsz04_display.TITLE"), "!", 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); + 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); + } + + 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; + } +} + +//++++ +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/renben/process/plm/tmom010/TMom010SetPFMEAHandler.java b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEAHandler.java new file mode 100644 index 0000000..110454f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEAHandler.java @@ -0,0 +1,48 @@ +package com.connor.renben.process.plm.tmom010; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom010SetPFMEAHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null + ||!(app.getTargetComponent() instanceof TCComponentItemRevision) + || !(app.getTargetComponent().getType().toUpperCase().indexOf("PFMEA") >= 0)) { + MessageBox.post(rb.getString("qxzbbdx10_display.TITLE"), "", MessageBox.ERROR); + return null; + } + String UID; + UID=app.getTargetComponent().getUid(); + TMom010SetPFMEACommand command = new TMom010SetPFMEACommand(app, + session,UID); + if(UID==null) { + MessageBox.post("ѡ", "", MessageBox.ERROR); + return null; + } + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txPFMEAsb10_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEAOperation.java b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEAOperation.java new file mode 100644 index 0000000..9c9f180 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/TMom010SetPFMEAOperation.java @@ -0,0 +1,287 @@ +package com.connor.renben.process.plm.tmom010; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.swing.JFrame; +import javax.swing.JProgressBar; +import javax.swing.plaf.metal.MetalProgressBarUI; + +import com.connor.renben.process.plm.bean.PFMEABean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ProgressBarThread; +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 TMom010SetPFMEAOperation 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; + private ProgressBarThread wait; + + public TMom010SetPFMEAOperation(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 { + //+++ӽ + wait = new ProgressBarThread("","ڱ..."); + wait.start(); + //+++ + Connection connection = null; + PreparedStatement pstmtUpdate = null; + PreparedStatement pstmtInsert = null; + PreparedStatement pstmtDelete = null; + ResultSet rs = null; + InputStream input = null; + try { + if (isOwning) { + // TMomMethodUtil.setByPass(session, true); + this.itemRevision.getRelatedComponent("IMAN_master_form_rev") + .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.itemRevision.getRelatedComponent("IMAN_master_form_rev") + .save(); + this.itemRevision.getRelatedComponent("IMAN_master_form_rev") + .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(); + } + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ȡݿ + connection = SqlUtilT.getTCConnection(); + connection.setAutoCommit(false); + + // ѯźID + String selectSQL = String.format(pro.getProperty("SETPFMEASELECT2"), meprocess.getUid()); + rs = SqlUtilT.read(selectSQL); + Map itemIdMap = new HashMap(); + while (rs.next()) { + itemIdMap.put(rs.getString("RB3_REQUIREMENT"), rs.getString("RB3_MEOPID")); + } + + // ɾ + String deleteSQL = pro.getProperty("SETPFMEADELETE").replace("'%s'", "?"); + pstmtDelete = connection.prepareStatement(deleteSQL); + for (String deleteRow : deleteRows) { + pstmtDelete.setString(1, deleteRow); + pstmtDelete.addBatch(); + } + pstmtDelete.executeBatch(); + + // ׼ºͲ + String updateSQL = pro.getProperty("SETPFMEAUPDATE") + .replace("'%s'", "?") // ַƴӸΪѯ + .replace("'%s'", "?"); + String insertSQL = pro.getProperty("INSERTPFMEA"); + + pstmtUpdate = connection.prepareStatement(updateSQL); + pstmtInsert = connection.prepareStatement(insertSQL); + + // + for (List rowList : dataValueList) { + if (rowList.get(0) != null && !rowList.get(0).isEmpty()) { + if (plmeidList.contains(rowList.get(0))) { + // + setUpdateParameters(pstmtUpdate, rowList, UID); + pstmtUpdate.addBatch(); + } else { + // + setInsertParameters(pstmtInsert, rowList, meprocess, itemIdMap, UID); + pstmtInsert.addBatch(); + } + + } + } + + // ִʣ + pstmtUpdate.executeBatch(); + pstmtInsert.executeBatch(); + + // ύ + connection.commit(); + wait.setBool(true); + wait.interrupt(); + } catch (Exception e) { + // ع + if (connection != null) { + try { + connection.rollback(); + } catch (SQLException ex) { + ex.printStackTrace(); + } + } + MessageBox.post(e.toString(), "", MessageBox.ERROR); + throw e; + } finally { + // رԴ + if (rs != null) SqlUtilT.free(rs); + if (pstmtUpdate != null) pstmtUpdate.close(); + if (pstmtInsert != null) pstmtInsert.close(); + if (pstmtDelete != null) pstmtDelete.close(); + if (input != null) input.close(); + if (connection != null) { + try { + connection.setAutoCommit(true); // ָԶύģʽ + SqlUtilT.freeAll(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + + private void setUpdateParameters(PreparedStatement pstmt, List rowList, String UID) throws SQLException { + // ø² + pstmt.setString(1, rowList.get(1)); // RB3_GYBH + pstmt.setString(2, rowList.get(2)); // RB3_GCMC + pstmt.setString(3, rowList.get(3)); // RB3_STATION + pstmt.setString(4, rowList.get(4)); // RB3_REQUIREMENT + pstmt.setString(5, rowList.get(5)); // RB3_QZSXMS + pstmt.setString(6, rowList.get(6)); // RB3_QZSXHG + pstmt.setString(7, rowList.get(7)); // RB3_YZD + pstmt.setString(8, rowList.get(8)); // RB3_JB + pstmt.setString(9, rowList.get(9)); // RB3_QZSXQY + pstmt.setString(10, rowList.get(10)); // RB3_XXGCKZYF + pstmt.setString(11, rowList.get(11)); // RB3_PDS + pstmt.setString(12, rowList.get(12)); // RB3_XXGCKZTC + pstmt.setString(13, rowList.get(13)); // RB3_TCD + pstmt.setString(14, rowList.get(14)); // RB3_RPN + pstmt.setString(15, rowList.get(15)); // RB3_JYCS + pstmt.setString(16, rowList.get(16)); // RB3_ZZR + pstmt.setString(17, rowList.get(17)); // RB3_JHWCRQ + pstmt.setString(18, rowList.get(18)); // RB3_CQDCS + pstmt.setString(19, rowList.get(19)); // RB3_NEW_SEV + pstmt.setString(20, rowList.get(20)); // RB3_NEW_OCC + pstmt.setString(21, rowList.get(21)); // RB3_NEW_DET + pstmt.setString(22, rowList.get(22)); // RB3_NEW_RPN + pstmt.setString(23, rowList.get(23)); // RB3_IDEAL_STATE + pstmt.setString(24, rowList.get(24)); // RB3_SPECIAL + pstmt.setString(25, rowList.get(25)); // RB3_HH + pstmt.setString(26, rowList.get(26)); // RB3_HBDYG + pstmt.setString(27, rowList.get(30)); // OCCURRRENCE + pstmt.setString(28, rowList.get(31)); // DETECTION + pstmt.setString(29, rowList.get(32)); // PRIORITY + pstmt.setString(30, rowList.get(33)); // P1 + pstmt.setString(31, rowList.get(34)); // P2 + pstmt.setString(32, rowList.get(35)); // P3 + pstmt.setString(33, rowList.get(36)); // P4 + pstmt.setString(34, rowList.get(37)); // P5 + pstmt.setString(35, rowList.get(0)); // plmeid + pstmt.setString(36, UID); // revisionid + } + + private void setInsertParameters(PreparedStatement pstmt, List rowList, + TCComponent meprocess, Map itemIdMap, + String UID) throws SQLException { + // ò + pstmt.setString(1, rowList.get(0)); // PLMEID + pstmt.setString(2, meprocess.getUid()); // PROCESSPUID + pstmt.setString(3, itemIdMap.get(rowList.get(4))); // RB3_MEOPID + pstmt.setString(4, rowList.get(1)); // RB3_GYBH + pstmt.setString(5, rowList.get(2)); // RB3_GCMC + pstmt.setString(6, rowList.get(3)); // RB3_STATION + pstmt.setString(7, rowList.get(4)); // RB3_REQUIREMENT + pstmt.setString(8, rowList.get(5)); // RB3_QZSXMS + pstmt.setString(9, rowList.get(6)); // RB3_QZSXHG + pstmt.setString(10, rowList.get(7)); // RB3_YZD + pstmt.setString(11, rowList.get(8)); // RB3_JB + pstmt.setString(12, rowList.get(9)); // RB3_QZSXQY + pstmt.setString(13, rowList.get(10)); // RB3_XXGCKZYF + pstmt.setString(14, rowList.get(11)); // RB3_PDS + pstmt.setString(15, rowList.get(12)); // RB3_XXGCKZTC + pstmt.setString(16, rowList.get(13)); // RB3_TCD + pstmt.setString(17, rowList.get(14)); // RB3_RPN + pstmt.setString(18, rowList.get(15)); // RB3_JYCS + pstmt.setString(19, rowList.get(16)); // RB3_ZZR + pstmt.setString(20, rowList.get(17)); // RB3_JHWCRQ + pstmt.setString(21, rowList.get(18)); // RB3_CQDCS + pstmt.setString(22, rowList.get(19)); // RB3_NEW_SEV + pstmt.setString(23, rowList.get(20)); // RB3_NEW_OCC + pstmt.setString(24, rowList.get(21)); // RB3_NEW_DET + pstmt.setString(25, rowList.get(22)); // RB3_NEW_RPN + pstmt.setString(26, rowList.get(23)); // RB3_IDEAL_STATE + pstmt.setString(27, rowList.get(25)); + pstmt.setString(28, rowList.get(26)); + pstmt.setString(29, rowList.get(27)); + pstmt.setString(30, rowList.get(24)); + pstmt.setString(31, rowList.get(28)); + pstmt.setString(32, rowList.get(29)); + pstmt.setString(33, rowList.get(30)); + pstmt.setString(34, rowList.get(31)); + pstmt.setString(35, rowList.get(32)); + pstmt.setString(36, rowList.get(33)); + pstmt.setString(37, rowList.get(34)); + pstmt.setString(38, rowList.get(35)); + pstmt.setString(39, rowList.get(36)); + pstmt.setString(40, rowList.get(37)); + pstmt.setString(41, UID); // revisionuid + pstmt.setString(42, rowList.get(rowList.size()-1)); // һ + } +} diff --git a/src/com/connor/renben/process/plm/tmom010/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/tmom010/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..c868ef8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/TableCellTextAreaRenderer.java @@ -0,0 +1,262 @@ +package com.connor.renben.process.plm.tmom010; + +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 TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private int severityZone[][] = { + {3,3,3,3,3,3,3,3,3,3}, + {3,3,3,3,3,3,2,2,1,1}, + {3,3,3,3,3,3,2,2,1,1}, + {3,3,3,3,2,2,1,1,1,1}, + {3,3,2,2,2,2,1,1,1,1}, + {3,2,2,2,1,1,1,1,1,1}, + {3,2,2,2,1,1,1,1,1,1}, + {3,2,1,1,1,1,1,1,1,1}, + {3,1,1,1,1,1,1,1,1,1}, + {3,1,1,1,1,1,1,1,1,1} + }; + private int detectionZone[][] = { + {3,3,3,3,3,3,3,3,3,3}, + {3,3,3,3,3,3,3,3,3,3}, + {3,3,3,3,3,3,3,3,3,3}, + {3,3,3,3,3,3,3,3,2,2}, + {3,3,3,3,3,3,3,3,2,2}, + {3,3,3,3,3,3,2,2,1,1}, + {3,3,3,3,2,2,2,2,1,1}, + {3,2,2,2,2,2,1,1,1,1}, + {3,2,1,1,1,1,1,1,1,1}, + {3,2,1,1,1,1,1,1,1,1} + }; + private int priorityLevel[][] = { + {1,1,2}, + {1,2,3}, + {2,2,3} + }; + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + 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")) { + // 7,11,13 + 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(); + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + 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(""); + } + } else if(table.getColumnName(column).equals("New_RPN")) { + // 19,20,21 + String yzd = table.getValueAt(row, 19) == null ? "0" : table + .getValueAt(row, 19).toString(); + String pds = table.getValueAt(row, 20) == null ? "0" : table + .getValueAt(row, 20).toString(); + String tcd = table.getValueAt(row, 21) == null ? "0" : table + .getValueAt(row, 21).toString(); + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + 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(""); + } + } + else if(table.getColumnName(column).equals("Ƶ")){// 7 2 5 2 3 + 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(); + if(isStr2Num(yzd) && isStr2Num(pds) && !yzd.equals("0")&& !pds.equals("0")) + { + + int sz = severityZone[Integer.valueOf(pds)-1][Integer.valueOf(yzd)-1]; + table.setValueAt(String.valueOf(sz), row, column); + setText(String.valueOf(sz)); + } + else + { + setText(""); + } + } + else if(table.getColumnName(column).equals("Ƶ")){ + String yzd = table.getValueAt(row, 7) == null ? "0" : table + .getValueAt(row, 7).toString(); + String tcd = table.getValueAt(row, 13) == null ? "0" : table + .getValueAt(row, 13).toString(); + if(isStr2Num(yzd) && isStr2Num(tcd) && !yzd.equals("0")&& !tcd.equals("0")) + { + int dz = detectionZone[Integer.valueOf(tcd)-1][Integer.valueOf(yzd)-1]; +// int dz = detectionZone[2-1][8-1]; + table.setValueAt(String.valueOf(dz), row, column); + setText(String.valueOf(dz)); + } + else + { + setText(""); + } + } + else if(table.getColumnName(column).equals("ȼ")){ + String yzd = table.getValueAt(row, 25) == null ? "0" : table + .getValueAt(row, 25).toString(); + String tcd = table.getValueAt(row, 26) == null ? "0" : table + .getValueAt(row, 26).toString(); + if(isStr2Num(yzd) && isStr2Num(tcd) && !yzd.equals("0")&& !tcd.equals("0")) + { + int pl = priorityLevel[Integer.valueOf(tcd)-1][Integer.valueOf(yzd)-1]; + table.setValueAt(String.valueOf(pl), row, column); + setText(String.valueOf(pl)); + } + else + { + setText(""); + } + } + 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 (table.getColumnName(column).equals("RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + setBackground(Color.RED); + setForeground(Color.black); + } + else if (table.getColumnName(column).equals("New_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 (isSelected) { + setBackground(new Color(184,184,184)); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// Ϲæ + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 壬һַҪʽɴSimpleAttributeSetַֿ˳ʹDocumentinsertString + 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(); + } + } + + /** + * 鿴һַǷתΪ + * @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/tmom010/TableCellTextAreaRenderer2.java b/src/com/connor/renben/process/plm/tmom010/TableCellTextAreaRenderer2.java new file mode 100644 index 0000000..d17be65 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/TableCellTextAreaRenderer2.java @@ -0,0 +1,159 @@ +package com.connor.renben.process.plm.tmom010; + +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ַֿ˳ʹDocumentinsertString + 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/renben/process/plm/tmom010/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/tmom010/TextAreaCellEditor.java new file mode 100644 index 0000000..78b5b37 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/TextAreaCellEditor.java @@ -0,0 +1,193 @@ +package com.connor.renben.process.plm.tmom010; + +import java.awt.Component; +import java.util.EventObject; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +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.classClass󣩣 + // ŵһCellEditorListenerʵ + listener = (CellEditorListener) listeners[i + 1]; + // changeEventȥ֪ͨ༭Ѿ༭ + // editingStoppedУJTablegetCellEditorValue()ȡصԪֵ + // Ұֵݸ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ַֿ˳ʹDocumentinsertString + 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/tmom010/outExcel.java b/src/com/connor/renben/process/plm/tmom010/outExcel.java new file mode 100644 index 0000000..cab3a16 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom010/outExcel.java @@ -0,0 +1,116 @@ +package com.connor.renben.process.plm.tmom010; +import java.io.*; + +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import jxl.Cell; +import jxl.CellType; +import jxl.LabelCell; +import jxl.NumberCell; +import jxl.Sheet; +import jxl.Workbook; +import jxl.read.biff.BiffException; + +public class outExcel { + + public boolean readExcel(File file,DefaultTableModel tableModel,JTable jTable){ + Workbook rwb = null; + + Object[] object = new Object[jTable.getColumnCount()]; + try{ + + FileInputStream is = new FileInputStream(file); + //һworkbookȡexcelļ + rwb = Workbook.getWorkbook(is); +// õi + Sheet st = rwb.getSheet(0);//ַȡsheet,1Ϊ֣Ϊ±꣬0ʼ +// //õst +// System.out.println(""+ st.getColumns()); +// //õst +// System.out.println(""+ st.getRows()); + if(st.getRows()>2){ + for(int t=tableModel.getRowCount()-1;t>=0;t--){ + tableModel.removeRow(t); + } + //ѭ + for(int i = 10;i= 0) { + topBomLine = ((TCComponentBOMLine) component); + } else { + MessageBox.post(rb.getString("qxzdc11_display.TITLE"), "", MessageBox.ERROR); + return; + } + } else { + MessageBox.post(rb.getString("qxzdc11_display.TITLE"), "", MessageBox.ERROR); + } + if (topBomLine != null) { + // ȡBOM + getBomLine(topBomLine); + MessageBox.post(rb.getString("cxplcg11_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } + super.executeModal(); + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws Exception + */ + public Map getBomLine( + TCComponentBOMLine topline) throws Exception { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + // TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, + // topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (int i = 0; i < childrens.length; i++) {//bl_item_object_type//MEProcess + boolean is_meprocess = "MEProcess".equals(childrens[i].getComponent().getProperty("bl_item_object_type")); + ((TCComponentBOMLine) childrens[i].getComponent()) + .setStringProperty("bl_sequence_no", + String.valueOf(((sequence_no + 1) * 10))); + //ݹ + if(is_meprocess) + getBomLine((TCComponentBOMLine) childrens[i].getComponent()); + else + sequence_no++; + System.out.println(((TCComponentBOMLine) childrens[i] + .getComponent()).getStringProperty("bl_sequence_no")); + // bomMap.put(((TCComponentBOMLine)childrens[i].getComponent()).getStringProperty("bl_sequence_no"), + // ((TCComponentBOMLine)childrens[i].getComponent())); + } + System.out.println("sequence_no==>"+sequence_no); + } + topline.unlock(); + bomWindow.unlock(); + bomWindow.save(); + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom011/TMom011OrderBomNumberHandler.java b/src/com/connor/renben/process/plm/tmom011/TMom011OrderBomNumberHandler.java new file mode 100644 index 0000000..a7465f8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom011/TMom011OrderBomNumberHandler.java @@ -0,0 +1,35 @@ +package com.connor.renben.process.plm.tmom011; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom011OrderBomNumberHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom011OrderBomNumberCommand command = new TMom011OrderBomNumberCommand( + app, session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("cxplczbhsb11_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom012/CTMap.java b/src/com/connor/renben/process/plm/tmom012/CTMap.java new file mode 100644 index 0000000..c5aac61 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/CTMap.java @@ -0,0 +1,331 @@ +package com.connor.renben.process.plm.tmom012; + +import java.awt.Dimension; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = false; + + 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; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + //return this.isEditable; + } + + @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 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; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + 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); + } + } + + // if (processRowList.contains(row)) { + // for (int i = 0; i < processRowList.size(); i++) { + // 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+1) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + // else + // { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == + // row-1) + // { + // index = i+1; + // processRowList.add(i+1, row); + // } + // 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/tmom012/CTUI.java b/src/com/connor/renben/process/plm/tmom012/CTUI.java new file mode 100644 index 0000000..2a3f82c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom012; + +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/tmom012/CTable.java b/src/com/connor/renben/process/plm/tmom012/CTable.java new file mode 100644 index 0000000..19c0b7b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/CTable.java @@ -0,0 +1,269 @@ +package com.connor.renben.process.plm.tmom012; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.connor.renben.process.plm.tmom004.ComboBoxCellEditor; +import com.connor.renben.process.plm.util.TMomMethodUtil; + +public class CTable extends JTable { + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + ComboBoxCellEditor comboBoxCellEditor = new ComboBoxCellEditor( + new Object[] { 2, 3, 4, 5, 6, 7, 8, 9, 10 }); + ComboBoxCellEditor gaugeComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_GAUGE_VALUES")); + ComboBoxCellEditor frequencyComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_FREQUENCY_VALUES")); + + ComboBoxCellEditor owningComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_OWNING_VALUES")); + ComboBoxCellEditor reactionPlanComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_REACTION_VALUES")); + ComboBoxCellEditor controlMethodComboBoxCellEditor = new ComboBoxCellEditor(TMomMethodUtil.getPreferenceValues("RB3_CONTROLMETHOD_VALUES")); + public CTable(TableModel model) { + super(model); + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); +// // Ӽ̼ +// this.addKeyListener(new KeyAdapter() { +// @Override +// public void keyPressed(KeyEvent arg0) { +// // TODO Auto-generated method stub +// if(arg0.getKeyChar() == KeyEvent.VK_DELETE) +// { +// int[] selectRows = CTable.this.getSelectedRows(); +// int[] selectColumns = CTable.this.getSelectedColumns(); +// for (int i = 0; i < selectRows.length; i++) { +// for (int j = 0; j < selectColumns.length; j++) { +// CTable.this.setValueAt("", selectRows[i], selectColumns[j]); +// } +// } +// } +// super.keyPressed(arg0); +// } +// }); + 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("New_SEV") + || this.getColumnName(column).equals("New_OCC") + || this.getColumnName(column).equals("New_DET")) { + return comboBoxCellEditor; + } +// else if (this.getColumnName(column).equals("/")) +// { +// gaugeComboBoxCellEditor.setEditable(true); +// return gaugeComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("Ƶ")) +// { +// frequencyComboBoxCellEditor.setEditable(true); +// return frequencyComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("")) { +// owningComboBoxCellEditor.setEditable(true); +// return owningComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("Ʒ")) { +// controlMethodComboBoxCellEditor.setEditable(true); +// return controlMethodComboBoxCellEditor; +// } +// else if (this.getColumnName(column).equals("Ӧƻ")) { +// reactionPlanComboBoxCellEditor.setEditable(true); +// return reactionPlanComboBoxCellEditor; +// } + else { + return cellEditor; + } + // Point point = new Point(row,column); + // if(map.containsKey(point)){ + // return map.get(point); + // }else{ + // return super.getCellEditor(row, column); + // } + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + return renderer; + } + + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + // @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/tmom012/CellSpan.java b/src/com/connor/renben/process/plm/tmom012/CellSpan.java new file mode 100644 index 0000000..7635e0d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.tmom012; + +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/tmom012/ComboBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom012/ComboBoxCellEditor.java new file mode 100644 index 0000000..4132924 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/ComboBoxCellEditor.java @@ -0,0 +1,88 @@ +package com.connor.renben.process.plm.tmom012; + +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/tmom012/CopyOfTMom012ControlPlanLibraryCommand.java b/src/com/connor/renben/process/plm/tmom012/CopyOfTMom012ControlPlanLibraryCommand.java new file mode 100644 index 0000000..4798287 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/CopyOfTMom012ControlPlanLibraryCommand.java @@ -0,0 +1,403 @@ +package com.connor.renben.process.plm.tmom012; +//package com.connor.renben.process.plm.tmom012; +// +//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 javax.swing.JTable; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.DefaultMutableTreeNode; +// +//import com.connor.renben.process.plm.bean.ControlPlanTreeBean; +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.connor.renben.process.plm.util.CTreeNode; +//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 CopyOfTMom012ControlPlanLibraryCommand extends AbstractAIFCommand { +// +// private TCSession session; +// private AbstractAIFApplication app; +// private String commandId; +// private String titleName="Ƽƻ"; +// private String titleLabel="CONTROL PLAN/Ƽƻ"; +// private InterfaceAIFComponent comp; +// private TCComponent form; +// private boolean isOwning = false; +// //private List> processRowList = new ArrayList>(); +// private TCComponentUser user;// ǰ¼û +// private List> dataList = new ArrayList>();// е +// private ControlPlanTreeBean bean; +// private Properties pro = new Properties(); +// private String[] header = new String[]{"PLMEID","ͼ","ߴ","Ʒ","" +// ,"Է","Ʒ///","/","","Ƶ","׼ռٷֱ","ĩռٷֱ","ռٷֱ","","Ʒ" +// ,"淶/¼","Ӧƻ","ڵID","ַλ"}; +// +// public CopyOfTMom012ControlPlanLibraryCommand() { +// super(); +// } +// +// public CopyOfTMom012ControlPlanLibraryCommand(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 getAuthority() { +//// ResultSet rs = null; +//// try { +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +//// InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +//// Properties pro = new Properties(); +//// pro.load(input); +//// //յ +//// String userName = form.getReferenceProperty("owning_user") +//// .getStringProperty("user_id"); +//// String sql; +//// if(user.getUserId().equals(userName)) +//// { +//// sql = String.format(pro.getProperty("CONTROLPLANSELECT3"),form.getUid()); +//// } +//// else +//// { +//// sql = String.format(pro.getProperty("CONTROLPLANSELECT2"),form.getUid(),user.getUserId()); +//// } +//// rs = SqlUtilT.read(sql); +//// while (rs.next()) { +//// List rowList = new ArrayList(); +//// rowList.add(rs.getString("RB3_MEOPID")); +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } +//// } +// +//// /** +//// * ȡݿе +//// */ +//// private void getData() { +//// // TODO Auto-generated method stub +//// ResultSet rs = null; +//// InputStream input = null; +//// try { +//// // ȡݿ +////// SqlUtilT.getConnectionTC10(); +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +//// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +//// Properties pro = new Properties(); +//// pro.load(input); +//// String sql = String +//// .format(pro.getProperty("PFMEALIBRARYSELECT")); +//// rs = SqlUtilT.read(sql); +//// while (rs.next()) { +//// List rowList = new ArrayList(); +//// rowList.add(rs.getString("PLMEID")); +//// rowList.add(rs.getInt("RB3_NO")); +//// rowList.add(rs.getString("RB3_STATION")); +//// rowList.add(rs.getString("RB3_REQUIREMENT")); +//// rowList.add(rs.getString("RB3_QZSXMS")); +//// rowList.add(rs.getString("RB3_QZSXHG")); +//// rowList.add(rs.getString("RB3_YZD")); +//// rowList.add(rs.getString("RB3_JB")); +//// rowList.add(rs.getString("RB3_QZSXQY")); +//// rowList.add(rs.getString("RB3_XXGCKZYF")); +//// rowList.add(rs.getString("RB3_PDS")); +//// rowList.add(rs.getString("RB3_XXGCKZTC")); +//// rowList.add(rs.getString("RB3_TCD")); +//// rowList.add(rs.getString("RB3_RPN")); +//// rowList.add(rs.getString("RB3_JYCS")); +//// rowList.add(rs.getString("RB3_ZZR")); +//// rowList.add(rs.getString("RB3_JHWCRQ")); +//// rowList.add(rs.getString("RB3_CQDCS")); +//// rowList.add(rs.getString("RB3_NEW_SEV")); +//// rowList.add(rs.getString("RB3_NEW_OCC")); +//// rowList.add(rs.getString("RB3_NEW_DET")); +//// rowList.add(rs.getString("RB3_NEW_RPN")); +//// rowList.add(rs.getString("RB3_IDEAL_STATE")); +//// rowList.add(rs.getString("RB3_SPECIAL")); +//// dataList.add(rowList); +//// } +//// } 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) { +//// AIFComponentContext[] context = ((TCComponentItemRevision) comp).getItem().whereReferenced(); +//// for (int i = 0; i < context.length; i++) { +//// if(context[i].getComponent().getType().equals("MEProcess")) +//// { +//// meprocess = (TCComponent) context[i].getComponent(); +//// } +//// } +//// form = ((TCComponentItemRevision) comp) +//// .getRelatedComponent("IMAN_master_form_rev"); +//// } +//// else +//// { +//// MessageBox.post("ѡ汾", "", MessageBox.ERROR); +//// return; +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } +//// } +// +// /** +// * ȡݿе +// */ +// private void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // ȡݿ +// SqlUtilT.getConnectionTC10(); +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +// String sql = String.format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID is null"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// bean = getChidren(beans.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 ControlPlanTreeBean getChidren(ControlPlanTreeBean controlPlanTreeBean) { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// try { +// //ѯȨ޿ +// String sql = String.format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID = \'%s\'",controlPlanTreeBean.getId()); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// if (beans.size() > 0) { +// controlPlanTreeBean.setChidrenBeans(beans); +// for (ControlPlanTreeBean controlPlanTreeBean2 : beans) { +// getChidren(controlPlanTreeBean2); +// } +// } +// return controlPlanTreeBean; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return controlPlanTreeBean; +// } +// +// public CTreeNode createNodes(DefaultMutableTreeNode node,ControlPlanTreeBean bean) { +// CTreeNode root = null; +// System.out.println(bean.getName()); +// root = new CTreeNode(bean); +// try { +// if(bean != null) +// { +// ResultSet rs = null; +// //ѯȨ޿ +// String sql = String.format(pro.getProperty("CONTROLPLANLIBRARYSELECT"),bean.getId()); +// rs = SqlUtilT.read(sql); +// List> beans = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// //list.add(rs.getString("RB3_JQSB")); +// //list.add(rs.getString("RB3_SMJY")); +// list.add(rs.getString("RB3_QPTBH")); +// list.add(rs.getString("RB3_CC")); +// list.add(rs.getString("RB3_CP")); +// list.add(rs.getString("RB3_GC")); +// list.add(rs.getString("RB3_TSTX")); +// list.add(rs.getString("RB3_CPGC")); +// list.add(rs.getString("RB3_CLFF")); +// list.add(rs.getString("RB3_RL")); +// list.add(rs.getString("RB3_PL")); +// list.add(rs.getString("RB3_SJSJ")); +// list.add(rs.getString("RB3_GCSJ")); +// list.add(rs.getString("RB3_MJSJ")); +// list.add(rs.getString("RB3_FZR")); +// list.add(rs.getString("RB3_KZFF")); +// list.add(rs.getString("RB3_CZGF")); +// list.add(rs.getString("RB3_FYJH")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("RB3_SPECIAL")); +// beans.add(list); +// } +// if (beans.size() > 0) { +// final JTable table = getNewjTable(null, null, header,beans.size()+1); +// for (int i = 0; i < beans.size()+1; i++) { +// if(i == 0) +// { +// for (int j = 0; j < header.length; j++) { +// table.setValueAt(header[j], i, j); +// } +// } +// else +// { +// for (int j = 0; j < beans.get(i-1).size(); j++) { +// table.setValueAt(beans.get(i-1).get(j), i, j); +// } +// } +// } +// DefaultMutableTreeNode child = new DefaultMutableTreeNode(table); +// root.add(child); +// node.add(root); +// if(bean.getChidrenBeans() != null) +// { +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root,bean.getChidrenBeans().get(i)); +// } +// } +// } +// else if(bean.getChidrenBeans() == null || bean.getChidrenBeans().size() == 0) +// { +// if(node != null) +// { +// node.add(root); +// } +// } +// else +// { +// if(node != null) +// { +// node.add(root); +// } +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root,bean.getChidrenBeans().get(i)); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// +// return root; +// } +// +// //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 { +// // ȡ汾 +// try { +// InputStream input = null; +// //ȡSQL +// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +// pro.load(input); +// //ȡνṹڵ +// getData(); +// final CTreeNode node = createNodes(null, bean); +// new Thread() { +// @Override +// public void run() { +// TMom012ControlPlanLibraryDialog dislog = new TMom012ControlPlanLibraryDialog( +// app, session,commandId,form, node,header,isOwning,titleName,titleLabel); +// } +// }.start(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// super.executeModal(); +// } +// } diff --git a/src/com/connor/renben/process/plm/tmom012/CopyOfTMom012ControlPlanLibraryDialog.java b/src/com/connor/renben/process/plm/tmom012/CopyOfTMom012ControlPlanLibraryDialog.java new file mode 100644 index 0000000..83fe248 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/CopyOfTMom012ControlPlanLibraryDialog.java @@ -0,0 +1,722 @@ +package com.connor.renben.process.plm.tmom012; +//package com.connor.renben.process.plm.tmom012; +// +//import java.awt.BorderLayout; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Font; +//import java.awt.Toolkit; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.sql.ResultSet; +//import java.sql.SQLException; +//import java.util.ArrayList; +//import java.util.Enumeration; +//import java.util.List; +//import java.util.UUID; +// +//import javax.swing.JButton; +//import javax.swing.JFrame; +//import javax.swing.JLabel; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.JTable; +//import javax.swing.JTextField; +//import javax.swing.JTree; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.DefaultMutableTreeNode; +//import javax.swing.tree.DefaultTreeCellRenderer; +//import javax.swing.tree.DefaultTreeModel; +// +//import com.connor.renben.process.plm.bean.ControlPlanTreeBean; +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.connor.renben.process.plm.tmom013.TMom013PFMEALibraryOperation; +//import com.connor.renben.process.plm.util.CTreeNode; +//import com.connor.renben.process.plm.util.MyTableModel; +//import com.connor.renben.process.plm.util.TMomFinalUtil; +//import com.connor.renben.process.plm.util.TreeTableCellEditor; +//import com.connor.renben.process.plm.util.TreeTableCellRenderer; +//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 CopyOfTMom012ControlPlanLibraryDialog extends AbstractAIFDialog implements ActionListener { +// +// private AbstractAIFApplication app; +// private TCSession session; +// private String titleName; +// private String title; +// private String commandId; +// //private CTMap map; +// static JScrollPane scrollPane; +//// private String[] header = new String[]{"PLM
EID","/
ձ","",",豸
,װ,о","ͼ","ߴ","Ʒ","" +//// ,"
Է","Ʒ//
/","/
","","Ƶ","","Ʒ" +//// ,"淶/
¼
","Ӧƻ"}; +// private String[] header; +// private List> dataValeList = new ArrayList>();; +// +// private CTreeNode node; +// private List deleteRows = new ArrayList(); +// private SpecialDialog specialDialog; +// private String nodeName;//ڵ +// +// //ؼ +// private JPanel titlePanel;// +// private JLabel titleLabel; +// +// private JPanel treePanel;//νṹ +// private static JTree tree; +// +// private JPanel rootPanel;//ť +// private JButton addButton;// +// private JButton addNodeButton;//ӽڵ +// private JButton remButton;//Ƴ +// private JButton remNodeButton;//Ƴڵ +// private JButton saveButton;// +// private JButton addSpecialButton;// +// //JButton sendbutton = new JButton(""); +// +// +// public CopyOfTMom012ControlPlanLibraryDialog(AbstractAIFApplication app, +// TCSession session,String commandId,TCComponent form,CTreeNode node,String[] header,boolean isOwning,String titleName,String title) { +// super(); +// this.setLocationRelativeTo(null); +// //this.dataList = dataList; +// this.node = node; +// this.app = app; +// this.session = session; +// this.commandId = commandId; +// this.titleName =titleName; +// this.title = title; +// this.header = header; +// init(); +// } +// +//// /** +//// * ̬ÿ޸ +//// */ +//// 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 void init() { +// this.setTitle(this.titleName); +// this.setPreferredSize(new Dimension(800, 600)); +// //ʼⲿֿؼ +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel(this.title); +// this.titleLabel.setFont(new Font("", 1, 18)); +// this.titlePanel.add(titleLabel); +// +// this.treePanel = new JPanel(new BorderLayout()); +// this.tree = new JTree(this.node); +// this.tree.setRowHeight(0); +// this.tree.setCellRenderer(new TreeTableCellRenderer()); +// this.tree.setCellEditor(new TreeTableCellEditor(this.tree, new DefaultTreeCellRenderer())); +// this.tree.setEditable(true); +// //this.table = getjTable(null, null, header, null); +// //ӹ +// this.treePanel.add(new JScrollPane(this.tree),BorderLayout.CENTER); +// +// 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(""); +// this.addSpecialButton = new JButton(""); +// //this.sendbutton = new JButton(""); +// //this.sendbutton.addActionListener(this); +// this.rootPanel.add(addNodeButton); +// this.rootPanel.add(addButton); +// this.rootPanel.add(remButton); +// this.rootPanel.add(remNodeButton); +// this.rootPanel.add(saveButton); +// this.rootPanel.add(addSpecialButton); +// //this.rootPanel.add(sendbutton); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// +// // +// this.createActionEvent(); +// this.setLayout(new BorderLayout()); +// this.add(centerPanel, BorderLayout.NORTH); +// this.add(this.treePanel, BorderLayout.CENTER); +// // dialog.add(tablePanel, BorderLayout.CENTER); +// this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.showDialog(); +// +// +// } +// +// //Ӽ +// public void createActionEvent() { +// this.addButton.addActionListener(this); +// this.addNodeButton.addActionListener(this); +// this.remButton.addActionListener(this); +// this.remNodeButton.addActionListener(this); +// this.saveButton.addActionListener(this); +// this.addSpecialButton.addActionListener(this); +// } +//// /** +//// * дݵJtable +//// */ +//// private void setJTable() { +//// for (int i = 0; i < dataList.size(); i++) { +//// List rowList = dataList.get(i); +//// for (int j = 0; j < header.length; j++) { +//// map.setValueAt(rowList.get(j), i, j); +//// } +//// } +//// } +// +//// // Jtableͨ÷ +//// public CTable getjTable(CTable partsTable, DefaultTableModel dtm, +//// Object[] titleNames, Object[][] values) { +//// int simpleLen = 100; +//// int totleLen = 1000; +//// if (partsTable == null) { +//// if(dataList.size() == 0) +//// { +//// this.map = new CTMap(1, titleNames.length); +//// this.map.setValueAt(1, 0, 1); +//// } +//// else +//// { +//// this.map = new CTMap(dataList.size(), titleNames.length); +//// } +//// map.setColumnIdentifiers(titleNames); +//// setJTable(); +//// partsTable = new CTable(map); +//// //partsTable.setRowHeight(1, 50); +//// //partsTable.setRowHeight(2, 100); +//// partsTable.setRowHeight(50); +//// // +//// partsTable.HiddenCell(0); +//// partsTable.HiddenCell(titleNames.length-1); +////// //ʾȾ +//// TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); +//// partsTable.setDefaultRenderer(Object.class, renderer); +////// //ñ༭Ⱦ +////// 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); +//// } +//// } +//// return partsTable; +//// } +// +// //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); +// //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 actionPerformed(ActionEvent arg0) { +// Object source=arg0.getSource(); +// if(source.equals(this.addButton)) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("ս")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// if(table.getSelectedRow() > -1) +// { +// ((CTMap)table.getModel()).insertRow(table.getSelectedRow()+1); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount()-2), table.getSelectedRow()+1, table.getColumnCount()-2); +// table.revalidate(); +// table.repaint(); +// this.tree.updateUI(); +// } +// } +// else +// { +// JTable t2 = getNewjTable(null, null, header, 2); +// t2.setRowHeight(50); +// for (int i = 0; i < t2.getRowCount(); i++) { +// if(i == 0) +// { +// for (int j = 0; j < header.length; j++) { +// t2.setValueAt(header[j],i,j); +// } +// } +// else +// { +// t2.setValueAt(((ControlPlanTreeBean)node.getUserObject()).getId(), i, t2.getColumnCount()-2); +// } +// } +// DefaultMutableTreeNode child = new DefaultMutableTreeNode(t2); +// ((DefaultTreeModel)tree.getModel()).insertNodeInto(child,node,0); +// } +// } +// else if(source.equals(this.addNodeButton)) +// { +// final JFrame frame = new JFrame(); +// frame.setLocationRelativeTo(this); +// frame.setSize(new Dimension(200,100)); +// JLabel label = new JLabel("ڵ"); +// final JTextField field = new JTextField(20); +// JButton okButton = new JButton("ȷ"); +// okButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// // TODO Auto-generated method stub +// nodeName = field.getText(); +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("ս")); +// String selectSql = ""; +// String insterSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// selectSql = "select addId_Sequence.nextval as id from dual"; +// insterSql = "insert into RB3_CONTROLPLAN_TREE values(?,?,?,?)"; +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// selectSql = "select ADDPFMEAID_SEQUENCE.nextval as id from dual"; +// insterSql = "insert into RB3_PFMEA_TREE values(?,?,?,?)"; +// break; +// default: +// break; +// } +// String id = ""; +// try { +// ResultSet rs = SqlUtilT.read(selectSql); +// while (rs.next()) { +// id = rs.getString("id"); +// } +// } catch (SQLException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// UUID uid = UUID.randomUUID(); +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(uid.toString().replace("-", "")); +// bean.setId(id); +// bean.setName(nodeName); +// bean.setParentId(((ControlPlanTreeBean)node.getUserObject()).getId()); +// if(((ControlPlanTreeBean)node.getUserObject()).getChidrenBeans() == null) +// { +// List beanList = new ArrayList(); +// beanList.add(bean); +// ((ControlPlanTreeBean)node.getUserObject()).setChidrenBeans(beanList); +// } +// else +// { +// ((ControlPlanTreeBean)node.getUserObject()).getChidrenBeans().add(bean); +// } +// ((DefaultTreeModel)tree.getModel()).insertNodeInto(new CTreeNode(bean),node,0); +// SqlUtilT.write(new String[]{uid.toString().replace("-", ""),id,nodeName,bean.getParentId()},insterSql); +// frame.dispose(); +// } +// }); +// 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 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.remButton)) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("ս")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// if(table.getSelectedRow() >= 1 && table.getSelectedColumn() > 0) +// { +// (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); +// int row = table.getSelectedRow(); +// 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()); +// table.revalidate(); +// table.repaint(); +// this.tree.updateUI(); +// } +// } +// } +// else if(source.equals(this.remNodeButton)) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("ս")); +// if(node.getUserObject() instanceof CTable) +// { +// if(((DefaultMutableTreeNode)node.getParent()).getUserObject() instanceof ControlPlanTreeBean) +// { +// ControlPlanTreeBean parentNode = ((ControlPlanTreeBean)((DefaultMutableTreeNode)node.getParent()).getUserObject()); +// ((DefaultTreeModel)tree.getModel()).removeNodeFromParent(node); +// String deleteSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// deleteSql = String.format("delete from RB3_CONTROLPLAN_TREE where PARENT_ID = \'%s\'", parentNode.getId()); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// deleteSql = String.format("delete from RB3_PFMEA_TREE where PARENT_ID = \'%s\'", parentNode.getId()); +// break; +// default: +// break; +// } +// SqlUtilT.delete(deleteSql); +// } +// } +// else +// { +// //node.add(new DefaultMutableTreeNode("ս")); +// if(node.getUserObject() instanceof ControlPlanTreeBean) +// { +// if(((DefaultMutableTreeNode)node.getParent()).getUserObject() instanceof ControlPlanTreeBean) +// { +// ControlPlanTreeBean parentNode = ((ControlPlanTreeBean)((DefaultMutableTreeNode)node.getParent()).getUserObject()); +// if(parentNode.getChidrenBeans() != null && parentNode.getChidrenBeans().contains((ControlPlanTreeBean)node.getUserObject())) +// { +// parentNode.getChidrenBeans().remove((ControlPlanTreeBean)node.getUserObject()); +// } +// } +// ((DefaultTreeModel)tree.getModel()).removeNodeFromParent(node); +// String deleteSql = ""; +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// deleteSql = String.format("delete from RB3_CONTROLPLAN_TREE where plmeid = \'%s\'", ((ControlPlanTreeBean)node.getUserObject()).getPlmeid()); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// deleteSql = String.format("delete from RB3_PFMEA_TREE where plmeid = \'%s\'", ((ControlPlanTreeBean)node.getUserObject()).getPlmeid()); +// break; +// default: +// break; +// } +// SqlUtilT.delete(deleteSql); +// } +// } +// } +// else if(source.equals(this.saveButton)) +// { +// okEvent(true); +// this.disposeDialog(); +// this.dispose(); +// } +// else if(source.equals(addSpecialButton)) +// { +// if (this.specialDialog == null) { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// System.out.println(table.getSelectedRow()+"==="+table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } +// } else { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("ս")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// System.out.println(table.getSelectedRow()+"==="+table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } +// } +// else +// { +// this.disposeDialog(); +// this.dispose(); +// //this.setVisible(false); +// } +// } +// +// private void okEvent(boolean isSave) { +// // TODO Auto-generated method stub +// //ݱ浽 +// try { +// if(tree.getSelectionPath() != null) +// { +// DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// if(table.getSelectedRow() >= 0 && table.getSelectedColumn() >= 0) +// { +// (table.getCellEditor(table.getSelectedRow(), table.getSelectedColumn())).stopCellEditing(); +// } +// } +// } +//// if(isOwning) +//// { +//// } +// //ȡJTableе +// this.dataValeList.clear(); +// List> dataValeList = getTableValue(this.node); +// switch (commandId) { +// case "com.connor.renben.process.plm.commands.ControlPlanLibrary": +// TMom012ControlPlanLibraryOperation operation = new TMom012ControlPlanLibraryOperation(this.session,dataValeList,deleteRows); +// session.queueOperation(operation); +// break; +// case "com.connor.renben.process.plm.commands.PFMEALibrary": +// TMom013PFMEALibraryOperation pfmeaOperation = new TMom013PFMEALibraryOperation(this.session,dataValeList,deleteRows); +// session.queueOperation(pfmeaOperation); +// break; +// default: +// break; +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// MessageBox.post(e.toString(), "", MessageBox.ERROR); +// e.printStackTrace(); +// } +// } +// +// private List> getTableValue(DefaultMutableTreeNode node) { +// // TODO Auto-generated method stub +// Enumeration children = node.children(); +// while (children.hasMoreElements()) { +// DefaultMutableTreeNode child = children.nextElement(); +// if (child.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)child.getUserObject()); +// for (int j = 1; j < table.getRowCount(); j++) { +// List rowValue = new ArrayList(); +// for (int j2 = 0; j2 < table.getColumnCount(); j2++) { +// if(table.getValueAt(j, j2) != null) +// { +// rowValue.add(table.getValueAt(j, j2).toString()); +// } +// else +// { +// rowValue.add(""); +// } +// } +// dataValeList.add(rowValue); +// } +// } +// else +// { +// getTableValue(child); +// } +// } +// +//// for (int i = 0; i < tree.getComponents().length; i++) { +//// for (int j = 0; j < table.getRowCount(); j++) { +//// List rowValue = new ArrayList(); +//// for (int j2 = 0; j2 < this.map.getColumnCount(); j2++) { +//// if(table.getValueAt(j, j2) != null) +//// { +//// rowValue.add(table.getValueAt(j, j2).toString()); +//// } +//// else +//// { +//// rowValue.add(""); +//// } +//// } +//// rowValue.add(""); +//// dataValeList.add(rowValue); +//// } +//// } +//// for (int i = 0; i < processRowList.size(); i++) { +//// List rows = processRowList.get(i); +//// } +// return dataValeList; +// } +// +// 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 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() { +// // TODO Auto-generated method stub +// this.setTitle("ѡ"); +// 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("ȷ"); +// this.okButton.addActionListener(this); +// this.celButton = new JButton("ȡ"); +// 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) CopyOfTMom012ControlPlanLibraryDialog.tree.getSelectionPath().getLastPathComponent(); +// //node.add(new DefaultMutableTreeNode("ս")); +// if(node.getUserObject() instanceof CTable) +// { +// CTable table = ((CTable)node.getUserObject()); +// 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/renben/process/plm/tmom012/TMom012ControlPlanLibraryCommand.java b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryCommand.java new file mode 100644 index 0000000..10d53d0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryCommand.java @@ -0,0 +1,484 @@ +package com.connor.renben.process.plm.tmom012; + +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 javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.DraggableTabbedPane; +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 TMom012ControlPlanLibraryCommand extends AbstractAIFCommand { + + private TCSession session; + private AbstractAIFApplication app; + private String commandId; + private String titleName = "Ƽƻ"; + private String titleLabel = "CONTROL PLAN/Ƽƻ"; + private InterfaceAIFComponent comp; + private TCComponent form; + private boolean isOwning = false; + // private List> processRowList = new + // ArrayList>(); + private TCComponentUser user;// ǰ¼û + private List> dataList = new ArrayList>();// е + private Properties pro = new Properties(); + private String[] header = new String[] { "PLMEID", "ID", ",豸,װ,о", "ĩ/ҵ׼", "", "Ʒ", "", "Է", "Ʒ///", "/", "", + "Ƶ", "Ʒ", "Ӧƻ", "ڵID", "ַλ" }; + // ǩҳ + // private JTabbedPane tabbedPane; + // private DraggableTabbedPane tabbedPane; + private List beans = new ArrayList(); + + public TMom012ControlPlanLibraryCommand() { + super(); + } + + public TMom012ControlPlanLibraryCommand(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 getAuthority() { + // ResultSet rs = null; + // try { + // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", + // "tc10", "infodba"); + // InputStream input = new + // BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + // Properties pro = new Properties(); + // pro.load(input); + // //յ + // String userName = form.getReferenceProperty("owning_user") + // .getStringProperty("user_id"); + // String sql; + // if(user.getUserId().equals(userName)) + // { + // sql = String.format(pro.getProperty("CONTROLPLANSELECT3"),form.getUid()); + // } + // else + // { + // sql = + // String.format(pro.getProperty("CONTROLPLANSELECT2"),form.getUid(),user.getUserId()); + // } + // rs = SqlUtilT.read(sql); + // while (rs.next()) { + // List rowList = new ArrayList(); + // rowList.add(rs.getString("RB3_MEOPID")); + // } + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + + // /** + // * ȡݿе + // */ + // private void getData() { + // // TODO Auto-generated method stub + // ResultSet rs = null; + // InputStream input = null; + // try { + // // ȡݿ + // // SqlUtilT.getConnectionTC10(); + // SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", + // "tc10", "infodba"); + // input = new + // BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + // Properties pro = new Properties(); + // pro.load(input); + // String sql = String + // .format(pro.getProperty("PFMEALIBRARYSELECT")); + // rs = SqlUtilT.read(sql); + // while (rs.next()) { + // List rowList = new ArrayList(); + // rowList.add(rs.getString("PLMEID")); + // rowList.add(rs.getInt("RB3_NO")); + // rowList.add(rs.getString("RB3_STATION")); + // rowList.add(rs.getString("RB3_REQUIREMENT")); + // rowList.add(rs.getString("RB3_QZSXMS")); + // rowList.add(rs.getString("RB3_QZSXHG")); + // rowList.add(rs.getString("RB3_YZD")); + // rowList.add(rs.getString("RB3_JB")); + // rowList.add(rs.getString("RB3_QZSXQY")); + // rowList.add(rs.getString("RB3_XXGCKZYF")); + // rowList.add(rs.getString("RB3_PDS")); + // rowList.add(rs.getString("RB3_XXGCKZTC")); + // rowList.add(rs.getString("RB3_TCD")); + // rowList.add(rs.getString("RB3_RPN")); + // rowList.add(rs.getString("RB3_JYCS")); + // rowList.add(rs.getString("RB3_ZZR")); + // rowList.add(rs.getString("RB3_JHWCRQ")); + // rowList.add(rs.getString("RB3_CQDCS")); + // rowList.add(rs.getString("RB3_NEW_SEV")); + // rowList.add(rs.getString("RB3_NEW_OCC")); + // rowList.add(rs.getString("RB3_NEW_DET")); + // rowList.add(rs.getString("RB3_NEW_RPN")); + // rowList.add(rs.getString("RB3_IDEAL_STATE")); + // rowList.add(rs.getString("RB3_SPECIAL")); + // dataList.add(rowList); + // } + // } 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) { + // AIFComponentContext[] context = ((TCComponentItemRevision) + // comp).getItem().whereReferenced(); + // for (int i = 0; i < context.length; i++) { + // if(context[i].getComponent().getType().equals("MEProcess")) + // { + // meprocess = (TCComponent) context[i].getComponent(); + // } + // } + // form = ((TCComponentItemRevision) comp) + // .getRelatedComponent("IMAN_master_form_rev"); + // } + // else + // { + // MessageBox.post("ѡ汾", "", MessageBox.ERROR); + // return; + // } + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + + /** + * ȡݿе + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + String sql = String.format(pro.getProperty("TM2CONTROLPLANTREESELECT")); + // String sql = String.format("select * from RB3_CONTROLPLAN_TREE"); + 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(); + } + } + +// public void createTabbedPane(List beans) { +// tabbedPane = new DraggableTabbedPane(); +// try { +// if (beans != null && beans.size() > 0) { +// for (int i = 0; i < beans.size(); i++) { +// ResultSet rs = null; +// // ѯȨ޿ +// String sql = String.format(pro +// .getProperty("CONTROLPLANLIBRARYSELECT"), beans +// .get(i).getId()); +// rs = SqlUtilT.read(sql); +// List> rowList = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// list.add(rs.getString("RB3_QPTBH")); +// list.add(rs.getString("RB3_CC")); +// list.add(rs.getString("RB3_CP")); +// list.add(rs.getString("RB3_GC")); +// list.add(rs.getString("RB3_TSTX")); +// list.add(rs.getString("RB3_CPGC")); +// list.add(rs.getString("RB3_CLFF")); +// list.add(rs.getString("RB3_RL")); +// list.add(rs.getString("RB3_PL")); +// list.add(rs.getString("RB3_SJSJ")); +// list.add(rs.getString("RB3_GCSJ")); +// list.add(rs.getString("RB3_MJSJ")); +// list.add(rs.getString("RB3_FZR")); +// list.add(rs.getString("RB3_KZFF")); +// list.add(rs.getString("RB3_CZGF")); +// list.add(rs.getString("RB3_FYJH")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("RB3_SPECIAL")); +// rowList.add(list); +// } +// if (rowList.size() > 0) { +// JTable table = getNewjTable(null, null, header, +// rowList.size()); +// Adapter adapter = new Adapter(table); +// for (int j = 0; j < rowList.size(); j++) { +// for (int k = 0; k < rowList.get(j).size(); k++) { +// table.setValueAt(rowList.get(j).get(k), j, k); +// } +// } +// JScrollPane scrollPane = new JScrollPane(table); +// scrollPane.getVerticalScrollBar().setUnitIncrement(2); +// tabbedPane.add(beans.get(i).getName(), scrollPane); +// } else { +// JTable table = getNewjTable(null, null, header, +// rowList.size() + 1); +// Adapter adapter = new Adapter(table); +// table.setValueAt(beans.get(i).getId(), 0, +// table.getColumnCount() - 2); +// JScrollPane scrollPane = new JScrollPane(table); +// scrollPane.getVerticalScrollBar().setUnitIncrement(2); +// tabbedPane.add(beans.get(i).getName(), scrollPane); +// } +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// SqlUtilT.freeAll(); +// } +// } + + // public ControlPlanTreeBean getChidren(ControlPlanTreeBean + // controlPlanTreeBean) { + // // TODO Auto-generated method stub + // ResultSet rs = null; + // try { + // //ѯȨ޿ + // String sql = + // String.format("select * from RB3_CONTROLPLAN_TREE where PARENT_ID = + // \'%s\'",controlPlanTreeBean.getId()); + // rs = SqlUtilT.read(sql); + // List beans = new ArrayList(); + // while (rs.next()) { + // ControlPlanTreeBean bean = new ControlPlanTreeBean(); + // bean.setPlmeid(rs.getString("PLMEID")); + // bean.setId(rs.getString("ID")); + // bean.setName(rs.getString("NAME")); + // bean.setParentId(rs.getString("PARENT_ID")); + // beans.add(bean); + // } + // if (beans.size() > 0) { + // controlPlanTreeBean.setChidrenBeans(beans); + // for (ControlPlanTreeBean controlPlanTreeBean2 : beans) { + // getChidren(controlPlanTreeBean2); + // } + // } + // return controlPlanTreeBean; + // } catch (Exception e) { + // // TODO: handle exception + // e.printStackTrace(); + // } + // return controlPlanTreeBean; + // } + + // public CTreeNode createNodes(DefaultMutableTreeNode + // node,ControlPlanTreeBean bean) { + // CTreeNode root = null; + // System.out.println(bean.getName()); + // root = new CTreeNode(bean); + // try { + // if(bean != null) + // { + // ResultSet rs = null; + // //ѯȨ޿ + // String sql = + // String.format(pro.getProperty("CONTROLPLANLIBRARYSELECT"),bean.getId()); + // rs = SqlUtilT.read(sql); + // List> beans = new ArrayList>(); + // while (rs.next()) { + // List list = new ArrayList(); + // list.add(rs.getString("PLMEID")); + // //list.add(rs.getString("RB3_JQSB")); + // //list.add(rs.getString("RB3_SMJY")); + // list.add(rs.getString("RB3_QPTBH")); + // list.add(rs.getString("RB3_CC")); + // list.add(rs.getString("RB3_CP")); + // list.add(rs.getString("RB3_GC")); + // list.add(rs.getString("RB3_TSTX")); + // list.add(rs.getString("RB3_CPGC")); + // list.add(rs.getString("RB3_CLFF")); + // list.add(rs.getString("RB3_RL")); + // list.add(rs.getString("RB3_PL")); + // list.add(rs.getString("RB3_SJSJ")); + // list.add(rs.getString("RB3_GCSJ")); + // list.add(rs.getString("RB3_MJSJ")); + // list.add(rs.getString("RB3_FZR")); + // list.add(rs.getString("RB3_KZFF")); + // list.add(rs.getString("RB3_CZGF")); + // list.add(rs.getString("RB3_FYJH")); + // list.add(rs.getString("PARENT_ID")); + // list.add(rs.getString("RB3_SPECIAL")); + // beans.add(list); + // } + // if (beans.size() > 0) { + // final JTable table = getNewjTable(null, null, header,beans.size()+1); + // for (int i = 0; i < beans.size()+1; i++) { + // if(i == 0) + // { + // for (int j = 0; j < header.length; j++) { + // table.setValueAt(header[j], i, j); + // } + // } + // else + // { + // for (int j = 0; j < beans.get(i-1).size(); j++) { + // table.setValueAt(beans.get(i-1).get(j), i, j); + // } + // } + // } + // DefaultMutableTreeNode child = new DefaultMutableTreeNode(table); + // root.add(child); + // node.add(root); + // if(bean.getChidrenBeans() != null) + // { + // for (int i = 0; i < bean.getChidrenBeans().size(); i++) { + // createNodes(root,bean.getChidrenBeans().get(i)); + // } + // } + // } + // else if(bean.getChidrenBeans() == null || bean.getChidrenBeans().size() + // == 0) + // { + // if(node != null) + // { + // node.add(root); + // } + // } + // else + // { + // if(node != null) + // { + // node.add(root); + // } + // for (int i = 0; i < bean.getChidrenBeans().size(); i++) { + // createNodes(root,bean.getChidrenBeans().get(i)); + // } + // } + // } + // } catch (Exception e) { + // // TODO: handle exception + // e.printStackTrace(); + // } + // + // return root; + // } + + // 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 { + // ȡ汾 + try { + InputStream input = null; + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro.load(input); + // ȡνṹڵ + getData(); + new Thread() { + @Override + public void run() { + TMom012ControlPlanLibraryDialog dislog = new TMom012ControlPlanLibraryDialog(app, session, + commandId, form, beans, header, isOwning, titleName, titleLabel); + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryDialog.java b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryDialog.java new file mode 100644 index 0000000..fe981bf --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryDialog.java @@ -0,0 +1,1581 @@ +package com.connor.renben.process.plm.tmom012; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +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.List; +import java.util.Locale; +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 com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TableCellTextAreaRenderer2; +import com.connor.renben.process.plm.tmom013.TMom013PFMEALibraryOperation; +import com.connor.renben.process.plm.tmom022.TMom022SetThesaurusOperation; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.MyTableModel; +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 TMom012ControlPlanLibraryDialog 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 static JPopupMenu mainMenu; + private JMenuItem addItem; + private JMenuItem remItem; + private static JPopupMenu leftMenu; + private JMenuItem addNodeItem; + private JMenuItem remNodeItem; + private JMenuItem updateNodItem; + private JMenuItem shrinkColumnItem; + private JMenuItem celShrinkColumnItem; + + private JPanel rootPanel;// ť + //private JButton addButton;// + //private JButton addNodeButton;// ӽڵ + //private JButton remButton;// Ƴ + //private JButton remNodeButton;// Ƴڵ + private JButton saveButton;// + //private JButton addSpecialButton;// + + + public TMom012ControlPlanLibraryDialog(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.commandId = commandId; + this.titleName = titleName; + this.title = title; + this.header = header; + init(); + } + + private void init() { + this.setTitle(this.titleName); + this.setPreferredSize(new Dimension(800, 600)); + //ȡʻ + 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 + if(index == -1) + { + switch (commandId) { + case "com.connor.renben.process.plm.commands.ControlPlanLibrary": + refreshTable(); + break; + case "com.connor.renben.process.plm.commands.PFMEALibrary": + refreshPFMEATable(); + break; + case "com.connor.renben.process.plm.commands.Thesaurus": + refreshThesaurusTable(); + break; + default: + break; + } + 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); + } + switch (commandId) { + case "com.connor.renben.process.plm.commands.ControlPlanLibrary": + refreshTable(); + break; + case "com.connor.renben.process.plm.commands.PFMEALibrary": + refreshPFMEATable(); + break; + case "com.connor.renben.process.plm.commands.Thesaurus": + refreshThesaurusTable(); + break; + default: + break; + } + 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()); + } + } + }); + 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); + JScrollPane scrollPane2 = new JScrollPane(leftTable); + scrollPane2.setPreferredSize(new Dimension(300, 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.mainMenu.add(this.addItem); + this.mainMenu.add(this.remItem); + this.mainMenu.add(this.shrinkColumnItem); + this.mainMenu.add(this.celShrinkColumnItem); + + 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.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(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(); + + } + + + 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("RB3_JQSB")); + list.add(rs.getString("RB3_SMJY")); + list.add(rs.getString("RB3_QPTBH")); + //list.add(rs.getString("RB3_CC")); + //list.add(rs.getString("RB3_NO")); + list.add(rs.getString("RB3_CP")); + list.add(rs.getString("RB3_GC")); + list.add(rs.getString("RB3_TSTX")); + list.add(rs.getString("RB3_CPGC")); + list.add(rs.getString("RB3_CLFF")); + list.add(rs.getString("RB3_RL")); + list.add(rs.getString("RB3_PL")); + //list.add(rs.getString("RB3_FZR")); + list.add(rs.getString("RB3_KZFF")); + //list.add(rs.getString("RB3_CZGF")); + list.add(rs.getString("RB3_FYJH")); + //list.add(rs.getString("RB3_SJSJ")); + //list.add(rs.getString("RB3_GCSJ")); + //list.add(rs.getString("RB3_MJSJ")); + list.add(rs.getString("PARENT_ID")); + list.add(rs.getString("RB3_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 void refreshPFMEATable() { + // 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("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("RB3_STATION")); + list.add(rs.getString("RB3_REQUIREMENT")); + list.add(rs.getString("RB3_QZSXMS")); + list.add(rs.getString("RB3_QZSXHG")); + list.add(rs.getString("RB3_YZD")); + list.add(rs.getString("RB3_JB")); + list.add(rs.getString("RB3_QZSXQY")); + list.add(rs.getString("RB3_XXGCKZYF")); + list.add(rs.getString("RB3_PDS")); + list.add(rs.getString("RB3_XXGCKZTC")); + list.add(rs.getString("RB3_TCD")); + list.add(rs.getString("RB3_RPN")); + list.add(rs.getString("RB3_JYCS")); + list.add(rs.getString("RB3_ZZR")); + list.add(rs.getString("RB3_JHWCRQ")); + list.add(rs.getString("RB3_CQDCS")); + list.add(rs.getString("RB3_NEW_SEV")); + list.add(rs.getString("RB3_NEW_OCC")); + list.add(rs.getString("RB3_NEW_DET")); + list.add(rs.getString("RB3_NEW_RPN")); + list.add(rs.getString("RB3_IDEAL_STATE")); + list.add(rs.getString("RB3_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")); + 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() - 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(); + } + } + + /** + * + */ + 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); + } + 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 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("RB3_VALUE")); + //list.add(rs.getString("RB3_VALUE2")); + //list.add(rs.getString("RB3_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.addSpecialButton.addActionListener(this); + } + + // Jtableͨ÷ + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, + Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + CTMap map; + 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); + partsTable.setRowHeight(50); + //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); + switch (commandId) { + case "com.connor.renben.process.plm.commands.ControlPlanLibrary": + table.setValueAt( + table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 2), + table.getSelectedRow() + 1, + table.getColumnCount() - 2); + break; + case "com.connor.renben.process.plm.commands.PFMEALibrary": + + table.setValueAt( + table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 1), + table.getSelectedRow() + 1, + table.getColumnCount() - 1); + break; + case "com.connor.renben.process.plm.commands.Thesaurus": + String id = (String) table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 1); + table.setValueAt( + table.getValueAt(table.getSelectedRow(), + table.getColumnCount() - 1), + table.getSelectedRow() + 1, + table.getColumnCount() - 1); + break; + default: + break; + } + 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 = ""; + switch (commandId) { + case "com.connor.renben.process.plm.commands.ControlPlanLibrary": + //selectSql = "select addId_Sequence.nextval as id from dual"; + insterSql = "insert into RB3_CONTROLPLAN_TREE values(?,?,?,?)"; + break; + case "com.connor.renben.process.plm.commands.PFMEALibrary": + //selectSql = "select ADDPFMEAID_SEQUENCE.nextval as id from dual"; + insterSql = "insert into RB3_PFMEA_TREE values(?,?,?,?)"; + break; + case "com.connor.renben.process.plm.commands.Thesaurus": + //selectSql = "select ADDID_THESAURUS.nextval as id from dual"; + insterSql = "insert into RB3_THESAURUS_TREE values(?,?,?,?)"; + break; + default: + break; + } + //String id = ""; + try { +// SqlUtilT.getTCConnection(); +// rs = SqlUtilT.read(selectSql); +// while (rs.next()) { +// id = rs.getString("id"); +// } + 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); + 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; + } + frame.dispose(); + //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(); + String updateSql = ""; + switch (commandId) { + case "com.connor.renben.process.plm.commands.ControlPlanLibrary": + updateSql = String + .format("update RB3_CONTROLPLAN_TREE set NAME = ?,PARENT_ID = ? where PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); + break; + case "com.connor.renben.process.plm.commands.PFMEALibrary": + updateSql = String + .format("update RB3_PFMEA_TREE set NAME = ?,PARENT_ID = ? where PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); + break; + case "com.connor.renben.process.plm.commands.Thesaurus": + updateSql = String + .format("update RB3_THESAURUS_TREE set NAME = ?,PARENT_ID = ? where PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); + break; + default: + break; + } + try { + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { nodeName, nodeID }, + updateSql); + 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; + } + frame.dispose(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + 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; + 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()); + table.revalidate(); + table.repaint(); + //this.tabbedPane.updateUI(); + } +// } +// } + } 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": + deleteTreeSql = String + .format("delete from RB3_PFMEA_TREE where PLMEID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 0).toString()); + deleteNodeSql = String + .format("delete from RB3_PFMEA_NODE where PARENT_ID = \'%s\'", + leftTable.getValueAt(leftTable.getSelectedRow(), 1).toString()); + 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(addSpecialButton)) { +// if (this.specialDialog == null) { +//// 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; +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +//// } +//// } +// } else { +// this.specialDialog.show(); +// } +// } + else { + //this.disposeDialog(); + this.dispose(); + // this.setVisible(false); + } + } + + private void okEvent(boolean isSave) { + isMeopSave = false; + // TODO Auto-generated method stub + // ݱ浽 + try { +// // Ƴ +// Component component = tabbedPane.getSelectedComponent(); +// if (component instanceof JScrollPane) { +// JScrollPane scrollPane = (JScrollPane) component; +// Component tableComponent = scrollPane.getViewport().getView(); +// if (tableComponent instanceof CTable) { +// CTable table = ((CTable) tableComponent); +// +// } +// } + // ȡJTableе + List> dataValeList = getTableValue(); + switch (commandId) { + case "com.connor.renben.process.plm.commands.ControlPlanLibrary": + TMom012ControlPlanLibraryOperation operation = new TMom012ControlPlanLibraryOperation( + this.session, dataValeList, deleteRows); + session.queueOperation(operation); + break; + case "com.connor.renben.process.plm.commands.PFMEALibrary": + TMom013PFMEALibraryOperation pfmeaOperation = new TMom013PFMEALibraryOperation( + this.session, dataValeList, deleteRows); + session.queueOperation(pfmeaOperation); + break; + case "com.connor.renben.process.plm.commands.Thesaurus": + TMom022SetThesaurusOperation thesaurusOperation = new TMom022SetThesaurusOperation( + this.session, dataValeList, deleteRows); + session.queueOperation(thesaurusOperation); + break; + default: + break; + } + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + 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(); + } + 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()); + } + } + 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/renben/process/plm/tmom012/TMom012ControlPlanLibraryHandler.java b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryHandler.java new file mode 100644 index 0000000..8184f45 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryHandler.java @@ -0,0 +1,49 @@ +package com.connor.renben.process.plm.tmom012; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom011.TMom011OrderBomNumberCommand; +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 TMom012ControlPlanLibraryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + TMom012ControlPlanLibraryCommand command = new TMom012ControlPlanLibraryCommand( + app, session, commandId); + try { + TCPreferenceService service = session.getPreferenceService(); + String[] options = service.getStringArray(TCPreferenceService.TC_preference_site, "Cust_ControlPlanLibrary_Privilege"); + boolean hasPrivilege = false; + for(String option : options){ + if(option.equals(session.getUserName())){ + command.executeModal(); + hasPrivilege = true; + } + } + if(!hasPrivilege){ + MessageBox.post(rb.getString("wglqx12_display.TITLE"), "", MessageBox.ERROR); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txkzjhksb12_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryOperation.java b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryOperation.java new file mode 100644 index 0000000..59d4130 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/TMom012ControlPlanLibraryOperation.java @@ -0,0 +1,112 @@ +package com.connor.renben.process.plm.tmom012; + +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.renben.process.plm.bean.PFMEABean; +import com.connor.renben.process.plm.sql.util.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 TMom012ControlPlanLibraryOperation extends AbstractAIFOperation { + + private List> dataValueList; + private TCSession session; + private List deleteRows; + + public TMom012ControlPlanLibraryOperation(TCSession session, + List> dataValueList, List deleteRows) { + this.session = session; + this.dataValueList = dataValueList; + this.deleteRows = deleteRows; + + } + + @Override + public void executeOperation() throws Exception { + 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("CONTROLPLANLIBRARYDELETE"), + deleteRows.get(i)); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + // ѯźID + // ݿд + for (int i = 0; i < dataValueList.size(); i++) { + SqlUtilT.getTCConnection(); + List rowList = dataValueList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("")) { + // ȡݿ + String updateSQL = String.format( + pro.getProperty("CONTROLPLANLIBRARYUPDATE"), + 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), "", + "","","" }, updateSQL); + } else { + String insertSQL = pro + .getProperty("CONTROLPLANLIBRARYINSERT"); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), 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(1),"" }, + insertSQL); + } + SqlUtilT.freeAll(); + } + } 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/renben/process/plm/tmom012/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/tmom012/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..a65a5eb --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/TableCellTextAreaRenderer.java @@ -0,0 +1,292 @@ +package com.connor.renben.process.plm.tmom012; + +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 javax.swing.text.StyledDocument; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + 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(); + + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + 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(""); + } +// 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 if (table.getColumnName(column).equals("New_RPN")) { + // 17,18,19 + String yzd = table.getValueAt(row, 18) == null ? "0" : table + .getValueAt(row, 18).toString(); + String pds = table.getValueAt(row, 19) == null ? "0" : table + .getValueAt(row, 19).toString(); + String tcd = table.getValueAt(row, 20) == null ? "0" : table + .getValueAt(row, 20).toString(); + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + 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(""); + } +// 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(value != null) + // { + // SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setAlignment(set, StyleConstants.ALIGN_CENTER);//þ + // StyledDocument doc = this.getStyledDocument(); + // try { + // //doc.remove(0, value.toString().length()); + // doc.setCharacterAttributes(0, doc.getLength(), set, false); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + // + // 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 (table.getColumnName(column).equals("New_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(Color.YELLOW); + // 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); +// } + else { + setBackground(Color.white); + 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ַֿ˳ʹDocumentinsertString + 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(); + } + } + /** + * 鿴һַǷתΪ + * @param str ַ + * @return true ; false + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + // + // @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/tmom012/TableCellTextAreaRenderer2.java b/src/com/connor/renben/process/plm/tmom012/TableCellTextAreaRenderer2.java new file mode 100644 index 0000000..2df1430 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/TableCellTextAreaRenderer2.java @@ -0,0 +1,208 @@ +package com.connor.renben.process.plm.tmom012; + +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; + +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 (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()); + } + // + // 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 (processRows == null || processRows.size() <= 0 + || !processRows.contains(row)) { + setBackground(Color.YELLOW); + setForeground(Color.black); + } else { + setBackground(Color.white); + setForeground(Color.black); + } + System.out.println(row); + if (row == table.getSelectedRow()) { + setBackground(Color.YELLOW); + setForeground(Color.black); + } + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + setBackground(Color.YELLOW); + setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// Ϲæ + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 壬һַҪʽɴSimpleAttributeSetַֿ˳ʹDocumentinsertString + 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/tmom012/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/tmom012/TextAreaCellEditor.java new file mode 100644 index 0000000..d93bd3c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom012/TextAreaCellEditor.java @@ -0,0 +1,204 @@ +package com.connor.renben.process.plm.tmom012; + +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.classClass󣩣 + // ŵһCellEditorListenerʵ + listener = (CellEditorListener) listeners[i + 1]; + // changeEventȥ֪ͨ༭Ѿ༭ + // editingStoppedУJTablegetCellEditorValue()ȡصԪֵ + // Ұֵݸ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ַֿ˳ʹDocumentinsertString + 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/tmom013/CopyOfTMom013PFMEALibraryCommand.java b/src/com/connor/renben/process/plm/tmom013/CopyOfTMom013PFMEALibraryCommand.java new file mode 100644 index 0000000..a6a9662 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom013/CopyOfTMom013PFMEALibraryCommand.java @@ -0,0 +1,411 @@ +package com.connor.renben.process.plm.tmom013; +//package com.connor.renben.process.plm.tmom013; +// +//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 javax.swing.JTable; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.DefaultMutableTreeNode; +// +//import com.connor.renben.process.plm.bean.ControlPlanTreeBean; +//import com.connor.renben.process.plm.sql.util.SqlUtilT; +//import com.connor.renben.process.plm.tmom012.CTMap; +//import com.connor.renben.process.plm.tmom012.CTable; +//import com.connor.renben.process.plm.tmom012.TMom012ControlPlanLibraryDialog; +//import com.connor.renben.process.plm.util.CTreeNode; +//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 CopyOfTMom013PFMEALibraryCommand extends AbstractAIFCommand { +// +// private TCSession session; +// private AbstractAIFApplication app; +// private String commandId; +// private String titleName="PFMEA"; +// private String titleLabel="DZʧЧģʽ"; +// private InterfaceAIFComponent comp; +// private TCComponent form; +// private boolean isOwning = false; +// //private List> processRowList = new ArrayList>(); +// private TCComponentUser user;// ǰ¼û +// private List> dataList = new ArrayList>();// е +// private ControlPlanTreeBean bean; +// private Properties pro = new Properties(); +// private String[] header = new String[]{"PLMEID","Station","Ҫ","DZʧЧģʽ","DZʧЧ","ضS","","DZʧЧ/","й̿Ԥ" +// ,"ƵO","й̿̽","̽D","RPN","ʩ","","ƻ","ȡĴʩ","New_SEV","New_OCC","New_DET" +// ,"New_RPN","Ideal_State","ڵID","λ"}; +// +// public CopyOfTMom013PFMEALibraryCommand() { +// super(); +// } +// +// public CopyOfTMom013PFMEALibraryCommand(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 getAuthority() { +//// ResultSet rs = null; +//// try { +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +//// InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +//// Properties pro = new Properties(); +//// pro.load(input); +//// //յ +//// String userName = form.getReferenceProperty("owning_user") +//// .getStringProperty("user_id"); +//// String sql; +//// if(user.getUserId().equals(userName)) +//// { +//// sql = String.format(pro.getProperty("CONTROLPLANSELECT3"),form.getUid()); +//// } +//// else +//// { +//// sql = String.format(pro.getProperty("CONTROLPLANSELECT2"),form.getUid(),user.getUserId()); +//// } +//// rs = SqlUtilT.read(sql); +//// while (rs.next()) { +//// List rowList = new ArrayList(); +//// rowList.add(rs.getString("RB3_MEOPID")); +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } +//// } +// +//// /** +//// * ȡݿе +//// */ +//// private void getData() { +//// // TODO Auto-generated method stub +//// ResultSet rs = null; +//// InputStream input = null; +//// try { +//// // ȡݿ +////// SqlUtilT.getConnectionTC10(); +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +//// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +//// Properties pro = new Properties(); +//// pro.load(input); +//// String sql = String +//// .format(pro.getProperty("PFMEALIBRARYSELECT")); +//// rs = SqlUtilT.read(sql); +//// while (rs.next()) { +//// List rowList = new ArrayList(); +//// rowList.add(rs.getString("PLMEID")); +//// rowList.add(rs.getInt("RB3_NO")); +//// rowList.add(rs.getString("RB3_STATION")); +//// rowList.add(rs.getString("RB3_REQUIREMENT")); +//// rowList.add(rs.getString("RB3_QZSXMS")); +//// rowList.add(rs.getString("RB3_QZSXHG")); +//// rowList.add(rs.getString("RB3_YZD")); +//// rowList.add(rs.getString("RB3_JB")); +//// rowList.add(rs.getString("RB3_QZSXQY")); +//// rowList.add(rs.getString("RB3_XXGCKZYF")); +//// rowList.add(rs.getString("RB3_PDS")); +//// rowList.add(rs.getString("RB3_XXGCKZTC")); +//// rowList.add(rs.getString("RB3_TCD")); +//// rowList.add(rs.getString("RB3_RPN")); +//// rowList.add(rs.getString("RB3_JYCS")); +//// rowList.add(rs.getString("RB3_ZZR")); +//// rowList.add(rs.getString("RB3_JHWCRQ")); +//// rowList.add(rs.getString("RB3_CQDCS")); +//// rowList.add(rs.getString("RB3_NEW_SEV")); +//// rowList.add(rs.getString("RB3_NEW_OCC")); +//// rowList.add(rs.getString("RB3_NEW_DET")); +//// rowList.add(rs.getString("RB3_NEW_RPN")); +//// rowList.add(rs.getString("RB3_IDEAL_STATE")); +//// rowList.add(rs.getString("RB3_SPECIAL")); +//// dataList.add(rowList); +//// } +//// } 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) { +//// AIFComponentContext[] context = ((TCComponentItemRevision) comp).getItem().whereReferenced(); +//// for (int i = 0; i < context.length; i++) { +//// if(context[i].getComponent().getType().equals("MEProcess")) +//// { +//// meprocess = (TCComponent) context[i].getComponent(); +//// } +//// } +//// form = ((TCComponentItemRevision) comp) +//// .getRelatedComponent("IMAN_master_form_rev"); +//// } +//// else +//// { +//// MessageBox.post("ѡ汾", "", MessageBox.ERROR); +//// return; +//// } +//// } catch (Exception e) { +//// e.printStackTrace(); +//// } +//// } +// +// /** +// * ȡݿе +// */ +// private void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // ȡݿ +// SqlUtilT.getConnectionTC10(); +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +// String sql = String.format("select * from RB3_PFMEA_TREE where PARENT_ID is null"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// bean = getChidren(beans.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 ControlPlanTreeBean getChidren(ControlPlanTreeBean controlPlanTreeBean) { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// try { +// //ѯȨ޿ +// String sql = String.format("select * from RB3_PFMEA_TREE where PARENT_ID = \'%s\'",controlPlanTreeBean.getId()); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// bean.setPlmeid(rs.getString("PLMEID")); +// bean.setId(rs.getString("ID")); +// bean.setName(rs.getString("NAME")); +// bean.setParentId(rs.getString("PARENT_ID")); +// beans.add(bean); +// } +// if (beans.size() > 0) { +// controlPlanTreeBean.setChidrenBeans(beans); +// for (ControlPlanTreeBean controlPlanTreeBean2 : beans) { +// getChidren(controlPlanTreeBean2); +// } +// } +// return controlPlanTreeBean; +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return controlPlanTreeBean; +// } +// +// public CTreeNode createNodes(DefaultMutableTreeNode node,ControlPlanTreeBean bean) { +// CTreeNode root = null; +// System.out.println(bean.getName()); +// root = new CTreeNode(bean); +// try { +// if(bean != null) +// { +// ResultSet rs = null; +// //ѯȨ޿ +// String sql = String.format(pro.getProperty("PFMEALIBRARYSELECT"),bean.getId()); +// rs = SqlUtilT.read(sql); +// List> beans = new ArrayList>(); +// while (rs.next()) { +// List list = new ArrayList(); +// list.add(rs.getString("PLMEID")); +// //list.add(rs.getString("RB3_JQSB")); +// //list.add(rs.getString("RB3_SMJY")); +// list.add(rs.getString("RB3_STATION")); +// list.add(rs.getString("RB3_REQUIREMENT")); +// list.add(rs.getString("RB3_QZSXMS")); +// list.add(rs.getString("RB3_QZSXHG")); +// list.add(rs.getString("RB3_YZD")); +// list.add(rs.getString("RB3_JB")); +// list.add(rs.getString("RB3_QZSXQY")); +// list.add(rs.getString("RB3_XXGCKZYF")); +// list.add(rs.getString("RB3_PDS")); +// list.add(rs.getString("RB3_XXGCKZTC")); +// list.add(rs.getString("RB3_TCD")); +// list.add(rs.getString("RB3_RPN")); +// list.add(rs.getString("RB3_JYCS")); +// list.add(rs.getString("RB3_ZZR")); +// list.add(rs.getString("RB3_JHWCRQ")); +// list.add(rs.getString("RB3_CQDCS")); +// list.add(rs.getString("RB3_NEW_SEV")); +// list.add(rs.getString("RB3_NEW_OCC")); +// list.add(rs.getString("RB3_NEW_DET")); +// list.add(rs.getString("RB3_NEW_RPN")); +// list.add(rs.getString("RB3_IDEAL_STATE")); +// list.add(rs.getString("PARENT_ID")); +// list.add(rs.getString("RB3_SPECIAL")); +// beans.add(list); +// } +// if (beans.size() > 0) { +// final JTable table = getNewjTable(null, null, header,beans.size()+1); +// for (int i = 0; i < beans.size()+1; i++) { +// if(i == 0) +// { +// for (int j = 0; j < header.length; j++) { +// table.setValueAt(header[j], i, j); +// } +// } +// else +// { +// for (int j = 0; j < beans.get(i-1).size(); j++) { +// table.setValueAt(beans.get(i-1).get(j), i, j); +// } +// } +// } +// DefaultMutableTreeNode child = new DefaultMutableTreeNode(table); +// root.add(child); +// node.add(root); +// if(bean.getChidrenBeans() != null) +// { +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root,bean.getChidrenBeans().get(i)); +// } +// } +// } +// else if(bean.getChidrenBeans() == null || bean.getChidrenBeans().size() == 0) +// { +// if(node != null) +// { +// node.add(root); +// } +// } +// else +// { +// if(node != null) +// { +// node.add(root); +// } +// for (int i = 0; i < bean.getChidrenBeans().size(); i++) { +// createNodes(root,bean.getChidrenBeans().get(i)); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// +// return root; +// } +// +// //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 { +// // ȡ汾 +// try { +// InputStream input = null; +// //ȡSQL +// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +// pro.load(input); +// //ȡνṹڵ +// getData(); +// final CTreeNode node = createNodes(null, bean); +// new Thread() { +// @Override +// public void run() { +// TMom012ControlPlanLibraryDialog dislog = new TMom012ControlPlanLibraryDialog( +// app, session,commandId,form, node,header,isOwning,titleName,titleLabel); +// } +// }.start(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// super.executeModal(); +// } +// } diff --git a/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryCommand.java b/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryCommand.java new file mode 100644 index 0000000..9c73f82 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryCommand.java @@ -0,0 +1,260 @@ +package com.connor.renben.process.plm.tmom013; + +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 javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom012.CTMap; +import com.connor.renben.process.plm.tmom012.CTable; +import com.connor.renben.process.plm.tmom012.TMom012ControlPlanLibraryDialog; +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 TMom013PFMEALibraryCommand extends AbstractAIFCommand { + + private TCSession session; + private AbstractAIFApplication app; + private String commandId; + private String titleName = "PFMEA"; + private String titleLabel = "DZʧЧģʽ"; + 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ʩȼ", + "Ʒ", + "ɸѡ루ѡ", + "Ԥʩ", + "̽ʩ", + "", + "Ŀ", + "״̬", + "ȡ֤ݵĴʩ" , + "", + "ضȣSSeverity(S)", + "ƵȣOOccurrence(O)", + "̽ȣDDetection(D)", + "Ʒ", + "PFMEA AP ", + "ע", "ڵID"}; + + public TMom013PFMEALibraryCommand() { + super(); + } + + public TMom013PFMEALibraryCommand(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); + } + //createTabbedPane(beans); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + } + + } + +// public void createTabbedPane(List beans) { +// tabbedPane = new DraggableTabbedPane(); +// try { +// if (beans != null && beans.size() > 0) { +// for (int i = 0; i < beans.size(); i++) { +// ResultSet rs = null; +// // ѯȨ޿ +// String sql = String.format(pro +// .getProperty("PFMEALIBRARYSELECT"), beans.get(i) +// .getId()); +// rs = SqlUtilT.read(sql); +// List> dataList = new ArrayList>(); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("PLMEID")); +// rowList.add(rs.getString("RB3_STATION")); +// rowList.add(rs.getString("RB3_REQUIREMENT")); +// rowList.add(rs.getString("RB3_QZSXMS")); +// rowList.add(rs.getString("RB3_QZSXHG")); +// rowList.add(rs.getString("RB3_YZD")); +// rowList.add(rs.getString("RB3_JB")); +// rowList.add(rs.getString("RB3_QZSXQY")); +// rowList.add(rs.getString("RB3_XXGCKZYF")); +// rowList.add(rs.getString("RB3_PDS")); +// rowList.add(rs.getString("RB3_XXGCKZTC")); +// rowList.add(rs.getString("RB3_TCD")); +// rowList.add(rs.getString("RB3_RPN")); +// rowList.add(rs.getString("RB3_JYCS")); +// rowList.add(rs.getString("RB3_ZZR")); +// rowList.add(rs.getString("RB3_JHWCRQ")); +// rowList.add(rs.getString("RB3_CQDCS")); +// rowList.add(rs.getString("RB3_NEW_SEV")); +// rowList.add(rs.getString("RB3_NEW_OCC")); +// rowList.add(rs.getString("RB3_NEW_DET")); +// rowList.add(rs.getString("RB3_NEW_RPN")); +// rowList.add(rs.getString("RB3_IDEAL_STATE")); +// rowList.add(rs.getString("PARENT_ID")); +// rowList.add(rs.getString("RB3_SPECIAL")); +// dataList.add(rowList); +// } +// if (dataList.size() > 0) { +// JTable table = getNewjTable(null, null, header, +// dataList.size()); +// for (int j = 0; j < dataList.size(); j++) { +// for (int k = 0; k < dataList.get(j).size(); k++) { +// table.setValueAt(dataList.get(j).get(k), j, k); +// } +// } +// tabbedPane.add(beans.get(i).getName(), new JScrollPane( +// table)); +// } else { +// JTable table = getNewjTable(null, null, header, +// dataList.size() + 1); +// table.setValueAt(beans.get(i).getId(), 0, +// table.getColumnCount() - 2); +// tabbedPane.add(beans.get(i).getName(), new JScrollPane( +// table)); +// } +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// SqlUtilT.free(); +// } +// } + + // 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() { + TMom012ControlPlanLibraryDialog dislog = new TMom012ControlPlanLibraryDialog( + 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/renben/process/plm/tmom013/TMom013PFMEALibraryHandler.java b/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryHandler.java new file mode 100644 index 0000000..75a8ed0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryHandler.java @@ -0,0 +1,50 @@ +package com.connor.renben.process.plm.tmom013; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom011.TMom011OrderBomNumberCommand; +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 TMom013PFMEALibraryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + TMom013PFMEALibraryCommand command = new TMom013PFMEALibraryCommand( + 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(rb.getString("wglqx12_display.TITLE"), "", MessageBox.ERROR); + } + //command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txPFMEAksb13_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryOperation.java b/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryOperation.java new file mode 100644 index 0000000..f52d7e8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom013/TMom013PFMEALibraryOperation.java @@ -0,0 +1,117 @@ +package com.connor.renben.process.plm.tmom013; + +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.renben.process.plm.bean.PFMEABean; +import com.connor.renben.process.plm.sql.util.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 TMom013PFMEALibraryOperation extends AbstractAIFOperation { + + private List> dataValueList; + private TCSession session; + private List deleteRows; + + public TMom013PFMEALibraryOperation(TCSession session, + List> dataValueList, List deleteRows) { + this.session = session; + this.dataValueList = dataValueList; + this.deleteRows = deleteRows; + } + + @Override + public void executeOperation() throws Exception { + 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 < dataValueList.size(); i++) { + // ȡݿ + SqlUtilT.getTCConnection(); + List rowList = dataValueList.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)}, + updateSQL); + } else { + String insertSQL = pro.getProperty("PFMEALIBRARYINSERT"); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + 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(32),rowList.get(23),rowList.get(1), + rowList.get(24),rowList.get(25),rowList.get(26), + rowList.get(27),rowList.get(28),rowList.get(29), + rowList.get(30),rowList.get(31)}, insertSQL); + } + SqlUtilT.freeAll(); + } + //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/renben/process/plm/tmom013/sql.properties b/src/com/connor/renben/process/plm/tmom013/sql.properties new file mode 100644 index 0000000..75d7ba2 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom013/sql.properties @@ -0,0 +1,60 @@ +INSERTSQL=insert into RB3_CONTROLPLAN values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +INSERTCHECKTABLESQL=insert into RB3_CHECK_TABLE values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +DELETE=delete from RB3_CONTROLPLAN where RB3_MEOPID = \'%s\' and PROCESSPUID = \'%s\' +INSERTPFMEA=INSERT INTO RB3_PFMEA VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) +BOMCHECKSAVESELECT=select RB3_MEOPID,rb3_gybh,RB3_GCMC,RB3_JQSB from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and rb3_gcmc not like (\'%s\') group by RB3_MEOPID,rb3_gybh,RB3_GCMC,RB3_JQSB +BOMCHECKSAVESELECTPERMISSIONS=select RB3_MEOPID,rb3_gybh,RB3_GCMC from RB3_PERMISSIONS where PROCESSPUID = \'%s\' group by RB3_MEOPID,rb3_gybh,RB3_GCMC +BOMCHECKSAVESELECTPFMEA=select RB3_MEOPID,rb3_gybh,RB3_GCMC from RB3_PFMEA where PROCESSPUID = \'%s\' group by RB3_MEOPID,rb3_gybh,RB3_GCMC +BOMCHECKSAVESELECT2=select * from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVESELECTPERMISSIONS2 = select * from RB3_PERMISSIONS where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVESELECTPFMEA2=select * from RB3_PFMEA where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVESELECT3=select * from RB3_PFMEA where PROCESSPUID = \'%s\' and RB3_MEOPID not in %s +BOMCHECKSAVEUPDATE=update RB3_CONTROLPLAN set RB3_GYBH = ?,RB3_GCMC = ?,RB3_JQSB = ? where PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' and rb3_gcmc not like (\'%s\') +BOMCHECKSAVEUPDATE2=update RB3_CONTROLPLAN set RB3_GYBH = ?,RB3_GCMC = ?,RB3_JQSB = ? where PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' and rb3_gcmc like (\'%s\') + +DELETEPFMEA=delete from RB3_PFMEA where RB3_MEOPID = \'%s\' and PROCESSPUID = \'%s\' +UPDATEPFMEA=update RB3_PFMEA set RB3_STATION= ? where PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' + +INSERTPERMISSIONS=INSERT INTO RB3_PERMISSIONS VALUES(?,?,?,?,?,?,?,?,?) +UPDATEPERMISSIONS=UPDATE RB3_PERMISSIONS SET RB3_GYBH = ?,RB3_GCMC = ? WHERE PROCESSPUID = \'%s\' and RB3_MEOPID = \'%s\' +DELETEPERMISSIONS=DELETE FROM RB3_PERMISSIONS WHERE RB3_MEOPID = \'%s\' and PROCESSPUID = \'%s\' + +CONTROLPLANSELECT=select t1.*,t2.rb3_user,t2.rb3_inspectionuser from rb3_controlplan t1 left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid where t1.PROCESSPUID = \'%s\' and t1.type = \'%s\' order by TO_NUMBER(replace(t1.RB3_GYBH,chr(10),'')),to_number(t1.RB3_HH) +CONTROLPLANUPDATE=update RB3_CONTROLPLAN set RB3_GYBH = ?,RB3_GCMC = ?,RB3_JQSB = ?,RB3_SMJY = ?,RB3_QPTBH = ?,RB3_CC = ?,RB3_NO = ?,RB3_CP = ?,RB3_GC = ?,RB3_TSTX = ?,RB3_CPGC = ?,RB3_CLFF = ?,RB3_RL = ?,RB3_PL = ?,RB3_FZR = ?,RB3_KZFF = ?,RB3_CZGF = ?,RB3_FYJH = ?,RB3_SJSJ = ?,RB3_GCSJ = ?,RB3_MJSJ = ?,RB3_TOOL_INSPECT = ?,RB3_SPECIAL = ?,RB3_SFWC = ?,RB3_HH = ?,RB3_HBDYG = ? where plmeid = \'%s\' +CONTROLPLANOPERATIONSELECT=select RB3_MEOPID,rb3_gybh from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and RB3_MEOPID is not null group by RB3_MEOPID,rb3_gybh +CONTROLPLANDELETE=delete from RB3_CONTROLPLAN where PLMEID = \'%s\' + +OPDIVISIONDIALOGSELECT=select processpuid,rb3_meopid,rb3_gybh,rb3_gcmc,rb3_user,rb3_inspectionuser,RB3_USER_NAME,RB3_INSPECTIONUSER_NAME from RB3_PERMISSIONS where PROCESSPUID = \'%s\' group by processpuid, rb3_meopid,rb3_gybh,rb3_gcmc,rb3_user,rb3_inspectionuser,RB3_USER_NAME,RB3_INSPECTIONUSER_NAME ORDER BY to_number(RB3_GYBH) +OPDIVISIONDIALOGUPDATE=UPDATE RB3_PERMISSIONS SET RB3_USER = ?,RB3_INSPECTIONUSER = ?,RB3_USER_NAME = ?,RB3_INSPECTIONUSER_NAME = ? WHERE PROCESSPUID = \'%s\' AND RB3_MEOPID = \'%s\' + +CONTROLSYNERGYSELECT=select wm_concat(rb3_meopid) as rb3_meopid,RB3_USER_ID from RB3_CONTROLSYNERGY_VIEW where PROCESSPUID = '\%s\' group by RB3_USER_ID +CONTROLSYNERGYUPDATE=UPDATE RB3_PERMISSIONS SET RB3_CONTROLPLANUSER = ? WHERE PLMEID = \'%s\' + +SETPFMEASELECT=SELECT * FROM RB3_PFMEA WHERE PROCESSPUID = \'%s\' order by to_number(RB3_GYBH),to_number(RB3_HH) +SETPFMEADELETE=delete from RB3_PFMEA where PLMEID = \'%s\' +SETPFMEASELECT2=SELECT RB3_MEOPID,RB3_REQUIREMENT from RB3_PFMEA where PROCESSPUID = \'%s\' group by RB3_MEOPID,rb3_gybh +SETPFMEAUPDATE=update RB3_PFMEA set RB3_GYBH = ?,RB3_STATION = ?,RB3_GCMC = ?,RB3_REQUIREMENT = ?,RB3_QZSXMS = ?,RB3_QZSXHG = ?,RB3_YZD = ?,RB3_JB = ?,RB3_QZSXQY = ?,RB3_XXGCKZYF = ?,RB3_PDS = ?,RB3_XXGCKZTC = ?,RB3_TCD = ?,RB3_RPN = ?,RB3_JYCS = ?,RB3_ZZR = ?,RB3_JHWCRQ = ?,RB3_CQDCS = ?,RB3_NEW_SEV = ?,RB3_NEW_OCC = ?,RB3_NEW_DET = ?,RB3_NEW_RPN = ?,RB3_IDEAL_STATE = ?,RB3_SPECIAL = ?,RB3_HH = ?,RB3_HBDYG = ? where plmeid = \'%s\' + + +TM2CONTROLPLANTREESELECT=select * from RB3_CONTROLPLAN_TREE ORDER BY TO_NUMBER(PARENT_ID) +CONTROLPLANLIBRARYSELECT=SELECT * FROM RB3_CONTROLPLAN_NODE WHERE PARENT_ID = \'%s\' order BY TO_NUMBER(replace(ID,chr(10),'')) +CONTROLPLANLIBRARYDELETE=delete from RB3_CONTROLPLAN_NODE where PLMEID = \'%s\' +CONTROLPLANLIBRARYUPDATE=update RB3_CONTROLPLAN_NODE set ID = ?, RB3_QPTBH = ?,RB3_CC = ?,RB3_NO = ?,RB3_CP = ?,RB3_GC = ?,RB3_TSTX = ?,RB3_CPGC = ?,RB3_CLFF = ?,RB3_RL = ?,RB3_PL = ?,RB3_FZR = ?,RB3_KZFF = ?,RB3_CZGF = ?,RB3_FYJH = ?,RB3_SJSJ = ?,RB3_GCSJ = ?,RB3_MJSJ = ?,RB3_SPECIAL = ? where plmeid = \'%s\' +CONTROLPLANLIBRARYINSERT=INSERT INTO RB3_CONTROLPLAN_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + +TM2PFMEATREESELECT=select * from RB3_PFMEA_TREE ORDER BY TO_NUMBER(PARENT_ID) +PFMEALIBRARYSELECT=SELECT * FROM RB3_PFMEA_NODE WHERE PARENT_ID = \'%s\' order BY TO_NUMBER(replace(ID,chr(10),'')) +PFMEALIBRARYDELETE=delete from RB3_PFMEA_NODE where PLMEID = \'%s\' +PFMEALIBRARYUPDATE=update RB3_PFMEA_NODE set ID = ?, RB3_STATION = ?,RB3_REQUIREMENT = ?,RB3_QZSXMS = ?,RB3_QZSXHG = ?,RB3_YZD = ?,RB3_JB = ?,RB3_QZSXQY = ?,RB3_XXGCKZYF = ?,RB3_PDS = ?,RB3_XXGCKZTC = ?,RB3_TCD = ?,RB3_RPN = ?,RB3_JYCS = ?,RB3_ZZR = ?,RB3_JHWCRQ = ?,RB3_CQDCS = ?,RB3_NEW_SEV = ?,RB3_NEW_OCC = ?,RB3_NEW_DET = ?,RB3_NEW_RPN = ?,RB3_IDEAL_STATE = ?,RB3_SPECIAL = ? where plmeid = \'%s\' +PFMEALIBRARYINSERT=INSERT INTO RB3_PFMEA_NODE VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) + + +CONTROLPLANOUTPUTSELECT =select t1.*,t2.rb3_user,t2.rb3_inspectionuser from rb3_controlplan t1 left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid where t1.RB3_MEOPID = \'%s\' and t1.type = \'%s\' order by to_number(t1.RB3_GYBH),to_number(t1.RB3_HH) + +!==============================================TMOM022================================================! +TM2THESAURUSTREESELECT=select * from RB3_THESAURUS_TREE ORDER BY TO_NUMBER(PARENT_ID) +TM2THESAURUSNODESELECT=SELECT * FROM RB3_THESAURUS_NODE WHERE PARENT_ID = \'%s\' order BY TO_NUMBER(replace(ID,chr(10),'')) +TM2THESAURUSNODEDELETE=delete from RB3_THESAURUS_NODE where PLMEID = \'%s\' +TM2THESAURUSNODEDUPDATE=update RB3_THESAURUS_NODE set ID = ?, RB3_VALUE = ? where plmeid = \'%s\' +TM2THESAURUSNODEDINSERT=INSERT INTO RB3_THESAURUS_NODE VALUES(?,?,?,?,?,?) + diff --git a/src/com/connor/renben/process/plm/tmom014/TMom014CheckCheckTableHandler.java b/src/com/connor/renben/process/plm/tmom014/TMom014CheckCheckTableHandler.java new file mode 100644 index 0000000..5746acb --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom014/TMom014CheckCheckTableHandler.java @@ -0,0 +1,143 @@ +package com.connor.renben.process.plm.tmom014; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom014CheckCheckTableHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + int operateCode = -1; + String fileSource = null; + switch (commandId) { + case "com.connor.renben.process.plm.commands.CheckCXSJTYCheckTableCommand": + operateCode = TMomFinalUtil.CXSJTY_CHECKTABLE; + fileSource="׼Լ¼ͨã.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckCXSJCNCCheckTableCommand": + operateCode = TMomFinalUtil.CXSJCNCZY_CHECKTABLE; + fileSource="׼Լ¼CNCרã.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckCXGCCheckTableCommand": + operateCode = TMomFinalUtil.CXGCJ_CHECKTABLE; + fileSource="ιԼ¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckCXMJCheckTableCommand": + operateCode = TMomFinalUtil.CXMJ_CHECKTABLE; + fileSource="ĩ¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckCXXJCheckTableCommand": + operateCode = TMomFinalUtil.CXXJ_CHECKTABLE; + fileSource="ιѲ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJZCheckTableCommand": + operateCode = TMomFinalUtil.ZX_CHECKTABLE; + fileSource="Ʒ¼׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJJGSJCheckTableCommand": + operateCode = TMomFinalUtil.JJGSJ_CHECKTABLE; + fileSource="ӹƲƷ׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJJGGCCheckTableCommand": + operateCode = TMomFinalUtil.JJGGCJ_CHECKTABLE; + fileSource="ӹƲƷ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJJGMJCheckTableCommand": + operateCode = TMomFinalUtil.JJGMJ_CHECKTABLE; + fileSource="ӹƲƷĩ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJJGHDSJCheckTableCommand": + operateCode = TMomFinalUtil.JJGHDSJ_CHECKTABLE; + fileSource="ӹƷ׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckJJGHDMJCheckTableCommand": + operateCode = TMomFinalUtil.JJGHDMJ_CHECKTABLE; + fileSource="ӹƷĩ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckMKSJCheckTableCommand": + operateCode = TMomFinalUtil.MKSJ_CHECKTABLE; + fileSource="ä׸Ӧ׼׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckMKGCCheckTableCommand": + operateCode = TMomFinalUtil.MKGCJ_CHECKTABLE; + fileSource="ä׸Ӧ̼¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckMKMJCheckTableCommand": + operateCode = TMomFinalUtil.MKMJ_CHECKTABLE; + fileSource="ä׸Ӧĩ¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckGXZLCheckTableCommand": + operateCode = TMomFinalUtil.GXZL_CHECKTABLE; + fileSource=".xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckZZCheckTableCommand": + operateCode = TMomFinalUtil.ZZ_CHECKTABLE; + fileSource="ռ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CheckCPZLCheckTableCommand": + operateCode = TMomFinalUtil.CPZL_CHECKTABLE; + fileSource="Ʒ.xlsx"; + break; + default: + break; + } + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + new TMom014CheckTableDialog(app, session, operateCode, fileSource); +// TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,operateCode, fileSource,null,false,"E:\\"); +// try { +// command.executeModal(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// MessageBox.post("ʧ", "", MessageBox.ERROR); +// } + return null; + } + public static ArrayList getCPGCMaxOrMix(String str) { + Pattern pattern = null; + if(str.contains("")) + pattern = Pattern.compile("\\d+.\\d+"); + else + if(str.contains(".")) + pattern = Pattern.compile("\\d+.\\d+"); + else + pattern = Pattern.compile("\\d"); + Matcher matcher = pattern.matcher(str); + ArrayList aClass = new ArrayList<>(); + while (matcher.find()) { + aClass.add(matcher.group()); + } + ArrayList date = new ArrayList<>(); + if(aClass.size()==2){ + float value1 = Float.valueOf(aClass.get(0)); + float value2 = Float.valueOf(aClass.get(1)); + DecimalFormat fnum = new DecimalFormat("##0.00"); + String max=fnum.format(value1+value2); + String min=fnum.format(value1-value2); + date.add(max); + date.add(min); + } + if(aClass.size()==1){ + date.add("0"); + date.add(aClass.get(0)); + } + else{ + date.add(" "); + date.add(" "); + } + return date; + } +} diff --git a/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableCommand.java b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableCommand.java new file mode 100644 index 0000000..f699c69 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableCommand.java @@ -0,0 +1,724 @@ +package com.connor.renben.process.plm.tmom014; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.connor.renben.process.plm.bean.CheckTable; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom014CheckTableCommand extends AbstractAIFCommand { + private TCSession session; + private AbstractAIFUIApplication app; + private String fileSource; + private int operateCode; + private TCComponentMEOPRevision item; + private boolean toTC; + private String url; + private String controlType; + private String controlPlanRev; + ArrayList data_List; + + + public TMom014CheckTableCommand(TCSession session, + AbstractAIFUIApplication app, int operateCode, String fileSource, TCComponentMEOPRevision item, boolean toTC, String url,String controlType) { + this.session = session; + this.app = app; + this.operateCode = operateCode; + this.fileSource = fileSource; + this.item = item; + this.toTC = toTC; + this.url = url; + this.controlType = controlType; + } + + @Override + public void executeModal() throws Exception { + String userName = this.session.getUserName();//owning_user + ResultSet ac_rs = null; + try { + if(item==null){ + InterfaceAIFComponent targetcomp = this.app.getTargetComponent(); + try { + item = (TCComponentMEOPRevision) targetcomp; + } catch (ClassCastException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ѡ汾󴫵ݣ", "", MessageBox.ERROR); + } + } + //鿴Ȩ + String ac_sql = "select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,nvl(rb3_user,' ') as rb3_user,nvl(RB3_INSPECTIONUSER,' ') as RB3_INSPECTIONUSER from RB3_PERMISSIONS where RB3_MEOPID='"+item.getProperty("item_id")+"'"; + System.out.println(ac_sql); + SqlUtilT.getTCConnection(); + ac_rs = SqlUtilT + .read(ac_sql); + String inspectionUser = null; + while(ac_rs.next()){ + inspectionUser = ac_rs.getString("RB3_INSPECTIONUSER"); + } + if((inspectionUser!=null&&session.getUserName().equals(inspectionUser))||session.getUserName().equals("admin")){ + TCUtils.openLogByPass(session, "鱨"); + TMomMethodUtil.setByPass(session, true); + } + TCAccessControlService tccs = session.getTCAccessControlService(); + String[] privileges = {"READ","WRITE","DELETE"}; + boolean[] have_privileges = tccs.checkPrivileges(item, privileges); + for(boolean have_privilege:have_privileges){ + if(toTC){ + if(!have_privilege){ + MessageBox.post("\""+item+"\"ûдȨޣ", "", MessageBox.ERROR); + return; + } + } + } + + String item_id = item.getProperty("item_id"); + System.out.println("item_id=>"+item_id); +// String controlType = "RB3_SSCKZJH"; + if(toTC){ + controlType = getControlType(); + } + if(controlType==null&&toTC){ + MessageBox.post("δҵѷĿƼƻ", "", MessageBox.WARNING); + return; + } + else{ + //ȡƼƻеļ + data_List = getCXDate(item_id,controlType,operateCode); + new Thread() { + @Override + public void run() { + session.queueOperation(new TMom014CheckTableOperation(app, session,operateCode,fileSource,item,toTC,url+fileSource,data_List)); + + + } + }.start(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + MessageBox.post(""+fileSource.split("\\.")[0]+"", "", MessageBox.ERROR); + + return; + } finally { + TCUtils.closeLogByPass(session, "鱨"); + TMomMethodUtil.setByPass(session, false); + if (ac_rs != null) { + com.connor.renben.process.plm.sql.util.SqlUtilT.free(ac_rs); + } + + com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); + } + + super.executeModal(); + } + + + + + /** + * + * @param item_id + * @param controlType + * @param operateCode + * @return + * @throws Exception + */ + private ArrayList getCXDate(String item_id, String controlType ,int operateCode) throws Exception { + boolean hava_minAndMax = false; + boolean is_rlAndPl = true; + String[] shousuobi_type = {"RB3_SJSJ","RB3_GCSJ","RB3_MJSJ"};//׼̼ĩ + String shousuobi = null; // + StringBuilder sql = + new StringBuilder() + .append("select PROCESSPUID,RB3_MEOPID,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff ,rb3_rl,rb3_pl,rb3_special,rb3_tstx,rb3_jqsb ,rb3_sjsj,rb3_gcsj,rb3_mjsj,rb3_hh ,rb3_fzr ,rb3_gcmc from rb3_controlplan where rb3_meopid='"+item_id+"' and type='"+controlType+"'") ;//and RB3_smjy like '%׼%'"; + switch (operateCode) { + case 0: + case 20: + hava_minAndMax = true; + shousuobi = shousuobi_type[0]; + sql.append(" and rb3_smjy like '%׼%'"); + break; + case 4: + hava_minAndMax = true; + shousuobi = shousuobi_type[0]; + sql.append(" and rb3_smjy like '%׼%' "); + break; + case 1: + hava_minAndMax = true; + shousuobi = shousuobi_type[1]; + sql.append(" and rb3_smjy like '%̼%'"); + break; + case 2: + hava_minAndMax = true; + shousuobi = shousuobi_type[2]; + sql.append(" and rb3_smjy like '%ĩ%'"); + break; + case 3: + hava_minAndMax = true; + shousuobi = shousuobi_type[1]; + sql.append(" and rb3_gcmc like '%飨%'"); + break; + case 5: + hava_minAndMax = true; + shousuobi = shousuobi_type[0]; + sql.append(" and rb3_smjy like '%׼%' and rb3_gc is null"); + break; + case 7: + hava_minAndMax = true; + shousuobi = shousuobi_type[2]; + sql.append(" and rb3_smjy like '%ĩ%' and rb3_gc is null"); + break; + case 6: + hava_minAndMax = true; + shousuobi = shousuobi_type[1]; + is_rlAndPl = false; + sql.append(" and rb3_smjy like '%̼%' and rb3_gc is null "); + break; + case 8: + hava_minAndMax = true; + shousuobi = shousuobi_type[0]; + sql.append(" and rb3_smjy like '%׼%' and rb3_cp is not null"); + break; + case 10: + hava_minAndMax = true; + shousuobi = shousuobi_type[2]; + sql.append(" and rb3_smjy like '%ĩ%' and rb3_cp is not null"); + break; + case 9: + hava_minAndMax = true; + shousuobi = shousuobi_type[1]; + is_rlAndPl = false; + sql.append(" and rb3_smjy like '%̼%' and rb3_cp is not null"); + break; + case 11: + case 16: + hava_minAndMax = true; + shousuobi = shousuobi_type[1]; + sql.append(" and (rb3_gcmc like '%飨%' or rb3_gcmc like '%\n%') and rb3_gc is null"); + break; + case 12: + hava_minAndMax = true; + shousuobi = shousuobi_type[1]; + sql.append(" and (rb3_gcmc like '%飨%' or rb3_gcmc like '%ռ%' or rb3_gcmc like '%ȫߴ%' or rb3_gcmc like '%ȫ%') and rb3_gc is null "); + break; + case 13: + hava_minAndMax = true; + shousuobi = shousuobi_type[1]; + sql.append(" and rb3_cp is not null"); + break; + case 14: + shousuobi = shousuobi_type[0]; + sql.delete(0, sql.length()); + sql.append("select distinct rb3_qptbh from (select rb3_qptbh,rb3_hh from rb3_controlplan where rb3_meopid='"+item_id+"' and type='"+controlType+"' and rb3_tool_inspect='1' and rb3_smjy like '%׼%'" ); + break; + case 15: + shousuobi = shousuobi_type[2]; + sql.delete(0, sql.length()); + sql.append("select distinct rb3_qptbh from (select rb3_qptbh,rb3_hh from rb3_controlplan where rb3_meopid='"+item_id+"' and type='"+controlType+"' and rb3_tool_inspect='1' and rb3_smjy like '%ĩ%'"); + break; + default: + break; + } + sql.append(" and rb3_qptbh is not null order by rb3_hh"); + if(operateCode == 14 || operateCode == 15) + sql.append(")"); + System.out.println(sql.toString()); + ResultSet rs = null; + com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); + ArrayList shousuobi_list = new ArrayList<>(); + try { + rs = com.connor.renben.process.plm.sql.util.SqlUtilT + .read(sql.toString()); + ArrayList> data = new ArrayList<>(); + + ArrayList checkTables = new ArrayList<>(); + String meopId = null; +// if(rs.next()){ + meopId = item_id; + +// } +// rs = com.connor.renben.process.plm.sql.util.SqlUtilT +// .read(sql.toString()); + + + if(operateCode==0||operateCode==2||operateCode==4){ + while(rs.next()){ + CheckTable checkTable = new CheckTable(); + if(operateCode==4) + checkTable.setType("0"); + else + checkTable.setType(String.valueOf(operateCode)); + checkTable.setMeopId(meopId); + ArrayList arr = new ArrayList<>(); + String qptbh = getDate(rs.getString("RB3_QPTBH")); + + String cp = getDate(rs.getString("RB3_CP")); + arr.add(cp); + + checkTable.setCp(cp); + checkTable.setSerialNo(qptbh); + + int num = 1; + // ҪΪ:x-x ιԼ¼/ιѲ ֶ + if(rs.getString("RB3_CPGC").indexOf("-") != -1){ + String ss = getNum(rs.getString("RB3_CPGC").split("-")[0]); + if(ss.matches("\\d+")){ + num = Integer.valueOf(ss); + } + } + + + String cpgc = getDate(rs.getString("RB3_CPGC"))+"special"+rs.getString("RB3_SPECIAL"); + arr.add(cpgc); + arr.add(qptbh); + + String clff = getDate(rs.getString("RB3_CLFF")); + String fzr = getDate(rs.getString("RB3_FZR")); + String rl = getDate(rs.getString("RB3_RL")); + String pl = getDate(rs.getString("RB3_PL")); + String hh = getDate(rs.getString("RB3_HH")); + String tstx = getDate(rs.getString("RB3_TSTX")); + + + + checkTable.setClff(clff); + checkTable.setFzr(fzr); + checkTable.setRl(rl); + checkTable.setPl(pl); + checkTable.setHh(hh); + checkTable.setTstx(tstx); + //װ +// if(shousuobi != null && !shousuobi.isEmpty()) +// shousuobi_list.add(getDate(rs.getString(shousuobi))); + + if(shousuobi != null && !shousuobi.isEmpty()){ + for(int i = 0 ; i < num ; i++){ + shousuobi_list.add(getDate(rs.getString(shousuobi))); + } + } + if(num==1){ + data.add(arr); + checkTables.add(checkTable); + } + + else + { + for(int i = 0 ; i < num ; i++){ + ArrayList arr1 = (ArrayList) arr.clone(); + String qp = arr1.get(arr1.size()-1); + arr1.remove(arr1.size()-1); + arr1.add(qp+"-"+(i+1)); + data.add(arr1); + + CheckTable checkTable1 = new CheckTable(); + checkTable1 = checkTable.clone(); + checkTable1.setSerialNo(qp+"-"+(i+1)); + checkTables.add(checkTable1); + + } + + } + + + //data.add(arr); + //checkTables.add(checkTable); + + + } + } + if(operateCode==1||operateCode==3||operateCode==6||operateCode==9||operateCode==11||operateCode==12||operateCode==20||operateCode==16){ + int rowCount = 0; + while(rs.next()){ + rowCount++; + ArrayList arr = new ArrayList<>(); + CheckTable checkTable = new CheckTable(); + if(operateCode==20){ + checkTable.setType("0"); + } + else if(operateCode == 9||operateCode == 6){ + checkTable.setType("1"); + } + else if(operateCode == 16){ + checkTable.setType("11"); + } + else + checkTable.setType(String.valueOf(operateCode)); + if(checkTable.getMeopId()!="") + checkTable.setMeopId(meopId); + + //String cpgc = rs.getString("RB3_CPGC"); + int num = 1; + // ҪΪ:x-x ιԼ¼/ιѲ ֶ + if((operateCode==1 || operateCode==3 || operateCode==6 || operateCode==11 || operateCode==12 || operateCode==20) && rs.getString("RB3_CPGC") != null && rs.getString("RB3_CPGC").indexOf("-") != -1){ + String ss = getNum(rs.getString("RB3_CPGC").split("-")[0]); + if(ss.matches("\\d+")){ + num = Integer.valueOf(ss); + } +// if(!ss.equals("0")){ +// cpgc = cpgc.substring(ss.length()+1, cpgc.length()); +// if (ss.matches("\\d+")) { +// num = Integer.valueOf(ss); +// } +// } + + } + String cp = getDate(rs.getString("RB3_CP")); + arr.add(cp); + + + checkTable.setCp(cp); + //arr.add(cpgc); + arr.add(getDate(rs.getString("RB3_CPGC"))+"special"+rs.getString("RB3_SPECIAL")); + + String clff = getDate(rs.getString("RB3_CLFF")); + arr.add(clff); + + checkTable.setClff(clff); + + String rl = getDate(rs.getString("RB3_RL")); + String pl = getDate(rs.getString("RB3_PL")); + if(is_rlAndPl) + arr.add( rl + "/" + pl); + else{ + arr.add(rl); + arr.add(pl); + } + + checkTable.setRl(rl); + checkTable.setPl(pl); + + String tstx = getDate(rs.getString("RB3_TSTX")); + arr.add(tstx); + + checkTable.setTstx(tstx); + + String rb3_qptbh = rs.getString("RB3_QPTBH"); + if(operateCode!=9){ + arr.add(getDate(rb3_qptbh)); + } + + checkTable.setSerialNo(rb3_qptbh); + + String fzr = getDate(rs.getString("RB3_FZR")); + checkTable.setFzr(fzr); + + String hh = getDate(rs.getString("RB3_HH")); + checkTable.setHh(hh); + + if(shousuobi != null && !shousuobi.isEmpty()){ + for(int i = 0 ; i < num ; i++){ + shousuobi_list.add(getDate(rs.getString(shousuobi))); + } + } + if(num==1){ + data.add(arr); + checkTables.add(checkTable); + } + + else + if(operateCode!=9){ + for(int i = 0 ; i < num ; i++){ + ArrayList arr1 = (ArrayList) arr.clone(); + String qp = arr1.get(arr1.size()-1); + arr1.remove(arr1.size()-1); + arr1.add(qp+"-"+(i+1)); + data.add(arr1); + + CheckTable checkTable1 = new CheckTable(); + checkTable1 = checkTable.clone(); + checkTable1.setSerialNo(qp+"-"+(i+1)); + checkTables.add(checkTable1); + + } + }else{ + for(int i = 0 ; i < num ; i++){ + CheckTable checkTable1 = checkTable.clone(); + checkTable1.setSerialNo(checkTable.getSerialNo()+"-"+i); + checkTables.add(checkTable1); + } + } + } + System.out.println("rowCount:" + rowCount); + } + if(operateCode==5||operateCode==7||operateCode==8||operateCode==10||operateCode==13){ + while(rs.next()){ + CheckTable checkTable = new CheckTable(); + if(operateCode==8||operateCode==5) + checkTable.setType("0"); + else if(operateCode == 10||operateCode==7){ + checkTable.setType("2"); + } + else + checkTable.setType(String.valueOf(operateCode)); + if(checkTable.getMeopId()!="") + checkTable.setMeopId(meopId); + int num = 1; + ArrayList arr = new ArrayList<>(); + if((operateCode==5 || operateCode==7 || operateCode == 13) &&rs.getString("RB3_CPGC").indexOf("-") != -1){ + String ss = getNum(rs.getString("RB3_CPGC").split("-")[0]); + if(ss.matches("\\d+")){ + num = Integer.valueOf(ss); + } + } + + String cp = getDate(rs.getString("RB3_CP")); + String clff = getDate(rs.getString("RB3_CLFF")); + String tstx = getDate(rs.getString("RB3_TSTX")); + String qptbh = getDate(rs.getString("RB3_QPTBH")); + String fzr = getDate(rs.getString("RB3_FZR")); + String hh = getDate(rs.getString("RB3_HH")); + String rl = getDate(rs.getString("RB3_RL")); + String pl = getDate(rs.getString("RB3_PL")); + arr.add(cp); + arr.add(getDate(rs.getString("RB3_CPGC"))+"special"+rs.getString("RB3_SPECIAL")); + arr.add(clff); + arr.add(tstx); + if(operateCode==5||operateCode==7||operateCode==13) + arr.add(qptbh); + checkTable.setCp(cp); + checkTable.setClff(clff); + checkTable.setTstx(tstx); + checkTable.setSerialNo(qptbh); + checkTable.setFzr(fzr); + checkTable.setHh(hh); + checkTable.setRl(rl); + checkTable.setPl(pl); + if(shousuobi != null && !shousuobi.isEmpty()) + for(int i = 0 ; i < num ; i++){ + shousuobi_list.add(getDate(rs.getString(shousuobi))); + } + if(num==1){ + data.add(arr); + checkTables.add(checkTable); + } + else + if(operateCode==5||operateCode==7||operateCode==13){ + for(int i = 0 ; i < num ; i++){ + ArrayList arr1 = (ArrayList) arr.clone(); + String qp = arr1.get(arr1.size()-1); + arr1.remove(arr1.size()-1); + arr1.add(qp+"-"+(i+1)); + data.add(arr1); + CheckTable checkTable1 = new CheckTable(); + checkTable1 = checkTable.clone(); + checkTable1.setSerialNo(qp+"-"+(i+1)); + checkTables.add(checkTable1); + } + }else{ + for(int i = 0 ; i < num ; i++){ + CheckTable checkTable1 = checkTable.clone(); + checkTable1.setSerialNo(checkTable.getSerialNo()+"-"+i); + checkTables.add(checkTable1); + } + } + } + } + if(operateCode == 14 || operateCode == 15){ + StringBuffer qptbhs = new StringBuffer(); + while(rs.next()){ + qptbhs.append(rs.getString("RB3_QPTBH")+","); + } + qptbhs.deleteCharAt(qptbhs.length()-1); + String hd_sql = "select rb3_qptbh,rb3_tstx,rb3_cp,rb3_cpgc,rb3_clff,rb3_smjy ,rb3_hh ,rb3_gcmc from rb3_controlplan where rb3_meopid='"+item_id+"' and type='"+controlType+"' and rb3_qptbh in ("+qptbhs+") and rb3_smjy like '%"+(shousuobi.equals("RB3_SJSJ")?"׼":"ĩ")+"%'"; + System.out.println("hd_sql=====>"+hd_sql.toString()); + rs = com.connor.renben.process.plm.sql.util.SqlUtilT.read(hd_sql.toString()); + while(rs.next()){ + CheckTable checkTable = new CheckTable(); + checkTable.setType(String.valueOf(operateCode)); + checkTable.setMeopId(meopId); + ArrayList arr = new ArrayList<>(); + String qptbh = rs.getString("RB3_QPTBH"); + String cpgc = rs.getString("rb3_cpgc"); + String tstx = rs.getString("RB3_TSTX"); + String cp = rs.getString("RB3_CP"); + String clff = rs.getString("RB3_CLFF"); + String hh = getDate(rs.getString("RB3_HH")); + + + + arr.add(getDate(qptbh)); + arr.add(getDate(tstx)); + arr.add(getDate(cp)); + arr.add(getDate(cpgc)); + arr.add(getDate(clff)); + + checkTable.setSerialNo(qptbh); + checkTable.setTstx(tstx); + checkTable.setCp(cp); + checkTable.setCpgc(cpgc); + checkTable.setClff(clff); + checkTable.setHh(hh); + checkTables.add(checkTable); + data.add(arr); + + + } + } + + ArrayList data_list = new ArrayList<>(); + data_list.add(data); + data_list.add(hava_minAndMax); + data_list.add(shousuobi_list); + data_list.add(checkTables); + return data_list; + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + com.connor.renben.process.plm.sql.util.SqlUtilT.free(rs); + } + com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); + } + return null; + } + private String getDate(String str){ + if(str!=null) + { + if(str.indexOf("\n") > 0 && str.indexOf("\r") > 0) + { + return str.split("\n")[0].split("\r")[0].replace(" ", ""); + } + else if(str.indexOf("\n") > 0) + { + System.out.println("ֻس" + str); + return str.split("\n")[0].replace(" ", ""); + } + else if(str.indexOf("\r") > 0) + { + System.out.println("ֻƱ" + str); + return str.split("\r")[0].replace(" ", ""); + } + else + { + System.out.println("ʲô" + str); + return str; + } + } + return " "; + } + /** + * жַǷ + * @param content + * @return + */ + private boolean hasDigit(String content) { + boolean flag = false; + Pattern p = Pattern.compile(".*\\d+.*"); + Matcher m = p.matcher(content); + if (m.matches()) { + flag = true; + } + return flag; + } + /** + * ȡµĿƼƻ + * @param item ѡеĹ + * @return + * @throws Exception + */ + private String getControlType() throws Exception { + String kzjhType = null; + TCComponent[] its = item.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponentItemRevision tccir = (TCComponentItemRevision) its[0]; + AIFComponentContext[] aifccs = tccir.whereReferenced(); + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEProcess) { + TCComponentMEProcess tccmep = (TCComponentMEProcess) aifcc_MEOP.getComponent(); + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + String itemType = null; + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + itemType = kzjh.getType(); + if(toTC){ + if ("RB3_SCKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjh.getReleasedItemRevisions().length!=0){ + kzjhType=itemType; + controlPlanRev = kzjh.getLatestItemRevision().getProperty("item_revision_id"); + } + + if ("RB3_SSCKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjh.getReleasedItemRevisions().length!=0) + if(!"RB3_SCKZJH".equals(kzjhType)){ + kzjhType=itemType; + controlPlanRev = kzjh.getLatestItemRevision().getProperty("item_revision_id"); + } + + if ("RB3_YJKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjh.getReleasedItemRevisions().length!=0) + if(kzjhType==null){ + kzjhType=itemType; + controlPlanRev = kzjh.getLatestItemRevision().getProperty("item_revision_id"); + } + + } + else{ + if ("RB3_SCKZJH".equals(itemType)) + //жǷΪƼƻ + kzjhType=itemType; + + if ("RB3_SSCKZJH".equals(itemType)) + //жǷΪƼƻ + if(!"RB3_SCKZJH".equals(kzjhType)) + kzjhType=itemType; + + if ("RB3_YJKZJH".equals(itemType)) + //жǷΪƼƻ + if(kzjhType==null) + kzjhType=itemType; + + } + } + + + } + } + } + return kzjhType; + } + private static String getNum(String str) { + Pattern p = Pattern.compile("(\\d+\\.\\d+)"); + //MatcherĹ췽Ҳ˽е,ⴴ,ֻͨPattern.matcher(CharSequence input)õʵ. + Matcher m = p.matcher(str); + //m.findжϸַǷ"(\\d+\\.\\d+)"ƥӴ + if (m.find()) { + //ƥ,жǷΪnull + //group()еIJ0ʾƥ1ʾƥһŵ,2ʾƥڶ,ֻһ,10һ + str = m.group(1) == null ? "" : m.group(1); + } else { + //ƥ䲻Сͽƥ + p = Pattern.compile("(\\d+)"); + m = p.matcher(str); + if (m.find()) { + //ƥ + str = m.group(1) == null ? "" : m.group(1); + } else { + //ûСƥ,ַûСΪ + str = ""; + } + } + return str; + } +} diff --git a/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableDialog.java b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableDialog.java new file mode 100644 index 0000000..dcd1f77 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableDialog.java @@ -0,0 +1,258 @@ +package com.connor.renben.process.plm.tmom014; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; +import java.util.ResourceBundle; + +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.connor.renben.process.plm.bean.CXListBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +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 TMom014CheckTableDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFUIApplication app; + private TCSession session; + private int operateCode; + private String fileSource; + private TCComponentMEOPRevision item; + + + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private JPanel panel1; + private JPanel panel2; + private JPanel panel3; + private JRadioButton radioBtn1; + private JRadioButton radioBtn2; + private ButtonGroup bg; + private JPanel rootPanel; + private boolean have_ssckzjh; + private boolean have_sckzjh; + + public TMom014CheckTableDialog() { + super(false); + } + + public TMom014CheckTableDialog(AbstractAIFUIApplication app, + TCSession session, int operateCode, String fileSource) { + super(false); + this.app = app; + this.session = session; + this.operateCode = operateCode; + this.fileSource = fileSource; +// this.item = item; + + + init(); + + } + + public void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + getControlType(); + this.setTitle(rb.getString("dc_display.TITLE")+fileSource.split("\\.")[0]); + this.setPreferredSize(new Dimension(480, 150)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + okButton = new JButton(rb.getString("qd_display.TITLE")); + celButton = new JButton(rb.getString("qx_display.TITLE")); + fileButton = new JButton("..."); + radioBtn1 = new JRadioButton(rb.getString("ssckzjh_display.TITLE"),true); + radioBtn2 = new JRadioButton(rb.getString("sckzjh_display.TITLE")); + ButtonGroup bg = new ButtonGroup(); + bg.add(radioBtn1); + bg.add(radioBtn2); + + fileButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + selectFileButtonEvent(e); + } + }); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + try { + okEvent(e); +// MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + } catch (IOException e1) { + MessageBox.post("ʧ", "ʧ", MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + celEvent(e); + } + }); + pathText = new JTextField(30); + pathText.setText("C:"); + panel1 = new JPanel(new PropertyLayout()); + panel1.add("1.1.right.top.preferred.preferred", new JLabel(" ")); + panel1.add("2.1.right.top.preferred.preferred", new JLabel(rb.getString("xzwjj_display.TITLE"))); + panel1.add("2.2.left.top.preferred.preferred", pathText); + panel1.add("2.3.left.top.preferred.preferred", fileButton); + panel2 = new JPanel(new FlowLayout()); + panel2.add(okButton); + panel2.add(new JLabel(" ")); + panel2.add(celButton); + if(have_ssckzjh&&have_sckzjh){ + panel3 = new JPanel(new FlowLayout()); + panel3.add(radioBtn1); + panel3.add(radioBtn2); + } + + rootPanel = new JPanel(new BorderLayout()); + rootPanel.add(panel1, BorderLayout.CENTER); + rootPanel.add(panel2, BorderLayout.SOUTH); + if(have_ssckzjh&&have_sckzjh){ + rootPanel.add(panel3, BorderLayout.NORTH); + } + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + /** + * ȷťҵ¼ + * + * @param e + * @throws IOException + */ + public void okEvent(ActionEvent e) throws IOException { + String kzjhType = null; + if(have_ssckzjh&&have_sckzjh) + kzjhType = this.radioBtn1.isSelected()?"RB3_SSCKZJH":"RB3_SCKZJH"; + else if(have_ssckzjh) + kzjhType = "RB3_SSCKZJH"; + else{ + kzjhType = "RB3_SCKZJH"; + } + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,operateCode, fileSource,item,false,this.pathText.getText()+"\\",kzjhType); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + this.dispose(); + } + /** + * ȡťҵ¼ + * + * @param e + */ + public void celEvent(ActionEvent e) { + + 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()); + } + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private void getControlType() { + try { + String kzjhType = null; + InterfaceAIFComponent targetcomp = this.app.getTargetComponent(); + try { + item = (TCComponentMEOPRevision) targetcomp; + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ѡ汾󴫵ݣ", "", MessageBox.ERROR); + e.printStackTrace(); + } + TCComponent[] its = item.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponentItemRevision tccir = (TCComponentItemRevision) its[0]; + AIFComponentContext[] aifccs = tccir.whereReferenced(); + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEProcess) { + TCComponentMEProcess tccmep = (TCComponentMEProcess) aifcc_MEOP.getComponent(); + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + + if ("RB3_SCKZJH".equals(itemType)){ + +// //жǷΪƼƻ +// kzjhType=itemType; + have_sckzjh = true; + } + if ("RB3_SSCKZJH".equals(itemType)) { + //жǷΪƼƻ + if(!"RB3_SCKZJH".equals(kzjhType)) +// kzjhType=itemType; + have_ssckzjh = true; + } + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableHandler.java b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableHandler.java new file mode 100644 index 0000000..bc5b7b0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableHandler.java @@ -0,0 +1,112 @@ +package com.connor.renben.process.plm.tmom014; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom014CheckTableHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + int operateCode = -1; + String fileSource = null; + switch (commandId) { + case "com.connor.renben.process.plm.commands.CXSJTYCheckTableCommand": + operateCode = TMomFinalUtil.CXSJTY_CHECKTABLE; + fileSource="׼Լ¼ͨã.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CXSJCNCCheckTableCommand": + operateCode = TMomFinalUtil.CXSJCNCZY_CHECKTABLE; + fileSource="׼Լ¼CNCרã.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CXGCCheckTableCommand": + operateCode = TMomFinalUtil.CXGCJ_CHECKTABLE; + fileSource="ιԼ¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CXMJCheckTableCommand": + operateCode = TMomFinalUtil.CXMJ_CHECKTABLE; + fileSource="ĩ¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CXXJCheckTableCommand": + operateCode = TMomFinalUtil.CXXJ_CHECKTABLE; + fileSource="ιѲ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JZCheckTableCommand": + operateCode = TMomFinalUtil.ZX_CHECKTABLE; + fileSource="Ʒ¼׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JJGSJCheckTableCommand": + operateCode = TMomFinalUtil.JJGSJ_CHECKTABLE; + fileSource="ӹƲƷ׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JJGGCCheckTableCommand": + operateCode = TMomFinalUtil.JJGGCJ_CHECKTABLE; + fileSource="ӹƲƷ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JJGMJCheckTableCommand": + operateCode = TMomFinalUtil.JJGMJ_CHECKTABLE; + fileSource="ӹƲƷĩ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JJGHDSJCheckTableCommand": + operateCode = TMomFinalUtil.JJGHDSJ_CHECKTABLE; + fileSource="ӹƷ׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.JJGHDMJCheckTableCommand": + operateCode = TMomFinalUtil.JJGHDMJ_CHECKTABLE; + fileSource="ӹƷĩ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.MKSJCheckTableCommand": + operateCode = TMomFinalUtil.MKSJ_CHECKTABLE; + fileSource="ä׸Ӧ׼׼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.MKGCCheckTableCommand": + operateCode = TMomFinalUtil.MKGCJ_CHECKTABLE; + fileSource="ä׸Ӧ̼¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.MKMJCheckTableCommand": + operateCode = TMomFinalUtil.MKMJ_CHECKTABLE; + fileSource="ä׸Ӧĩ¼.xlsx"; + break; + case "com.connor.renben.process.plm.commands.GXZLCheckTableCommand": + operateCode = TMomFinalUtil.GXZL_CHECKTABLE; + fileSource="(ʱ).xlsx"; + break; + case "com.connor.renben.process.plm.commands.GXZLPCCheckTableCommand": + operateCode = TMomFinalUtil.GXZLPC_CHECKTABLE; + fileSource="().xlsx"; + break; + case "com.connor.renben.process.plm.commands.ZZCheckTableCommand": + operateCode = TMomFinalUtil.ZZ_CHECKTABLE; + fileSource="ռ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.CPZLCheckTableCommand": + operateCode = TMomFinalUtil.CPZL_CHECKTABLE; + fileSource="Ʒ.xlsx"; + break; + default: + break; + } + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom014CheckTableCommand command = new TMom014CheckTableCommand(session, app,operateCode, fileSource,null,true,"D:\\",null); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ʧ", "", MessageBox.ERROR); + } + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableOperation.java b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableOperation.java new file mode 100644 index 0000000..83f73d6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom014/TMom014CheckTableOperation.java @@ -0,0 +1,1200 @@ +package com.connor.renben.process.plm.tmom014; + +import java.io.BufferedInputStream; +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.io.OutputStream; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.IndexedColors; +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.XSSFDataFormat; +import org.apache.poi.xssf.usermodel.XSSFFont; +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.connor.renben.process.plm.bean.CheckTable; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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 TMom014CheckTableOperation extends AbstractAIFOperation { + + @SuppressWarnings("unused") + private AbstractAIFUIApplication app; + private TCSession session; + private int operateCode; + private String fileSource; + private String objectName; + private Map map = new HashMap<>(); + private TCComponentMEOPRevision item; + private boolean toTC; + private String fileOutUrl; + private ArrayList data_List; + private static String after_shousuo; + @SuppressWarnings("unused") + private static int position; + + public TMom014CheckTableOperation(AbstractAIFUIApplication app, + TCSession session, int operateCode, String fileSource, TCComponentMEOPRevision item, boolean toTC, String fileOutUrl, ArrayList data_List) { + this.app = app; + this.session = session; + this.operateCode = operateCode; + this.fileSource = fileSource; + this.item = item; + this.toTC = toTC; + this.fileOutUrl = fileOutUrl; + this.data_List = data_List; + } + @Override + public void executeOperation() throws Exception { + getProductProp(); + if(toTC) + createCXZYZDS(); + else{ + //updateCheckTable(); + File newFile = new File(TMomMethodUtil.getFile(session, fileSource.split("\\.")[0], "MSExcelX").getPath()); + InputStream is = new FileInputStream(newFile); + byte[] model_file_byte = new byte[is.available()]; + is.read(model_file_byte); + is.close(); + OutputStream os = new FileOutputStream(fileOutUrl); + os.write(model_file_byte); + os.close(); + if(operateCode!=0&&operateCode!=1&&operateCode!=2&&operateCode!=3&&operateCode!=11&&operateCode!=12&&operateCode!=13&&operateCode!=16){ + map.put("汾", " "); + } + File model_flie = new File(fileOutUrl); + writeToFile(model_flie,true); + writeExcelWithCellName(model_flie,fileOutUrl,getProductProp()); + } + System.out.println("over"); + TCUtils.closeLogByPass(session, "鱨"); + TMomMethodUtil.setByPass(session, false); + } +/** + * + * @throws Exception + */ +private Map getProductProp(){ + // TODO Auto-generated method stub + try { + String meop_id = item.getProperty("item_id"); + String meop_name = item.getProperty("object_name"); + map.put("", meop_name.split("/")[0]); + + TCComponent itemRevM = item.getRelatedComponents("IMAN_master_form_rev")[0]; + if(operateCode==9&&operateCode==10){ + map.put("ӹ", itemRevM.getProperty("jgcx")); + if(operateCode==9){ + map.put("Ȧͺ", itemRevM.getProperty("rb3_xqxh")); + } + } + map.put("ͼֽ", itemRevM.getProperty("rb3_gytz")); + TCComponent[] its; + its = item.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponentItemRevision tccir= (TCComponentItemRevision) its[0]; + AIFComponentContext[] emopRev_aifccs = item.whereReferenced(); + AIFComponentContext emopRev_aifcc = emopRev_aifccs[0]; + TCComponentItem emop_item = (TCComponentItem) emopRev_aifcc.getComponent(); + map.put("ձ",emop_item.getProperty("rb3_id")); + AIFComponentContext[] aifccs = tccir.whereReferenced(); + for(AIFComponentContext aifcc_MEOP:aifccs){ + TCComponentMEProcess tccmep = (TCComponentMEProcess) aifcc_MEOP.getComponent(); + if(operateCode !=1 && operateCode !=3 && operateCode != 4 && operateCode != 10 && operateCode != 12 && operateCode != 13){ + getMEToolList(map, tccmep, meop_id); + } + AIFComponentContext[] aifcc_MEPs = tccmep.whereReferenced(); + for(AIFComponentContext aifcc_MEP:aifcc_MEPs){ + String aifcc_MEP_Type = aifcc_MEP.getComponent().getType(); + if("RB3_Product".equals(aifcc_MEP_Type)){ + TCComponentItem product = (TCComponentItem) aifcc_MEP.getComponent(); + objectName = product.getProperty("item_id"); + + map.put("Ʒͺ", objectName); + map.put("Ʒ", product.getProperty("object_name")); + Date date = new Date(); + SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd"); + map.put("", format1.format(date.getTime())); +// for(String key :map.keySet()){ +// System.out.println(key+"=>"+map.get(key)); +// } + return map; + } + } + break; + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch(Exception e){ + e.printStackTrace(); + MessageBox.post("ѡ󴫵ݣ", "", MessageBox.ERROR); + } + return map; + } + + private void createCXZYZDS() { + try { + if(operateCode!=11&&operateCode!=12&&operateCode!=13&&operateCode!=16){ + TCComponent[] zyzdss = item + .getRelatedComponents("RB3_zuoyezhidaoshu"); + boolean have_checkTable = false; + for (TCComponent zyzds : zyzdss) { + if ("RB3_Check_table".equals(zyzds.getType())&&fileSource.split("\\.")[0].equals(zyzds.getProperty("object_name"))) { + TCComponentItem zyzds_final = (TCComponentItem) zyzds; + outputExcel(zyzds_final); + have_checkTable = true; + } + } + if(!have_checkTable){ + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("Item"); + TCComponentType uom = this.session.getTypeComponent("UnitOfMeasure"); + TCComponent[] uoms = uom.extent(); + TCComponentItem newItem = ccomponentitemtype.create(ccomponentitemtype.getNewID(),"00","RB3_Check_table",fileSource.split("\\.")[0],"",uoms[0]); + item.add("RB3_zuoyezhidaoshu", newItem); + outputExcel(newItem); + } + } + else{ + if(operateCode==11||operateCode==12||operateCode==13||operateCode==16){ + TCComponent[] zyzdss = item + .getRelatedComponents("RB3_xjbb"); + boolean have_checkTable = false; + for (TCComponent zyzds : zyzdss) { + if ("RB3_Check_table".equals(zyzds.getType())&&fileSource.split("\\.")[0].equals(zyzds.getProperty("object_name"))) { + TCComponentItem zyzds_final = (TCComponentItem) zyzds; + outputExcel(zyzds_final); + have_checkTable = true; + } + } + if(!have_checkTable){ + TCComponentItemType ccomponentitemtype = (TCComponentItemType)session.getTypeComponent("Item"); + TCComponentType uom = this.session.getTypeComponent("UnitOfMeasure"); + TCComponent[] uoms = uom.extent(); + TCComponentItem newItem = ccomponentitemtype.create(ccomponentitemtype.getNewID(),"00","RB3_Check_table",fileSource.split("\\.")[0],"",uoms[0]); + item.add("RB3_xjbb", newItem); + outputExcel(newItem); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + /** + * 鱨Excel + * @param item + * @throws TCException + * @throws IOException + */ + private void outputExcel(TCComponentItem item) throws Exception{ + + AIFComponentContext[] zyzdsChildrens = item.getLatestItemRevision().getChildren(); + TCComponentItemRevision zyzdsRev = item.getLatestItemRevision(); + boolean have_Excel = false; + for(AIFComponentContext zyzdsChildren:zyzdsChildrens){ + if("MSExcelX".equals(zyzdsChildren.getComponent().getType())){ + have_Excel = true; +// int getconfir = ConfirmationDialog.post(" ", fileSource.split("\\.")[0]+"ѴڣǷ񸲸ǣ"); +// if(getconfir == ConfirmationDialog.YES){ + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + writeToFile(tcFile[0].getFmsFile(),false); + + new Thread(){ + @Override + public void run() { + //updateCheckTable(); + } + }.start();; +// } +// else +// return; + } + } + if(!have_Excel){ + File newFile = new File(TMomMethodUtil.getFile(session, fileSource.split("\\.")[0], "MSExcelX").getPath()); + InputStream is = new FileInputStream(newFile); + byte[] model_file_byte = new byte[is.available()]; + is.read(model_file_byte); + is.close(); + OutputStream os = new FileOutputStream(fileOutUrl); + os.write(model_file_byte); + os.close(); + + setVersionNum(zyzdsRev); + File model_flie = new File(fileOutUrl); + writeToFile(model_flie,true); + + new Thread(){ + @Override + public void run() { + //updateCheckTable(); + } + }.start();; + + writeExcelWithCellName(model_flie,fileOutUrl,getProductProp()); + +// String as1[] = { fileOutUrl};// ļ· + String as2[] = { "excel" }; + String as3[] = { "MSExcelX" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType + .create(fileSource, "excel", + "MSExcelX"); + tccomponentDataset.setFiles(new String[]{fileOutUrl}, as3, as4, as2); + item.getLatestItemRevision().add("TC_Attaches",tccomponentDataset); + new File(fileOutUrl).delete(); + + } + } + protected void updateCheckTable() { + int version = 0; + @SuppressWarnings("unchecked") + ArrayList cts = (ArrayList)data_List.get(3); + InputStream input = new BufferedInputStream(TMom014CheckTableOperation.class.getResourceAsStream( + "sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ȡݿ + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs1 = null; + String sql = null; + + for(CheckTable ct:cts){ + System.out.println(ct); + } + + if(cts.size() !=0 ){ + String WHERE = "where RB3_PRODUCT_ID = '"+map.get("Ʒͺ")+"' and rb3_meop_id = '"+cts.get(0).getMeopId()+"' and rb3_type = '"+cts.get(0).getType()+"'"; + sql = "select * from rb3_check_table " + WHERE; + String latestVersion_sql = "select max(rb3_version) rb3_version from rb3_check_table " + WHERE; + System.out.println(sql); + try { + rs = SqlUtilT.read(sql); + rs1 = SqlUtilT.read(latestVersion_sql); + + while(rs1.next()){ + String s_version = rs1.getString("RB3_VERSION"); + if(s_version!=null){ + version = Integer.valueOf(s_version); + String deleteSql = "delete from rb3_check_table where RB3_PRODUCT_ID = '"+map.get("Ʒͺ")+"' and rb3_meop_id = '"+cts.get(0).getMeopId()+"' and rb3_type = '"+cts.get(0).getType()+"' and rb3_version = '" + version + "'"; + System.out.println("deleteSql==============>"+deleteSql); + SqlUtilT.delete(deleteSql); + version++; + } + break; + } + + + String insertSQL = pro.getProperty("INSERTCHECKTABLESQL"); + System.out.println(insertSQL); + for(int i = 0; i < cts.size() ; i++){ + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + map.get("Ʒͺ"), + map.get("Ʒ"), + cts.get(i).getMeopId(), + map.get(""), + cts.get(i).getSerialNo(), + cts.get(i).getCp(), + cts.get(i).getCpgc(), + cts.get(i).getMax(), + cts.get(i).getMin(), + cts.get(i).getClff(), + cts.get(i).getRl(), + cts.get(i).getPl(), + cts.get(i).getTstx(), + cts.get(i).getType(), + String.valueOf(version), + cts.get(i).getFzr(), + map.get("ձ"), + cts.get(i).getHh(), + map.get("ͼֽ"), + "" + }, insertSQL); + } + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs1 != null) { + SqlUtilT.free(rs1); + } + } + } + } + @SuppressWarnings("unchecked") + private void writeToFile(File fmsFile ,boolean is_firstCreate) { + // TODO Auto-generated method stub + fmsFile.setWritable(true); + writeExcelForCXCheckTable(fmsFile.getPath(), fmsFile, (ArrayList>)data_List.get(0), (boolean)data_List.get(1), (ArrayList)data_List.get(2)); + if(!is_firstCreate) + writeExcelWithCellName(fmsFile,fmsFile.getPath(),getProductProp()); + } + + /** + * бд뵽excelȥ + * @param write_Address + * @param is + * @param date + * @param rb3_jqsb + * @param hava_minAndMax + * @param have_No_ + * @param string + */ + private void writeExcelForCXCheckTable(String write_Address,File file ,ArrayList> date,boolean hava_minAndMax, ArrayList shousuobi_list){ + try { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is); + is.close(); + OutputStream output = new FileOutputStream(new File(write_Address)); + XSSFCellStyle style = wb.createCellStyle(); +// if(rb3_jqsb!=null) +// ExcelUtil07.writeExcelWithOneCellName(wb, "豸", rb3_jqsb); + 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(); +// XSSFCellStyle style =wb.createCellStyle(); + XSSFDataFormat df = wb.createDataFormat(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + XSSFSheet sheet = wb.getSheetAt(0); + sheet.setForceFormulaRecalculation(true); + boolean isCreate = false; +// int row_num = 0 ; + for (int i = 0; i < date.size(); i++) { + int page = i/20; + //ȡһ + ArrayList cell_Date = date.get(i); + //һеݽд + for (int j = 0; j < cell_Date.size(); j++) { + int namedCellIdx = wb.getNameIndex("head" + + String.valueOf(j + 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++) { + XSSFSheet s = wb.getSheet(crefs[k].getSheetName()); + Row r = null; + if(operateCode == 0 || operateCode==1 || operateCode == 2 || operateCode==3 || operateCode == 5 || operateCode == 6 || operateCode == 7 || operateCode == 11 || operateCode == 12 || operateCode == 13 || operateCode == 20|| operateCode == 16) + {//ҪӦı + if(!isCreate){ + int position = crefs[k].getRow() + 2; + for(int z = 0 ; z < date.size(); z++){ + r = createRow(s, crefs[k].getRow() + 2);//һ + copyRows(position, position, position, s); + } + for(int z = 0 ; z < date.size(); z++){ + s.getRow(position + z + 1).setHeight(s.getRow(position).getHeight()); + } + isCreate = true; + } + } + if(operateCode == 4) + r = s.getRow(crefs[k].getRow() + i + (page*10) + 1); + else + r = s.getRow(crefs[k].getRow() + i + 1); + Cell c = null; + if(r.getCell(crefs[k].getCol()) != null) + c = r.getCell(crefs[k].getCol()); + else + c = r.createCell(crefs[k].getCol()); + if(j==1 && (operateCode!= 14 && operateCode!= 15)){ + CheckTable checkTable = null; + ArrayList arr_checkTable = (ArrayList)data_List.get(3); + if(arr_checkTable.size()!=0) + checkTable = arr_checkTable.get(i); + toSpecial(j, wb, c, cell_Date,checkTable); + ArrayList arr = getCPGCMaxAndMix(cell_Date.get(j),shousuobi_list.get(i)); + if(shousuobi_list.get(i)!=" "){ + c.setCellValue(after_shousuo); + checkTable.setCpgc(after_shousuo); + } + boolean hasNotMinAndMax = operateCode != 0 && operateCode != 2 ; + if(hava_minAndMax){ + Cell minCell = null; + minCell = r.getCell(crefs[k].getCol()+1); + Cell maxCell = null; + maxCell = r.getCell(crefs[k].getCol()+2); + if(minCell == null) + { + minCell = r.createCell(crefs[k].getCol()+1); + } + if(maxCell == null) + { + maxCell = r.getCell(crefs[k].getCol()+2); + } + XSSFCellStyle cellstyle = wb.createCellStyle(); + cellstyle = (XSSFCellStyle) minCell.getCellStyle(); + cellstyle = (XSSFCellStyle) maxCell.getCellStyle(); + String format = "0.0000000000"; +// if(position!=0){ +// cellstyle.setDataFormat(df.getFormat(format.substring(0, position+2))); +// } +// XSSFCellStyle cellstyles = wb.createCellStyle(); +// cellstyles.cloneStyleFrom(cellstyle); + if(operateCode != 5 && operateCode != 6 && operateCode != 7){ + if(arr.get(0) != null && arr.get(0) != " " && arr.get(0)!="OK") + { + if(hasNotMinAndMax){ + minCell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + String ss = Double.parseDouble(cleanZero(arr.get(0)))+""; + + int position = ss.length() - ss.indexOf(".") + 1; + if(position!=0){ + cellstyle.setDataFormat(df.getFormat(format.substring(0, position))); + } + XSSFCellStyle cellstyles = wb.createCellStyle(); + cellstyles.cloneStyleFrom(cellstyle); + minCell.setCellStyle(cellstyles); + minCell.setCellValue(Double.parseDouble(arr.get(0))); + } + checkTable.setMin(String.valueOf(Double.parseDouble(arr.get(0)))); + + } + else{ + if(hasNotMinAndMax){ + minCell.setCellValue(arr.get(0)); + } + checkTable.setMin(String.valueOf(arr.get(0))); + } + if(arr.get(1)!=null&&arr.get(1)!= " " && arr.get(1)!="OK"){ + if(hasNotMinAndMax){ + maxCell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + + String ss = Double.parseDouble(cleanZero(arr.get(1)))+""; + int position = ss.length() - ss.indexOf(".") + 1; + if(position!=0){ + cellstyle.setDataFormat(df.getFormat(format.substring(0, position))); + } + XSSFCellStyle cellstyles = wb.createCellStyle(); + cellstyles.cloneStyleFrom(cellstyle); + maxCell.setCellStyle(cellstyles); + maxCell.setCellValue(Double.parseDouble(arr.get(1))); + } + checkTable.setMax(String.valueOf(Double.parseDouble(arr.get(1)))); + + } + else{ + if(hasNotMinAndMax) + maxCell.setCellValue(arr.get(1)); + checkTable.setMax(String.valueOf(arr.get(1))); + } + } + else{ + if(arr.get(1)!=null&&arr.get(1)!=" " && arr.get(1)!="OK"){ + if(hasNotMinAndMax){ + minCell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + + String ss = Double.parseDouble(cleanZero(arr.get(1)))+""; + int position = ss.length() - ss.indexOf(".") + 1; + if(position!=0){ + cellstyle.setDataFormat(df.getFormat(format.substring(0, position))); + } + XSSFCellStyle cellstyles = wb.createCellStyle(); + cellstyles.cloneStyleFrom(cellstyle); + + minCell.setCellStyle(cellstyles); + minCell.setCellValue(Double.parseDouble(arr.get(1))); + } + checkTable.setMax(String.valueOf(Double.parseDouble(arr.get(1)))); + + } + else{ + if(hasNotMinAndMax) + minCell.setCellValue(arr.get(1)); + checkTable.setMax(String.valueOf(arr.get(1))); + } + if(arr.get(0)!=null&&arr.get(0)!=" " && arr.get(0)!="OK"){ + if(hasNotMinAndMax){ + maxCell.setCellType(XSSFCell.CELL_TYPE_NUMERIC); + + String ss = Double.parseDouble(cleanZero(arr.get(0)))+""; + int position = ss.length() - ss.indexOf(".") + 1; + if(position!=0){ + cellstyle.setDataFormat(df.getFormat(format.substring(0, position))); + } + XSSFCellStyle cellstyles = wb.createCellStyle(); + cellstyles.cloneStyleFrom(cellstyle); + + maxCell.setCellStyle(cellstyles); + maxCell.setCellValue(Double.parseDouble(arr.get(0))); + } + checkTable.setMin(String.valueOf(Double.parseDouble(arr.get(0)))); + + } + else{ + if(hasNotMinAndMax) + maxCell.setCellValue(arr.get(0)); + checkTable.setMin(String.valueOf(arr.get(0))); + } + } + } + + } + else + c.setCellValue(cell_Date.get(j)); + if(j==4 && operateCode == 6){ + XSSFCellStyle time_style = wb.createCellStyle(); + //time_style.setFillForegroundColor(IndexedColors.AUTOMATIC.getIndex()); + //time_style.setFillPattern(CellStyle.SOLID_FOREGROUND); + time_style.setFillForegroundColor(IndexedColors.AUTOMATIC.getIndex()); + time_style.setFillPattern(CellStyle.LEAST_DOTS); + String time = getNum(cell_Date.get(j)); + if(time != null && time != ""){ + if(2%Integer.parseInt(time) != 0){ + System.out.println(2%Integer.parseInt(time)); + Cell c_1 = r.getCell(crefs[k].getCol()+4); + c_1.setCellStyle(time_style); + } + if(4%Integer.parseInt(time)!= 0){ + System.out.println(4%Integer.parseInt(time)); + Cell c_2 = r.getCell(crefs[k].getCol()+7); + c_2.setCellStyle(time_style); + } + if(6%Integer.parseInt(time) != 0){ + System.out.println(6%Integer.parseInt(time)); + Cell c_3 = r.getCell(crefs[k].getCol()+10); + c_3.setCellStyle(time_style); + } + if(8%Integer.parseInt(time) != 0){ + System.out.println(8%Integer.parseInt(time)); + Cell c_4 = r.getCell(crefs[k].getCol()+13); + c_4.setCellStyle(time_style); + } + if(10%Integer.parseInt(time) != 0){ + System.out.println(10%Integer.parseInt(time)); + Cell c_5 = r.getCell(crefs[k].getCol()+16); + c_5.setCellStyle(time_style); + } + if(12%Integer.parseInt(time) != 0){ + System.out.println(12%Integer.parseInt(time)); + Cell c_6 = r.getCell(crefs[k].getCol()+19); + c_6.setCellStyle(time_style); + } + } + } + } + } + + } +// for(CheckTable tc:(ArrayList)data_List.get(3)){ +// System.out.println(tc.toString()); +// } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(e.toString(), "", MessageBox.ERROR); + } + } + public String cleanZero(String s){ + if(s.indexOf(".") > 0){ + + // + + s = s.replaceAll("0+?$", "");//ȥõ + + s = s.replaceAll("[.]$", "");//СȫȥС + + } + return s; + } + /** + * + * @param cols + * @param wb + * @param cell + * @param cell_Date + */ + public void toSpecial(int cols,XSSFWorkbook wb,Cell cell,ArrayList cell_Date,CheckTable checkTable){ + String cpgc = cell_Date.get(cols); + String[] strs = cpgc.split("special"); + if(cpgc != null &&cpgc !=""){ + if(!"null".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] != ""&&operateCode!=5&&operateCode!=6&&operateCode!=7) { + cell.setCellValue(setCellFont(wb, + strs[0], index, index + 1, 8, + "Y14.5M")); + checkTable.setCpgc(strs[0]); + } + else{ + String nominalVal = null; + nominalVal= strs[0]; + cell.setCellValue(setCellFont(wb, + nominalVal, index, index + 1, 8, + "Y14.5M")); + checkTable.setCpgc(strs[0]); + } + + } + + } + 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] != ""&&operateCode!=5&&operateCode!=6&&operateCode!=7) { + cell.setCellValue(setCellFont(wb, + strs[0], index, index + 1, + 8, "Y14.5M")); + checkTable.setCpgc(strs[0]); + } + else{ + String nominalVal = null; + nominalVal= strs[0]; + cell.setCellValue(setCellFont(wb, + nominalVal, index, index + 1, 8, + "Y14.5M")); + checkTable.setCpgc(strs[0]); + } + } + } + } + } + else{ + if(operateCode!=5&&operateCode!=6&&operateCode!=7){ + //ֱдstrs[0] + cell.setCellValue(strs[0]); + checkTable.setCpgc(strs[0]); + } + else{ + String nominalVal = null; + nominalVal= strs[0]; + cell.setCellValue(nominalVal); + checkTable.setCpgc(strs[0]); + } + + } + } + + } + 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 str + * @return + */ + public static ArrayList getCPGCMaxAndMix(String str,String gc) { + after_shousuo = null; + position = 0; + ArrayList data = new ArrayList<>(); + try { + List list = new ArrayList<>(); + if(str.indexOf("")!=-1){ + String[] ss = str.split(""); + for(String s :ss){ + if(s.length()!=0) + list.add(getNum(s)); + } + if(list.size()>=1){ + BigDecimal b0 = null; + BigDecimal b1 = null; + // x ģʽ + if(list.size()==1){ + b0 = new BigDecimal(0); + b1 = new BigDecimal(list.get(0)); + } + // x y ģʽ + if(list.size()==2){ + if(ss[0].indexOf("-") != -1) + b0 = new BigDecimal(getNum(ss[0].split("-")[1])); + else + b0 = new BigDecimal(list.get(0)); + b1 = new BigDecimal(list.get(1)); + } + String v1 = null; + String v2 = null; + if(!" ".equals(gc)){ + BigDecimal b2 = null; + if(gc.indexOf("%")!=-1) + b2 = new BigDecimal(getNum((Double.valueOf(gc.split("%")[0])/100)+"")); + else + b2 = new BigDecimal(getNum(gc)); + v1 = String.valueOf(b0.subtract(new BigDecimal(Double.toString(b1.multiply(b2).doubleValue())))); + v2 = String.valueOf(b0.add(new BigDecimal(Double.toString(b1.multiply(b2).doubleValue())))); + data.add(v1); + data.add(v2); + after_shousuo = str.replace(b1.toString(), String.valueOf(b1.multiply(b2).doubleValue())).split("special")[0]; + } + else{ + v1 = String.valueOf(b0.subtract(b1)); + v2 = String.valueOf(b0.add(b1)); + data.add(v1); + data.add(v2); + } + int position1 = v1.length() - v1.indexOf(".")-1 ; + int position2 = v2.length() - v2.indexOf(".")-1 ; + position = position1>=position2?position1:position2; + + } + return data; + } + + if(str.toUpperCase().indexOf("MAX")!=-1||str.indexOf("")!=-1||str.indexOf("<")!=-1||str.indexOf("")!=-1){ + String v1 = null; + if(!" ".equals(gc)){ + String s1 = getNum(str); + BigDecimal b1 = new BigDecimal(getNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); + v1 = String.valueOf(b1.multiply(b2).doubleValue()); + data.add("0"); + data.add(v1); + after_shousuo = str.replace(s1,v1).split("special")[0]; + } + else{ + if(str.toUpperCase().indexOf("MAX")!=-1) + v1 = getNum(str); + else{ + if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + else if (str.indexOf("<") >= 0) + { + v1 = getFirstNum(str.split("<")[1]); + } + else if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + } +// v1 = getFirstNum(str.substring(1,str.length())); + data.add("0"); + data.add(v1); + } + position = v1.length() - v1.indexOf(".")-1 ; + return data; + } + if(str.toUpperCase().indexOf("MIN")!=-1||str.indexOf("")!=-1||str.indexOf(">")!=-1||str.indexOf("")!=-1){ + String v1 = null; + if(!" ".equals(gc)&&!"0".equals(gc)){ + String s1 = getNum(str); + BigDecimal b1 = new BigDecimal(getNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); + // String val = String.valueOf(b1.multiply(b2).doubleValue()); + v1 = String.valueOf(b1.divide(b2,10,BigDecimal.ROUND_HALF_UP).doubleValue()); + data.add(v1); + data.add(" "); + after_shousuo = str.replace(s1,v1).split("special")[0]; + } + else{ + if(str.toUpperCase().indexOf("MIN")!=-1) + v1 = getNum(str); + else{ + if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + else if (str.indexOf(">") >= 0) + { + v1 = getFirstNum(str.split(">")[1]); + } + else if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + //v1 = getFirstNum(str.substring(1,str.length())); + } + data.add(v1); + data.add(" "); + } + position = v1.length() - v1.indexOf(".")-1 ; + return data; + } + if(str.indexOf("~")!=-1 || str.indexOf("")!=-1){ + String v1 = null; + String v2 = null; + if(str.indexOf("~")!=-1 || str.indexOf("")!=-1){ + v1 = getNum(str.split("~")[0]); + v2 = getNum(getFirstNum(str.split("~")[1])); + if(str.split("~")[0].indexOf("-")!=-1) + data.add("-"+v1); + else + data.add(v1); + if(str.split("~")[1].indexOf("-")!=-1) + data.add("-"+v2); + else + data.add(v2); + } + int position1 = v1.length() - v1.indexOf(".")-1 ; + int position2 = v2.length() - v2.indexOf(".")-1 ; + position = position1>=position2?position1:position2; + //after_shousuo = str.split("special")[0]; + return data; + } + if(getNum(str)!=""){ + String v1 = null; + if(!" ".equals(gc)){ + String s1 = getNum(str); + BigDecimal b1 = new BigDecimal(getNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); + v1 = String.valueOf(b1.multiply(b2).doubleValue()); + data.add("0"); + data.add(v1); + after_shousuo = str.replace(s1,v1).split("special")[0]; + } + else{ + v1 = getNum(str); + data.add("0"); + data.add(v1); + } + position = v1.length() - v1.indexOf(".")-1 ; + return data; + } + if(getNum(str)==""){ + data.add("OK"); + data.add("OK"); + return data; + } + } catch (Exception e) { + data.add(" "); + data.add(" "); + } + return data; + } + private static String getFirstNum(String str) { + String ss = ""; + boolean isNum = false; + for(int i = 0 ; i < str.length() ; i++){//c < 48 || c > 57 + if((str.charAt(i)>= 48 && str.charAt(i) <= 57) || str.charAt(i) == 46){ + ss = ss+str.charAt(i); + isNum = true; + } + else{ + if(isNum){ + break; + } + } + } + return ss; + + } + private static String getNum(String str) { + Pattern p = Pattern.compile("(\\d+\\.\\d+)"); + //MatcherĹ췽Ҳ˽е,ⴴ,ֻͨPattern.matcher(CharSequence input)õʵ. + Matcher m = p.matcher(str); + //m.findжϸַǷ"(\\d+\\.\\d+)"ƥӴ + if (m.find()) { + //ƥ,жǷΪnull + //group()еIJ0ʾƥ1ʾƥһŵ,2ʾƥڶ,ֻһ,10һ + str = m.group(1) == null ? "" : m.group(1); + } else { + //ƥ䲻Сͽƥ + p = Pattern.compile("(\\d+)"); + m = p.matcher(str); + if (m.find()) { + //ƥ + str = m.group(1) == null ? "" : m.group(1); + } else { + //ûСƥ,ַûСΪ + str = ""; + } + } + return str; + } + /** + * ȡ豸 + * @param itemն + * @param meop_idid + * @return + */ + private void getMEToolList(Map map,TCComponentItem item, String meop_id){ + try { + StringBuilder scsb = new StringBuilder();//豸 + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline=((TCComponentBOMLine) children.getComponent()); + if(meop_id.equals(subline.getProperty("bl_item_item_id"))){ + AIFComponentContext[] sublineChildrens = subline.getChildren(); + Map sbjt = new HashMap<>(); + for(AIFComponentContext sublineChildren:sublineChildrens){ + TCComponent meTool = (TCComponent) sublineChildren.getComponent(); + String meToolName= meTool.getProperty("bl_item_fnd0IcsClassNames"); + if("".equals(meToolName)||"ѹ".equals(meToolName)||"ѹ".equals(meToolName)||"".equals(meToolName)||"ӹ".equals(meToolName)||"ս¯".equals(meToolName)||"¯".equals(meToolName)||"ST".equals(meToolName)||"ɰ".equals(meToolName)||"".equals(meToolName)||"豸".equals(meToolName)||"ϴ豸".equals(meToolName)||"ȴ".equals(meToolName)||"ĥ".equals(meToolName)||"ë".equals(meToolName)){ + String str = meTool.getProperty("bl_item_object_name"); + String[] keyAndValue = str.split("/"); + if(keyAndValue.length>1){ + String map_key = keyAndValue[0]; + String map_value = keyAndValue[1]; + if(sbjt.containsKey(map_key)) + sbjt.put(map_key, sbjt.get(map_key).append(",").append(map_value)); + else + sbjt.put(map_key, new StringBuilder (map_value)); + } + else + if(!sbjt.containsKey(str)){ + sbjt.put(str, null); + } + } + } + for(String key:sbjt.keySet()){ + if(scsb.length()!=0) + scsb.append(";"); + if(sbjt.get(key)!=null) + scsb.append(key+"/"+sbjt.get(key)); + else + scsb.append(key); + } + map.put("豸", scsb.toString()); + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + /** + * ֵд뵽Excel + * + * @param fileOutUrl + * @param file + * @param cellName + * @param cellValue + */ + public static void writeExcelWithCellName(File file, + String fileOutUrl, Map map) { + try { + for(String key : map.keySet()){ + System.out.println(key+":"+map.get(key)); + } + InputStream is = new FileInputStream(file); + Workbook wb = new XSSFWorkbook(is);// retrieve workbook + is.close(); + FileOutputStream output = new FileOutputStream(new File(fileOutUrl)); + for (String key : map.keySet()) { + 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()); + c.setCellValue(map.get(key)); + } + } + } + } + wb.write(output); + output.close(); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + //ȡ汾 + public String setVersionNum(TCComponentItemRevision itemRev) throws TCException, IOException{ + if(operateCode!=0&&operateCode!=1&&operateCode!=2&&operateCode!=3&&operateCode!=11&&operateCode!=12&&operateCode!=13&&operateCode!=16){ + String VerNum = itemRev.getProperty("current_revision_id"); + InputStream is = new FileInputStream(fileOutUrl); + XSSFWorkbook wb = new XSSFWorkbook(is); + is.close(); + ExcelUtil07.writeExcelWithOneCellName(wb, "汾", VerNum); + OutputStream os = new FileOutputStream(new File(fileOutUrl)); + wb.write(os); + os.close(); + } + return null; + } + /** + * ҵҪ½һPOIrow + * @param sheet + * @param rowIndex + * @param createRow_style + * @return + */ + private 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; + } + public static void copyRows(int startRow, int endRow, int pPosition, + XSSFSheet sheet) { + int pStartRow = startRow - 1; + int pEndRow = endRow - 1; + int targetRowFrom; + int targetRowTo; + int columnCount; + CellRangeAddress region = null; + int i; + int j; + if (pStartRow == -1 || pEndRow == -1) { + return; + } + // ϲĵԪ + for (i = 0; i < sheet.getNumMergedRegions(); i++) { + region = sheet.getMergedRegion(i); + if ((region.getFirstRow() >= pStartRow) + && (region.getLastRow() <= pEndRow)) { + targetRowFrom = region.getFirstRow() - pStartRow + pPosition; + targetRowTo = region.getLastRow() - pStartRow + pPosition; + CellRangeAddress newRegion = region.copy(); + newRegion.setFirstRow(targetRowFrom); + newRegion.setFirstColumn(region.getFirstColumn()); + newRegion.setLastRow(targetRowTo); + newRegion.setLastColumn(region.getLastColumn()); + sheet.addMergedRegion(newRegion); + } + } + // п + for (i = pStartRow; i <= pEndRow; i++) { + XSSFRow sourceRow = sheet.getRow(i); + columnCount = sourceRow.getLastCellNum(); + if (sourceRow != null) { + XSSFRow newRow = sheet.createRow(pPosition - pStartRow + i); + newRow.setHeight(sourceRow.getHeight()); + for (j = 0; j < columnCount; j++) { + XSSFCell templateCell = sourceRow.getCell(j); + if (templateCell != null) { + XSSFCell newCell = newRow.createCell(j); + copyCell(templateCell, newCell); + } + } + } + } + } + private static void copyCell(XSSFCell srcCell, XSSFCell distCell) { + distCell.setCellStyle(srcCell.getCellStyle()); + if (srcCell.getCellComment() != null) { + distCell.setCellComment(srcCell.getCellComment()); + } + int srcCellType = srcCell.getCellType(); + distCell.setCellType(srcCellType); + if (srcCellType == XSSFCell.CELL_TYPE_NUMERIC) { + if (HSSFDateUtil.isCellDateFormatted(srcCell)) { + distCell.setCellValue(srcCell.getDateCellValue()); + } else { + distCell.setCellValue(srcCell.getNumericCellValue()); + } + } else if (srcCellType == XSSFCell.CELL_TYPE_STRING) { + distCell.setCellValue(srcCell.getRichStringCellValue()); + } else if (srcCellType == XSSFCell.CELL_TYPE_BLANK) { + // nothing21 + } else if (srcCellType == XSSFCell.CELL_TYPE_BOOLEAN) { + distCell.setCellValue(srcCell.getBooleanCellValue()); + } else if (srcCellType == XSSFCell.CELL_TYPE_ERROR) { + distCell.setCellErrorValue(srcCell.getErrorCellValue()); + } else if (srcCellType == XSSFCell.CELL_TYPE_FORMULA) { + distCell.setCellFormula(srcCell.getCellFormula()); + } else { // nothing29 + + } + } +} + diff --git a/src/com/connor/renben/process/plm/tmom014/Test.java b/src/com/connor/renben/process/plm/tmom014/Test.java new file mode 100644 index 0000000..81532be --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom014/Test.java @@ -0,0 +1,82 @@ +package com.connor.renben.process.plm.tmom014; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Scanner; + +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.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.CellReference; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class Test { + public static void main(String[] args) { +// String str = "1"; +// +// String s = str.split("\n")[0].split("\r")[0].replace(" ", "");; +// +// System.out.println(s); + + + System.out.println(""); + Scanner scanner = new Scanner(System.in); + //ȡû + //int num = scanner.nextInt(); + for (int i = 3; i >= 1; i--) { + for (int j= 0;j < 3 - i; j++) { + System.out.print(" "); + } + for (int k= 0;k < 2*i - 1; k++) { + System.out.print("*"); + } + System.out.println(""); + } +// String sql = "select rb3_cpgc from rb3_controlplan where plmeid='0821d39d14b142c88f3a8c5b7a4a9a94'"; +// ResultSet rs = null; +// String str = null; +// com.connor.renben.process.plm.sql.util.SqlUtilT.getTCConnection(); +// try { +// rs = com.connor.renben.process.plm.sql.util.SqlUtilT +// .read(sql); +// while(rs.next()){ +// str = rs.getString("RB3_CPGC"); +// } +// } catch (SQLException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } finally { +// if (rs != null) { +// com.connor.renben.process.plm.sql.util.SqlUtilT.free(rs); +// } +// com.connor.renben.process.plm.sql.util.SqlUtilT.freeAll(); +// } +// System.out.println(getDate(null)); + } + private static String getDate(String str){ + + if(str!=null){ + for(int i = 0 ; i < str.length() ; ){ + if(str.charAt(i)!='\n') + break; + else + str = str.substring(1, str.length()); + } + return str.split("\n")[0]; + } + return " "; + } +} diff --git a/src/com/connor/renben/process/plm/tmom014/sql.properties b/src/com/connor/renben/process/plm/tmom014/sql.properties new file mode 100644 index 0000000..fe2b581 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom014/sql.properties @@ -0,0 +1 @@ +INSERTCHECKTABLESQL=insert into RB3_CHECK_TABLE values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/tmom014/产品质量检查表.xlsx b/src/com/connor/renben/process/plm/tmom014/产品质量检查表.xlsx new file mode 100644 index 0000000..74b053c Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/产品质量检查表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/工序质量检查表.xlsx b/src/com/connor/renben/process/plm/tmom014/工序质量检查表.xlsx new file mode 100644 index 0000000..84c996b Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/工序质量检查表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/成形工序巡检检查表.xlsx b/src/com/connor/renben/process/plm/tmom014/成形工序巡检检查表.xlsx new file mode 100644 index 0000000..99322db Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/成形工序巡检检查表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/成形工序过程自检记录表(操作工).xlsx b/src/com/connor/renben/process/plm/tmom014/成形工序过程自检记录表(操作工).xlsx new file mode 100644 index 0000000..97f829e Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/成形工序过程自检记录表(操作工).xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/成形工序过程自检记录表(操作工).xlsx b/src/com/connor/renben/process/plm/tmom014/成形工序过程自检记录表(操作工).xlsx new file mode 100644 index 0000000..1cf0621 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/成形工序过程自检记录表(操作工).xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/成形末件记录表.xlsx b/src/com/connor/renben/process/plm/tmom014/成形末件记录表.xlsx new file mode 100644 index 0000000..fd38662 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/成形末件记录表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(CNC专用).xlsx b/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(CNC专用).xlsx new file mode 100644 index 0000000..d59f707 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(CNC专用).xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(通用).xls b/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(通用).xls new file mode 100644 index 0000000..4ae0537 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(通用).xls differ diff --git a/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(通用).xlsx b/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(通用).xlsx new file mode 100644 index 0000000..35d5736 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/成形首检调试记录表(通用).xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/最终检查表.xlsx b/src/com/connor/renben/process/plm/tmom014/最终检查表.xlsx new file mode 100644 index 0000000..e5666ba Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/最终检查表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/机加工科产品末件检查表.xlsx b/src/com/connor/renben/process/plm/tmom014/机加工科产品末件检查表.xlsx new file mode 100644 index 0000000..c2c72de Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/机加工科产品末件检查表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/机加工科产品过程质量检查表.xlsx b/src/com/connor/renben/process/plm/tmom014/机加工科产品过程质量检查表.xlsx new file mode 100644 index 0000000..0fd9239 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/机加工科产品过程质量检查表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/机加工科产品首件检查表.xlsx b/src/com/connor/renben/process/plm/tmom014/机加工科产品首件检查表.xlsx new file mode 100644 index 0000000..7fd30aa Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/机加工科产品首件检查表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火批次末件记录单.xlsx b/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火批次末件记录单.xlsx new file mode 100644 index 0000000..296b16b Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火批次末件记录单.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火批次首件批准单.xlsx b/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火批次首件批准单.xlsx new file mode 100644 index 0000000..9309f31 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火批次首件批准单.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火过程检验记录表.xlsx b/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火过程检验记录表.xlsx new file mode 100644 index 0000000..440bc2c Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/盲孔感应淬火过程检验记录表.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom014/精整工序产品批量生产记录单(批准单).xlsx b/src/com/connor/renben/process/plm/tmom014/精整工序产品批量生产记录单(批准单).xlsx new file mode 100644 index 0000000..9a8eedd Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom014/精整工序产品批量生产记录单(批准单).xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerCommand.java b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerCommand.java new file mode 100644 index 0000000..2cf8504 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerCommand.java @@ -0,0 +1,272 @@ +package com.connor.renben.process.plm.tmom015; + +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 javax.swing.JOptionPane; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom015ChangeControlPlanOwnerCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent targetComponent; + private TCComponentItem processItem; + private TCComponentItem product; + private List> dataList = new ArrayList>(); + private String[] titleNames = new String[] { "PLMEID", "ID", "", + "", "","û","ûID" }; + private boolean meopIsComplete = false; + + public TMom015ChangeControlPlanOwnerCommand(AbstractAIFApplication app, + TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + + /** + * ȡмĹ + * @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 = new String[props.length]; + for (int i = 0; i < props.length; i++) { + if(props[i].indexOf("/") >= 0) + { + values[i] = props[i].split("/")[0]; + } + else + { + values[i] = props[i]; + } + } + } + } + else + { + MessageBox.post("δѡ", "", MessageBox.ERROR); + } + return Arrays.asList(values); + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + new Thread() { + @Override + public void run() { + //ȡɵǰûĹ + ResultSet rs = null; + ResultSet rs1 = null; + ResultSet rs2 = null; + InputStream input = null; + try { + targetComponent = app.getTargetComponent(); + if (targetComponent.getType().indexOf("KZJH") < 0 && targetComponent instanceof TCComponentItem) { + MessageBox.post("ѡƼƻ汾", "", MessageBox.ERROR); + return; + } + //ͨƼƻȡ + TCComponentItemRevision kzjhRevision = (TCComponentItemRevision)targetComponent; + //ȡƼƻ + TCComponentItem kzjhItem = null; + AIFComponentContext[] items = kzjhRevision.whereReferenced(); + for (int i = 0; i < items.length; i++) { + if(items[i].getComponent().getType().indexOf("KZJH") >= 0 && items[i].getComponent() instanceof TCComponentItem) + { + kzjhItem = (TCComponentItem)items[i].getComponent(); + } + } + //ͨƼƻȡ + AIFComponentContext[] processItems = kzjhItem.whereReferenced(); + for (int i = 0; i < processItems.length; i++) { + if(processItems[i].getComponent().getType().indexOf("MEProcess") >= 0 && processItems[i].getComponent() instanceof TCComponentItem) + { + processItem = (TCComponentItem)processItems[i].getComponent(); + } + } + //ݹջȡƷ + AIFComponentContext[] productItems = processItem.whereReferenced(); + for (int i = 0; i < productItems.length; i++) { + if(productItems[i].getComponent().getType().indexOf("Product") >= 0 && productItems[i].getComponent() instanceof TCComponentItem) + { + product = (TCComponentItem) productItems[i].getComponent(); + } + } + List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = ""; + if(session.getUser().getStringProperty("user_id").equals(processItem.getReferenceProperty("owning_user").getStringProperty("user_id")) || session.getUser().getStringProperty("user_id").equals("admin")) + { + sql = String.format("select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " from (select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,nvl(rb3_user,' ') as rb3_user,nvl(RB3_INSPECTIONUSER,' ') as RB3_INSPECTIONUSER " + + " from RB3_PERMISSIONS)" + + " unpivot (rb3_user_id for type in (rb3_user, RB3_INSPECTIONUSER) ) " + + " where PROCESSPUID = \'%s\' " + + " group by PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " order by to_number(RB3_GYBH)", + processItem.getUid()); + } + else + { + sql = String.format("select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + "from (select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,nvl(rb3_user,' ') as rb3_user,nvl(RB3_INSPECTIONUSER,' ') as RB3_INSPECTIONUSER " + + " from RB3_PERMISSIONS)" + + "unpivot (rb3_user_id for type in (rb3_user, RB3_INSPECTIONUSER) ) " + + "where rb3_user_id = \'%s\' and PROCESSPUID = \'%s\' " + + "group by PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + "order by RB3_GYBH", + session.getUser().getStringProperty("user_id"),processItem.getUid()); + + //жǷɣʾ + String selectSql = String.format("select t1.RB3_SFWC from rb3_controlplan t1 " + + "left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid " + + "where t1.PROCESSPUID = \'%s\' and t1.type = \'%s\' and rb3_user =\'%s\'",processItem.getUid(),kzjhItem.getType().toUpperCase(),session.getUser().getStringProperty("user_id")); + rs1 = SqlUtilT.read(selectSql); + if(rs1.next()) + { + if(rs1.getString("RB3_SFWC") != null && rs1.getString("RB3_SFWC").equals("1")) + { + meopIsComplete = true; + } + } + else + { + //жǷɣʾ + String selectSql2 = String.format("select t1.RB3_SFWC from rb3_controlplan t1 " + + "left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid " + + "where t1.PROCESSPUID = \'%s\' and t1.type = \'%s\' and rb3_inspectionuser =\'%s\'",processItem.getUid(),kzjhItem.getType().toUpperCase(),session.getUser().getStringProperty("user_id")); + rs2 = SqlUtilT.read(selectSql2); + if(rs2.next()) + { + if(rs2.getString("RB3_SFWC").equals("1")) + { + meopIsComplete = true; + } + } + } + + } + if(meopIsComplete) + { + int i=JOptionPane.showConfirmDialog(null, "ƼƻѱɣǷĸˣ", "ĿƼƻ", JOptionPane.YES_NO_OPTION); + if(i!=JOptionPane.OK_OPTION) + { + return; + } + } + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("RB3_MEOPID")); + list.add(rs.getString("RB3_GYBH")); + list.add(rs.getString("RB3_GCMC")); + if(rs.getString("TYPE").toString().equals("RB3_USER")) + { + list.add("Լ"); + } + else if(rs.getString("TYPE").toString().equals("RB3_INSPECTIONUSER")) + { + list.add("Ѳ"); + Integer meopId = 0; + if(Integer.parseInt(list.get(2)) % 10 ==0) + { + meopId = Integer.parseInt(list.get(2))+5; + } + else + { + meopId = Integer.parseInt(list.get(2))+1; + } + list.set(2, meopId.toString()); + } + if(!rs.getString("RB3_USER_ID").equals(" ")) + { + list.add(type.find(rs.getString("RB3_USER_ID")).getStringProperty("user_name")); + } + else + { + list.add(""); + } + list.add(rs.getString("RB3_USER_ID")); +// if(!meopNameList.contains(rs.getString("RB3_GCMC")) && rs.getString("TYPE").toString() +// .equals("RB3_INSPECTIONUSER")) +// { +// continue; +// } + dataList.add(list); + } +// new Thread() { +// @Override +// public void run() { + TMom015ChangeControlPlanOwnerDialog dialog = new TMom015ChangeControlPlanOwnerDialog( + session, targetComponent, processItem,product,dataList, + titleNames); +// } +// }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs1 != null) { + SqlUtilT.free(rs1); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + }.start(); + + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerDialog.java b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerDialog.java new file mode 100644 index 0000000..078721a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerDialog.java @@ -0,0 +1,509 @@ +package com.connor.renben.process.plm.tmom015; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +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.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.TCGroupDialogTree; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentRole; +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 TMom015ChangeControlPlanOwnerDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private InterfaceAIFComponent targetComponent; + private TCComponentItem processItem; + private TCComponentItem product; + private List> dataList; + private String[] titleNames; + private List changRow = new ArrayList(); + private Map buttonMap = new HashMap(); + // ؼ + private JPanel tablePanel; + private JPanel rootPanel; + private CTMap map; + private CTable table; + private AddUserDialog userDialog; + private JButton okButton; + private JButton celButton; + //private JButton selectUser; + + + public TMom015ChangeControlPlanOwnerDialog(TCSession session, + InterfaceAIFComponent targetComponent,TCComponentItem processItem,TCComponentItem product, + List> dataList,String[] titleNames) { + // TODO Auto-generated constructor stub + this.session = session; + this.targetComponent = targetComponent; + this.processItem = processItem; + this.product = product; + this.dataList = dataList; + this.titleNames = titleNames; + init(); + } + + // 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); + map.setEditable(false); + setJTable(); + partsTable = new CTable(map); + // partsTable.setRowHeight(1, 50); + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length-1); + 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 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + for (int j = 0; j < rowList.size(); j++) { + map.setValueAt(rowList.get(j), i, j); + } + } + } + + private void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("gyfg08_display.TITLE")); + this.tablePanel = new JPanel(new BorderLayout()); + table = getjTable(null, null, titleNames, null); + table.setRowHeight(30); + table.getTableHeader().setVisible(true); + this.tablePanel.add(new JScrollPane(this.table), BorderLayout.CENTER); + // for (int i = 0; i < meopName.size(); i++) { + // JComponent valueComp = null; + // JComponent buttonComp = null; + // JLabel disNameLabel = new JLabel(); + // disNameLabel.setText(meopName.get(i)); + // JTextField valueText = new JTextField(20); + // valueComp = valueText; + // JButton button = new JButton("ѡԱ..."); + // button.addActionListener(this); + // buttonComp = button; + // itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", + // disNameLabel); + // itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", + // valueComp); + // itemPorpPanel.add((i + 1) + ".3.left.top.preferred.preferred", + // button); + // componentMap.put(meopName.get(i), valueComp); + // buttonMap.put(buttonComp,meopName.get(i)); + // } + + userDialog = new AddUserDialog(); + + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(this.tablePanel); + splitPane.setRightComponent(this.userDialog); + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + okButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); +// this.selectUser = new JButton("ѡԱ"); +// this.selectUser.addActionListener(this); + + this.rootPanel = new JPanel(new FlowLayout()); + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + //this.rootPanel.add(this.selectUser); + + this.setLayout(new BorderLayout()); + this.add(splitPane, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + Object source = arg0.getSource(); + if (source.equals(this.okButton)) { + try { + List> dataValueList = new ArrayList>(); + for (int i = 0; i < table.getRowCount(); i++) { + if (!this.changRow.contains(i)) { + continue; + } + List rowValue = new ArrayList(); + for (int j = 0; j < table.getColumnCount(); j++) { + rowValue.add(table.getValueAt(i, j) == null ? "" + : table.getValueAt(i, j).toString()); + } + dataValueList.add(rowValue); + } + + TMom015ChangeControlPlanOwnerOperation operation = new TMom015ChangeControlPlanOwnerOperation( + session,this.targetComponent,this.processItem,this.product, dataValueList); + session.queueOperation(operation); + this.disposeDialog(); + this.dispose(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.disposeDialog(); + this.dispose(); + } else { + //setValueText = componentMap.get(buttonMap.get(source)); + if (userDialog == null) { + userDialog = new AddUserDialog(); + } else { + userDialog.show(); + } + } + } + + + /** + * + * + * @author hub + * + */ + private class AddUserDialog extends JPanel { + + private JPanel panel; + private JPanel panel3; + private JLabel lable; + private JLabel searchLable; + private JTextField searchField; + //private JButton okButton; + private JButton searchButton; + private JButton celButton; + // private MyTable table; + private JTree userTree; + private DefaultMutableTreeNode node; + private DefaultTreeModel m_model; + private String value; + //private String meopName; + private List nameList = new ArrayList(); + TCGroupDialogTree treeDialog; + + public AddUserDialog() { + super(false); + //this.meopName = meopName; + init(); + } + + public void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + System.out.println("ʼ"); + //this.setTitle("֯ṹ"); + this.setPreferredSize(new Dimension(400, 300)); + + this.lable = new JLabel(rb.getString("xzz08_display.TITLE")); + + this.panel = new JPanel(new BorderLayout()); + this.panel3 = new JPanel(new FlowLayout()); + + this.searchLable = new JLabel(rb.getString("yhm08_display.TITLE")); + this.searchField = new JTextField(20); + + this.searchButton = new JButton(rb.getString("ss08_display.TITLE")); + this.searchButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + if (value != null && !value.equals(searchField.getText())) { + nameList.clear(); + value = searchField.getText(); + } else { + value = searchField.getText(); + } + DefaultMutableTreeNode node = searchNode( + searchField.getText(), nameList); + if (node != null) { + TCComponent user = ((TMomUserBean) node.getUserObject()) + .getUser(); + try { + nameList.add(user.getStringProperty("user_id")); + } catch (TCException e) { + e.printStackTrace(); + } + TreeNode[] nodes = m_model.getPathToRoot(node); + TreePath path = new TreePath(nodes); + userTree.scrollPathToVisible(path); + userTree.setSelectionPath(path); + } else { + MessageBox.post("δҵԱ", "", MessageBox.ERROR); + nameList.clear(); + } + } + }); +// okButton = new JButton("ȷ"); +// okButton.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// okAction(e); +// } +// }); +// celButton = new JButton("ȡ"); +// celButton.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// celAction(e); +// } +// }); + // JPanel orgPanel = new JPanel(new BorderLayout()); + + if (treeDialog == null) { + treeDialog = new TCGroupDialogTree(); + } + if (this.userTree == null) { + + TCSession session = (TCSession) AIFUtility + .getCurrentApplication().getSession(); + 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); + this.node = node1; + m_model = new DefaultTreeModel(node); + userTree = new JTree(m_model); + userTree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 2) { + okAction(); + } + } + }); + userTree.setRowHeight(20); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) userTree + .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(); + } + // this.userTree = treeDialog.getTcOrgTree(session, "NBTM"); + } + // orgPanel.add(BorderLayout.CENTER, this.userTree); + // panel2.add(lable); + // panel2.add(BorderLayout.CENTER, ); + panel3.add(searchField); + panel3.add(searchButton); +// panel3.add(okButton); +// panel3.add(celButton); + panel.add(panel3, BorderLayout.SOUTH); + panel.add(new JScrollPane(this.userTree), BorderLayout.CENTER); + this.add(panel, "Center"); + // this.setAlwaysOnTop(true); +// this.pack(); +// this.centerToScreen(); +// this.show(); + } + + 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 DefaultMutableTreeNode searchNode(String nodeStr, + List nameList) { + DefaultMutableTreeNode node = null; + Enumeration e = this.node.breadthFirstEnumeration(); + while (e.hasMoreElements()) { + node = (DefaultMutableTreeNode) e.nextElement(); + if (node.getUserObject() instanceof TMomUserBean) { + TCComponent user = ((TMomUserBean) node.getUserObject()) + .getUser(); + try { + String userName = user.getStringProperty("user_name"); + String userId = user.getStringProperty("user_id"); + if (userName != null) { + if ((userName.indexOf(nodeStr) >= 0 || userId.indexOf(nodeStr) >= 0) + && !nameList.contains(userId)) { + return node; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + return null; + } + + public void okAction() { + + Object selectObj = userTree.getLastSelectedPathComponent(); + if (selectObj instanceof DefaultMutableTreeNode) { + Object userObj = ((DefaultMutableTreeNode) selectObj) + .getUserObject(); + if (userObj instanceof TMomUserBean) { + if (((TMomUserBean) userObj).getUser() instanceof TCComponentUser) { + try { + TCComponentUser user = (TCComponentUser) ((TMomUserBean) userObj) + .getUser(); + // ȡ޸ĵ + String userId = table.getValueAt( + table.getSelectedRow(), + table.getSelectedColumn()) == null ? "" + : table.getValueAt(table.getSelectedRow(), + table.getSelectedColumn()) + .toString(); + if (table.getSelectedRow() >= 0 && table.getSelectedColumn() > 4) { + if ((userId == null || userId.equals("") || !user + .getStringProperty("user_id") + .equals(userId)) + && !changRow.contains(table + .getSelectedRow())) { + changRow.add(table.getSelectedRow()); + } + System.out.println(table.getSelectedRow() + + "======" + table.getSelectedColumn()); + table.setValueAt( + user.getStringProperty("user_name"), + table.getSelectedRow(), + table.getSelectedColumn()); + table.setValueAt(user.getStringProperty("user_id"), + table.getSelectedRow(), + table.getSelectedColumn() + 1); + // ((JTextField)setValueText).setText(user + // .getStringProperty("user_name")); + // userMap.put(meopName, user); + // this.disposeDialog(); + System.out.println("get user = " + user); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + MessageBox.post(e1.toString(), "", + MessageBox.ERROR); + e1.printStackTrace(); + // user = null; + // personName.setText(""); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + // user = null; + // personName.setText(""); + } + + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + // user = null; + // personName.setText(""); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + // user = null; + // personName.setText(""); + } + } + +// private void celAction(ActionEvent e) { +// this.dispose(); +// } + + } +} diff --git a/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerHandler.java b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerHandler.java new file mode 100644 index 0000000..8151519 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerHandler.java @@ -0,0 +1,33 @@ +package com.connor.renben.process.plm.tmom015; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom009.TMom009ControlSynergyCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom015ChangeControlPlanOwnerHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String commandId = arg0.getCommand().getId(); + TMom015ChangeControlPlanOwnerCommand command = new TMom015ChangeControlPlanOwnerCommand( + app, session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ĿƼƻʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerOperation.java b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerOperation.java new file mode 100644 index 0000000..2d8ccd0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom015/TMom015ChangeControlPlanOwnerOperation.java @@ -0,0 +1,204 @@ +package com.connor.renben.process.plm.tmom015; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCAttachmentType; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom015ChangeControlPlanOwnerOperation extends + AbstractAIFOperation { + + private TCSession session; + private List> dataValue; + private InterfaceAIFComponent targetComponent; + private TCComponentItem processItem; + private TCComponentItem product; + + public TMom015ChangeControlPlanOwnerOperation(TCSession session,InterfaceAIFComponent targetComponent, + TCComponentItem processItem,TCComponentItem product,List> dataValueList) { + // TODO Auto-generated constructor stub + this.session = session; + this.dataValue = dataValueList; + this.targetComponent = targetComponent; + this.product = product; + this.processItem = processItem; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + //ݿе + updateDate(); + TCComponentProcessType tccomponentprocesstype = (TCComponentProcessType) session + .getTypeComponent("Job"); + TCComponentTaskTemplateType tccomponenttasktemplatetype = (TCComponentTaskTemplateType) session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate atccomponenttasktemplate = tccomponenttasktemplatetype + .find("WF_61շֹ", TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (atccomponenttasktemplate == null) { + MessageBox.post("δҵģ壡", "", MessageBox.ERROR); + return; + } + List userIdList = new ArrayList<>(); + for (int i = 0; i < dataValue.size(); i++) { + if(!userIdList.contains(dataValue.get(i).get(6))) + { + userIdList.add(dataValue.get(i).get(6)); + } + } + for (int i = 0; i < userIdList.size(); i++) { + List meopList = new ArrayList<>(); + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + TCComponentUser[] user = null; + user = new TCComponentUser[] { type.find(userIdList.get(i)) }; + + for (int j = 0; j < dataValue.size(); j++) { + if(!meopList.contains(dataValue.get(j).get(1)) && dataValue.get(j).get(6).equals(userIdList.get(i))) + { + meopList.add(dataValue.get(j).get(1)); + } + } + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem[] meopItems = null; + if(meopList.size() >= 0) + { + //String[] meopId = dataList.get(i).get(0).toString().split(","); + meopItems = new TCComponentItem[meopList.size()]; + for (int j = 0; j < meopList.size(); j++) { + meopItems[j] = itemType.find(meopList.get(j)); + } + } + TCComponent[] components = null; + int[] componentType = null; + if(meopItems != null) + { + components = new TCComponent[meopItems.length+1]; + componentType = new int[meopItems.length+1]; + components[0] = ((TCComponentItemRevision)this.targetComponent); + componentType[0] = TCAttachmentType.TARGET; + for (int j = 1; j <= meopItems.length; j++) { + components[j] = meopItems[j-1]; + componentType[j] = TCAttachmentType.REFERENCE; + } + } + else + { + continue; + } + if (user != null && user.length > 0) { + for (int j = 0; j < user.length; j++) { + // һ ơģ塢Ŀ󡢸 + TCComponentProcess newProcess = (TCComponentProcess) tccomponentprocesstype + .create(product + .getStringProperty("item_id") + + "-Ƽƻ", this.targetComponent + .getProperty("object_name"), + atccomponenttasktemplate, + components, + componentType); + TMomMethodUtil.setProcess(session, newProcess, user[j]); + } + } + } +// for (int i = 0; i < dataValue.size(); i++) { +// // ȡԱ +// TCComponentUserType type = (TCComponentUserType) session +// .getTypeComponent("User"); +// TCComponentUser[] user; +// if (dataValue.get(i).get(6) == null +// || dataValue.get(i).get(6).equals("")) { +// continue; +// } else { +// user = new TCComponentUser[] { type.find(dataValue.get(i) +// .get(6)) };// 2135 +// } +// // ȡĿ +// // ȡѡеĶ +// TCComponentItemType itemType = (TCComponentItemType) this.session +// .getTypeComponent("Item"); +// TCComponentItem item = itemType.find(dataValue.get(i).get(1)); +// if (user != null && user.length > 0) { +// for (int j = 0; j < user.length; j++) { +// // һ ơģ塢Ŀ󡢸 +// TCComponentProcess newProcess = (TCComponentProcess) tccomponentprocesstype +// .create(item.getLatestItemRevision() +// .getStringProperty("object_string") +// + "-Ƽƻ", item +// .getLatestItemRevision() +// .getStringProperty("object_string"), +// atccomponenttasktemplate, +// new TCComponent[] { (TCComponent)targetComponent,item }, +// new int[] { TCAttachmentType.TARGET,TCAttachmentType.REFERENCE }); +// TMomMethodUtil.setProcess(session, newProcess, user[j]); +// } +// } +// } + } + + private void updateDate() { + // TODO Auto-generated method stub + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + for (int i = 0; i < dataValue.size(); i++) { + String updateSQL = ""; + if(dataValue.get(i).get(4).equals("Լ")) + { + updateSQL = String.format("update RB3_PERMISSIONS set RB3_USER_NAME = ?,RB3_USER = ? where plmeid = \'%s\'", + dataValue.get(i).get(0)); + } + else if(dataValue.get(i).get(4).equals("Ѳ")) + { + updateSQL = String.format("update RB3_PERMISSIONS set RB3_INSPECTIONUSER_NAME = ?,RB3_INSPECTIONUSER = ? where plmeid = \'%s\'", + dataValue.get(i).get(0)); + } + SqlUtilT.update(new String[] { dataValue.get(i).get(5),dataValue.get(i).get(6) }, + updateSQL); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + 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/tmom016/TMom016CirculationCardCommand.java b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardCommand.java new file mode 100644 index 0000000..38329be --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardCommand.java @@ -0,0 +1,84 @@ +package com.connor.renben.process.plm.tmom016; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.poi.ss.usermodel.Cell; +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.util.AreaReference; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom016CirculationCardCommand extends AbstractAIFCommand { + private TCSession session; + private AbstractAIFUIApplication app; + private String fileSource; + private int operateCode; + + public TMom016CirculationCardCommand(TCSession session, + AbstractAIFUIApplication app, int operateCode, String fileSource) { + this.session = session; + this.app = app; + this.operateCode = operateCode; + this.fileSource = fileSource; + } + + @Override + public void executeModal() throws Exception { + try { + new Thread() { + @Override + public void run() { + session.queueOperation(new TMom016CirculationCardOperation( + app, session, operateCode, fileSource)); + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + System.out.println(); + MessageBox.post(""+fileSource.split("\\.")[0]+"", "", MessageBox.ERROR); + return; + } + + super.executeModal(); + } + + +} diff --git a/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardDialog.java b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardDialog.java new file mode 100644 index 0000000..57bef3a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardDialog.java @@ -0,0 +1,94 @@ +package com.connor.renben.process.plm.tmom016; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.bean.CXListBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom016CirculationCardDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFUIApplication app; + private TCSession session; + + public TMom016CirculationCardDialog() { + super(false); + } + + public TMom016CirculationCardDialog(AbstractAIFUIApplication app, + TCSession session) { + super(false); + this.app = app; + this.session = session; + init(); + + } + + public void init() { + System.out.println("3"); +// TMom001CXInstructOperation operation = new TMom001CXInstructOperation(app, session); +// session.queueOperation(operation); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } + +// //Ӱť +// public void createActionEvent() { +// this.fileButton.addActionListener(this); +// this.okButton.addActionListener(this); +// this.celButton.addActionListener(this); +// } +// +// //ļѡ +// private void foldPath() +// { +// this.fileChooser.setFileSelectionMode(1); +// // ļѡ +// int state = this.fileChooser.showOpenDialog(null); +// if (state == 1) { +// return; +// } else { +// File f = fileChooser.getSelectedFile(); +// this.foldPath = f.getAbsolutePath(); +// } +// } +// +// @Override +// public void actionPerformed(ActionEvent arg0) { +// Object source=arg0.getSource(); +// if(source.equals(this.fileButton)) +// { +// this.foldPath(); +// this.fileTextField.setText(this.foldPath); +// } +// else if (source.equals(this.okButton)) +// { +// TMom001CXInstructOperation operation = new TMom001CXInstructOperation(app, session,this.cxListBean,this.fileNameField.getText(),this.foldPath,fileSource); +// session.queueOperation(operation); +// this.disposeDialog(); +// this.dispose(); +// } +// else +// { +// this.disposeDialog(); +// this.dispose(); +// } +// } + +} diff --git a/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardHandler.java b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardHandler.java new file mode 100644 index 0000000..5deb519 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardHandler.java @@ -0,0 +1,83 @@ +package com.connor.renben.process.plm.tmom016; + +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom016CirculationCardHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + String commandId = arg0.getCommand().getId(); + int operateCode = -1; + String fileSource = null; + switch (commandId) { + case "com.connor.renben.process.plm.commands.GXCirculationCardCommand": + operateCode = 0; + fileSource="ĩұƷת.xlsx"; + break; + case "com.connor.renben.process.plm.commands.FGCirculationCardCommand": + operateCode = 1; + fileSource="Ʒӹת.xlsx"; + break; + + default: + break; + } + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom016CirculationCardCommand command = new TMom016CirculationCardCommand(session, app,operateCode, fileSource); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("תʧ", "", MessageBox.ERROR); + } + return null; + } + public static ArrayList getCPGCMaxOrMix(String str) { + Pattern pattern = null; + if(str.contains("")) + pattern = Pattern.compile("\\d+.\\d+"); + else + if(str.contains(".")) + pattern = Pattern.compile("\\d+.\\d+"); + else + pattern = Pattern.compile("\\d"); + Matcher matcher = pattern.matcher(str); + ArrayList aClass = new ArrayList<>(); + while (matcher.find()) { + aClass.add(matcher.group()); + } + ArrayList date = new ArrayList<>(); + if(aClass.size()==2){ + float value1 = Float.valueOf(aClass.get(0)); + float value2 = Float.valueOf(aClass.get(1)); + DecimalFormat fnum = new DecimalFormat("##0.00"); + String max=fnum.format(value1+value2); + String min=fnum.format(value1-value2); + date.add(max); + date.add(min); + } + if(aClass.size()==1){ + date.add("0"); + date.add(aClass.get(0)); + } + else{ + date.add(" "); + date.add(" "); + } + return date; + } +} diff --git a/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardOperation.java b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardOperation.java new file mode 100644 index 0000000..a19996e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom016/TMom016CirculationCardOperation.java @@ -0,0 +1,309 @@ +package com.connor.renben.process.plm.tmom016; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.poi.ss.usermodel.Cell; +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.util.AreaReference; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.MessageBox; + +public class TMom016CirculationCardOperation extends AbstractAIFOperation { + + private AbstractAIFUIApplication app; + private TCSession session; + private int operateCode; + private String fileSource; + private String tcResource; + private String objectName; + private InterfaceAIFComponent targetcomp; + + + public TMom016CirculationCardOperation(AbstractAIFUIApplication app, + TCSession session, int operateCode, String fileSource) { + this.app = app; + this.session = session; + this.operateCode = operateCode; + this.fileSource = fileSource; + } + @Override + public void executeOperation() throws Exception { + ArrayList bomLines = new ArrayList<>(); + targetcomp = this.app.getTargetComponent(); + TCComponentMEProcessRevision item = null; + try { + item = (TCComponentMEProcessRevision) targetcomp; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ѡհ汾󴫵ݣ", "", MessageBox.ERROR); + + } + AIFComponentContext[] its = item.whereReferenced(); + TCComponentMEProcess tccmep = null; + for(AIFComponentContext it:its){ + if("MEProcess".equals(it.getComponent().getType())){ + tccmep = (TCComponentMEProcess) it.getComponent(); + } + break; + } + switch (operateCode) { + case 0: + bomLines.add("bl_sequence_no"); + bomLines.add("bl_item_object_name"); + bomLines.add("rb3_sccj"); + break; + case 1: + bomLines.add("bl_sequence_no"); + bomLines.add("bl_item_object_name"); + break; + + default: + break; + } +// for(ArrayList arr:getNomList(item,bomLines)){ +// for(String str:arr){ +// System.out.println(str); +// } +// } +// getNomList(item,bomLines); +// getProductProp(); + getProductProp(tccmep); + InputStream is = new FileInputStream(TMomMethodUtil.getFile(session, fileSource.split("\\.")[0],"MSExcelX")); + tcResource = "D:\\"+fileSource; + writeExcelForCirculationCard(tcResource, is, getNomList(tccmep,item,bomLines)); +// ExcelUtil07.writeExcelWithCellName(is,output,getProductProp(),operateCode); +// output.close(); +// new File("c:\\"+fileSource).delete(); + createCirculationCard(item); +// System.out.println("over"); + //13-7 11-7 + } + private ArrayList> getNomList(TCComponentMEProcess tccmep,TCComponentMEProcessRevision item,List bomLines){ + ArrayList> resultList = new ArrayList<>(); + try { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + + TCComponentBOMLine topline = bomWindow.setWindowTopLine(tccmep, + item, null, null); + bomWindow.lock(); + topline.lock(); + + + //ȡlovֵ +// Map sccjMap = new HashMap<>(); +// TCComponentListOfValues rtlistOfValues = TCLOVUtil.findLOVByName(this.session, "RB3_Workarea_LOV"); +// ListOfValuesInfo rtlistOfValuesInfo = rtlistOfValues.getListOfValues(); +// String[] groupName=rtlistOfValuesInfo.getStringListOfValues(); +// String[] groupDisplayName=rtlistOfValuesInfo.getLOVDisplayValues(); +// for (int i = 0; i < groupName.length; i++) { +// sccjMap.put(groupName[i],groupDisplayName[i]); +// } +// for(String key:sccjMap.keySet()){ +// System.out.println(key+"=>"+sccjMap.get(key)); +// } + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline=((TCComponentBOMLine) children.getComponent()); + ArrayList arr = new ArrayList<>(); + for(int i = 0 ; i < bomLines.size() ; i++){ + if(!"rb3_sccj".equals(bomLines.get(i))){ + arr.add(subline.getStringProperty((String) bomLines.get(i)).split("/")[0]); + + } + else{ +// System.out.println("subline.getProperty('rb3_sccj'))=>"+subline.getProperty("rb3_sccj")); + arr.add(subline.getProperty("rb3_sccj")); +// arr.add(sccjMap.get(subline.getProperty("rb3_sccj"))); + } + } + resultList.add(arr); + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return resultList; + } + private void writeExcelForCirculationCard(String write_Address,InputStream is,ArrayList> date){ + try { + OutputStream output = new FileOutputStream(new File(write_Address)); + XSSFWorkbook wb = new XSSFWorkbook(is); + is.close(); + XSSFCellStyle style = wb.createCellStyle(); + if(objectName!=null) + ExcelUtil07.writeExcelWithOneCellName(wb, "Ʒͺ", objectName); + 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); + sheet.setForceFormulaRecalculation(true); + int rowIndex = 0; + int index = 0; + for (int i = 0; i < date.size(); i++) { + boolean isAdd = true; + boolean isAddIndex = true; + ArrayList cell_Date = date.get(i); + System.out.println(cell_Date.toString()); + for (int j = 0; j < cell_Date.size(); j++) { + int namedCellIdx = wb.getNameIndex("head" + + String.valueOf(j + 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++) { + System.out.println("==" +crefs.length); + Sheet s = wb.getSheet(crefs[k].getSheetName()); + Row r = null; + if(index>1 && ((index%12 == 1&&operateCode==0)||(index%10 == 1&&operateCode==1)) && isAdd) + { + System.out.println("**"+crefs[k].getRow()); + rowIndex = rowIndex + 7; + isAdd = false; + index=0; + //r = s.getRow(crefs[k].getRow() + i + 1 + rowIndex); + } + else if(isAddIndex && j == cell_Date.size()-1) + { + index++; + isAddIndex = false; + } + + r = s.getRow(crefs[k].getRow() + i + 1 + rowIndex); + + System.out.println("--" +r.getRowNum()); + Cell c = r.getCell(crefs[k].getCol()); + c.setCellValue(cell_Date.get(j)); + } + } + } + wb.write(output); + output.close(); + System.out.println("-------OVER-------"); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +/** + * + * @throws Exception + */ +private Map getProductProp(TCComponentMEProcess tccmep){ + // TODO Auto-generated method stub + + try { +// InterfaceAIFComponent targetcomp = this.app.getTargetComponent(); + +// TCComponentMEProcess tccmep = (TCComponentMEProcess) targetcomp; + AIFComponentContext[] aifcc_MEPs = tccmep.whereReferenced(); + for(AIFComponentContext aifcc_MEP:aifcc_MEPs){ + String aifcc_MEP_Type = aifcc_MEP.getComponent().getType(); + if("RB3_Product".equals(aifcc_MEP_Type)){ + TCComponentItem product = (TCComponentItem) aifcc_MEP.getComponent(); + objectName = product.getProperty("item_id"); + Map map = new HashMap<>(); + map.put("Ʒͺ", objectName); + return map; + } + + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }catch(Exception e){ + e.printStackTrace(); + } + return null; + } + + private void createCirculationCard(TCComponentMEProcessRevision itemRev) { + try { +// InterfaceAIFComponent targetcomp = this.app.getTargetComponent(); +// if ("MEProcess".equals(tccmep.getType())) { +// TCComponentItem item = (TCComponentItem) tccmep; +// TCComponentItemRevision itemRev = item.getLatestItemRevision(); + TCComponent[] itemRevTC_Attaches = itemRev.getRelatedComponents("RB3_LZK"); + for(TCComponent t:itemRevTC_Attaches){ + if(fileSource.equals(t.toString())){ + int getConfir = ConfirmationDialog.post(" ",fileSource.split("\\.")[0]+"ѴڣǷ񸲸ǣ"); + if(getConfir==ConfirmationDialog.YES){ + itemRev.remove("TC_Attaches", t); + t.delete(); + } + else + return; + } + } + String as1[] = { tcResource};// ļ· + String as2[] = { "excel" }; + String as3[] = { "MSExcelX" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileSource, "excel","MSExcelX"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + itemRev.add("RB3_LZK",tccomponentDataset); + MessageBox.post(""+fileSource.split("\\.")[0]+"", " ", MessageBox.INFORMATION); + new File(tcResource).delete(); + +// } else { +// +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom016/制品加工部返工流转卡.xlsx b/src/com/connor/renben/process/plm/tmom016/制品加工部返工流转卡.xlsx new file mode 100644 index 0000000..b37b02c Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom016/制品加工部返工流转卡.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom016/粉末冶金产品后处理工序流转卡.xlsx b/src/com/connor/renben/process/plm/tmom016/粉末冶金产品后处理工序流转卡.xlsx new file mode 100644 index 0000000..14de3c8 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom016/粉末冶金产品后处理工序流转卡.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessCommand.java b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessCommand.java new file mode 100644 index 0000000..6b85269 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessCommand.java @@ -0,0 +1,187 @@ +package com.connor.renben.process.plm.tmom017; + +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.imageio.ImageIO; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +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 TMom017PackageProcessCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private TCComponent form; + private TCComponentItem product; + private List> dataList = new ArrayList>(); + private String[] properName = new String[] { + "rb3_press_drawing", // ͻͼ + "rb3_khmc"// ͻ + }; + private String[] productProperName = new String[] { + "item_id", // Ʒ + "object_name", // Ʒ + "owning_user" //Ҫ + }; + private String[] formProperName = new String[] { + "rb3_remark" // ע + }; + private TCProperty[] properties; + private TCProperty[] productProperties; + private TCProperty[] formProperties; + + public TMom017PackageProcessCommand(AbstractAIFApplication app, + TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + private void getDate() { + // TODO Auto-generated method stub + ResultSet rs = null; + try { + SqlUtilT.getTCConnection(); + String sql = String.format("select * from RB3_PACKAGEPROCESS where RB3_PUID = \'%s\'",app.getTargetComponent().getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getObject(1)); + rowList.add(rs.getObject(2)); + rowList.add(rs.getObject(3) == null ? "" : rs.getObject(3)); + rowList.add(rs.getObject(4) == null ? "" : rs.getObject(4)); + rowList.add(rs.getObject(5) == null ? "" : rs.getObject(5)); + rowList.add(rs.getObject(6) == null ? "" : rs.getObject(6)); + rowList.add(rs.getObject(7) == null ? "" : rs.getObject(7)); + rowList.add(rs.getObject(8) == null ? "" : rs.getObject(8)); + rowList.add(rs.getObject(9) == null ? "" : rs.getObject(9)); + rowList.add(rs.getObject(10) == null ? "" : rs.getObject(10)); + rowList.add(rs.getObject(11) == null ? "" : rs.getObject(11)); + rowList.add(rs.getObject(12) == null ? "" : rs.getObject(12)); + rowList.add(rs.getObject(13) == null ? "" : rs.getObject(13)); + rowList.add(rs.getObject(14) == null ? "" : rs.getObject(14)); + rowList.add(rs.getObject(15) == null ? "" : rs.getObject(15)); + rowList.add(rs.getObject(16) == null ? "" : rs.getObject(16)); + rowList.add(rs.getObject(17) == null ? "" : rs.getObject(17)); + rowList.add(rs.getObject(18) == null ? "" : rs.getObject(18)); + rowList.add(rs.getObject(19) == null ? "" : rs.getObject(19)); + rowList.add(rs.getObject(20) == null ? "" : rs.getObject(20)); + rowList.add(rs.getObject(21) == null ? "" : rs.getObject(21)); + rowList.add(rs.getObject(22) == null ? "" : rs.getObject(22)); + if(rs.getBlob(23) == null) + { + rowList.add(null); + } + else + { + rowList.add(ImageIO.read(rs.getBlob(23).getBinaryStream())); + } + if(rs.getBlob(24) == null) + { + rowList.add(null); + } + else + { + rowList.add(ImageIO.read(rs.getBlob(24).getBinaryStream())); + } + if(rs.getBlob(25) == null) + { + rowList.add(null); + } + else + { + rowList.add(ImageIO.read(rs.getBlob(25).getBinaryStream())); + } + //rowList.add(ImageIO.read(rs.getBlob(24).getBinaryStream())); + //rowList.add(ImageIO.read(rs.getBlob(25).getBinaryStream())); +// rowList.add(rs.getBinaryStream(23)); +// rowList.add(rs.getBinaryStream(24)); +// rowList.add(rs.getBinaryStream(25)); + rowList.add(rs.getObject(26) == null ? "" : rs.getObject(26)); + dataList.add(rowList); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + } + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + if(app.getTargetComponent().getType().indexOf("ZYZDS") < 0 && !(app.getTargetComponent() instanceof TCComponentItemRevision)) + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qxzbzgyzyzds17_display.TITLE"), "", MessageBox.ERROR); + return; + } + getDate(); + + TCComponentItemRevision itemRevision = (TCComponentItemRevision) app.getTargetComponent(); + this.form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + this.formProperties = this.form.getTCProperties(this.formProperName); + //ȡҵָ + TCComponentItem item = itemRevision.getItem(); + //ȡ汾 + AIFComponentContext[] componentContexts = item.whereReferenced(); + for (int i = 0; i < componentContexts.length; i++) { + if(componentContexts[i].getComponent().getType().indexOf("MEOP") >= 0 && componentContexts[i].getComponent() instanceof TCComponentItemRevision) + { + TCComponentItemRevision meopRevision = (TCComponentItemRevision) componentContexts[i].getComponent(); + //ȡ + TCComponentItem meopItem = meopRevision.getItem(); + //ȡհ汾 + TCComponent[] items = meopItem.whereUsed(TCComponent.WHERE_USED_ALL); + for (int j = 0; j < items.length; j++) { + if(items[j].getType().indexOf("MEProcess") >= 0 && items[j] instanceof TCComponentItemRevision) + { + TCComponentItemRevision meprocessRevision = (TCComponentItemRevision) items[j]; + //ȡ + TCComponentItem meprocessItem = meprocessRevision.getItem(); + //ȡƷ + AIFComponentContext[] productItems = meprocessItem.whereReferenced(); + for (int k = 0; k < productItems.length; k++) { + if(productItems[k].getComponent().getType().indexOf("Product") >= 0 && productItems[k].getComponent() instanceof TCComponentItem) + { + this.product = (TCComponentItem) productItems[k].getComponent(); + this.productProperties = this.product.getTCProperties(this.productProperName); + //ȡƷ°汾 + TCComponentItemRevision productItemRevision = this.product.getLatestItemRevision(); + //ȡ°汾 + TCComponent revMaster = productItemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (revMaster != null) { + properties = revMaster.getTCProperties(properName); + } + } + } + } + } + } + } + + new Thread() { + @Override + public void run() { + TMom017PackageProcessDialog dialog = new TMom017PackageProcessDialog( + session, app,dataList,properties,productProperties,form,formProperties); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessDialog.java b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessDialog.java new file mode 100644 index 0000000..9117491 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessDialog.java @@ -0,0 +1,1158 @@ +package com.connor.renben.process.plm.tmom017; + +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.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.image.BufferedImage; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.sql.Blob; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.SimpleDateFormat; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; +import java.util.UUID; +import java.util.Vector; + +import javax.imageio.ImageIO; +import javax.swing.BorderFactory; +import javax.swing.DefaultListSelectionModel; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; + +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.renben.process.plm.bean.packageProcess.Preferences; +import com.connor.renben.process.plm.bean.packageProcess.Preferences.PackageProcess; +import com.connor.renben.process.plm.bean.packageProcess.Preferences.PackageProcess.TextFieldButton; +import com.connor.renben.process.plm.bean.packageProcess.Preferences.PackageProcess.TextFieldButton.Value; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.CTextFieldButton; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.ImageFilter; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom017PackageProcessDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private String imagePath; + private String componentImagePath; + private String packagingImagePath; + private List> dataList; + private TCComponent form; + private TCProperty[] properties; + private TCProperty[] productProperties; + private TCProperty[] formProperties; + //Table + private boolean isshown = false; + private JScrollPane jspTable; + private JTable table; + private JFrame dialog; + private File file;//ļ + //ҳؼ + private JFileChooser jfc;//ļѡ + + private JPanel titlePanel;// + private JLabel titleLabel; + + //ϲϢ + private JPanel topPanel; + private JLabel projectNoLabel;//Ʒ + private JTextField projectNoField; + private JLabel projectNameLabel;//Ʒ + private JTextField projectNameField; + private JLabel userFigureNoLabel;//ûͼ + private JTextField userFigureNoField; + private JLabel clientNameLabel;//ͻ + private JTextField clientNameField; + private JLabel technologyManageLabel;// + private JTextField technologyManageField; + + private JLabel componentImageLabel;//ͼƬ + + private JPanel mainPanel;// д + + // ǩҳ + private JTabbedPane tabbedPane; + + private JPanel panel1;// һ + private JLabel bzfsLabel;//װʽ + private JComboBox bzfsComboBox ; + private JLabel qyfsLabel;// ͷʽ + private JComboBox qyfsComboBox; + private JLabel numberLabel;//ÿ + private JTextField numberTextField; + private JLabel label;/// + + private JPanel panel2;// ڶ + private JLabel cartonNameLabel;//ֽ + private CTextFieldButton cartonNameFieldButton; + private JLabel packageQuotaLabel;//װ + private JTextField packageQuotaField; + private JLabel label1;///ʱ + + private JPanel panel3;// + private JLabel nylonBagNameLabel;// + private CTextFieldButton nylonBagNameFieldButton; + private JLabel finishedProductWeightLabel;//Ʒ + private JTextField finishedProductWeightField; + private JLabel label2;// g + + private JPanel panel4;// + private JLabel plasticUptakeNameLabel;// + private CTextFieldButton plasticUptakeNameFieldButton; + private JTextField plasticUptakeName2Field; + private JLabel roughWeightLabel;//ë + private JTextField roughWeightField; + private JLabel label3;// kg + + private JPanel panel5;// + private JLabel outerBoxLabel;//ǩ + private JComboBox outerBoxComboBox; + + private JPanel panel6;// + private JLabel storageTrayLabel;// + private JComboBox storageTrayBox; + private JTextField storageTrayField; + private JLabel label4;// / + private JTextField tierField; + private JLabel label5;/// + + private JLabel imageLabel;//ͼƬ + + private JPanel panel7;// + private JLabel explainLabel;//˵ + private JTextArea explainArea; + + private JLabel attentionLabel;//ע + private JTextArea attentionArea; + private JLabel designUserLabel;//Ա + private JTextField designUserField; + private JLabel ratifyUserLabel;//׼Ա + private JTextField ratifyUserField; + private JLabel changeDateLabel;//޸ + private DateButton changeDateButton; + private JLabel remarkLabel;//ע + private JTextArea remarkArea; + + //ڶҳ + private JLabel carriagePackTypeLabel;//װ + private JComboBox carriagePackTypeBox; + private JLabel packagingLabel;//ʽ + private JComboBox packagingBox; + private JLabel palletSpecLabel;//̹ + private JComboBox palletSpecBox; + private JLabel methodsReinforcementLabel;//ӹ̷ʽ + private JComboBox methodsReinforcementBox; + + private JLabel packagingImageLabel;// + + private JTextArea textkArea; + + private JPanel rootPanel;//ť + private JButton saveButton;// + private JButton outputButton;// + private JButton celButton;//ȡ + + public TMom017PackageProcessDialog(TCSession session, + AbstractAIFApplication app,List> dataList,TCProperty[] properties, + TCProperty[] productProperties,TCComponent form,TCProperty[] formProperties) { + // TODO Auto-generated constructor stub + super(false); + this.app = app; + this.session = session; + this.dataList = dataList; + this.form = form; + this.properties = properties; + this.productProperties = productProperties; + this.formProperties = formProperties; + init(); + this.file = TMomMethodUtil.getFile(session, "װ","MSExcelX"); + try { + setProperty(); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + 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("bzgy17_display.TITLE")); + this.setPreferredSize(new Dimension(900, 750)); + + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("bzgy17_display.TITLE")); + this.titleLabel.setFont(new Font("", 1, 18)); + this.titlePanel.add(titleLabel); + + this.topPanel = new JPanel(new PropertyLayout()); + this.projectNoLabel = new JLabel(rb.getString("cpdh17_display.TITLE")); + this.projectNoField = new JTextField(20); + this.projectNameLabel = new JLabel(rb.getString("cpmc17_display.TITLE")); + this.projectNameField = new JTextField(20); + this.userFigureNoLabel = new JLabel(rb.getString("yhth17_display.TITLE")); + this.userFigureNoField = new JTextField(20); + this.clientNameLabel = new JLabel(rb.getString("chmc17_display.TITLE")); + this.clientNameField = new JTextField(20); + this.technologyManageLabel = new JLabel(rb.getString("jszg17_display.TITLE")); + this.technologyManageField = new JTextField(20); + + this.componentImageLabel = new JLabel(rb.getString("sjxzljtp17_display.TITLE"));//ͼƬ + this.componentImageLabel.setPreferredSize(new Dimension(150, 110)); + this.componentImageLabel.setOpaque(true); + this.componentImageLabel.setBackground(Color.WHITE); + this.componentImageLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + // TODO Auto-generated method stub + if(arg0.getClickCount() == 2) + { + selectFileButtonEvent(arg0); + } + //super.mouseClicked(arg0); + } + }); + this.topPanel.add("1.1.left.top", this.projectNoLabel); + this.topPanel.add("1.2.left.top", this.projectNoField); + this.topPanel.add("1.3.left.top", this.technologyManageLabel); + this.topPanel.add("1.4.left.top", this.technologyManageField); + this.topPanel.add("2.1.left.top", this.projectNameLabel); + this.topPanel.add("2.2.left.top", this.projectNameField); + this.topPanel.add("3.1.left.top", this.userFigureNoLabel); + this.topPanel.add("3.2.left.top", this.userFigureNoField); + this.topPanel.add("4.1.left.top", this.clientNameLabel); + this.topPanel.add("4.2.left.top", this.clientNameField); + + JPanel partPanel = new JPanel(new PropertyLayout()); + partPanel.setPreferredSize(new Dimension(830,140)); + partPanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black),"Ϣ")); + partPanel.add("1.1.left.top", topPanel); + partPanel.add("1.2.right.top", componentImageLabel); + + this.panel1 = new JPanel(new PropertyLayout()); + this.bzfsLabel = new JLabel(rb.getString("bzfs17_display.TITLE")); + this.bzfsComboBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.BZFS_COMBOBOX_VALUES)); + this.bzfsComboBox.setEditable(true); + this.bzfsComboBox.setPreferredSize(new Dimension(167, 20)); + this.qyfsLabel = new JLabel(rb.getString("jyfs17_display.TITLE")); + this.qyfsComboBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.QYFS_COMBOBOX_VALUES)); + this.qyfsComboBox.setPreferredSize(new Dimension(165, 20)); + this.qyfsComboBox.setEditable(true); + this.numberLabel = new JLabel(rb.getString("mxsl17_display.TITLE")); + this.numberTextField = new JTextField(8); + this.label = new JLabel(rb.getString("jx17_display.TITLE")); + this.panel1.add("1.1.left.top",this.bzfsLabel); + this.panel1.add("1.2.left.top",this.bzfsComboBox); + this.panel1.add("1.3.left.top",this.qyfsLabel); + this.panel1.add("1.4.left.top",this.qyfsComboBox); + this.panel1.add("1.5.left.top",this.numberLabel); + this.panel1.add("1.6.left.top",this.numberTextField); + this.panel1.add("1.7.left.top",this.label); + + this.panel2 = new JPanel(new PropertyLayout()); + this.cartonNameLabel = new JLabel(rb.getString("wzxm17_display.TITLE")); + this.cartonNameFieldButton = new CTextFieldButton (){ + + @Override + public void handleClick(CTextFieldButton textFieldButton) { + // TODO Auto-generated method stub + if (isshown) { + TMom017PackageProcessDialog.this.getLayeredPane().remove(jspTable); + isshown = false; + } else { + jspTable = getJspTable(cartonNameFieldButton,cartonNameLabel); + int x = cartonNameLabel.getX()+cartonNameLabel.getWidth()+5; + int y = 261; + jspTable.setLocation(x, y); + TMom017PackageProcessDialog.this.getLayeredPane().add(jspTable, 0); + isshown = true; + table.requestFocus(); + } + TMom017PackageProcessDialog.this.getLayeredPane().validate(); + TMom017PackageProcessDialog.this.getLayeredPane().repaint(); + }}; + this.cartonNameFieldButton.setPreferredSize(new Dimension(390, 20)); + this.packageQuotaLabel = new JLabel(rb.getString("bzde17_display.TITLE")); + this.packageQuotaField = new JTextField(8); + this.label1 = new JLabel(rb.getString("xs17_display.TITLE")); + this.panel2.add("1.1.left.top", this.cartonNameLabel); + this.panel2.add("1.2.left.top", this.cartonNameFieldButton); + this.panel2.add("1.3.left.top", this.packageQuotaLabel); + this.panel2.add("1.4.left.top", this.packageQuotaField); + this.panel2.add("1.5.left.top", this.label1); + + this.panel3 = new JPanel(new PropertyLayout()); + this.nylonBagNameLabel = new JLabel(rb.getString("nldm17_display.TITLE")); + this.nylonBagNameFieldButton = new CTextFieldButton (){ + + @Override + public void handleClick(CTextFieldButton textFieldButton) { + // TODO Auto-generated method stub + if (isshown) { + TMom017PackageProcessDialog.this.getLayeredPane().remove(jspTable); + isshown = false; + } else { + jspTable = getJspTable(nylonBagNameFieldButton,nylonBagNameLabel); + int x = nylonBagNameLabel.getX()+nylonBagNameLabel.getWidth()+5; + int y = 287; + jspTable.setLocation(x, y); + TMom017PackageProcessDialog.this.getLayeredPane().add(jspTable, 0); + isshown = true; + table.requestFocus(); + } + TMom017PackageProcessDialog.this.getLayeredPane().validate(); + TMom017PackageProcessDialog.this.getLayeredPane().repaint(); + }}; + this.nylonBagNameFieldButton.setPreferredSize(new Dimension(390, 20)); + this.finishedProductWeightLabel = new JLabel(rb.getString("cpdz17_display.TITLE")); + this.finishedProductWeightField = new JTextField(8); + this.label2 = new JLabel("g"); + this.panel3.add("1.1.left.top",this.nylonBagNameLabel); + this.panel3.add("1.2.left.top",this.nylonBagNameFieldButton); + this.panel3.add("1.3.left.top",this.finishedProductWeightLabel); + this.panel3.add("1.4.left.top",this.finishedProductWeightField); + this.panel3.add("1.5.left.top",this.label2); + + this.panel4 = new JPanel(new PropertyLayout()); + this.plasticUptakeNameLabel = new JLabel(rb.getString("xsm17_display.TITLE")); + this.plasticUptakeNameFieldButton = new CTextFieldButton (){ + + @Override + public void handleClick(CTextFieldButton textFieldButton) { + // TODO Auto-generated method stub + if (isshown) { + TMom017PackageProcessDialog.this.getLayeredPane().remove(jspTable); + isshown = false; + //return; + } else { + jspTable = getJspTable(plasticUptakeNameFieldButton,plasticUptakeNameLabel); + int x = plasticUptakeNameLabel.getX()+plasticUptakeNameLabel.getWidth()+5; + int y = 313; + jspTable.setLocation(x, y); + TMom017PackageProcessDialog.this.getLayeredPane().add(jspTable, 0); + isshown = true; + table.requestFocus(); + } + TMom017PackageProcessDialog.this.getLayeredPane().validate(); + TMom017PackageProcessDialog.this.getLayeredPane().repaint(); + }}; + this.plasticUptakeNameFieldButton.setPreferredSize(new Dimension(340, 20)); + this.plasticUptakeName2Field = new JTextField(); + this.plasticUptakeName2Field.setPreferredSize(new Dimension(45, 20)); + this.roughWeightLabel = new JLabel(rb.getString("zxmz17_display.TITLE")); + this.roughWeightField = new JTextField(8); + this.label3 = new JLabel("kg"); + this.panel4.add("1.1.left.top", this.plasticUptakeNameLabel); + this.panel4.add("1.2.left.top", this.plasticUptakeNameFieldButton); + this.panel4.add("1.3.left.top", this.plasticUptakeName2Field); + this.panel4.add("1.4.left.top", this.roughWeightLabel); + this.panel4.add("1.5.left.top", this.roughWeightField); + this.panel4.add("1.6.left.top", this.label3); + this.panel5 = new JPanel(new PropertyLayout()); + this.outerBoxLabel = new JLabel(rb.getString("wxbq17_display.TITLE")); + this.outerBoxComboBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.OUTERBOX_COMBOBOX_VALUESS)); + this.outerBoxComboBox.setPreferredSize(new Dimension(390, 20)); + this.outerBoxComboBox.setEditable(true); + this.panel5.add("1.1.left.top", this.outerBoxLabel); + this.panel5.add("1.2.left.top", this.outerBoxComboBox); + + + this.panel6 = new JPanel(new PropertyLayout());// + this.storageTrayLabel = new JLabel(rb.getString("rktp17_display.TITLE"));// + this.storageTrayBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.STORAGETRAY_COMBOBOX_VALUES)); + this.storageTrayBox.setPreferredSize(new Dimension(340, 20)); + this.storageTrayBox.setEditable(true); + this.storageTrayField = new JTextField(); + this.storageTrayField.setPreferredSize(new Dimension(45, 20)); + this.label4 = new JLabel(rb.getString("xc17_display.TITLE"));// 4 + this.tierField = new JTextField(); + this.tierField.setPreferredSize(new Dimension(45, 20)); + this.label5 = new JLabel(rb.getString("ct17_display.TITLE"));// 5 + panel6.add("1.1.left.top", storageTrayLabel); + panel6.add("1.2.left.top", storageTrayBox); + panel6.add("1.3.left.top", storageTrayField); + panel6.add("1.4.left.top", label4); + panel6.add("1.5.left.top", tierField); + panel6.add("1.6.left.top", label5); + + this.mainPanel = new JPanel(new PropertyLayout()); + this.mainPanel.add("1.1.left.top", panel1); + this.mainPanel.add("2.1.left.top", panel2); + this.mainPanel.add("3.1.left.top", panel3); + this.mainPanel.add("4.1.left.top", panel4); + this.mainPanel.add("5.1.left.top", panel5); + this.mainPanel.add("6.1.left.top", panel6); + //ͼƬѡؼ + this.imageLabel = new JLabel(rb.getString("sjxztp17_display.TITLE")); + this.imageLabel.setPreferredSize(new Dimension(200,130)); + this.imageLabel.setOpaque(true); + this.imageLabel.setBackground(Color.WHITE); + this.imageLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + // TODO Auto-generated method stub + if(arg0.getClickCount() == 2) + { + selectFileButtonEvent(arg0); + } + //super.mouseClicked(arg0); + } + }); + + JPanel imagePanel = new JPanel(new PropertyLayout()); + imagePanel.setPreferredSize(new Dimension(830,180)); + imagePanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black),"װϢ")); + imagePanel.add("1.1.left.top", mainPanel); + imagePanel.add("1.2.left.top", imageLabel); + + + this.panel7 = new JPanel(new PropertyLayout()); + JPanel explainPanel = new JPanel(new PropertyLayout()); + this.explainLabel = new JLabel(rb.getString("bzsm17_display.TITLE")); + this.explainArea = new JTextArea(); + this.explainArea.setPreferredSize(new Dimension(450, 200)); + explainPanel.add("1.1.left.top", explainLabel); + explainPanel.add("2.1.left.top", explainArea); + JPanel attentionPanel = new JPanel(new PropertyLayout()); + this.attentionLabel = new JLabel(rb.getString("zysx17_display.TITLE")); + this.attentionArea = new JTextArea(); + this.attentionArea.setPreferredSize(new Dimension(342, 100)); + attentionPanel.add("1.1.left.top", attentionLabel); + attentionPanel.add("2.1.left.top", attentionArea); + JPanel otherPanel = new JPanel(new PropertyLayout()); + this.designUserLabel = new JLabel(rb.getString("bzry17_display.TITLE"));//Ա + this.designUserField = new JTextField(); + this.designUserField.setPreferredSize(new Dimension(115, 20)); + this.ratifyUserLabel = new JLabel(rb.getString("pzry17_display.TITLE"));//׼Ա + this.ratifyUserField = new JTextField(); + this.ratifyUserField.setPreferredSize(new Dimension(115, 20)); + this.changeDateLabel = new JLabel(rb.getString("xgrq17_display.TITLE"));//޸ + this.changeDateButton = new DateButton(new SimpleDateFormat("YYYY-MM-DD")); + this.changeDateButton.setPreferredSize(new Dimension(115,20)); + this.remarkLabel = new JLabel(rb.getString("bz17_display.TITLE"));//޸ + this.remarkArea = new JTextArea(); + this.remarkArea.setPreferredSize(new Dimension(115, 50)); + otherPanel.add("1.1.left.top", designUserLabel); + otherPanel.add("1.2.left.top", designUserField); + otherPanel.add("1.3.left.top", ratifyUserLabel); + otherPanel.add("1.4.left.top", ratifyUserField); + otherPanel.add("2.1.left.top", changeDateLabel); + otherPanel.add("2.2.left.top", changeDateButton); + otherPanel.add("2.3.left.top", remarkLabel); + otherPanel.add("2.4.left.top", remarkArea); + + JPanel otherPanel2 = new JPanel(new PropertyLayout()); + otherPanel2.add("1.1.left.top", attentionPanel); + otherPanel2.add("2.1.left.top", otherPanel); + panel7.add("1.1.left.top", explainPanel); + panel7.add("1.2.left.top", otherPanel2); + panel7.setPreferredSize(new Dimension(830,250)); + panel7.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black),"Ϣ")); + + JPanel leftPanel = new JPanel(new PropertyLayout()); + this.carriagePackTypeLabel = new JLabel(rb.getString("ysbzlx17_display.TITLE"));//װ + this.carriagePackTypeBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.CARRIAGEPACK_COMBOBOX_VALUES)); + this.carriagePackTypeBox.setEditable(true); + this.carriagePackTypeBox.setPreferredSize(new Dimension(167, 20)); + this.packagingLabel = new JLabel(rb.getString("dbfs17_display.TITLE"));//ʽ + this.packagingBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.PACKAGING_COMBOBOX_VALUES)); + this.packagingBox.setEditable(true); + this.packagingBox.setPreferredSize(new Dimension(167, 20)); + this.palletSpecLabel = new JLabel(rb.getString("tpgg17_display.TITLE"));//̹ + this.palletSpecBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.PALLETSPEC_COMBOBOX_VALUES)); + this.palletSpecBox.setEditable(true); + this.palletSpecBox.setPreferredSize(new Dimension(167, 20)); + this.methodsReinforcementLabel = new JLabel(rb.getString("jgfs17_display.TITLE"));//ӹ̷ʽ + this.methodsReinforcementBox = new JComboBox<>(getComboBoxValues(TMomFinalUtil.METHODSREINFORCEMENT_COMBOBOX_VALUES)); + this.methodsReinforcementBox.setEditable(true); + this.methodsReinforcementBox.setPreferredSize(new Dimension(167, 20)); + + //ͼƬѡؼ + this.packagingImageLabel = new JLabel(rb.getString("sjxzdbt17_display.TITLE")); + this.packagingImageLabel.setPreferredSize(new Dimension(200,130)); + this.packagingImageLabel.setOpaque(true); + this.packagingImageLabel.setBackground(Color.WHITE); + this.packagingImageLabel.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + // TODO Auto-generated method stub + if(arg0.getClickCount() == 2) + { + selectFileButtonEvent(arg0); + } + //super.mouseClicked(arg0); + } + }); + leftPanel.add("1.1.left.top",this.carriagePackTypeLabel); + leftPanel.add("1.2.left.top",this.carriagePackTypeBox); + leftPanel.add("2.1.left.top",this.packagingLabel); + leftPanel.add("2.2.left.top",this.packagingBox); + leftPanel.add("3.1.left.top",this.palletSpecLabel); + leftPanel.add("3.2.left.top",this.palletSpecBox); + leftPanel.add("4.1.left.top",this.methodsReinforcementLabel); + leftPanel.add("4.2.left.top",this.methodsReinforcementBox); + + JPanel panel2 = new JPanel(new PropertyLayout()); + panel2.add("1.1.left.top",leftPanel); + panel2.add("2.1.left.top",this.packagingImageLabel); + + this.textkArea = new JTextArea(); + this.textkArea.setPreferredSize(new Dimension(500,200)); + + JPanel secondPanel = new JPanel(new PropertyLayout()); + secondPanel.add("1.1.left.top",panel2); + secondPanel.add("1.2.left.top",this.textkArea); + + JPanel firstPanel = new JPanel(new PropertyLayout()); + firstPanel.add("1.1.left.top",imagePanel); + firstPanel.add("2.1.left.top",panel7); + + this.tabbedPane = new JTabbedPane(); + this.tabbedPane.add(rb.getString("dybzxx17_display.TITLE"), new JScrollPane(firstPanel)); + this.tabbedPane.add(rb.getString("ysbzxx17_display.TITLE"), new JScrollPane(secondPanel)); + + + JPanel panel = new JPanel(new BorderLayout()); + panel.add(partPanel,BorderLayout.NORTH); + panel.add(tabbedPane, BorderLayout.CENTER); + + this.rootPanel = new JPanel(new FlowLayout()); + this.saveButton = new JButton(rb.getString("bc_display.TITLE")); + this.saveButton.addActionListener(this); + this.outputButton = new JButton(rb.getString("dc_display.TITLE")); + this.outputButton.addActionListener(this); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.addActionListener(this); + this.rootPanel.add(this.saveButton); + this.rootPanel.add(this.outputButton); + this.rootPanel.add(this.celButton); + +// JPanel mainTitlePanel = new JPanel(new PropertyLayout()); +// mainTitlePanel.add("1.1.center.top",titlePanel); +// mainTitlePanel.add("2.1.left.top", partPanel); + // titlePanel.add(partPanel); + + this.setLayout(new BorderLayout()); + this.add(titlePanel,BorderLayout.NORTH); + this.add(rootPanel, BorderLayout.SOUTH); + this.add(panel, BorderLayout.CENTER); + this.showDialog(); + + } + + private String[] getComboBoxValues(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 + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("wzdsxx17_display.TITLE"), "", MessageBox.ERROR); + } + return values; + } + + private void setProperty() throws SQLException { + // TODO Auto-generated method stub + if(this.properties != null) + { + this.userFigureNoField.setText(this.properties[0] == null ? "" : this.properties[0].getStringValue()); + this.clientNameField.setText(this.properties[1] == null ? "" : this.properties[1].getStringValue()); + } + if(this.productProperties != null) + { + this.projectNoField.setText(this.productProperties[0] == null ? "" : this.productProperties[0].getStringValue()); + this.projectNameField.setText(this.productProperties[1] == null ? "" : this.productProperties[1].getStringValue()); + try { + this.technologyManageField.setText((this.productProperties[2] == null ? "" : this.productProperties[2].getReferenceValue().getStringProperty("user_name"))); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(this.formProperties != null) + { + this.remarkArea.setText(this.formProperties[0] == null ? "" : this.formProperties[0].getStringValue()); + } + if(this.dataList.size() > 0) + { + this.bzfsComboBox.setSelectedItem(dataList.get(0).get(2)); + this.qyfsComboBox.setSelectedItem(dataList.get(0).get(3)); + this.numberTextField.setText(dataList.get(0).get(4).toString()); + this.cartonNameFieldButton.setText(dataList.get(0).get(5).toString()); + this.packageQuotaField.setText(dataList.get(0).get(6).toString()); + this.nylonBagNameFieldButton.setText(dataList.get(0).get(7).toString()); + this.finishedProductWeightField.setText(dataList.get(0).get(8).toString()); + this.plasticUptakeNameFieldButton.setText(dataList.get(0).get(9).toString()); + this.plasticUptakeName2Field.setText(dataList.get(0).get(10).toString()); + this.roughWeightField.setText(dataList.get(0).get(11).toString()); + this.outerBoxComboBox.setSelectedItem(dataList.get(0).get(12)); + this.storageTrayBox.setSelectedItem(dataList.get(0).get(13)); + this.storageTrayField.setText(dataList.get(0).get(14).toString()); + this.carriagePackTypeBox.setSelectedItem(dataList.get(0).get(15).toString()); + this.packagingBox.setSelectedItem(dataList.get(0).get(16).toString()); + this.palletSpecBox.setSelectedItem(dataList.get(0).get(17).toString()); + this.methodsReinforcementBox.setSelectedItem(dataList.get(0).get(18).toString()); + this.explainArea.setText(dataList.get(0).get(19).toString()); + this.attentionArea.setText(dataList.get(0).get(20).toString()); + this.textkArea.setText(dataList.get(0).get(21).toString()); + this.tierField.setText(dataList.get(0).get(25).toString()); + if(dataList.get(0).get(22) != null) + { + try { +// BufferedInputStream inputImage = new BufferedInputStream((InputStream) dataList.get(0).get(22)); +// InputStream is = (InputStream) dataList.get(0).get(22); +// FileOutputStream fos = new FileOutputStream(new File("C:\\abc.jpg")); +// byte[] buffer = new byte[4 * 1024]; +// int length = 0; +// while ((length = is.read(buffer)) != -1) { +// fos.write(buffer, 0, length); +// } +// fos.flush(); +// fos.close(); +// is.close(); + Image image = dataList.get(0).get(22) == null ? null : (Image) dataList.get(0).get(22) ; + if(image != null) + { + ImageIcon icon = new ImageIcon(image); + icon.setImage(icon.getImage().getScaledInstance((int)componentImageLabel.getPreferredSize().getWidth(),(int)componentImageLabel.getPreferredSize().getHeight(), Image.SCALE_DEFAULT)); + this.componentImageLabel.setIcon(icon); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(dataList.get(0).get(23) != null) + { + try { + Image image = dataList.get(0).get(23) == null ? null : (Image) dataList.get(0).get(23); + if(image != null) + { + ImageIcon icon = new ImageIcon(image); + icon.setImage(icon.getImage().getScaledInstance((int)imageLabel.getPreferredSize().getWidth(),(int)imageLabel.getPreferredSize().getHeight(), Image.SCALE_DEFAULT)); + this.imageLabel.setIcon(icon); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(dataList.get(0).get(24) != null) + { + try { + Image image = dataList.get(0).get(24) == null ? null : (Image)dataList.get(0).get(24); + if(image != null) + { + ImageIcon icon = new ImageIcon(image); + icon.setImage(icon.getImage().getScaledInstance((int)this.packagingImageLabel.getPreferredSize().getWidth(),(int)packagingImageLabel.getPreferredSize().getHeight(), Image.SCALE_DEFAULT)); + this.packagingImageLabel.setIcon(icon); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + } + + public File inputstreamtofile(InputStream ins){ + File file = new File(System.getenv("TEMP")+"\\"+"1.JPG"); + try { + OutputStream os = new FileOutputStream(file); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + os.close(); + ins.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return file; + } + + /** + * ͼƬѡ + * @param e + */ + public void selectFileButtonEvent(MouseEvent e) { + this.jfc = new JFileChooser(); + this.jfc.setFileFilter(new ImageFilter()); + this.jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + int state = this.jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + if(e.getSource().equals(this.imageLabel)) + { + imagePath = f.getAbsolutePath(); + } + else if(e.getSource().equals(this.componentImageLabel)) + { + componentImagePath = f.getAbsolutePath(); + } + else if(e.getSource().equals(this.packagingImageLabel)) + { + packagingImagePath = f.getAbsolutePath(); + } + System.out.println(f.getAbsolutePath()); + ImageIcon icon = new ImageIcon(f.getAbsolutePath()); + icon.setImage(icon.getImage().getScaledInstance((int)((JLabel)e.getSource()).getPreferredSize().getWidth(), + (int)((JLabel)e.getSource()).getPreferredSize().getHeight(), Image.SCALE_DEFAULT)); + ((JLabel)e.getSource()).setIcon(icon); + } + } + + private JScrollPane getJspTable(final CTextFieldButton fieldButton,JLabel label) { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + //if (jspTable == null) { + Vector rowdata = new Vector(); +// for (int i = 0; i < 10; i++) { +// Vector row = new Vector(); +// row.add("000" + i); +// row.add("CustomName" + i); +// row.add("CustomAddress" + i); +// rowdata.add(row); +// } + rowdata = getPropertys(label.getText().trim()); + Vector header = new Vector(); + if(fieldButton.equals(this.nylonBagNameFieldButton)) + { + header.add(rb.getString("dh17_display.TITLE")); + header.add(rb.getString("cckcg17_display.TITLE")); + header.add(rb.getString("hd17_display.TITLE")); + } + else if(fieldButton.equals(this.cartonNameFieldButton)) + { + header.add(rb.getString("dh17_display.TITLE")); + header.add(rb.getString("cl17_display.TITLE")); + header.add(rb.getString("gg17_display.TITLE")); + header.add(rb.getString("bz17_display.TITLE")); + } + else if(fieldButton.equals(this.plasticUptakeNameFieldButton)) + { + header.add(rb.getString("ks17_display.TITLE")); + header.add(rb.getString("xh_display.TITLE")); + header.add(rb.getString("gg17_display.TITLE")); + header.add(rb.getString("cp17_display.TITLE")); + } + table = new JTable(rowdata, header); + table.setSelectionMode(DefaultListSelectionModel.SINGLE_SELECTION); + table.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() == 1) { + int row = table.getSelectedRow(); + if(fieldButton.equals(nylonBagNameFieldButton)) + { + fieldButton.setText(table.getValueAt(row, 0).toString() + + "" + table.getValueAt(row, 1).toString() + + "/" + table.getValueAt(row, 2).toString()); + } + else if(fieldButton.equals(cartonNameFieldButton)) + { + fieldButton.setText(table.getValueAt(row, 0).toString() + + "-" + table.getValueAt(row, 2).toString()); + } + else if(fieldButton.equals(plasticUptakeNameFieldButton)) + { + fieldButton.setText(table.getValueAt(row, 1).toString() + + "" + table.getValueAt(row, 3).toString() + + ""+ table.getValueAt(row, 2).toString()); + } + TMom017PackageProcessDialog.this.getLayeredPane().remove(jspTable); + isshown = false; + TMom017PackageProcessDialog.this.getLayeredPane().validate(); + TMom017PackageProcessDialog.this.getLayeredPane().repaint(); + } + } + }); + table.addFocusListener(new FocusListener() { + public void focusGained(FocusEvent e) { + } + + public void focusLost(FocusEvent e) { + Component target = e.getOppositeComponent(); + if (target == fieldButton) { + return; + } else { + TMom017PackageProcessDialog.this.getLayeredPane().remove(jspTable); + isshown = false; + TMom017PackageProcessDialog.this.getLayeredPane().validate(); + TMom017PackageProcessDialog.this.getLayeredPane().repaint(); + } + } + }); + jspTable = new JScrollPane(table); + //jspTable.setViewportView(table); + jspTable.setSize(new Dimension(350, 100)); + //} + return jspTable; + } +// //ȡXMLļ +// private void getFile() { +// // TODO Auto-generated method stub +// try { +// TCPreferenceService service = this.session.getPreferenceService(); +// String[] modelFiles = service.getStringValues(TMomFinalUtil.PROCESS_MODEL_FILE); +// if (modelFiles == null) +// { +// System.out.println("δҵѡ"); +// return; +// } +// String puid = ""; +// for (int i = 0; i < modelFiles.length; i++) { +// if(modelFiles[i].split("-")[0].equals("װ")) +// { +// puid = modelFiles[i].split("-")[1]; +// } +// } +// TCComponentDataset dat = (TCComponentDataset)this.session +// .stringToComponent(puid); +// TCComponentTcFile[] tcFile = dat.getTcFiles(); +// if(tcFile != null && tcFile.length == 0) +// { +// System.out.println("δҵļ"); +// } +// else +// { +// this.file = tcFile[0].getFmsFile(); +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } + + private Vector getPropertys(String textFieldButtonName) { + // TODO Auto-generated method stub + JAXBContext context; + Vector rowdata = new Vector(); + try { + if(this.file != null) + { + context = JAXBContext.newInstance(Preferences.class); + Unmarshaller shaller = context.createUnmarshaller(); + JAXBElement root = shaller.unmarshal( + new StreamSource(this.file), + Preferences.class); + Preferences electronform = root.getValue(); + List PackageProcess = electronform.getPackageProcess(); + for (PackageProcess PackageProcess2 : PackageProcess) { + List TextFieldButton = PackageProcess2.getTextFieldButton(); + for (TextFieldButton textFieldButton2 : TextFieldButton) { + List values = textFieldButton2.getValue(); + if(textFieldButton2.getName().equals(textFieldButtonName)) + { + for (Value value : values) { + Vector row = new Vector(); + row.add(value.getProperty1()); + row.add(value.getProperty2()); + row.add(value.getProperty3()); + row.add(value.getProperty4()); + rowdata.add(row); + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return rowdata; + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if(source.equals(this.saveButton)) + { + ResultSet rs = null; + try { + this.form.lock(); + this.form.setStringProperty("rb3_remark", this.remarkArea.getText()); + this.form.save(); + this.form.unlock(); + this.form.refresh(); + Connection con=SqlUtilT.getTCConnection(); + //ݿdengluΪݿsaΪݿʺż롣 + Statement stmt=con.createStatement(); //Statement + FileInputStream componentStr = null; + FileInputStream str = null; + FileInputStream packagingStr = null; + if(imagePath != null) + { + str = new FileInputStream(new File(imagePath)); + } + if(componentImagePath != null) + { + componentStr = new FileInputStream(new File(componentImagePath)); + } + if(packagingImagePath != null) + { + packagingStr = new FileInputStream(new File(packagingImagePath)); + } + SqlUtilT.getTCConnection(); + String selectSql = String.format("select * from RB3_PACKAGEPROCESS where RB3_PUID = \'%s\'",app.getTargetComponent().getUid()); + rs = SqlUtilT.read(selectSql); + //dataList != null && dataList.size() > 0 + if(rs.next()) + { + String updateSql = String.format("update RB3_PACKAGEPROCESS " + + "set RB3_BZFS = ?,RB3_QYFS = ?,RB3_NUMBER = ?," + + "RB3_CARTON_NAME = ?,RB3_PACKAGE_QUOTA = ?,RB3_NYLONBAG_NAME = ?," + + "RB3_FINISHED_PRODUCT_WEIGHT = ?,RB3_PLASTIC_UPTAKE = ?,RB3_PLASTIC_UPTAKE_NUMBER = ?," + + "RB3_ROUGH_WEIGH = ?,RB3_OUTERBOX = ?,RB3_STORAGE_TRAY = ?,RB3_STORAGE_TRAY_NUMBER = ?,RB3_CARRIAGEPACK_TYPE = ?," + + "RB3_PACKAGING = ?,RB3_PALLET_SPEC = ?,RB3_METHODS_REINFORCEMENT = ?, RB3_EXPLAIN = ?,RB3_ATTENTION = ?, RB3_REMARK = ?," + + "RB3_TIER = ? where plmeid = \'%s\'", dataList.get(0).get(0)); + PreparedStatement pstmt=con.prepareStatement(updateSql); + pstmt.setObject(1, this.bzfsComboBox.getSelectedItem()); + pstmt.setObject(2, this.qyfsComboBox.getSelectedItem()); + pstmt.setObject(3, this.numberTextField.getText()); + pstmt.setObject(4, this.cartonNameFieldButton.getText()); + pstmt.setObject(5, this.packageQuotaField.getText()); + pstmt.setObject(6, this.nylonBagNameFieldButton.getText()); + pstmt.setObject(7, this.finishedProductWeightField.getText()); + pstmt.setObject(8, this.plasticUptakeNameFieldButton.getText()); + pstmt.setObject(9, this.plasticUptakeName2Field.getText()); + pstmt.setObject(10, this.roughWeightField.getText()); + pstmt.setObject(11, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(12, this.storageTrayBox.getSelectedItem()); + pstmt.setObject(13, this.storageTrayField.getText()); + pstmt.setObject(14, this.carriagePackTypeBox.getSelectedItem()); + pstmt.setObject(15, this.packagingBox.getSelectedItem()); + pstmt.setObject(16, this.palletSpecBox.getSelectedItem()); + pstmt.setObject(17, this.methodsReinforcementBox.getSelectedItem()); + pstmt.setObject(18, this.explainArea.getText()); + pstmt.setObject(19, this.attentionArea.getText()); + pstmt.setObject(20, this.textkArea.getText()); + pstmt.setObject(21, this.tierField.getText()); + pstmt.execute(); + if(str != null) + { + String updateSql2 = String.format("update RB3_PACKAGEPROCESS " + + "set RB3_PACK_IMAGE = ? where plmeid = \'%s\'", dataList.get(0).get(0)); + PreparedStatement pstmt2=con.prepareStatement(updateSql2); + pstmt2.setBinaryStream(1, str, str.available()); + pstmt2.execute(); + } + if(componentStr != null) + { + String updateSql2 = String.format("update RB3_PACKAGEPROCESS " + + "set RB3_COMPONENT_IMAGE = ? where plmeid = \'%s\'", dataList.get(0).get(0)); + PreparedStatement pstmt2=con.prepareStatement(updateSql2); + pstmt2.setBinaryStream(1, componentStr, componentStr.available()); + pstmt2.execute(); + } + if(packagingStr != null) + { + String updateSql2 = String.format("update RB3_PACKAGEPROCESS " + + "set RB3_PACKAGEING_IMAGE = ? where plmeid = \'%s\'", dataList.get(0).get(0)); + PreparedStatement pstmt2=con.prepareStatement(updateSql2); + pstmt2.setBinaryStream(1, packagingStr, packagingStr.available()); + pstmt2.execute(); + } + } + else + { + String sql="insert into RB3_PACKAGEPROCESS values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + PreparedStatement pstmt=con.prepareStatement(sql); + pstmt.setObject(1, UUID.randomUUID().toString().replace("-", "")); + pstmt.setObject(2, app.getTargetComponent().getUid()); + pstmt.setObject(3, this.bzfsComboBox.getSelectedItem()); + pstmt.setObject(4, this.qyfsComboBox.getSelectedItem()); + pstmt.setObject(5, this.numberTextField.getText()); + pstmt.setObject(6, this.cartonNameFieldButton.getText()); + pstmt.setObject(7, this.packageQuotaField.getText()); + pstmt.setObject(8, this.nylonBagNameFieldButton.getText()); + pstmt.setObject(9, this.finishedProductWeightField.getText()); + pstmt.setObject(10, this.plasticUptakeNameFieldButton.getText()); + pstmt.setObject(11, this.plasticUptakeName2Field.getText()); + pstmt.setObject(12, this.roughWeightField.getText()); + pstmt.setObject(13, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(14, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(15, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(16, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(17, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(18, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(19, this.outerBoxComboBox.getSelectedItem()); + pstmt.setObject(20, this.explainArea.getText()); + pstmt.setObject(21, this.attentionArea.getText()); + pstmt.setObject(22, this.attentionArea.getText()); + if(componentStr != null) + { + pstmt.setBinaryStream(23, componentStr, componentStr.available()); + } + else + { + pstmt.setBinaryStream(23, null, 0); + } + if(str != null) + { + pstmt.setBinaryStream(24, str, str.available()); + } + else + { + pstmt.setBinaryStream(24, null, 0); + } + if(str != null) + { + pstmt.setBinaryStream(25, packagingStr, packagingStr.available()); + } + else + { + pstmt.setBinaryStream(25, null, 0); + } + pstmt.setObject(26, this.tierField.getText()); + pstmt.execute(); + } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("bccg17_display.TITLE"), "ɹ", MessageBox.WARNING); + //this.disposeDialog(); + //this.dispose(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + } + } + else if (source.equals(this.outputButton)) + { + //ȡģļ + File file = TMomMethodUtil.getFile(session, "װģ", "MSExcelX"); + try { + InputStream input = new FileInputStream(file); + FileOutputStream output = new FileOutputStream(new File(System.getenv("TEMP")+"\\װ.xlsx")); + XSSFWorkbook wb = new XSSFWorkbook(input);// ( + XSSFSheet sheet = wb.getSheetAt(0); + ExcelUtil07.setNamedCellValue(wb, "Ʒ", this.projectNoField.getText()); + ExcelUtil07.setNamedCellValue(wb, "Ʒ", this.projectNameField.getText()); + ExcelUtil07.setNamedCellValue(wb, "ûͼ", this.userFigureNoField.getText()); + ExcelUtil07.setNamedCellValue(wb, "ͻ", this.clientNameField.getText()); + ExcelUtil07.setNamedCellValue(wb, "", this.technologyManageField.getText()); + ExcelUtil07.setNamedCellValue(wb, "װʽ", this.bzfsComboBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "ͷʽ", this.qyfsComboBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "ÿ", this.numberTextField.getText()); + ExcelUtil07.setNamedCellValue(wb, "ֽ", this.cartonNameFieldButton.getText()); + ExcelUtil07.setNamedCellValue(wb, "װ", this.packageQuotaField.getText()); + ExcelUtil07.setNamedCellValue(wb, "", this.nylonBagNameFieldButton.getText()); + ExcelUtil07.setNamedCellValue(wb, "Ʒ", this.finishedProductWeightField.getText()); + ExcelUtil07.setNamedCellValue(wb, "", this.plasticUptakeNameFieldButton.getText()); + ExcelUtil07.setNamedCellValue(wb, "ë", this.roughWeightField.getText()); + ExcelUtil07.setNamedCellValue(wb, "ǩ", this.outerBoxComboBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "", this.storageTrayBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "ÿ", this.storageTrayField.getText()); + ExcelUtil07.setNamedCellValue(wb, "ÿ", this.tierField.getText()); + ExcelUtil07.setNamedCellValue(wb, "װ", this.carriagePackTypeBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "ʽ", this.packagingBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "̹", this.palletSpecBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "ӹ̷ʽ", this.methodsReinforcementBox.getSelectedItem().toString()); + ExcelUtil07.setNamedCellValue(wb, "˵", this.explainArea.getText()); + ExcelUtil07.setNamedCellValue(wb, "ע", this.attentionArea.getText()); + ExcelUtil07.setNamedCellValue(wb, "Ա", this.designUserField.getText()); + ExcelUtil07.setNamedCellValue(wb, "׼Ա", this.ratifyUserField.getText()); + ExcelUtil07.setNamedCellValue(wb, "޸", this.changeDateButton.getText()); + ExcelUtil07.setNamedCellValue(wb, "ע", this.remarkArea.getText()); + ExcelUtil07.setNamedCellValue(wb, "1", this.plasticUptakeName2Field.getText()); + ExcelUtil07.setNamedCellValue(wb, "2", this.textkArea.getText()); + ExcelUtil07.insertPicture(wb, sheet, (ImageIcon) this.imageLabel.getIcon(), "װ",3,6); + ExcelUtil07.insertPicture(wb, sheet, (ImageIcon) this.componentImageLabel.getIcon(), "",2,5); + ExcelUtil07.insertPicture(wb, sheet, (ImageIcon) this.packagingImageLabel.getIcon(), "",3,7); + ExcelUtil07.setNamedCellValue(wb, "Ʒ2", this.projectNoField.getText()); + ExcelUtil07.setNamedCellValue(wb, "Ʒ2", this.projectNameField.getText()); + ExcelUtil07.setNamedCellValue(wb, "ûͼ2", this.userFigureNoField.getText()); + ExcelUtil07.setNamedCellValue(wb, "ͻ2", this.clientNameField.getText()); + ExcelUtil07.setNamedCellValue(wb, "2", this.technologyManageField.getText()); + ExcelUtil07.insertPicture(wb, wb.getSheetAt(1), (ImageIcon) this.componentImageLabel.getIcon(), "2",2,5); + wb.write(output); + output.close(); + input.close(); + ExcelUtil07.setExcelToItem(session, (TCComponentItemRevision)app.getTargetComponent(), System.getenv("TEMP")+"\\װ.xlsx","װ","TC_Attaches","MSExcelX",true); + System.out.println("-------WRITE EXCEL OVER-------"); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("dccg17_display.TITLE"), "ɹ", MessageBox.INFORMATION); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + else + { + this.dispose(); + this.disposeDialog(); + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessHandler.java b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessHandler.java new file mode 100644 index 0000000..16e31be --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessHandler.java @@ -0,0 +1,36 @@ +package com.connor.renben.process.plm.tmom017; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom017PackageProcessHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom017PackageProcessCommand command = new TMom017PackageProcessCommand( + app, session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("txbzgycw17_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessOperation.java b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessOperation.java new file mode 100644 index 0000000..3847fe3 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom017/TMom017PackageProcessOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom017; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom017PackageProcessOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom018/CTMap.java b/src/com/connor/renben/process/plm/tmom018/CTMap.java new file mode 100644 index 0000000..7d75d7c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/CTMap.java @@ -0,0 +1,336 @@ +package com.connor.renben.process.plm.tmom018; + +import java.awt.Dimension; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + 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; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (processRowList != null && processRowList.size() > 0) { + if (!processRowList.contains(arg0)) { + return false; + } else { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + } else { + return false; + } + } + + @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 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; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + 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); + } + } + + // if (processRowList.contains(row)) { + // for (int i = 0; i < processRowList.size(); i++) { + // 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+1) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + // else + // { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == + // row-1) + // { + // index = i+1; + // processRowList.add(i+1, row); + // } + // 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/tmom018/CTUI.java b/src/com/connor/renben/process/plm/tmom018/CTUI.java new file mode 100644 index 0000000..22d2abb --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom018; + +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/tmom018/CTable.java b/src/com/connor/renben/process/plm/tmom018/CTable.java new file mode 100644 index 0000000..2bf6bbe --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/CTable.java @@ -0,0 +1,252 @@ +package com.connor.renben.process.plm.tmom018; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + + +public class CTable extends JTable { + 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 }); + ComboBoxCellEditor comboBoxCellEditor2 = new ComboBoxCellEditor( + new Object[] { "׼", "̼", "ĩ","Ѳ" }); + CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + 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); + } + + 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 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("ĩ")) + { + return comboBoxCellEditor2; + } + else if (this.getColumnName(column).equals("")) { + return checkBoxCellEditor; + } + else { + return cellEditor; + } + // Point point = new Point(row,column); + // if(map.containsKey(point)){ + // return map.get(point); + // }else{ + // return super.getCellEditor(row, column); + // } + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + //TODO Auto-generated method stub + if (this.getColumnName(column).equals("")) { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + + // @Override + // public TableCellRenderer getCellRenderer(int row, int column) { + // // TODO Auto-generated method stub + // // if(row == 0) + // // { + // // return super.getCellRenderer(row, column); + // // } + // // else + // // { + // return renderer; + // // } + // + // } + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + // @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/tmom018/CellSpan.java b/src/com/connor/renben/process/plm/tmom018/CellSpan.java new file mode 100644 index 0000000..6bf238e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.tmom018; + +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/tmom018/CheckBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom018/CheckBoxCellEditor.java new file mode 100644 index 0000000..47a9697 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/CheckBoxCellEditor.java @@ -0,0 +1,120 @@ +package com.connor.renben.process.plm.tmom018; + +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.JComboBox; +import javax.swing.JLabel; +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.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 CTMap tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(""); + // 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("")) { + 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/tmom018/ComboBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom018/ComboBoxCellEditor.java new file mode 100644 index 0000000..15929a0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/ComboBoxCellEditor.java @@ -0,0 +1,88 @@ +package com.connor.renben.process.plm.tmom018; + +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/tmom018/TMom018ReviewControlPlanCommand.java b/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanCommand.java new file mode 100644 index 0000000..575e700 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanCommand.java @@ -0,0 +1,550 @@ +package com.connor.renben.process.plm.tmom018; + +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.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import com.connor.renben.process.plm.bean.ControlPlanBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom018ReviewControlPlanCommand extends AbstractAIFCommand { + private TCSession session; + private AbstractAIFApplication app;// ȡѡĿ + private TCComponentTask task;//ѡе + private InterfaceAIFComponent comp; + private TCComponentItem item; + private TCComponentItemRevision itemRevision; + private TCComponent form; + private TCComponentItem meprocess; + private boolean isOwning = false; + private String[] properName = new String[] { + "rb3_zylxdh", // Ҫϵ˵绰 + "rb3_sor", // SOR/ + "rb3_hxxz", // С + "rb3_gkgcpz",// ˿͹׼/ + "rb3_gfgcpz", // /׼/ + "rb3_gkzlpz",// ˿׼/ + "rb3_gfgc",// / + "rb3_gfdh",// + "rb3_xgdj",// ޸ĵȼ + "rb3_cxnd",// / + "rb3_gkzlpz",// ˿׼/ + "rb3_qtpzrq1", // ׼/1 + "rb3_qtpzrq2" }; // ׼/2; + private Map combineMap = new HashMap();// źϲԪ + private TCProperty[] properties; + // private List> processRowList = new + // ArrayList>(); + private List processRows = new ArrayList(); + private List meopNameList; + private Map> labelRows = new HashMap>();//ע + private TCComponentUser user;// ǰ¼û + private List> dataList = new ArrayList>();// е + private List plmeidList = new ArrayList();// plmeid + private List meopId = new ArrayList();// ID + private List> completeDataList = new ArrayList>();// ɵԱ + + public TMom018ReviewControlPlanCommand() { + super(); + } + + public TMom018ReviewControlPlanCommand(AbstractAIFApplication app, + TCSession session) { + this.session = session; + this.app = app; + this.comp = app.getTargetComponent(); + this.user = session.getUser(); + } + + /** + * ȡ + */ + private void getControlPlanCompleteUser() { + // ȡµĹ + ResultSet rs = null; + try { + TCProperty[] tcProperties = form.getTCProperties(new String[] { + "rb3_complete_user", "rb3_complete_date" }); + String[] users = tcProperties[0].getStringValueArray(); + String[] date = tcProperties[1].getStringValueArray(); + Map completeUser = new HashMap(); + for (int i = 0; i < date.length; i++) { + completeUser.put(users[i], date[i]); + } + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + // ȡݿ + SqlUtilT.getTCConnection(); + String sql = String + .format("select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " from (select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,nvl(rb3_user,' ') as rb3_user,nvl(RB3_INSPECTIONUSER,' ') as RB3_INSPECTIONUSER " + + " from RB3_PERMISSIONS)" + + " unpivot (rb3_user_id for type in (rb3_user, RB3_INSPECTIONUSER) ) " + + " where PROCESSPUID = \'%s\' " + + " group by PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " order by to_number(RB3_GYBH)", meprocess.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("RB3_MEOPID")); + rowList.add(rs.getString("RB3_GYBH")); + rowList.add(rs.getString("RB3_GCMC")); + if (rs.getString("TYPE").toString().equals("RB3_USER")) { + rowList.add("Լ"); + } else if (rs.getString("TYPE").toString() + .equals("RB3_INSPECTIONUSER")) { + rowList.add("Ѳ"); + } + if (!rs.getString("RB3_USER_ID").equals(" ")) { + rowList.add(type.find(rs.getString("RB3_USER_ID")) + .getStringProperty("user_name")); + } else { + rowList.add(""); + } + // Ƿ + if (completeUser.keySet().contains(rs.getString("RB3_USER_ID"))) { + rowList.add(""); + rowList.add(completeUser.get(rs.getString("RB3_USER_ID"))); + } else { + rowList.add(""); + rowList.add(""); + } + if(!meopNameList.contains(rs.getString("RB3_GCMC")) && rs.getString("TYPE").toString() + .equals("RB3_INSPECTIONUSER")) + { + continue; + } + completeDataList.add(rowList); + } + // ȡȨޱе + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + } + + /** + * ȡݿе + */ + private void getData() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("CONTROLPLANSELECT"), + meprocess.getUid(), item.getType().toUpperCase()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("RB3_GYBH")); + rowList.add(rs.getString("RB3_GCMC") == null ? "" : rs.getString("RB3_GCMC")); + rowList.add(rs.getString("RB3_JQSB")); + rowList.add(rs.getString("RB3_SMJY")); + rowList.add(rs.getString("RB3_QPTBH")); + rowList.add(rs.getString("RB3_CC")); + rowList.add(rs.getString("RB3_NO")); + rowList.add(rs.getString("RB3_CP")); + rowList.add(rs.getString("RB3_GC")); + rowList.add(rs.getString("RB3_TSTX")); + rowList.add(rs.getString("RB3_CPGC")); + rowList.add(rs.getString("RB3_CLFF")); + rowList.add(rs.getString("RB3_RL")); + rowList.add(rs.getString("RB3_PL")); + rowList.add(rs.getString("RB3_FZR")); + rowList.add(rs.getString("RB3_KZFF")); + rowList.add(rs.getString("RB3_CZGF")); + rowList.add(rs.getString("RB3_FYJH")); + rowList.add(rs.getString("RB3_SJSJ")); + rowList.add(rs.getString("RB3_GCSJ")); + rowList.add(rs.getString("RB3_MJSJ")); + rowList.add(rs.getString("RB3_TOOL_INSPECT") == null ? "0" : rs.getString("RB3_TOOL_INSPECT"));//22 + rowList.add(rs.getString("RB3_SPECIAL"));//23 + rowList.add(((Integer)rs.getInt("RB3_SFWC")).toString() == null ? "" : ((Integer)rs.getInt("RB3_SFWC")).toString());//24 + rowList.add(rs.getString("RB3_USER") == null ? "" : rs.getString("RB3_USER"));//25 + rowList.add(rs.getString("RB3_INSPECTIONUSER") == null ? "" : rs.getString("RB3_INSPECTIONUSER"));//26 + rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID"));//27 + rowList.add(rs.getInt("RB3_HH"));//28 + rowList.add(rs.getString("RB3_HBDYG"));//29 + rowList.add(rs.getInt("RB3_HHC"));//30 + rowList.add(rs.getString("RB3_LABEL") == null ? "" : rs.getString("RB3_LABEL"));//31 + dataList.add(rowList); + } + // е,ȡǰû޸ĵк + String userName = task.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( + 30, + i + - Integer.parseInt(dataList.get(i).get(28) + .toString())); + if (isRelease) { + continue; + } + if ((dataList.get(i).get(25).equals(userName) && dataList.get(i).get(2).toString().indexOf("飨") < 0)//飨 + || (dataList.get(i).get(26).equals(userName) && dataList.get(i).get(2).toString().indexOf("飨") >= 0)){ + processRows.add(i); + if(!dataList.get(i).get(dataList.get(i).size()-1).toString().equals("")) + { + if(dataList.get(i).get(dataList.get(i).size()-1).toString().indexOf(",") >= 0) + { + labelRows.put(i, Arrays.asList(dataList.get(i).get(dataList.get(i).size()-1).toString().split(","))); + } + else + { + labelRows.put(i, Arrays.asList(new String[]{ dataList.get(i).get(dataList.get(i).size()-1).toString() })); + } + //labelRows.add(i); + } + //plmeidList.add(dataList.get(i).get(0).toString()); + } + } + input.close(); + // for (int j = 0; j < meopId.size(); j++) { + // for (int i = 0; i < dataList.size(); i++) { + // //кŲ + // dataList.get(i).set( + // 24, + // i- Integer.parseInt(dataList.get(i).get(21) + // .toString())); + // //dataList.get(i).set(17, i); + // if (meopId.size() > 0) { + // + // if (dataList.get(i).get(2) + // .equals(meopId.get(j))) { + // processRows.add(i); + // } + // } + // } + // //processRowList.add(processRow); + // } + } 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(); + } + + } + + private void getItem() { + try { + // ȡѡжİ汾 + if(comp instanceof TCComponentTask) + { + task = (TCComponentTask)comp; + try { + TCComponentContextList contextList = task.getRelatedList("root_target_attachments"); + for (int i = 0; i < contextList.getListCount(); i++) { + if (contextList.get(i).getComponent() instanceof TCComponentItemRevision && contextList.get(i).getComponent().getType().indexOf("KZJH") >= 0) { + itemRevision = (TCComponentItemRevision)contextList.get(i).getComponent(); + AIFComponentContext[] context = itemRevision + .getItem().whereReferenced(); + for (int j = 0; j < context.length; j++) { + if (context[j].getComponent().getType().equals("MEProcess")) { + meprocess = (TCComponentItem) context[j].getComponent(); + } + } + item = itemRevision.getItem(); + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //System.out.println("task"); + } + else + { + MessageBox.post("ѡ", "", MessageBox.ERROR); + throw new Exception("δҵ"); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + //ǷDOڵ + public boolean isDoTask(String meopId,String userId) { + try { + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem meopItem = itemType.find(meopId); + if(meopItem != null) + { + TCComponent[] items = meopItem + .getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + if (items[i].getType().indexOf("DoTask") >= 0) { + TCComponentUser user = (TCComponentUser) items[i].getRelatedComponent("owning_user"); + if(user.getUserId().equals(userId)) + { + return true; + } + } + + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + //Ƿڵ + public boolean isReviewTask(String meopId,String userId) { + try { + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem meopItem = itemType.find(meopId); + if(meopItem != null) + { + TCComponent[] items = meopItem + .getRelatedComponents("process_stage_list"); + for (int i = 0; i < items.length; i++) { + if (items[i].getType().indexOf("ReviewTask") >= 0) { + TCComponentUser user = (TCComponentUser) items[i].getRelatedComponent("owning_user"); + if(user.getUserId().equals(userId)) + { + return true; + } + } + + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + + public void getCombineMap() { + try { + if (dataList != null && dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + if (dataList.get(i).get(29) != null + && !dataList.get(i).get(29).equals("")) { + String sombine = dataList.get(i).get(29).toString(); + int rowDif = Integer.parseInt(dataList.get(i).get(30) + .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) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + + /** + * ȡмĹ + * @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 = new String[props.length]; + for (int i = 0; i < props.length; i++) { + if(props[i].indexOf("/") >= 0) + { + values[i] = props[i].split("/")[0]; + } + else + { + values[i] = props[i]; + } + } + } + } + else + { + MessageBox.post("δѡ", "", MessageBox.ERROR); + } + return Arrays.asList(values); + } + + @Override + public void executeModal() throws Exception { + // ȡ汾 + getItem(); + meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); + //ȡ + final ControlPlanBean controlPlanBean = new ControlPlanBean(); + controlPlanBean.setKzjhbh(itemRevision.getProperty("item_id") + "/"+ itemRevision.getProperty("item_revision_id")); + controlPlanBean.setZylxr(item.getReferenceProperty("owning_user").getStringProperty("user_name")); + 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") != "") + { + controlPlanBean.setBzriq(revComponent.getProperty("date_released")); + } + if(revId == newestRevisiovId) + { + controlPlanBean.setXdrq(revComponent.getProperty("date_released")); + } + } + } + if(controlPlanBean.getBzriq() == null) + { + controlPlanBean.setBzriq(""); + } + if(controlPlanBean.getXdrq() == null) + { + controlPlanBean.setXdrq(""); + } + //ݹȡƷ + 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(); + TCComponentItemRevision productLastRevision = product.getLatestItemRevision(); + controlPlanBean.setLjh(productLastRevision.getProperty("item_id") + "/"+ productLastRevision.getProperty("item_revision_id")); + controlPlanBean.setLjmc(product.getStringProperty("object_name")); + //ȡ汾 + TCComponent revMaster = productLastRevision.getRelatedComponent("IMAN_master_form_rev"); + controlPlanBean.setKhtzbh(revMaster.getStringProperty("rb3_press_drawing")); + } + } +// ƼƻţƼƻITME_ID/汾 +// ҪϵˣƼƻ +// ڣƣһ汾ʱ +// ڣ޶°淢ʱ +// /հ汾ƷITEM_ID/汾 +// /Ʒobject_name +// ͻͼֽţƷ汾еĿͻͼ + + if (form != null) { + properties = form.getTCProperties(properName); + } + getData(); + getCombineMap(); + getControlPlanCompleteUser(); + if (properties == null) { + return; + } + new Thread() { + @Override + public void run() { + TMom018ReviewControlPlanDialog dislog = new TMom018ReviewControlPlanDialog( + app, session, processRows,labelRows, form, item, meprocess, + properties,controlPlanBean, combineMap, dataList, completeDataList, + meopId,plmeidList, isOwning); + } + }.start(); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanDialog.java b/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanDialog.java new file mode 100644 index 0000000..ee6c851 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanDialog.java @@ -0,0 +1,1451 @@ +package com.connor.renben.process.plm.tmom018; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.IOException; +import java.util.ArrayList; +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 javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextPane; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.ControlPlanBean; +import com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTextField; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom018ReviewControlPlanDialog extends JFrame implements ActionListener{ + private AbstractAIFApplication app; + private TCSession session; + private TCProperty[] properties; + private ControlPlanBean controlPlanBean; + private CTMap map; + static JScrollPane scrollPane; + // private String[] header = new + // String[]{"PLM
EID","/
ձ","",",豸
,װ,о","ͼ","ߴ","Ʒ","" + // ,"
Է","Ʒ//
/","/
","","Ƶ","","Ʒ" + // ,"淶/
¼
","Ӧƻ"}; + private String[] header = new String[] { "PLMEID", "/ձ", "", + ",豸,װ,о", "ĩ", "ͼ", "ߴ","", "Ʒ", "", "Է", + "Ʒ///", "/", "", "Ƶ", "", "Ʒ", "淶/¼", + "Ӧƻ", "׼ռٷֱ", "ռٷֱ","ĩռٷֱ","", "λ","Ƿ" }; + private String[] header2 = new String[] { "PLMEID", "ͼ", "ߴ", "Ʒ", + "", "Է", "Ʒ///", "/", "", "Ƶ", "׼ռٷֱ", + "ĩռٷֱ", "ռٷֱ", "", "Ʒ", "淶/¼", "Ӧƻ", + "ڵID", "ַλ" }; + private String[] completeUserHeader = new String[] { "ID", "","", "","û","",""}; + private Map combineMap;// źϲԪ + private TCComponent form;// ѡжİ汾 + private TCComponent item;// ѡж + private TCComponent meprocess;// ѡڵĹ + private List processRows;// ǰû޸ĵк + private Map> labelRows;//ע + private List> dataList; + private List> completeDataList;// ɵԱ + private List plmeidList;// plmeid + private List meopId;// + private List deleteRows = new ArrayList(); + // private TextAreaCellEditor textAreaCellEditor; + private TreeBean bean; + private Properties pro = new Properties(); + private boolean isComplete = false; + private boolean isOwning; + + // ؼ + private JPanel titlePanel;// + private JLabel titleLabel; + + private JPanel mainPanel;// д + + private JPanel checkPanel;// ѡť + private JRadioButton scCheckBox;// + private JRadioButton sscCheckBox;// + private JRadioButton yjCheckBox;// + + private JPanel panel1;// һ + private JLabel kzjhbhLabel;// Ƽƻ + private CTextField kzjhbhField; + private JLabel zylxrLabel;// Ҫϵ + private CTextField zylxrField; + private JLabel zylxrdhLabel;// Ҫϵ˵绰 + private CTextField zylxrdhField; + private JLabel bzriqLabel;// ڣƣ + private CTextField bzriqField; + private JLabel xdrqLabel;// ڣ޶ + private CTextField xdrqField;// ڣ޶ + + private JPanel panel2;// ڶ + private JLabel sorhmLabel;// SOR + private CTextField sorhmField; + private JLabel ljhLabel;// + private CTextField ljhField; + private JLabel hxxzLabel;// С + private CTextField hxxzField; + private JLabel gkgcpzLabel;// ˿͹׼/ + private CTextField gkgcpzField; + + private JPanel panel3;// + private JLabel khtzbhLabel;// ͻͼֽ + private CTextField khtzbhField; + private JLabel ljmcLabel;// / + private CTextField ljmcField; + private JLabel gfpzrqLabel;// /׼/ + private CTextField gfpzrqField; + private JLabel gkzlpzLabel;// ˿׼/ + private CTextField gkzlpzField; + + private JPanel panel4;// + private JLabel gfgcLabel;// / + private CTextField gfgcField; + private JLabel gfdhLabel;// + private CTextField gfdhField; + private JLabel xgdjLabel;// ޸ĵȼ + private CTextField xgdjField; + private JLabel cxLabel;// + private CTextField cxField; + private JLabel gkpzLabel;// ˿׼/ + private CTextField gkpzField; + private JLabel qtpzLabel;// ׼/ + private CTextField qtpzField; + private JLabel qtpzrqLabel;// ׼ + private CTextField qtpzrqField; + + private JPanel topPanel;// һеԺ͸ѡ + + private JPanel tablePanel;// ؼ + private TableCellTextAreaRenderer renderer;// Ⱦ + private static CTable table; + //ʾѡеԪ + private JTextPane showValuePane; + // + private CTable completeUserTable;//Ƽƻ + + +// //Ҽ˵ +// private static JPopupMenu menu; +// //Ҽ˵ +// private JMenuItem addRowItem; +// private JMenuItem addItem; +// private JMenuItem remItem; +// private JMenuItem comBineItem; +// private JMenuItem splitItem; +// private JMenuItem deleteSpecialItem; + private JPanel rootPanel;// ť + private JButton labelButton;// ע + private JButton remLabelButton;// Ƴע +// private JButton completeButton;// +// //private JButton deleteSpecialButton;// Ƴ +// private JButton addSpecialButton;// +// private JButton libraryButton;// 򿪿Ƽƻ + + private JPanel centerPanel; + + public TMom018ReviewControlPlanDialog(AbstractAIFApplication app, + TCSession session, List processRows,Map> labelRows, TCComponent form, + TCComponent item, TCComponent meprocess, TCProperty[] properties,ControlPlanBean controlPlanBean, + Map combineMap, List> dataList,List> completeDataList, + List meopId,List plmeidList, boolean isOwning) { + super(); + // this.processRowList = processRowList; + this.processRows = processRows; + this.labelRows = labelRows; + this.dataList = dataList; + this.completeDataList = completeDataList; + this.plmeidList = plmeidList; + this.meopId = meopId; + this.combineMap = combineMap; + this.form = form; + this.item = item; + this.meprocess = meprocess; + this.properties = properties; + this.controlPlanBean = controlPlanBean; + this.app = app; + this.session = session; + this.isOwning = isOwning; + init(); + comBine(); + } + + 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()); + } + } + } + + private void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("txkzjh_display.TITLE")); + this.setPreferredSize(new Dimension(1000, 800)); + // ʼⲿֿؼ + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("CP/kzjh_display.TITLE")); + this.titleLabel.setFont(new Font("", 1, 18)); + this.titlePanel.add(titleLabel); + // ʼ˵ֿؼ + this.yjCheckBox = new JRadioButton(rb.getString("yj_display.TITLE")); + this.sscCheckBox = new JRadioButton(rb.getString("ssc_display.TITLE")); + this.scCheckBox = new JRadioButton(rb.getString("sc_display.TITLE")); + ButtonGroup group=new ButtonGroup(); + group.add(this.yjCheckBox); + group.add(this.sscCheckBox); + group.add(this.scCheckBox); + this.checkPanel = new JPanel(new BorderLayout()); + this.checkPanel.setPreferredSize(new Dimension(175, 50)); + this.checkPanel.setBorder((BorderFactory + .createLineBorder(Color.gray, 1))); + this.checkPanel.add(scCheckBox, BorderLayout.EAST); + this.checkPanel.add(sscCheckBox, BorderLayout.CENTER); + this.checkPanel.add(yjCheckBox, BorderLayout.WEST); + + this.panel1 = new JPanel(new PropertyLayout()); + this.panel1.setPreferredSize(new Dimension(795, 50)); + this.kzjhbhLabel = new JLabel(rb.getString("kzjhbh_display.TITLE")); + this.kzjhbhLabel.setPreferredSize(new Dimension(150, 20)); + this.kzjhbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, + 1))); + this.kzjhbhField = new CTextField(this.controlPlanBean.getKzjhbh()); + this.kzjhbhField.setPreferredSize(new Dimension(150, 20)); + this.zylxrLabel = new JLabel(rb.getString("zylxrbzr_display.TITLE")); + this.zylxrLabel.setBorder((BorderFactory + .createLineBorder(Color.gray, 1))); + this.zylxrLabel.setPreferredSize(new Dimension(150, 20)); + this.zylxrField = new CTextField(this.controlPlanBean.getZylxr()); + this.zylxrField.setPreferredSize(new Dimension(150, 20)); + this.zylxrdhLabel = new JLabel(rb.getString("zylxrdhbzrdh_display.TITLE")); + this.zylxrdhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, + 1))); + this.zylxrdhLabel.setPreferredSize(new Dimension(170, 20)); + this.zylxrdhField = new CTextField(this.properties[0].getStringValue()); + this.zylxrdhField.setPreferredSize(new Dimension(170, 20)); + this.bzriqLabel = new JLabel(rb.getString("rq(bz)_display.TITLE")); + this.bzriqLabel.setBorder((BorderFactory + .createLineBorder(Color.gray, 1))); + this.bzriqLabel.setPreferredSize(new Dimension(151, 20)); + this.bzriqField = new CTextField(this.controlPlanBean.getBzriq()); + this.bzriqField.setPreferredSize(new Dimension(151, 20)); + this.xdrqLabel = new JLabel(rb.getString("rq(xd)_display.TITLE")); + this.xdrqLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.xdrqLabel.setPreferredSize(new Dimension(151, 20)); + this.xdrqField = new CTextField(this.controlPlanBean.getXdrq()); + xdrqField.setPreferredSize(new Dimension(151, 20)); + this.panel1.add("1.1.left.top", kzjhbhLabel); + this.panel1.add("1.2.left.top", zylxrLabel); + this.panel1.add("1.3.left.top", zylxrdhLabel); + this.panel1.add("1.4.left.top", bzriqLabel); + this.panel1.add("1.5.left.top", xdrqLabel); + + this.panel1.add("2.1.left.top", kzjhbhField); + this.panel1.add("2.2.left.top", zylxrField); + this.panel1.add("2.3.left.top", zylxrdhField); + this.panel1.add("2.4.left.top", bzriqField); + this.panel1.add("2.5.left.top", xdrqField); + + this.topPanel = new JPanel(new PropertyLayout()); + this.topPanel.add("1.1.left.top", this.checkPanel); + this.topPanel.add("1.2.left.top", this.panel1); + + this.panel2 = new JPanel(new PropertyLayout()); + this.panel2.setPreferredSize(new Dimension(975, 50)); + this.sorhmLabel = new JLabel(rb.getString("SORhmmc_display.TITLE")); + this.sorhmLabel.setPreferredSize(new Dimension(175, 20)); + this.sorhmLabel.setBorder((BorderFactory + .createLineBorder(Color.gray, 1))); + this.sorhmField = new CTextField(this.properties[1].getStringValue()); + this.sorhmField.setPreferredSize(new Dimension(175, 20)); + this.ljhLabel = new JLabel(rb.getString("ljhzzbb_display.TITLE")); + this.ljhLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.ljhLabel.setPreferredSize(new Dimension(150, 20)); + this.ljhField = new CTextField(this.controlPlanBean.getLjh()); + this.ljhField.setPreferredSize(new Dimension(150, 20)); + this.hxxzLabel = new JLabel(rb.getString("hxxz_display.TITLE")); + this.hxxzLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.hxxzLabel.setPreferredSize(new Dimension(324, 20)); + this.hxxzField = new CTextField(this.properties[2].getStringValue()); + this.hxxzField.setPreferredSize(new Dimension(324, 20)); + this.gkgcpzLabel = new JLabel(rb.getString("gkgcpzrq_display.TITLE")); + this.gkgcpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, + 1))); + this.gkgcpzLabel.setPreferredSize(new Dimension(308, 20)); + this.gkgcpzField = new CTextField(this.properties[3].getStringValue()); + this.gkgcpzField.setPreferredSize(new Dimension(308, 20)); + + this.panel2.add("1.1.left.top", sorhmLabel); + this.panel2.add("1.2.left.top", ljhLabel); + this.panel2.add("1.3.left.top", hxxzLabel); + this.panel2.add("1.4.left.top", gkgcpzLabel); + + this.panel2.add("2.1.left.top", sorhmField); + this.panel2.add("2.2.left.top", ljhField); + this.panel2.add("2.3.left.top", hxxzField); + this.panel2.add("2.4.left.top", gkgcpzField); + + this.panel3 = new JPanel(new PropertyLayout()); + this.panel3.setPreferredSize(new Dimension(975, 50)); + this.khtzbhLabel = new JLabel(rb.getString("khtzbh_display.TITLE")); + this.khtzbhLabel.setPreferredSize(new Dimension(175, 20)); + this.khtzbhLabel.setBorder((BorderFactory.createLineBorder(Color.gray, + 1))); + this.khtzbhField = new CTextField(this.controlPlanBean.getKhtzbh()); + this.khtzbhField.setPreferredSize(new Dimension(175, 20)); + this.ljmcLabel = new JLabel(rb.getString("ljmcms_display.TITLE")); + this.ljmcLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.ljmcLabel.setPreferredSize(new Dimension(150, 20)); + this.ljmcField = new CTextField(this.controlPlanBean.getLjmc()); + this.ljmcField.setPreferredSize(new Dimension(150, 20)); + this.gfpzrqLabel = new JLabel(rb.getString("gfgcpzrq_display.TITLE")); + this.gfpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, + 1))); + this.gfpzrqLabel.setPreferredSize(new Dimension(324, 20)); + this.gfpzrqField = new CTextField(this.properties[4].getStringValue()); + this.gfpzrqField.setPreferredSize(new Dimension(324, 20)); + this.gkzlpzLabel = new JLabel(rb.getString("gkzlpzrq_display.TITLE")); + this.gkzlpzLabel.setBorder((BorderFactory.createLineBorder(Color.gray, + 1))); + this.gkzlpzLabel.setPreferredSize(new Dimension(308, 20)); + this.gkzlpzField = new CTextField(this.properties[5].getStringValue()); + this.gkzlpzField.setPreferredSize(new Dimension(308, 20)); + + panel3.add("1.1.left.top", khtzbhLabel); + panel3.add("1.2.left.top", ljmcLabel); + panel3.add("1.3.left.top", gfpzrqLabel); + panel3.add("1.4.left.top", gkzlpzLabel); + + panel3.add("2.1.left.top", khtzbhField); + panel3.add("2.2.left.top", ljmcField); + panel3.add("2.3.left.top", gfpzrqField); + panel3.add("2.4.left.top", gkzlpzField); + + this.panel4 = new JPanel(new PropertyLayout()); + this.panel4.setPreferredSize(new Dimension(975, 50)); + this.gfgcLabel = new JLabel(rb.getString("gfgc_display.TITLE")); + this.gfgcLabel.setPreferredSize(new Dimension(175, 20)); + this.gfgcLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gfgcField = new CTextField(this.properties[6].getStringValue()); + this.gfgcField.setPreferredSize(new Dimension(175, 20)); + this.gfdhLabel = new JLabel(rb.getString("gfdh_display.TITLE")); + this.gfdhLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gfdhLabel.setPreferredSize(new Dimension(72, 20)); + this.gfdhField = new CTextField(this.properties[7].getStringValue()); + this.gfdhField.setPreferredSize(new Dimension(72, 20)); + this.xgdjLabel = new JLabel(rb.getString("xgdj18_display.TITLE")); + this.xgdjLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.xgdjLabel.setPreferredSize(new Dimension(72, 20)); + this.xgdjField = new CTextField(this.properties[8].getStringValue()); + this.xgdjField.setPreferredSize(new Dimension(72, 20)); + this.cxLabel = new JLabel(rb.getString("cxnd18_display.TITLE")); + this.cxLabel.setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.cxLabel.setPreferredSize(new Dimension(159, 20)); + this.cxField = new CTextField(this.properties[9].getStringValue()); + this.cxField.setPreferredSize(new Dimension(159, 20)); + this.gkpzLabel = new JLabel(rb.getString("gkpzrq_display.TITLE")); + this.gkpzLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.gkpzLabel.setPreferredSize(new Dimension(160, 20)); + this.gkpzField = new CTextField(this.properties[10].getStringValue()); + this.gkpzField.setPreferredSize(new Dimension(160, 20)); + this.qtpzLabel = new JLabel(rb.getString("qtpzrq_display.TITLE")); + this.qtpzLabel + .setBorder((BorderFactory.createLineBorder(Color.gray, 1))); + this.qtpzLabel.setPreferredSize(new Dimension(152, 20)); + this.qtpzField = new CTextField(this.properties[11].getStringValue()); + this.qtpzField.setPreferredSize(new Dimension(152, 20)); + this.qtpzrqLabel = new JLabel(rb.getString("qtpzrq_display.TITLE")); + this.qtpzrqLabel.setBorder((BorderFactory.createLineBorder(Color.gray, + 1))); + this.qtpzrqLabel.setPreferredSize(new Dimension(152, 20)); + this.qtpzrqField = new CTextField(this.properties[12].getStringValue()); + this.qtpzrqField.setPreferredSize(new Dimension(152, 20)); + panel4.add("1.1.left.top", gfgcLabel); + panel4.add("1.2.left.top", gfdhLabel); + panel4.add("1.3.left.top", xgdjLabel); + panel4.add("1.4.left.top", cxLabel); + panel4.add("1.5.left.top", gkpzLabel); + panel4.add("1.6.left.top", qtpzLabel); + panel4.add("1.7.left.top", qtpzrqLabel); + + panel4.add("2.1.left.top", gfgcField); + panel4.add("2.2.left.top", gfdhField); + panel4.add("2.3.left.top", xgdjField); + panel4.add("2.4.left.top", cxField); + panel4.add("2.5.left.top", gkpzField); + panel4.add("2.6.left.top", qtpzField); + panel4.add("2.7.left.top", qtpzrqField); + + this.mainPanel = new JPanel(new PropertyLayout()); + this.mainPanel.add("1.1.left.top", topPanel); + this.mainPanel.add("2.1.left.top", panel2); + this.mainPanel.add("3.1.left.top", panel3); + this.mainPanel.add("4.1.left.top", panel4); + + this.showValuePane = new JTextPane(); + this.showValuePane.setPreferredSize(new Dimension(800, 40)); + + this.tablePanel = new JPanel(new BorderLayout()); + this.table = getjTable(null, null, header, null); + // Ӽ̼ + this.table.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent arg0) { + // TODO Auto-generated method stub + if(arg0.getKeyChar() == 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++) { + table.setValueAt("", selectRows[i], selectColumns[j]); + } + } + } + super.keyPressed(arg0); + } + }); + // ӹ + JScrollPane scrollPane = new JScrollPane(this.table); + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + this.tablePanel.add(scrollPane, BorderLayout.CENTER); + + // + JPanel completeUserTablePanel = new JPanel(new BorderLayout()); + this.completeUserTable = getNewjTable(null, null, completeUserHeader, completeDataList.size()); + this.completeUserTable.setRowHeight(30); + for (int j = 0; j < completeDataList.size(); j++) { + for (int k = 0; k < completeDataList.get(j).size(); k++) { + this.completeUserTable.setValueAt(completeDataList.get(j).get(k),j, k); + } + } + // ӹ + JScrollPane scrollPane1 = new JScrollPane(this.completeUserTable); + scrollPane1.getVerticalScrollBar().setUnitIncrement(10); + completeUserTablePanel.add(scrollPane1, BorderLayout.CENTER); + + JPanel centerPanel = new JPanel(new BorderLayout()); + centerPanel.add(titlePanel, BorderLayout.NORTH); + centerPanel.add(mainPanel, BorderLayout.CENTER); + + // JPanel centerPanel2 = new JPanel(new BorderLayout()); + // centerPanel2.add(centerPanel,BorderLayout.NORTH); + // centerPanel2.add(tablePanel, BorderLayout.CENTER); + + JSplitPane showSeleceCellValuePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + showSeleceCellValuePanel.setOneTouchExpandable(true);// ÷ָʾͷ + showSeleceCellValuePanel.setContinuousLayout(true);// ͷػͼ + showSeleceCellValuePanel.setTopComponent(new JScrollPane(showValuePane)); + showSeleceCellValuePanel.setBottomComponent(tablePanel); + +// JPanel showSeleceCellValuePanel = new JPanel(new BorderLayout()); +// showSeleceCellValuePanel.add(new JScrollPane(showValuePane),BorderLayout.NORTH); +// showSeleceCellValuePanel.add(tablePanel,BorderLayout.CENTER); + + // JPanel centerPanel2 = new JPanel(new BorderLayout()); + // centerPanel2.add(centerPanel,BorderLayout.NORTH); + // centerPanel2.add(tablePanel, BorderLayout.CENTER); + + JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setTopComponent(centerPanel); + splitPane.setBottomComponent(showSeleceCellValuePanel); + + JSplitPane splitPane2 = new JSplitPane(); + splitPane2.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane2.setContinuousLayout(true);// ͷػͼ + splitPane2.setLeftComponent(splitPane); + splitPane2.setRightComponent(completeUserTablePanel); + + this.rootPanel = new JPanel(); + this.labelButton = new JButton(rb.getString("bz18_display.TITLE")); + this.remLabelButton = new JButton(rb.getString("ycbz18_display.TITLE")); + this.labelButton.addActionListener(this); + this.remLabelButton.addActionListener(this); + this.rootPanel.add(labelButton); + this.rootPanel.add(remLabelButton); + + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(splitPane2, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.pack(); + this.show(); + + } + + /** + * дݵJtable + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + for (int j = 0; j < header.length; j++) { + map.setValueAt(rowList.get(j), i, j); + } + } + } + + // 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); + if (processRows != null && processRows.size() > 0) { + this.map.setProcessRowList(processRows); + } + setJTable(); + partsTable = new CTable(map); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length - 1); + partsTable.HiddenCell(titleNames.length - 2); + // + partsTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + + if(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()) != null) + { + showValuePane.setText(""); + showValuePane.setText(table.getValueAt(table.getSelectedRow(), table.getSelectedColumn()).toString()); + } + else + { + showValuePane.setText(""); + } + } + } + }); + // //ʾȾ + this.renderer = new TableCellTextAreaRenderer(); + this.renderer.setProcessRows(processRows); + this.renderer.setLabelRows(labelRows); + // //þ + partsTable.setDefaultRenderer(Object.class, this.renderer); + // //ñ༭Ⱦ + // 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); + } + } + return partsTable; + } + + // Jtableͨ÷ + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, + Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + CTMap map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); + partsTable = new CTable(map); + // 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 actionPerformed(ActionEvent arg0) { +// Object source = arg0.getSource(); +// if (source.equals(this.addRowItem)) { +// 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(table.getValueAt(table.getSelectedRow(), 1), table.getSelectedRow() + 1, 1); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), 2), table.getSelectedRow() + 1, 2); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount()-1), table.getSelectedRow() + 1, table.getColumnCount()-1); +// table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); +// this.processRows = map.getProcessRowList(); +// this.renderer.setProcessRows(processRows); +// 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(); +// } else if (source.equals(this.addItem)) { +// 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(), 1), table.getSelectedRow() + 1, 1); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), 2), table.getSelectedRow() + 1, 2); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), 3), table.getSelectedRow() + 1, 3); +// table.setValueAt(table.getValueAt(table.getSelectedRow(), table.getColumnCount()-1), table.getSelectedRow() + 1, table.getColumnCount()-1); +// this.processRows = map.getProcessRowList(); +// this.renderer.setProcessRows(processRows); +// 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(); +// } else if (source.equals(this.remItem)) { +// 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(); +// this.renderer.setProcessRows(processRows); +// 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(); +// } +// } else if (source.equals(this.comBineItem)) { +// // table.setRowHeight(2, 50); +// int[] rows = table.getSelectedRows(); +// int[] columns = table.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()); +// table.revalidate(); +// table.repaint(); +// } else if (source.equals(this.splitItem)) { +// 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; +// } +// Map cellMap = new HashMap(); +// 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(); +// } else if (source.equals(this.saveButton)) { +// if(processRows != null && processRows.size() > 0) +// { +// okEvent(); +// } +// //this.dispose(); +// } else if (source.equals(addSpecialButton)) { +// if (this.specialDialog == null) { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog = new SpecialDialog(); +// } else { +// System.out.println(table.getSelectedRow() + "===" +// + table.getSelectedColumn()); +// this.specialDialog.show(); +// } +// } else if (source.equals(libraryButton)) { +// 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(this.deleteSpecialItem)) { +// String columnName = table.getColumnName(table.getSelectedColumn()); +// String columnValue = table.getValueAt(table.getSelectedRow(), +// table.getColumnCount() - 1).toString(); +// if (columnValue != null && !columnValue.equals("")) { +// if (columnValue.indexOf("|") >= 0) { +// String[] columnValues = columnValue.split("\\|"); +// StringBuffer sb = new StringBuffer(); +// for (int i = 0; i < columnValues.length; i++) { +// if (columnValues[i].indexOf(columnName) < 0) { +// sb.append(columnValues[i]); +// sb.append("-"); +// } +// } +// table.setValueAt(sb.substring(0, sb.length() - 1), +// table.getSelectedRow(), table.getColumnCount() - 1); +// } else { +// if (columnValue.indexOf(columnName) >= 0) { +// table.setValueAt("", table.getSelectedRow(), +// table.getColumnCount() - 1); +// } +// } +// } +// } else if (source.equals(completeButton)) { +// if(processRows != null && processRows.size() > 0) +// { +// if (isOwning) { +// okEvent(); +// // this.disposeDialog(); +// this.dispose(); +// } else { +// try { +// InterfaceAIFComponent[] components = new InterfaceAIFComponent[meopId +// .size()+1]; +// components[0] = app.getTargetComponent(); +// TCComponentItemType itemType = (TCComponentItemType) this.session +// .getTypeComponent("Item"); +// for (int i = 1; i <= meopId.size(); i++) { +// components[i] = itemType.find(meopId.get(i-1)); +// } +// NewProcessCommand command = new NewProcessCommand( +// AIFDesktop.getActiveDesktop(), +// AIFDesktop.getActiveDesktop() +// .getCurrentApplication(), components); +// isComplete = true; +// okEvent(); +// // this.disposeDialog(); +// this.dispose(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// } +// } +// } else { +// // this.disposeDialog(); +// this.dispose(); +// } +// } + + 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; + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if(source.equals(this.labelButton)) + { + // ȡݿ + SqlUtilT.getTCConnection(); + try { + int[] selectRows = table.getSelectedRows(); + for (int i = 0; i < selectRows.length; i++) { + if(this.labelRows.keySet().contains((Integer)selectRows[i])) + { + List labelRowList = labelRows.get(selectRows[i]); + List copyLabelRowList = new ArrayList(); + copyLabelRowList.addAll(labelRowList); + int[] selectColumns = table.getSelectedColumns(); + for (int j = 0; j < selectColumns.length; j++) { + if(!labelRowList.contains(((Integer)selectColumns[j]).toString())) + { + copyLabelRowList.add(((Integer)selectColumns[j]).toString()); + this.labelRows.put((Integer)selectRows[i], copyLabelRowList); + } + this.renderer.setLabelRows(labelRows); + table.revalidate(); + table.repaint(); + //System.out.println(this.table.getValueAt(table.getSelectedRow(), 0)); + String updateSQL = String.format("UPDATE RB3_CONTROLPLAN SET RB3_LABEL = ? WHERE PLMEID = \'%s\'",this.table.getValueAt(selectRows[i], 0)); + SqlUtilT.update(new String[]{ copyLabelRowList.toString().substring(1, copyLabelRowList.toString().length()-1).replace(" ", "") }, updateSQL); + } + } + else + { + List labelColumnList = new ArrayList(); + int[] selectColumns = table.getSelectedColumns(); + for (int j = 0; j < selectColumns.length; j++) { + labelColumnList.add(((Integer)selectColumns[j]).toString()); + } + this.labelRows.put(selectRows[i], labelColumnList); + this.renderer.setLabelRows(labelRows); + table.revalidate(); + table.repaint(); + String updateSQL = String.format("UPDATE RB3_CONTROLPLAN SET RB3_LABEL = ? WHERE PLMEID = \'%s\'",this.table.getValueAt(selectRows[i], 0)); + SqlUtilT.update(new String[]{ labelColumnList.toString().substring(1, labelColumnList.toString().length()-1).replace(" ", "") }, updateSQL); + } + } + } catch (Exception e) { + // TODO: handle exception\ + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + else if(source.equals(this.remLabelButton)) + { + // ȡݿ + SqlUtilT.getTCConnection(); + try { + int[] selectRows = table.getSelectedRows(); + for (int i = 0; i < selectRows.length; i++) { + if(this.labelRows.keySet().contains((Integer)selectRows[i])) + { + List labelRowList = labelRows.get(selectRows[i]); + List copyLabelRowList = new ArrayList(); + copyLabelRowList.addAll(labelRowList); + int[] selectColumns = table.getSelectedColumns(); + for (int j = 0; j < selectColumns.length; j++) { + if(labelRowList.contains(((Integer)selectColumns[j]).toString())) + { + copyLabelRowList.remove(((Integer)selectColumns[j]).toString()); + this.labelRows.put((Integer)selectRows[i], copyLabelRowList); + } + this.renderer.setLabelRows(labelRows); + table.revalidate(); + table.repaint(); + String updateSQL = String.format("UPDATE RB3_CONTROLPLAN SET RB3_LABEL = ? WHERE PLMEID = \'%s\'",this.table.getValueAt(table.getSelectedRow(), 0)); + SqlUtilT.update(new String[]{ copyLabelRowList.toString().substring(1, copyLabelRowList.toString().length()-1).replace(" ", "") },updateSQL); + } + } + } + } catch (Exception e) { + // TODO: handle exception\ + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + } + +// 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() { +// // TODO Auto-generated method stub +// this.setTitle("ѡ"); +// 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("ȷ"); +// this.okButton.addActionListener(this); +// this.celButton = new JButton("ȡ"); +// 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 = TMom004SetControlPlanDialog.table.getSelectedRow(); +// int column = TMom004SetControlPlanDialog.table +// .getSelectedColumn(); +// // λ +// String columnName = TMom004SetControlPlanDialog.table +// .getColumnName(TMom004SetControlPlanDialog.table +// .getSelectedColumn()); +// +// int cursorIndex = ((TextAreaCellEditor) (TMom004SetControlPlanDialog.table +// .getCellEditor(row, column))).getIndex(); +// System.out.println("index+" + cursorIndex); +// (TMom004SetControlPlanDialog.table.getCellEditor(row, column)) +// .stopCellEditing(); +// // TMom004SetControlPlanDialog.table.getDefaultEditor(Object.class).stopCellEditing(); +// StringBuilder sb = new StringBuilder( +// TMom004SetControlPlanDialog.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 = TMom004SetControlPlanDialog.table.getValueAt( +// row, +// TMom004SetControlPlanDialog.table.getColumnCount() - 1); +// if (special == null || special.toString() == "") { +// TMom004SetControlPlanDialog.table +// .setValueAt(columnName + "-" + cursorIndex, row, +// TMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// } else { +// TMom004SetControlPlanDialog.table +// .setValueAt(special + "|" + columnName + "-" +// + cursorIndex, row, +// TMom004SetControlPlanDialog.table +// .getColumnCount() - 1); +// } +// System.out.println(sb.length()); +// String s = sb.insert( +// cursorIndex, +// this.table.getValueAt(this.table.getSelectedRow(), +// this.table.getSelectedColumn()).toString()) +// .toString(); +// TMom004SetControlPlanDialog.table.setValueAt(s, +// TMom004SetControlPlanDialog.table.getSelectedRow(), +// TMom004SetControlPlanDialog.table.getSelectedColumn()); +// System.out.println(TMom004SetControlPlanDialog.table +// .getValueAt(row, column).toString()); +// } else { +// this.dispose(); +// } +// } +// } +// +// /** +// * Ƽƻ +// * +// * @author Administrator +// * +// */ +// private class LibraryDialog extends JFrame { +// // ؼ +// private JPanel titlePanel;// +// private JLabel titleLabel; +// +// // ǩؼ +// private JTabbedPane tabbedPane; +// +// public LibraryDialog() { +// // TODO Auto-generated constructor stub +// super(); +// getData(); +// init(); +// } +// +// private void init() { +// // TODO Auto-generated method stub +// this.setTitle("Ƽƻ"); +// this.setPreferredSize(new Dimension(800, 600)); +// // ʼⲿֿؼ +// this.titlePanel = new JPanel(); +// this.titleLabel = new JLabel("CONTROL PLAN/Ƽƻ"); +// this.titleLabel.setFont(new Font("", 1, 18)); +// this.titlePanel.add(this.titleLabel); +// +// JPanel centerPanel = new JPanel(new BorderLayout()); +// centerPanel.add(titlePanel, BorderLayout.NORTH); +// +// this.setLayout(new BorderLayout()); +// this.add(centerPanel, BorderLayout.NORTH); +// this.add(this.tabbedPane, BorderLayout.CENTER); +// // dialog.add(tablePanel, BorderLayout.CENTER); +// // this.add(rootPanel, BorderLayout.SOUTH); +// this.pack(); +// this.show(); +// } +// +// // ȡPFMEA +// /** +// * ȡݿе +// */ +// private void getData() { +// // TODO Auto-generated method stub +// ResultSet rs = null; +// InputStream input = null; +// try { +// // ȡSQL +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// pro.load(input); +// // ȡݿ +// SqlUtilT.getConnectionTC10(); +//// SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", +//// "tc10", "infodba"); +// String sql = String +// .format("select * from RB3_CONTROLPLAN_TREE"); +// rs = SqlUtilT.read(sql); +// List beans = new ArrayList(); +// while (rs.next()) { +// ControlPlanTreeBean bean = new ControlPlanTreeBean(); +// 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(); +// } +// } +// } +// +// } +// +// public void createTabbedPane(List beans) { +// this.tabbedPane = new JTabbedPane(); +// try { +// if (beans != null && beans.size() > 0) { +// for (int i = 0; i < beans.size(); i++) { +// ResultSet rs = null; +// // ѯȨ޿ +// String sql = String.format( +// pro.getProperty("CONTROLPLANLIBRARYSELECT"), +// beans.get(i).getId()); +// rs = SqlUtilT.read(sql); +// List> dataList = new ArrayList>(); +// while (rs.next()) { +// List rowList = new ArrayList(); +// rowList.add(rs.getString("PLMEID")); +// // list.add(rs.getString("RB3_JQSB")); +// // list.add(rs.getString("RB3_SMJY")); +// rowList.add(rs.getString("RB3_QPTBH")); +// rowList.add(rs.getString("RB3_CC")); +// rowList.add(rs.getString("RB3_CP")); +// rowList.add(rs.getString("RB3_GC")); +// rowList.add(rs.getString("RB3_TSTX")); +// rowList.add(rs.getString("RB3_CPGC")); +// rowList.add(rs.getString("RB3_CLFF")); +// rowList.add(rs.getString("RB3_RL")); +// rowList.add(rs.getString("RB3_PL")); +// rowList.add(rs.getString("RB3_SJSJ")); +// rowList.add(rs.getString("RB3_GCSJ")); +// rowList.add(rs.getString("RB3_MJSJ")); +// rowList.add(rs.getString("RB3_FZR")); +// rowList.add(rs.getString("RB3_KZFF")); +// rowList.add(rs.getString("RB3_CZGF")); +// rowList.add(rs.getString("RB3_FYJH")); +// rowList.add(rs.getString("PARENT_ID")); +// rowList.add(rs.getString("RB3_SPECIAL")); +// dataList.add(rowList); +// } +// final CTable jtable; +// if (dataList.size() > 0) { +// jtable = getNewjTable(null, null, header2, +// dataList.size()); +// // ʾȾ +// TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); +// jtable.setDefaultRenderer(Object.class, renderer); +// for (int j = 0; j < dataList.size(); j++) { +// for (int k = 0; k < dataList.get(j).size(); k++) { +// jtable.setValueAt(dataList.get(j).get(k), +// j, k); +// } +// } +// } else { +// jtable = getNewjTable(null, null, header2, +// dataList.size() + 1); +// // ʾȾ +// TableCellTextAreaRenderer2 renderer = new TableCellTextAreaRenderer2(); +// jtable.setDefaultRenderer(Object.class, renderer); +// jtable.setValueAt(beans.get(i).getId(), 0, +// jtable.getColumnCount() - 2); +// } +// // +// jtable.HiddenCell(0); +// jtable.HiddenCell(header2.length - 1); +// jtable.HiddenCell(header2.length - 2); +// jtable.setRowHeight(40); +// // Ӽ +// jtable.addMouseListener(new MouseAdapter() { +// +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() == 2) { +// if (table.getSelectedRow() >= 0) { +// table.getCellEditor( +// table.getSelectedRow(), +// table.getSelectedColumn()) +// .stopCellEditing(); +// for (int i = 1; i < jtable +// .getColumnCount(); i++) { +// if (i == jtable.getColumnCount() - 2) { +// continue; +// } else if (i == jtable +// .getColumnCount() - 1) { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 3); +// } else { +// table.setValueAt( +// jtable.getValueAt( +// jtable.getSelectedRow(), +// i), +// table.getSelectedRow(), +// i + 4); +// } +// } +// } +// } +// } +// }); +// JScrollPane scrollPane = new JScrollPane(jtable); +// scrollPane.getVerticalScrollBar().setUnitIncrement(10); +// tabbedPane.add(beans.get(i).getName(), scrollPane); +// if (rs != null) { +// SqlUtilT.free(rs); +// } +// } +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } finally { +// SqlUtilT.free(); +// } +// } +// } + +} diff --git a/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanHandler.java b/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanHandler.java new file mode 100644 index 0000000..d3f57d6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/TMom018ReviewControlPlanHandler.java @@ -0,0 +1,30 @@ +package com.connor.renben.process.plm.tmom018; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class TMom018ReviewControlPlanHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom018ReviewControlPlanCommand command = new TMom018ReviewControlPlanCommand( + app, session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("˿Ƽƻʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom018/TableCellCheckboxRenderer.java b/src/com/connor/renben/process/plm/tmom018/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..f6c3850 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/TableCellCheckboxRenderer.java @@ -0,0 +1,104 @@ +package com.connor.renben.process.plm.tmom018; + +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.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.JTableHeader; +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 CTMap tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(""); + // 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("")) { + 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 +// if(value != null) +// { +// String valueStr = (boolean)value ? "true" : "false"; +// //System.out.println(valueStr); +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected((boolean)value); +// } +// else +// { +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected(false); +// } +// 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")); +// 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/tmom018/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/tmom018/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..5d176d7 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/TableCellTextAreaRenderer.java @@ -0,0 +1,217 @@ +package com.connor.renben.process.plm.tmom018; + +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(Color.YELLOW); + 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ַֿ˳ʹDocumentinsertString + 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/tmom018/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/tmom018/TextAreaCellEditor.java new file mode 100644 index 0000000..9737120 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom018/TextAreaCellEditor.java @@ -0,0 +1,193 @@ +package com.connor.renben.process.plm.tmom018; + +import java.awt.Component; +import java.util.EventObject; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +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.classClass󣩣 + // ŵһCellEditorListenerʵ + listener = (CellEditorListener) listeners[i + 1]; + // changeEventȥ֪ͨ༭Ѿ༭ + // editingStoppedУJTablegetCellEditorValue()ȡصԪֵ + // Ұֵݸ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ַֿ˳ʹDocumentinsertString + 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/tmom019/CTMap.java b/src/com/connor/renben/process/plm/tmom019/CTMap.java new file mode 100644 index 0000000..cf71ed0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/CTMap.java @@ -0,0 +1,344 @@ +package com.connor.renben.process.plm.tmom019; + +import java.awt.Dimension; +import java.util.List; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + 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; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if(arg1 == 1) + { + return true; + } + else + { + return false; + } +// if (processRowList != null && processRowList.size() > 0) { +// if (!processRowList.contains(arg0)) { +// return false; +// } else { +// if (arg0 == row && arg1 == column) { +// return this.isEditable; +// } else { +// return false; +// } +// } +// } else { +// return false; +// } + } + + @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 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; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + 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); + } + } + + // if (processRowList.contains(row)) { + // for (int i = 0; i < processRowList.size(); i++) { + // 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+1) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + // else + // { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == + // row-1) + // { + // index = i+1; + // processRowList.add(i+1, row); + // } + // 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/tmom019/CTUI.java b/src/com/connor/renben/process/plm/tmom019/CTUI.java new file mode 100644 index 0000000..5217b08 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom019; + +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/tmom019/CTable.java b/src/com/connor/renben/process/plm/tmom019/CTable.java new file mode 100644 index 0000000..acd8fa7 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/CTable.java @@ -0,0 +1,231 @@ +package com.connor.renben.process.plm.tmom019; + +import java.awt.Checkbox; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +public class CTable extends JTable { + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + 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(); + } + + @Override + public void setValueAt(Object obj, int i, int j) { + // TODO Auto-generated method stub + super.setValueAt(obj, i, j); + } + 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 (column == 1) { + return checkBoxCellEditor; + } + else { + return cellEditor; + } + // Point point = new Point(row,column); + // if(map.containsKey(point)){ + // return map.get(point); + // }else{ + // return super.getCellEditor(row, column); + // } + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + if(column == 1) + { + 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, 1); + } + } + + // @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/tmom019/CellSpan.java b/src/com/connor/renben/process/plm/tmom019/CellSpan.java new file mode 100644 index 0000000..84df566 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.tmom019; + +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/tmom019/CheckBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom019/CheckBoxCellEditor.java new file mode 100644 index 0000000..86635b1 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/CheckBoxCellEditor.java @@ -0,0 +1,120 @@ +package com.connor.renben.process.plm.tmom019; + +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.JComboBox; +import javax.swing.JLabel; +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.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 CTMap tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(tableModel.getColumnName(1)); + // 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 (selectColumn == 1) { + 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/tmom019/TMom019ControlPlanOutputCommand.java b/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputCommand.java new file mode 100644 index 0000000..a35e36a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputCommand.java @@ -0,0 +1,277 @@ +package com.connor.renben.process.plm.tmom019; + +import java.io.File; +import java.util.List; + +import com.connor.renben.process.plm.bean.ControlPlanBean; +import com.connor.renben.process.plm.bean.TMomControlPlanSimpleBean; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom019ControlPlanOutputCommand extends AbstractAIFCommand { + + protected TCSession session;// Ự + protected AbstractAIFUIApplication app;// Ӧ + protected File file;// excelģļ + protected int operateCode;// ִд + protected TCComponent meprocess; + protected TCComponentItem item; + protected String type; + protected InterfaceAIFComponent comp; + + /** + * + * @param session + * Ự + * @param app + * Ӧ + * @param fileSource + * ģ + * @param operateCode + * + */ + public TMom019ControlPlanOutputCommand(TCSession session, + AbstractAIFUIApplication app, File file, int operateCode,String type) { + + this.session = session; + this.app = app; + this.file = file; + this.operateCode = operateCode; + this.type = type; + } + + /** + * ȡ汾 + * + * @return + * @throws TCException + */ + public TCComponentForm getFormFromRev() throws TCException { + TCComponentForm revMasterForm = null; + comp = this.app.getTargetComponent(); + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; + item = rev.getItem(); + //ҵն + AIFComponentContext[] context = rev.getItem().whereReferenced(); + for (int i = 0; i < context.length; i++) { + if(context[i].getComponent().getType().equals("MEProcess")) + { + meprocess = (TCComponent) context[i].getComponent(); + } + } + // ȡĬճϵ + // String defaultRelation = rev.getDefaultPasteRelation(); + // TCComponent[] comps = + // rev.getReferenceListProperty(defaultRelation); + String fileName = null; + // ȡ + TCProperty prop = rev.getTCProperty("IMAN_master_form_rev"); + if (prop != null) { + TCComponent[] compst = prop.getReferenceValueArray(); + if (compst != null && compst.length == 1 + && compst[0] instanceof TCComponentForm) { + revMasterForm = (TCComponentForm) compst[0]; + } + } + } + return revMasterForm; + } + + /** + * ȡ + * + * @param bean + * @param index + * @param count + * @param prop + */ + public void getSimpleBean(List beanList, + int index, int count, TCProperty prop) { + // TMomControlPlanSimpleBean bean = null; + String[] propValues = null; + if (prop != null) { + propValues = prop.getStringArrayValue(); + if (propValues == null || propValues.length != count + || beanList.size() != count) { + return; + } + } else { + return; + } + for (int i = 0; i < count; i++) { + TMomControlPlanSimpleBean bean = beanList.get(i); + if (propValues[i] != null) + switch (index) { + case 18: + bean.setPartProcessNumber(propValues[i]); + break; + case 19: + bean.setProcessName(propValues[i]); + break; + case 20: + bean.setMachineDevice(propValues[i]); + break; + case 21: + bean.setBubbledPrintNo(propValues[i]); + break; + case 22: + bean.setSize(propValues[i]); + break; + case 23: + bean.setNo(propValues[i]); + case 24: + bean.setProduct(propValues[i]); + break; + case 25: + bean.setProcess(propValues[i]); + break; + case 26: + bean.setSpecialClass(propValues[i]); + break; + case 27: + bean.setProductProcessSpecificationTolerance(propValues[i]); + break; + case 28: + bean.setUpProductProcessSpecificationTolerance(propValues[i]); + break; + case 29: + bean.setDownProductProcessSpecificationTolerance(propValues[i]); + break; + case 30: + bean.setEvaluationMeasurementTechnique(propValues[i]); + break; + case 31: + bean.setSampleSize(propValues[i]); + case 32: + bean.setSampleFreq(propValues[i]); + break; + case 33: + bean.setResp(propValues[i]); + break; + case 34: + bean.setControlMethod(propValues[i]); + break; + case 35: + bean.setOperationCriteria(propValues[i]); + break; + case 36: + bean.setReactionPlan(propValues[i]); + break; + default: + break; + + } + } + + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + + + TCComponentForm form = null; + try { + form = getFormFromRev(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + // MessageBox.post("ѡ汾󣬻ûҵ汾İ汾˶ݺִи", "", + // MessageBox.ERROR); + // return; + } + if (form == null) { + MessageBox.post("ѡ汾󣬻ûҵ汾İ汾˶ݺִи", "", + MessageBox.ERROR); + return; + } + + final ControlPlanBean controlPlanBean = new ControlPlanBean(); + controlPlanBean.setKzjhbh(comp.getProperty("item_id") + "/"+ comp.getProperty("item_revision_id")); + controlPlanBean.setZylxr(item.getReferenceProperty("owning_user").getStringProperty("user_name")); + 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") != "") + { + controlPlanBean.setBzriq(revComponent.getProperty("date_released")); + } + if(revId == newestRevisiovId) + { + controlPlanBean.setXdrq(revComponent.getProperty("date_released")); + } + } + } + if(controlPlanBean.getBzriq() == null) + { + controlPlanBean.setBzriq(""); + } + if(controlPlanBean.getXdrq() == null) + { + controlPlanBean.setXdrq(""); + } + //ݹȡƷ + 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(); + TCComponentItemRevision productLastRevision = product.getLatestItemRevision(); + controlPlanBean.setLjh(productLastRevision.getProperty("item_id") + "/"+ productLastRevision.getProperty("item_revision_id")); + //controlPlanBean.setLjh(productLastRevision.getStringProperty("rb3_press_drawing")); + controlPlanBean.setLjmc(product.getStringProperty("object_name")); + //ȡ汾 + TCComponent revMaster = productLastRevision.getRelatedComponent("IMAN_master_form_rev"); + controlPlanBean.setKhtzbh(revMaster.getStringProperty("rb3_press_drawing")); + } + } +// ƼƻţƼƻITME_ID/汾 +// ҪϵˣƼƻ +// ڣƣһ汾ʱ +// ڣ޶°淢ʱ +// /հ汾ƷITEM_ID/汾 +// /Ʒobject_name +// ͻͼֽţƷ汾еĿͻͼ + + //TMomControlPlanBean bean = null; +// try { +// bean = exchangeFormMsgToBean(form); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// +// } + +// if (bean == null) { +// MessageBox.post("ȡݴ˶ݺִи", "", MessageBox.ERROR); +// return; +// } + TMom019ControlPlanOutputDialog dialog = new TMom019ControlPlanOutputDialog( + session, app,item,form,meprocess, file, operateCode,this.type,controlPlanBean); + //dialog.initDialog(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputDialog.java b/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputDialog.java new file mode 100644 index 0000000..81b8a22 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputDialog.java @@ -0,0 +1,776 @@ +package com.connor.renben.process.plm.tmom019; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Vector; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.ControlPlanBean; +import com.connor.renben.process.plm.bean.ControlPlanComboBoxBean; +import com.connor.renben.process.plm.bean.TMomControlPlanBean; +import com.connor.renben.process.plm.bean.TMomControlPlanSimpleBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom019ControlPlanOutputDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private AbstractAIFUIApplication app; + private TMomControlPlanBean controlPlanBean; + private ControlPlanBean controlPlanBean2; + private Vector ControlPlanComboBoxBeans = new Vector(); + private File file; + private int operateCode; + private String type; + private TCComponent meprocess; + private TCComponent item; + private TCComponentForm form; + private CTMap map; + private String[] header = new String[] { "PLMEID","ȫѡ", "/ձ", "", + ",豸,װ,о", "ĩ", "ͼ", "ߴ","", "Ʒ", "", "Է", + "Ʒ///", "/", "", "Ƶ", "", "Ʒ", "淶/¼", + "Ӧƻ","׼ռٷֱ", "ռٷֱ","ĩռٷֱ", "λ","Ƿ" }; + + // --------------------------------------------------ؼ + private JPanel mainPanel; + private JLabel meopLabel;// + private JComboBox meopComboBox; + private JButton selectButton;//ѯ + private JButton saveButton;// + //ؼ + private JPanel tablePanel; + private CTable table; + + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + private JPanel panel2; + + // -------------------------------------------------- + public TMom019ControlPlanOutputDialog(TCSession session, + AbstractAIFUIApplication app,TCComponent item,TCComponentForm form, TCComponent meprocess, + File file, int operateCode,String type,ControlPlanBean controlPlanBean2) { + super(false); + this.session = session; + this.app = app; + this.item = item; + this.form = form; + this.meprocess = meprocess; + this.file = file; + this.operateCode = operateCode; + this.type = type; + this.controlPlanBean2 = controlPlanBean2; + getComboBoxItem(); + initDialog(); + } + + /** + * ʼ + */ + public void initDialog() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("kzjhdc19_display.TITLE")); + this.setPreferredSize(new Dimension(1000, 800)); + + this.mainPanel = new JPanel(new PropertyLayout()); + this.meopLabel = new JLabel(rb.getString("gx19_display.TITLE")); + this.meopComboBox = new JComboBox(this.ControlPlanComboBoxBeans); + this.meopComboBox.setPreferredSize(new Dimension(187, 20)); + this.selectButton = new JButton(rb.getString("cx19_display.TITLE")); + + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + this.saveButton = new JButton(rb.getString("bc_display.TITLE")); + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + //Ӽ + this.fileButton.addActionListener(this); + this.saveButton.addActionListener(this); + this.selectButton.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + pathText = new JTextField(30); + pathText.setText("c:"); + fleName = new JTextField(30); + switch (operateCode) { + case TMomFinalUtil.AIXING_CHINESE_CONTROL: + fleName.setText("ſƼƻģ"); + break; + case TMomFinalUtil.AIXING_ENGLISH_CONTROL: + fleName.setText("ſƼƻӢģ"); + break; + case TMomFinalUtil.AIXING_CHINESE_ENGLISH_CONTROL: + fleName.setText("ſƼƻӢģ"); + break; + case TMomFinalUtil.BOGEHUALAEN_CHINESE_CONTROL: + fleName.setText("ḥտƼƻģ"); + break; + case TMomFinalUtil.BOGEHUALAEN_ENGLISH_CONTROL: + fleName.setText("ḥտƼƻӢģ"); + break; + case TMomFinalUtil.BOGEHUALAEN_CHINESE_ENGLISH_CONTROL: + fleName.setText("ḥտƼƻӢģ"); + break; + case TMomFinalUtil.MAIGELA_CHINESE_CONTROL: + fleName.setText("ɿƼƻģ"); + break; + case TMomFinalUtil.MAIGELA_ENGLISH_CONTROL: + fleName.setText("ɿƼƻӢģ"); + break; + case TMomFinalUtil.MAIGELA_CHINESE_ENGLISH_CONTROL: + fleName.setText("ɿƼƻӢģ"); + break; + case TMomFinalUtil.NBTM_CHINESE_CONTROL: + fleName.setText("Ƽƻģ"); + break; + case TMomFinalUtil.NBTM_ENGLISH_CONTROL: + fleName.setText("ƼƻӢģ"); + break; + case TMomFinalUtil.NBTM_CHINESE_ENGLISH_CONTROL: + fleName.setText("ƼƻӢģ"); + break; + default: + fleName.setText("Ƽƻ"); + break; + } + + this.mainPanel.add("1.1.right.top", this.meopLabel); + this.mainPanel.add("1.2.left.top", this.meopComboBox); + this.mainPanel.add("1.3.left.top", this.selectButton); + //this.mainPanel.add("2.1.right.top.preferred.preferred", new JLabel(" ")); + this.mainPanel.add("2.1.right.top.preferred.preferred", new JLabel(rb.getString("kzjhwjmc19_display.TITLE"))); + this.mainPanel.add("2.2.left.top.preferred.preferred", fleName); + this.mainPanel.add("3.1.right.top.preferred.preferred", new JLabel(rb.getString("xzwjj_display.TITLE"))); + this.mainPanel.add("3.2.left.top.preferred.preferred", pathText); + this.mainPanel.add("3.3.left.top.preferred.preferred", this.fileButton); + + this.tablePanel = new JPanel(new BorderLayout()); + this.table = getjTable(null, null, header, null); + // ӹ + JScrollPane scrollPane = new JScrollPane(this.table); + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + this.tablePanel.add(scrollPane, BorderLayout.CENTER); + + panel2 = new JPanel(new FlowLayout()); + panel2.add(this.saveButton); + panel2.add(new JLabel(" ")); + panel2.add(this.okButton); + panel2.add(new JLabel(" ")); + panel2.add(this.celButton); + +// rootPanel = new JPanel(new BorderLayout()); +// rootPanel.add(tablePanel, BorderLayout.CENTER); +// rootPanel.add(panel2, BorderLayout.SOUTH); + + this.setLayout(new BorderLayout()); + this.add(mainPanel, BorderLayout.NORTH); + this.add(tablePanel, BorderLayout.CENTER); + this.add(panel2, BorderLayout.SOUTH); + this.pack(); + //this.centerToScreen(); + this.showDialog(); + } + + /** + * ȡбֵ + */ + private void getComboBoxItem() { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format("select rb3_meopid,rb3_gcmc from rb3_controlplan where processpuid = \'%s\' and rb3_gcmc not like (\'飨%%\') group by rb3_meopid,rb3_gcmc",//飨 + meprocess.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + ControlPlanComboBoxBean controlPlanBean = new ControlPlanComboBoxBean(); + controlPlanBean.setItemId(rs.getString("RB3_MEOPID")); + controlPlanBean.setItemName(rs.getString("rb3_gcmc")); + this.ControlPlanComboBoxBeans.add(controlPlanBean); + } + } catch (Exception e) { + // TODO Auto-generated catch block + 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(); + } + } + // 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(0, titleNames.length); + map.setColumnIdentifiers(titleNames); + partsTable = new CTable(map); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length - 1); + partsTable.HiddenCell(titleNames.length - 2); + // + 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 (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; + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + + /** + * ȷťҵ¼ + * + * @param e + * @throws IOException + */ + public void okEvent(ActionEvent e) throws IOException { + InputStream is = new FileInputStream(file); + String outFilePath = this.pathText.getText() + "\\" + fleName.getText() + + ".xlsx"; + switch (operateCode) { + //ſƼƻ + case TMomFinalUtil.AIXING_CHINESE_CONTROL:case TMomFinalUtil.AIXING_ENGLISH_CONTROL:case TMomFinalUtil.AIXING_CHINESE_ENGLISH_CONTROL: + ExcelUtil07.writeAixinControlPlanToExcel(this.controlPlanBean, is, + outFilePath,this.type); + ExcelUtil07.setExcelToItem(session, (TCComponentItemRevision)app.getTargetComponent(), outFilePath,fleName.getText(),"RB3_khkzjh","MSExcelX",false); + break; + //ɿƼƻ + case TMomFinalUtil.BOGEHUALAEN_CHINESE_CONTROL:case TMomFinalUtil.BOGEHUALAEN_ENGLISH_CONTROL:case TMomFinalUtil.BOGEHUALAEN_CHINESE_ENGLISH_CONTROL: + ExcelUtil07.writeBogehuanaControlPlanToExcel(this.controlPlanBean, + is, outFilePath,this.type); + ExcelUtil07.setExcelToItem(session, (TCComponentItemRevision)app.getTargetComponent(), outFilePath,fleName.getText(),"RB3_khkzjh","MSExcelX",false); + break; + //ɿƼƻ + case TMomFinalUtil.MAIGELA_CHINESE_CONTROL:case TMomFinalUtil.MAIGELA_ENGLISH_CONTROL:case TMomFinalUtil.MAIGELA_CHINESE_ENGLISH_CONTROL: + ExcelUtil07.writeMaigelaControlPlanToExcel(this.controlPlanBean, + is, outFilePath,this.type); + ExcelUtil07.setExcelToItem(session, (TCComponentItemRevision)app.getTargetComponent(), outFilePath,fleName.getText(),"RB3_khkzjh","MSExcelX",false); + break; + //Ƽƻ + case TMomFinalUtil.NBTM_CHINESE_CONTROL:case TMomFinalUtil.NBTM_ENGLISH_CONTROL:case TMomFinalUtil.NBTM_CHINESE_ENGLISH_CONTROL: + ExcelUtil07.writeNBTMControlPlanToExcel(this.controlPlanBean, + is, outFilePath,this.type); + ExcelUtil07.setExcelToItem(session, (TCComponentItemRevision)app.getTargetComponent(), outFilePath,fleName.getText(),"RB3_khkzjh","MSExcelX",false); + break; + default: + break; + } + this.dispose(); + } + + /** + * FormеתΪbeanе + * + * @param revMasterForm + * + * @return + * @throws TCException + */ + public TMomControlPlanBean exchangeFormMsgToBean( + TCComponentForm revMasterForm) throws TCException, Exception { + TMomControlPlanBean controlPlanBean = new TMomControlPlanBean(); + if (revMasterForm == null) { + return null; + } + String[] propNames = new String[] { "rb3_cpjd", // Ʒ׶ + "rb3_kzjhbh", // Ƽƻ + "rb3_zylxdh", // Ҫϵ˵绰 + "rb3_bzrq",// + "rb3_xdrq", // 5 ޶ + "rb3_sor", // SOR/ + "rb3_zxggcd", // /¸ij̶ + "rb3_hxxz", // С + "rb3_gkgcpz",// ˿͹׼/ + "rb3_khtzbh",// 10ͻͼֽ + "rb3_ljmc", // / + "rb3_gfgcpz", // /׼/ + "rb3_gkzlpz",// ˿׼/ + "rb3_gfgc",// / + "rb3_gfdh",// 15 + "rb3_cxnd",// / + "rb3_qtpzrq1", // ׼/1 + "rb3_qtpzrq2", // 18׼/2 + "rb3_ljgybh",// 19/ձ + "rb3_gcmcms",// 20/ + "rb3_jqsbgzjj",// /豸/װ/о + "rb3_qptbh",// ͼ + "rb3_cc",// ߴ + "rb3_xh", // + "rb3_cp",// 25Ʒ + "rb3_gc", // + "rb3_tstxfl",// Է + "rb3_cpgcgggc", // Ʒ/// + "rb3_spc", // ƫ + "rb3_xpc",// 30ƫ + "rb3_pgclff",// / + "rb3_rl", // + "rb3_pl", // Ƶ + "rb3_fzr", // + "rb3_kzff",// 35Ʒ + "rb3_czgf", // 淶/¼ + "rb3_fyjh", // 37Ӧƻ + "rb3_zylxr",// 38Ҫϵ + "rb3_gkpz", // 39˿׼/ + "rb3_xgdj" };// 40޸ĵȼ + // ȡԶ + TCProperty[] propValues = revMasterForm.getTCProperties(propNames); + if (propValues == null + || propValues.length != TMomControlPlanBean.PROP_COUNT) { + return null; + } + // õԵֵ + if (propValues[0] != null && propValues[0].getStringValue() != null) + controlPlanBean.setControlType(propValues[0].getStringValue()); + controlPlanBean.setControlPlanNo(this.controlPlanBean2.getKzjhbh()); + if (propValues[2] != null && propValues[2].getStringValue() != null) + controlPlanBean.setKeyPhone(propValues[2].getStringValue()); + controlPlanBean.setCreateDateStr(this.controlPlanBean2.getBzriq()); + controlPlanBean.setUpdateDateStr(this.controlPlanBean2.getXdrq());// 5 + if (propValues[5] != null && propValues[5].getStringValue() != null) + controlPlanBean.setSorName(propValues[5].getStringValue()); + controlPlanBean.setPartNumber(this.controlPlanBean2.getLjh()); + if (propValues[7] != null && propValues[7].getStringValue() != null) + controlPlanBean.setCoreTeam(propValues[7].getStringValue()); + if (propValues[8] != null && propValues[8].getStringValue() != null) + controlPlanBean.setCustromEngineeringApprovalDateStr(propValues[8] + .getStringValue()); + controlPlanBean.setCustromPartNumber(this.controlPlanBean2.getKhtzbh());// 10 + if (this.controlPlanBean2.getLjmc() != null && this.controlPlanBean2.getLjmc() != null) + controlPlanBean.setPartNameDesc(this.controlPlanBean2.getLjmc()); + if (propValues[11] != null && propValues[11].getStringValue() != null) + controlPlanBean.setSupplierApprovalDateStr(propValues[11] + .getStringValue()); + if (propValues[12] != null && propValues[12].getStringValue() != null) + controlPlanBean.setCustromQuantyApprovalDateStr(propValues[12] + .getStringValue()); + if (propValues[13] != null && propValues[13].getStringValue() != null) + controlPlanBean.setSupplier(propValues[13].getStringValue()); + if (propValues[14] != null && propValues[14].getStringValue() != null) + controlPlanBean.setSupplierCode(propValues[14].getStringValue());// 15 + if (propValues[15] != null && propValues[15].getStringValue() != null) + controlPlanBean.setMode(propValues[15].getStringValue()); + if (propValues[16] != null && propValues[16].getStringValue() != null) + controlPlanBean.setOtherApprovalDateStr(propValues[16] + .getStringValue()); + if (propValues[17] != null && propValues[17].getStringValue() != null) + controlPlanBean.setOtherApprovalIfDateStr(propValues[17] + .getStringValue()); + controlPlanBean.setKeyPersion(this.controlPlanBean2.getZylxr()); + if (propValues[38] != null && propValues[38].getStringValue() != null) + controlPlanBean.setCustromApprovalDateStr(propValues[38] + .getStringValue()); + if (propValues[39] != null && propValues[39].getStringValue() != null) + controlPlanBean.setChangeLev(propValues[39].getStringValue()); + + ResultSet rs = null; + try { + // Եֵ + SqlUtilT.getTCConnection(); + String sql = String.format("SELECT RB3_MEOPID,RB3_GYBH,RB3_GCMC,RB3_JQSB,RB3_SMJY,RB3_QPTBH,RB3_CC,RB3_NO,RB3_CP,RB3_GC,RB3_TSTX,RB3_CPGC,RB3_CLFF,RB3_RL,RB3_PL,RB3_FZR,RB3_KZFF,RB3_CZGF,RB3_FYJH,RB3_HBDYG,RB3_SPECIAL,RB3_CONCEAL FROM RB3_CONTROLPLAN where processpuid = \'%s\' and type = \'%s\' and rb3_revisionuid=\'%s\' order by to_number(RB3_GYBH),to_number(RB3_HH)", meprocess.getUid(),item.getType().toUpperCase(),app.getTargetComponent().getUid()); + System.out.println(sql); + rs = SqlUtilT.read(sql); + List simpleBeanList = new ArrayList<>(); + while (rs.next()) { + TMomControlPlanSimpleBean bean = new TMomControlPlanSimpleBean(); + bean.setMeopId(rs.getString("RB3_MEOPID"));// ID + bean.setPartProcessNumber(rs.getString("RB3_GYBH"));// ձ + bean.setProcessName(rs.getString("RB3_GCMC"));// + bean.setMachineDevice(rs.getString("RB3_JQSB"));// 豸 + bean.setSmjy(rs.getString("RB3_SMJY"));//ĩ + bean.setBubbledPrintNo(rs.getString("RB3_QPTBH"));// ͼ + bean.setNo(rs.getString("RB3_NO"));// + bean.setSize(rs.getString("RB3_CC"));// 5 ߴ + bean.setProduct(rs.getString("RB3_CP"));// Ʒ + bean.setProcess(rs.getString("RB3_GC"));// + bean.setSpecialClass(rs.getString("RB3_TSTX"));// + bean.setProductProcessSpecificationTolerance(rs.getString("RB3_CPGC"));// 10 Ʒ๫ + bean.setEvaluationMeasurementTechnique(rs.getString("RB3_CLFF"));// + bean.setSampleSize(rs.getString("RB3_RL"));// Ʒ + bean.setSampleFreq(rs.getString("RB3_PL"));// 15 ƷƵ + bean.setResp(rs.getString("RB3_FZR"));//rs.getString("") + bean.setControlMethod(rs.getString("RB3_KZFF"));// Ʒ + bean.setOperationCriteria(rs.getString("RB3_CZGF"));// 淶 + bean.setReactionPlan(rs.getString("RB3_FYJH"));// Ӧƻ + bean.setHbdyg(rs.getString("RB3_HBDYG")); + bean.setSpecial(rs.getString("RB3_SPECIAL")); + bean.setConceal(rs.getString("RB3_CONCEAL")); +// String[] concealMeops = TMomMethodUtil.getPreferenceValues("Cust_Conceal_Meop"); +// if(concealMeops.length > 0) +// { +// for(int i = 0; i< concealMeops.length;i++) +// { +// if(rs.getString("RB3_GCMC") != null && rs.getString("RB3_GCMC").indexOf(concealMeops[i]) >=0) +// { +// bean.setConceal("1"); +// } +// } +// } + simpleBeanList.add(bean); + } + controlPlanBean.setSimpleBeanList(simpleBeanList); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } +// if (propValues[18] != null) { +// String[] strValues = propValues[18].getStringArrayValue(); +// if (strValues != null) { +// int valueCount = strValues.length; +// List simpleBeanList = new ArrayList<>(); +// for (int i = 0; i < valueCount; i++) { +// +// TMomControlPlanSimpleBean simpleBean = new TMomControlPlanSimpleBean(); +// simpleBeanList.add(simpleBean); +// } +// for (int i = 18; i < TMomControlPlanBean.PROP_COUNT_T; i++) { +// getSimpleBean(simpleBeanList, i, valueCount, propValues[i]); +// } +// controlPlanBean.setSimpleBeanList(simpleBeanList); +// } +// } + + return controlPlanBean; + } + + 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); + ControlPlanComboBoxBean bean = (ControlPlanComboBoxBean) this.meopComboBox.getSelectedItem(); + String sql = String.format(pro.getProperty("CONTROLPLANOUTPUTSELECT"), bean.getItemId(),item.getType().toUpperCase()); + rs = SqlUtilT.read(sql); + List> rowList = new ArrayList>(); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("RB3_CONCEAL")); + list.add(rs.getString("RB3_GYBH")); + list.add(rs.getString("RB3_GCMC") == null ? "" : rs.getString("RB3_GCMC")); + list.add(rs.getString("RB3_JQSB")); + list.add(rs.getString("RB3_SMJY")); + list.add(rs.getString("RB3_QPTBH")); + list.add(rs.getString("RB3_CC")); + list.add(rs.getString("RB3_NO")); + list.add(rs.getString("RB3_CP")); + list.add(rs.getString("RB3_GC")); + list.add(rs.getString("RB3_TSTX")); + list.add(rs.getString("RB3_CPGC")); + list.add(rs.getString("RB3_CLFF")); + list.add(rs.getString("RB3_RL")); + list.add(rs.getString("RB3_PL")); + list.add(rs.getString("RB3_FZR")); + list.add(rs.getString("RB3_KZFF")); + list.add(rs.getString("RB3_CZGF")); + list.add(rs.getString("RB3_FYJH")); + list.add(rs.getString("RB3_SJSJ")); + list.add(rs.getString("RB3_GCSJ")); + list.add(rs.getString("RB3_MJSJ")); + list.add(rs.getString("RB3_SPECIAL")); + list.add(((Integer)rs.getInt("RB3_SFWC")).toString() == null ? "" : ((Integer)rs.getInt("RB3_SFWC")).toString());//23 + list.add(rs.getString("RB3_USER") == null ? "" : rs.getString("RB3_USER"));//24 + list.add(rs.getString("RB3_INSPECTIONUSER") == null ? "" : rs.getString("RB3_INSPECTIONUSER"));//25 + list.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID"));//26 + list.add(rs.getInt("RB3_HH"));//27 + list.add(rs.getString("RB3_HBDYG"));//28 + list.add(rs.getInt("RB3_HHC"));//28 + rowList.add(list); + } + for (int i = 0; i < rowList.size(); i++) { + // кŲ + rowList.get(i).set(30,i- Integer.parseInt(rowList.get(i).get(28).toString())); + } + Map combineMap = getCombineMap(rowList); + if (rowList.size() > 0) { + CTMap map = new CTMap(rowList.size(),header.length); + map.setColumnIdentifiers(header); + map.setEditable(true); + comBine(combineMap, map); + table.setModel(map); + for (int j = 0; j < rowList.size(); j++) { + for (int k = 0; k < header.length; k++) { + if(k == 0) + { + table.setValueAt(rowList.get(j).get(k), j, k); + } + else + { + table.setValueAt(rowList.get(j).get(k), j, k); + } + } + } + } else { + CTMap map = new CTMap(1,header.length); + map.setColumnIdentifiers(header); + table.setModel(map); + } + table.HiddenCell(0); + table.HiddenCell(header.length - 1); + table.HiddenCell(header.length - 2); + table.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 comBine(Map combineMap,CTMap map) { + // 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()); + } + } + } + /** + * ȡϲԪ + */ + public Map getCombineMap(List> rowList) { + Map combineMap = new HashMap();// źϲԪ + try { + if (rowList != null && rowList.size() > 0) { + for (int i = 0; i < rowList.size(); i++) { + if (rowList.get(i).get(29) != null + && !rowList.get(i).get(29).equals("")) { + String sombine = rowList.get(i).get(29).toString(); + int rowDif = Integer.parseInt(rowList.get(i).get(30) + .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])+1; + } + } else { + cloumn = new int[] { Integer + .parseInt(cells[1])+1 }; + } + combineMap.put(row, cloumn); + } + } + } + } + return combineMap; + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return combineMap; + } + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if(source.equals(this.fileButton)) + { + selectFileButtonEvent(actionevent); + } + else if(source.equals(this.okButton)) + { + try { + this.controlPlanBean = exchangeFormMsgToBean(this.form); + okEvent(actionevent); + MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + } catch (Exception e1) { + MessageBox.post("ʧ", "ʧ", MessageBox.ERROR); + e1.printStackTrace(); + } + } + else if(source.equals(this.saveButton)) + { + try { + SqlUtilT.getTCConnection(); + for (int i = 0; i < table.getRowCount(); i++) { + for (int j = 0; j < table.getColumnCount(); j++) { + String updateSql = String.format("update RB3_CONTROLPLAN set RB3_CONCEAL = ? where plmeid = \'%s\'", table.getValueAt(i, 0)); + SqlUtilT.update(updateSql, new String[]{ table.getValueAt(i, 1).toString() }); + } + } + this.panel2.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + panel2.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + this.rootPane.setBackground(Color.RED); + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + + } + else if(source.equals(this.selectButton)) + { + refreshTable(); + } + else if(source.equals(this.celButton)) + { + this.dispose(); + this.disposeDialog(); + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputHandler.java b/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputHandler.java new file mode 100644 index 0000000..ffac74f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/TMom019ControlPlanOutputHandler.java @@ -0,0 +1,127 @@ +package com.connor.renben.process.plm.tmom019; + +import java.io.File; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom019ControlPlanOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String commandId = arg0.getCommand().getId(); + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + int operateCode = -1; + File file = null; + String type = ""; + //String fileSource = null; + switch (commandId) { + //ſƼƻ + case "com.connor.renben.process.plm.commands.AiXinChineseControlOutputCommand": + operateCode = TMomFinalUtil.AIXING_CHINESE_CONTROL; + file = TMomMethodUtil.getFile(session, "ſƼƻ","MSExcelX"); + type = "CHINESE"; + //fileSource = "ſƼƻ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.AiXinEnglishControlOutputCommand": + operateCode = TMomFinalUtil.AIXING_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ſƼƻ","MSExcelX"); + type = "ENGLISH"; + //fileSource = "ſƼƻ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.AiXinChineseAndEnglishControlOutputCommand": + operateCode = TMomFinalUtil.AIXING_CHINESE_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ſƼƻ","MSExcelX"); + type = "CHINESEANDENGLISH"; + //fileSource = "ſƼƻ.xlsx"; + break; + //ſƼƻ + //ḥտƼƻ + case "com.connor.renben.process.plm.commands.BoGeLaChineseControlOutputCommand": + operateCode = TMomFinalUtil.BOGEHUALAEN_CHINESE_CONTROL; + file = TMomMethodUtil.getFile(session, "ḥտƼƻӢıͷ","MSExcelX"); + type = "CHINESE"; + //fileSource = "ḥտƼƻ-Ӣıͷ1.xlsx"; + break; + case "com.connor.renben.process.plm.commands.BoGeLaEnglishControlOutputCommand": + operateCode = TMomFinalUtil.BOGEHUALAEN_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ḥտƼƻӢıͷ","MSExcelX"); + type = "ENGLISH"; + //fileSource = "ḥտƼƻ-Ӣıͷ1.xlsx"; + break; + case "com.connor.renben.process.plm.commands.BoGeLaChineseAndEnglishControlOutputCommand": + operateCode = TMomFinalUtil.BOGEHUALAEN_CHINESE_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ḥտƼƻӢıͷ","MSExcelX"); + type = "CHINESEANDENGLISH"; + //fileSource = "ḥտƼƻ-Ӣıͷ1.xlsx"; + break; + //ḥտƼƻ + //ɿƼƻ + case "com.connor.renben.process.plm.commands.MaiGeLaChineseControlOutputCommand": + operateCode = TMomFinalUtil.MAIGELA_CHINESE_CONTROL; + file = TMomMethodUtil.getFile(session, "ɿƼƻ","MSExcelX"); + type = "CHINESE"; + //fileSource = "ɿƼƻ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.MaiGeLaEnglishControlOutputCommand": + operateCode = TMomFinalUtil.MAIGELA_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ɿƼƻ","MSExcelX"); + type = "ENGLISH"; + //fileSource = "ɿƼƻ.xlsx"; + break; + case "com.connor.renben.process.plm.commands.MaiGeLaChineseAndEnglishControlOutputCommand": + operateCode = TMomFinalUtil.MAIGELA_CHINESE_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ɿƼƻ","MSExcelX"); + type = "CHINESEANDENGLISH"; + //fileSource = "ɿƼƻ.xlsx"; + break; + //ɿƼƻ + //Ƽƻ + //ƼƻӢģ ѡ еϢ + case "com.connor.renben.process.plm.commands.NBTMChineseControlOutputCommand": + operateCode = TMomFinalUtil.NBTM_CHINESE_CONTROL; + file = TMomMethodUtil.getFile(session, "ƼƻӢģ","MSExcelX"); + type = "CHINESE"; + break; + case "com.connor.renben.process.plm.commands.NBTMEnglishControlOutputCommand": + operateCode = TMomFinalUtil.NBTM_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ƼƻӢģ","MSExcelX"); + type = "ENGLISH"; + break; + case "com.connor.renben.process.plm.commands.NBTMChineseAndEnglishControlOutputCommand": + operateCode = TMomFinalUtil.NBTM_CHINESE_ENGLISH_CONTROL; + file = TMomMethodUtil.getFile(session, "ƼƻӢģ","MSExcelX"); + type = "CHINESEANDENGLISH"; + break; + //Ƽƻ + default: + break; + } + if (operateCode != -1) { + TMom019ControlPlanOutputCommand command = new TMom019ControlPlanOutputCommand( + session, app, file, operateCode,type); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("Ʊʧ", "ʧ", MessageBox.ERROR); + } + + } else { + MessageBox.post("ѡȷָ˵", "", MessageBox.ERROR); + } + + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom019/TableCellCheckboxRenderer.java b/src/com/connor/renben/process/plm/tmom019/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..08cb4c8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/TableCellCheckboxRenderer.java @@ -0,0 +1,114 @@ +package com.connor.renben.process.plm.tmom019; + +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.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 CTMap tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(tableModel.getColumnName(1)); + // 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 (selectColumn == 1) { + 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 +// if(value != null) +// { +// String valueStr = (boolean)value ? "true" : "false"; +// //System.out.println(valueStr); +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected((boolean)value); +// } +// else +// { +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected(false); +// } +// 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")); +// 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/tmom019/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/tmom019/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..0f70017 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/TableCellTextAreaRenderer.java @@ -0,0 +1,275 @@ +package com.connor.renben.process.plm.tmom019; + +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 TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + 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")) { + // 7,11,13 + 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(); + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + 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(""); + } + } else if(table.getColumnName(column).equals("New_RPN")) { + // 19,20,21 + String yzd = table.getValueAt(row, 19) == null ? "0" : table + .getValueAt(row, 19).toString(); + String pds = table.getValueAt(row, 20) == null ? "0" : table + .getValueAt(row, 20).toString(); + String tcd = table.getValueAt(row, 21) == null ? "0" : table + .getValueAt(row, 21).toString(); + if(isStr2Num(yzd) && isStr2Num(pds) && isStr2Num(tcd)) + { + 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(""); + } + } + else + { + setText(value == null ? "" : value.toString()); + } + + // ж + // if(value != null && !value.toString().equals("")) + // { + // SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setAlignment(set, StyleConstants.ALIGN_CENTER);//þ + // Document doc = this.getStyledDocument(); + // try { + // doc.remove(0,value.toString().length()); + // doc.insertString(doc.getLength(), value.toString(),set); + // } catch (BadLocationException e) { + // System.out.println(value.toString()); + // e.printStackTrace(); + // } + // } + // + // 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 (table.getColumnName(column).equals("New_RPN") && value != null + && !value.equals("") + && Integer.parseInt(value.toString()) >= 100) { + 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); +// } + 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ַֿ˳ʹDocumentinsertString + 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(); + } + } + + /** + * 鿴һַǷתΪ + * @param str ַ + * @return true ; false + */ + public boolean isStr2Num(String str) { + try { + Integer.parseInt(str); + return true; + } catch (NumberFormatException e) { + return false; + } + } + // + // @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/tmom019/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/tmom019/TextAreaCellEditor.java new file mode 100644 index 0000000..9db388e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom019/TextAreaCellEditor.java @@ -0,0 +1,193 @@ +package com.connor.renben.process.plm.tmom019; + +import java.awt.Component; +import java.util.EventObject; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +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.classClass󣩣 + // ŵһCellEditorListenerʵ + listener = (CellEditorListener) listeners[i + 1]; + // changeEventȥ֪ͨ༭Ѿ༭ + // editingStoppedУJTablegetCellEditorValue()ȡصԪֵ + // Ұֵݸ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ַֿ˳ʹDocumentinsertString + 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/tmom019/东睦控制计划-中英文表头.xlsx b/src/com/connor/renben/process/plm/tmom019/东睦控制计划-中英文表头.xlsx new file mode 100644 index 0000000..dc1fe72 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/东睦控制计划-中英文表头.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/东睦控制计划-英文表头.xlsx b/src/com/connor/renben/process/plm/tmom019/东睦控制计划-英文表头.xlsx new file mode 100644 index 0000000..1a35a16 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/东睦控制计划-英文表头.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-中英文表头.xlsx b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-中英文表头.xlsx new file mode 100644 index 0000000..dc1fe72 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-中英文表头.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-中英文表头_1.xlsx b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-中英文表头_1.xlsx new file mode 100644 index 0000000..1536382 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-中英文表头_1.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-英文表头.xlsx b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-英文表头.xlsx new file mode 100644 index 0000000..4708e34 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-英文表头.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-英文表头1.xlsx b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-英文表头1.xlsx new file mode 100644 index 0000000..1a35a16 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/博格华纳舍弗勒控制计划-英文表头1.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/爱信控制计划.xlsx b/src/com/connor/renben/process/plm/tmom019/爱信控制计划.xlsx new file mode 100644 index 0000000..6ba72ee Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/爱信控制计划.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/生产控制计划模板4.xlsx b/src/com/connor/renben/process/plm/tmom019/生产控制计划模板4.xlsx new file mode 100644 index 0000000..a466e7a Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/生产控制计划模板4.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom019/麦格纳控制计划.xlsx b/src/com/connor/renben/process/plm/tmom019/麦格纳控制计划.xlsx new file mode 100644 index 0000000..0dc82d6 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom019/麦格纳控制计划.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputCommand.java b/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputCommand.java new file mode 100644 index 0000000..adaf89d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputCommand.java @@ -0,0 +1,101 @@ +package com.connor.renben.process.plm.tmom020; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom020ControlPlanInputCommand extends AbstractAIFCommand { + private AbstractAIFUIApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItem item; + private TCComponentItem meprocess; + + public TMom020ControlPlanInputCommand(TCSession session, + AbstractAIFUIApplication app) { + // TODO Auto-generated constructor stub + this.app = app; + this.comp = app.getTargetComponent(); + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // ȡѡжİ汾 + if (comp instanceof TCComponentItem) { + MessageBox.post("ѡƼƻ汾", "", MessageBox.ERROR); + throw new Exception("δҵ"); + } else if (comp instanceof TCComponentItemRevision) { + AIFComponentContext[] context = ((TCComponentItemRevision) comp) + .getItem().whereReferenced(); + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("MEProcess")) { + meprocess = (TCComponentItem) context[i].getComponent(); + } + } + item = ((TCComponentItemRevision) comp).getItem(); +// form = ((TCComponentItemRevision) comp) +// .getRelatedComponent("IMAN_master_form_rev"); + } + //ȡƼƻеĹźͲұ +// ResultSet rs = null; +// InputStream input = null; +// final Map itemIdMap = new HashMap(); +// try { +// // ȡSQL +// input = new BufferedInputStream(getClass().getResourceAsStream( +// "/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// SqlUtilT.getTCConnection(); +// // ѯźID +// String selectSQL = String.format( +// pro.getProperty("CONTROLPLANOPERATIONSELECT"), +// meprocess.getUid()); +// rs = SqlUtilT.read(selectSQL); +// while (rs.next()) { +// itemIdMap.put(rs.getString("rb3_gybh"), +// rs.getString("RB3_MEOPID")); +// } +// } 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(); +// } + // TODO Auto-generated method stub + new Thread() { + @Override + public void run() { + TMom020ControlPlanInputDialog dislog = new TMom020ControlPlanInputDialog( + app, session,item,meprocess); + } + }.start(); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputDialog.java b/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputDialog.java new file mode 100644 index 0000000..c82dcef --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputDialog.java @@ -0,0 +1,206 @@ +package com.connor.renben.process.plm.tmom020; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.HashMap; +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.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelFilter; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.SaveControlPlan; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom020ControlPlanInputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentItem item; + private TCComponentItem meprocess; + private Map itemIdMap = new HashMap(); + + private JFileChooser jfc;//ļѡ + + private JPanel mainPanel; + private JLabel label; + private JTextField textField; + private JButton fileButton; + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + + public TMom020ControlPlanInputDialog(AbstractAIFUIApplication app, + TCSession session,TCComponentItem item,TCComponentItem meprocess) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.item = item; + this.meprocess = meprocess; + 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("drkzjh20_display.TITLE")); + this.label = new JLabel(rb.getString("xzkzjhwj20_display.TITLE")); + this.textField = new JTextField(20); + this.fileButton = new JButton("...."); + this.fileButton.addActionListener(this); + this.mainPanel = new JPanel(new PropertyLayout()); + this.mainPanel.add("1.1.left.top",this.label); + this.mainPanel.add("1.2.left.top",this.textField); + this.mainPanel.add("1.3.left.top",this.fileButton); + 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(okButton); + this.rootPanel.add(celButton); + + this.setLayout(new BorderLayout()); + this.add(this.mainPanel,BorderLayout.CENTER); + this.add(this.rootPanel,BorderLayout.SOUTH); + this.showDialog(); + } + + /** + * ļѡ + * @param e + */ + public void selectFileButtonEvent() { + this.jfc = new JFileChooser(); + this.jfc.setFileFilter(new ExcelFilter()); + this.jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + int state = this.jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + System.out.println(f.getAbsolutePath()); + this.textField.setText(f.getAbsolutePath()); + } + } + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + Object source = actionevent.getSource(); + if(source.equals(this.fileButton)) + { + selectFileButtonEvent(); + } + else if(source.equals(this.okButton)) + { + ResultSet rs = null; + InputStream input = null; + try { + List> resultList = ExcelUtil07.readControlPlanExcel(new File(this.textField.getText())); + if(resultList != null && resultList.size() > 0) + { + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + //ɾƼƻе + SqlUtilT.getTCConnection(); + String deleteSql = String.format("delete from RB3_CONTROLPLAN where processpuid = \'%s\' and TYPE = \'%s\'", meprocess.getUid(),item.getType().toUpperCase()); + SqlUtilT.delete(deleteSql); + SqlUtilT.freeAll(); + //+++ + //SaveControlPlan controlPlan = new SaveControlPlan(session, meprocess); + SaveControlPlan controlPlan = new SaveControlPlan(session, meprocess,app.getTargetComponent()); + controlPlan.insertData(); + + SqlUtilT.getTCConnection(); + // ѯźID + String selectSQL = String.format( + pro.getProperty("CONTROLPLANOPERATIONSELECT"), + meprocess.getUid()); + rs = SqlUtilT.read(selectSQL); + while (rs.next()) { + itemIdMap.put(rs.getString("RB3_MEOPID"),rs.getString("rb3_gybh")); + } + + //ɾƼƻе + SqlUtilT.delete(deleteSql); + SqlUtilT.freeAll(); + + SqlUtilT.getTCConnection(); + // + String insertSQL = pro.getProperty("INSERTSQL"); + for (int i = 0; i < resultList.size(); i++) { + List rowList = resultList.get(i); + String meopId = ""; + if(itemIdMap.keySet().contains(String.valueOf(rowList.get(0)))) + { + meopId = itemIdMap.get(String.valueOf(rowList.get(0))); + } + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + meprocess.getUid(), rowList.get(0),meopId, + 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), (i + 1)+"","","0", + "","",item.getType().toUpperCase(),"0","0",rowList.get(6),"0" + }, insertSQL); + } + } + MessageBox.post("Ƽƻɹ", "ɹ", MessageBox.INFORMATION); + this.disposeDialog(); + this.dispose(); + } 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(); + } + } + else if(source.equals(this.celButton)) + { + this.disposeDialog(); + this.dispose(); + } + } + +} diff --git a/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputHandler.java b/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputHandler.java new file mode 100644 index 0000000..4ba2337 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom020/TMom020ControlPlanInputHandler.java @@ -0,0 +1,31 @@ +package com.connor.renben.process.plm.tmom020; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom019.TMom019ControlPlanOutputCommand; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom020ControlPlanInputHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + TMom020ControlPlanInputCommand command = new TMom020ControlPlanInputCommand(session, app); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("Ʊʧ", "ʧ", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom021/CTMap.java b/src/com/connor/renben/process/plm/tmom021/CTMap.java new file mode 100644 index 0000000..10e4aff --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/CTMap.java @@ -0,0 +1,332 @@ +package com.connor.renben.process.plm.tmom021; + +import java.awt.Dimension; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + private List processRowList; + private Map> labelRows;//ע + 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; + } + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + if (this.getColumnName(arg1).equals("")) { + return true; + } else if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + + @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); + } + } + } + //עм1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null + && listRow == row) { + labelRowList.remove(i); + } else if (labelRowList.get(i) != null + && listRow > row) { + labelRowList.set(i, ((Integer)(listRow-1)).toString()); + } + } + } + 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 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; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + 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); + } + } + } + //ע+1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null && i > index + && listRow >= row) { + labelRowList.set(i, ((Integer)(listRow + 1)).toString()); + } + } + } + + } + + 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/tmom021/CTUI.java b/src/com/connor/renben/process/plm/tmom021/CTUI.java new file mode 100644 index 0000000..cf6be99 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/CTUI.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom021; + +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/tmom021/CTable.java b/src/com/connor/renben/process/plm/tmom021/CTable.java new file mode 100644 index 0000000..010458e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/CTable.java @@ -0,0 +1,244 @@ +package com.connor.renben.process.plm.tmom021; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.connor.renben.process.plm.util.TMomMethodUtil; + +public class CTable extends JTable { + Map map; + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + TextAreaCellEditor cellEditor = new TextAreaCellEditor(); + CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + + 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("")) { + return checkBoxCellEditor; + } + else { + return cellEditor; + } + // Point point = new Point(row,column); + // if(map.containsKey(point)){ + // return map.get(point); + // }else{ + // return super.getCellEditor(row, column); + // } + } + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + //TODO Auto-generated method stub + if (this.getColumnName(column).equals("")) { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + 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()-2); + } + } + +// @Override +// public int[] getSelectedRows() { +// // TODO Auto-generated method stub +// List selectRowList = new ArrayList(); +// for (int i = 0; i < this.getRowCount(); i++) { +// if(this.getValueAt(i, this.getColumnCount() - 2).equals("1")) +// { +// selectRowList.add(i); +// } +// } +// int[] selectRows = new int[selectRowList.size()]; +// for (int i = 0; i < selectRowList.size(); i++) { +// selectRows[i] = selectRowList.get(i); +// } +// return selectRows; +// } + +// @Override +// public boolean isCellSelected(int i, int j) { +// if(this.getValueAt(i, this.getColumnCount() - 2).equals("1")) +// { +// return true; +// } +// else +// { +// return false; +// } +// } + +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/tmom021/CellSpan.java b/src/com/connor/renben/process/plm/tmom021/CellSpan.java new file mode 100644 index 0000000..06c57ee --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.renben.process.plm.tmom021; + +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/tmom021/CheckBoxCellEditor.java b/src/com/connor/renben/process/plm/tmom021/CheckBoxCellEditor.java new file mode 100644 index 0000000..40202e6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/CheckBoxCellEditor.java @@ -0,0 +1,120 @@ +package com.connor.renben.process.plm.tmom021; + +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.JComboBox; +import javax.swing.JLabel; +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.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 CTMap tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(""); + // 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("")) { + 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/tmom021/TMom021DeleteAllDataHandler.java b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteAllDataHandler.java new file mode 100644 index 0000000..ac5c18d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteAllDataHandler.java @@ -0,0 +1,84 @@ +package com.connor.renben.process.plm.tmom021; + +import javax.swing.JOptionPane; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom021DeleteAllDataHandler extends AbstractHandler { + private TCComponentItem item; + private TCComponentItemRevision itemRevision; + private TCComponent form; + private TCComponentItem meprocess; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + final AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + final TCSession session = (TCSession) app.getSession(); + new Thread() { + @Override + public void run() { + int result=JOptionPane.showConfirmDialog(null, "ǷɾƼƻݣ", "", JOptionPane.YES_NO_OPTION); + if(result==JOptionPane.YES_OPTION){ + InterfaceAIFComponent comp = app.getTargetComponent(); + try { + // ȡѡжİ汾 + if (comp instanceof TCComponentItem) { + MessageBox.post("ѡƼƻ汾", "", MessageBox.ERROR); + throw new Exception("δҵ"); + } else if (comp instanceof TCComponentItemRevision && comp.getType().indexOf("KZJH") >= 0) { + AIFComponentContext[] context = ((TCComponentItemRevision) comp) + .getItem().whereReferenced(); + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("MEProcess")) { + meprocess = (TCComponentItem) context[i].getComponent(); + } + } + itemRevision = ((TCComponentItemRevision) comp); + item = itemRevision.getItem(); + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + } + if(meprocess != null) + { + if(session.getUser().getUserId().equals(meprocess.getReferenceProperty("owning_user").getStringProperty("user_id")) || session.getUser().getUserId().equals("admin")) + { + SqlUtilT.getTCConnection(); + String deleteSql =String.format("delete from RB3_CONTROLPLAN where PROCESSPUID = \'%s\' and type = \'%s\'", meprocess.getUid(),item.getType().toUpperCase()); + SqlUtilT.delete(deleteSql); +// String deletePfmeaSql =String.format("delete from RB3_PFMEA where PROCESSPUID = \'%s\'", meprocess.getUid()); +// SqlUtilT.delete(deletePfmeaSql); +// String sql =String.format("delete from RB3_PERMISSIONS where PROCESSPUID = \'%s\'", meprocess.getUid()); +// SqlUtilT.delete(sql); + } + else + { + MessageBox.post("ɾƼƻȨޣ", "", MessageBox.ERROR); + return; + } + MessageBox.post("ɾɹ", "ɹ", MessageBox.INFORMATION); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + } + }.start(); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerCommand.java b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerCommand.java new file mode 100644 index 0000000..8b3409e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerCommand.java @@ -0,0 +1,245 @@ +package com.connor.renben.process.plm.tmom021; + +import java.io.BufferedInputStream; +import java.io.File; +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom015.TMom015ChangeControlPlanOwnerDialog; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom021DeleteCompleteMarkerCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent targetComponent; + TCComponentItem processItem = null; + TCComponentItem product = null; + private List> dataList = new ArrayList>(); + private List> meopTable_dataList = new ArrayList>(); + private String[] titleNames = new String[] { "PLMEID", "ID", "", + "", "","û","","ûID" }; + + + public TMom021DeleteCompleteMarkerCommand(AbstractAIFApplication app, + TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + /** + * ȡ + */ + private void getValues() + { + //ȡExcelϢ + File file = TMomMethodUtil.getFile(session, "","MSExcelX"); + try { + meopTable_dataList = ExcelUtil07.readExcel(file); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + /** + * ȡмĹ + * @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 = new String[props.length]; + for (int i = 0; i < props.length; i++) { + if(props[i].indexOf("/") >= 0) + { + values[i] = props[i].split("/")[0]; + } + else + { + values[i] = props[i]; + } + } + } + } + else + { + MessageBox.post("δѡ", "", MessageBox.ERROR); + } + return Arrays.asList(values); + } + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + this.targetComponent = app.getTargetComponent(); + if (this.targetComponent.getType().indexOf("KZJH") < 0 && this.targetComponent instanceof TCComponentItem) { + MessageBox.post("ѡƼƻ汾", "", MessageBox.ERROR); + return; + } + //ͨƼƻȡ + TCComponentItemRevision kzjhRevision = (TCComponentItemRevision)this.targetComponent; + //ȡƼƻ + TCComponentItem kzjhItem = null; + AIFComponentContext[] items = kzjhRevision.whereReferenced(); + for (int i = 0; i < items.length; i++) { + if(items[i].getComponent().getType().indexOf("KZJH") >= 0 && items[i].getComponent() instanceof TCComponentItem) + { + kzjhItem = (TCComponentItem)items[i].getComponent(); + } + } + //ͨƼƻȡ + AIFComponentContext[] processItems = kzjhItem.whereReferenced(); + for (int i = 0; i < processItems.length; i++) { + if(processItems[i].getComponent().getType().indexOf("MEProcess") >= 0 && processItems[i].getComponent() instanceof TCComponentItem) + { + processItem = (TCComponentItem)processItems[i].getComponent(); + } + } + //ݹջȡƷ + AIFComponentContext[] productItems = processItem.whereReferenced(); + for (int i = 0; i < productItems.length; i++) { + if(productItems[i].getComponent().getType().indexOf("Product") >= 0 && productItems[i].getComponent() instanceof TCComponentItem) + { + product = (TCComponentItem) productItems[i].getComponent(); + } + } + getValues(); + List xjList = new ArrayList<>(); + for(List meopList :meopTable_dataList){ + String meopType = meopList.get(4).toString(); + if(meopType!="" || meopType!=null){ + if(meopType.equals("2")){ + xjList.add(meopList.get(2)); + } + } + } + if(session.getUser().getUserId().equals(processItem.getReferenceProperty("owning_user").getStringProperty("user_id")) || session.getUser().getUserId().equals("admin")) + { + List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); + //ȡɵǰûĹ + ResultSet rs = null; + InputStream input = null; + try { + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = ""; + if(session.getUser().getStringProperty("user_id").equals(processItem.getReferenceProperty("owning_user").getStringProperty("user_id")) || session.getUser().getStringProperty("user_id").equals("admin")) + { + sql = String.format("select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " from (select PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,nvl(rb3_user,' ') as rb3_user,nvl(RB3_INSPECTIONUSER,' ') as RB3_INSPECTIONUSER " + + " from RB3_PERMISSIONS)" + + " unpivot (rb3_user_id for type in (rb3_user, RB3_INSPECTIONUSER) ) " + + " where PROCESSPUID = \'%s\' " + + " group by PLMEID,PROCESSPUID,RB3_MEOPID,RB3_GYBH,RB3_GCMC,rb3_user_id,type " + + " order by RB3_GYBH", + processItem.getUid()); + } + System.out.println(sql); + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List list = new ArrayList(); + list.add(rs.getString("PLMEID")); + list.add(rs.getString("RB3_MEOPID")); + list.add(rs.getString("RB3_GYBH")); + list.add(rs.getString("RB3_GCMC")); + if(rs.getString("TYPE").toString().equals("RB3_USER")) + { + list.add("Լ"); + } + else if(rs.getString("TYPE").toString().equals("RB3_INSPECTIONUSER")) + { + list.add("Ѳ"); + Integer meopId = 0; + if(Integer.parseInt(list.get(2)) % 10 ==0) + { + meopId = Integer.parseInt(list.get(2))+5; + } + else + { + meopId = Integer.parseInt(list.get(2))+1; + } + list.set(2, meopId.toString()); + } + if(!rs.getString("RB3_USER_ID").equals(" ")) + { + list.add(type.find(rs.getString("RB3_USER_ID")).getStringProperty("user_name")); + } + else + { + list.add(""); + } + list.add("0"); + list.add(rs.getString("RB3_USER_ID")); + if((!meopNameList.contains(rs.getString("RB3_GCMC")) && rs.getString("TYPE").toString() + .equals("RB3_INSPECTIONUSER"))&&!xjList.contains(rs.getString("RB3_GCMC")) && rs.getString("RB3_GCMC").indexOf("") < 0) + { + continue; + } + this.dataList.add(list); + } + System.out.println(dataList.toString()); + new Thread() { + @Override + public void run() { + TMom021DeleteCompleteMarkerDialog dialog = new TMom021DeleteCompleteMarkerDialog( + session, targetComponent,processItem,product, dataList, + titleNames); + } + }.start(); + } 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(); + } + } + else + { + MessageBox.post("ɾɱȨޣ", "", MessageBox.ERROR); + return; + } + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerDialog.java b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerDialog.java new file mode 100644 index 0000000..b52fada --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerDialog.java @@ -0,0 +1,180 @@ +package com.connor.renben.process.plm.tmom021; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom021DeleteCompleteMarkerDialog extends AbstractAIFDialog implements ActionListener{ + + private TCSession session; + private InterfaceAIFComponent targetComponent; + private TCComponentItem processItem; + private TCComponentItem product; + private List> dataList; + private String[] titleNames; + private List changRow = new ArrayList(); + private Map buttonMap = new HashMap(); + // ؼ + private JPanel tablePanel; + private JPanel rootPanel; + private CTMap map; + private CTable table; + private JButton okButton; + private JButton celButton; + + public TMom021DeleteCompleteMarkerDialog(TCSession session, + InterfaceAIFComponent targetComponent,TCComponentItem processItem, + TCComponentItem product, List> dataList, + String[] titleNames) { + // TODO Auto-generated constructor stub + this.session = session; + this.targetComponent = targetComponent; + this.processItem = processItem; + this.product = product; + this.dataList = dataList; + this.titleNames = titleNames; + init(); + } + + // 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); + map.setEditable(false); + setJTable(); + partsTable = new CTable(map); + // partsTable.setRowHeight(1, 50); + partsTable.HiddenCell(0); + partsTable.HiddenCell(titleNames.length-1); + 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 + */ + private void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + for (int j = 0; j < rowList.size(); j++) { + map.setValueAt(rowList.get(j), i, j); + } + } + } + + private void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setTitle(rb.getString("qcwcbj21_display.TITLE")); + this.tablePanel = new JPanel(new BorderLayout()); + table = getjTable(null, null, titleNames, null); + table.setRowHeight(30); + table.getTableHeader().setVisible(true); + this.tablePanel.add(new JScrollPane(this.table), BorderLayout.CENTER); + // for (int i = 0; i < meopName.size(); i++) { + // JComponent valueComp = null; + // JComponent buttonComp = null; + // JLabel disNameLabel = new JLabel(); + // disNameLabel.setText(meopName.get(i)); + // JTextField valueText = new JTextField(20); + // valueComp = valueText; + // JButton button = new JButton("ѡԱ..."); + // button.addActionListener(this); + // buttonComp = button; + // itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", + // disNameLabel); + // itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", + // valueComp); + // itemPorpPanel.add((i + 1) + ".3.left.top.preferred.preferred", + // button); + // componentMap.put(meopName.get(i), valueComp); + // buttonMap.put(buttonComp,meopName.get(i)); + // } + + this.okButton = new JButton(rb.getString("qd_display.TITLE")); + 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.rootPanel.add(this.selectUser); + + this.setLayout(new BorderLayout()); + this.add(this.tablePanel, BorderLayout.CENTER); + this.add(this.rootPanel, BorderLayout.SOUTH); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + Object source = arg0.getSource(); + if (source.equals(this.okButton)) { + try { + List> dataValueList = new ArrayList>(); + for (int i = 0; i < table.getRowCount(); i++) { + if (!this.table.getValueAt(i, this.table.getColumnCount() - 2).equals("1")) { + continue; + } + List rowValue = new ArrayList(); + for (int j = 0; j < table.getColumnCount(); j++) { + rowValue.add(table.getValueAt(i, j) == null ? "" + : table.getValueAt(i, j).toString()); + } + dataValueList.add(rowValue); + } + + TMom021DeleteCompleteMarkerOperation operation = new TMom021DeleteCompleteMarkerOperation( + session,this.targetComponent,processItem,product, dataValueList); + session.queueOperation(operation); + this.disposeDialog(); + this.dispose(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.disposeDialog(); + this.dispose(); + } + } + +} diff --git a/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerHandler.java b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerHandler.java new file mode 100644 index 0000000..0ef8eb4 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerHandler.java @@ -0,0 +1,30 @@ +package com.connor.renben.process.plm.tmom021; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class TMom021DeleteCompleteMarkerHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom021DeleteCompleteMarkerCommand command = new TMom021DeleteCompleteMarkerCommand( + app, session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ɱʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerOperation.java b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerOperation.java new file mode 100644 index 0000000..191c8f9 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/TMom021DeleteCompleteMarkerOperation.java @@ -0,0 +1,184 @@ +package com.connor.renben.process.plm.tmom021; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCAttachmentType; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom021DeleteCompleteMarkerOperation extends AbstractAIFOperation { + + private TCSession session; + private InterfaceAIFComponent targetComponent; + private TCComponentItem processItem; + private TCComponentItem product; + private List> dataValueList = new ArrayList>(); + public TMom021DeleteCompleteMarkerOperation(TCSession session, + InterfaceAIFComponent targetComponent,TCComponentItem processItem, + TCComponentItem product,List> dataValueList) { + // TODO Auto-generated constructor stub + this.session = session; + this.targetComponent = targetComponent; + this.processItem = processItem; + this.product = product; + this.dataValueList = dataValueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + SqlUtilT.getTCConnection(); + try { + TCComponentItem item = ((TCComponentItemRevision)targetComponent).getItem(); + for (int i = 0; i < dataValueList.size(); i++) { + if(dataValueList.get(i).get(4).equals("Լ")) + { + String updateSql =String.format("update RB3_CONTROLPLAN set rb3_sfwc = \'0\' where plmeid in (" + + "select t1.plmeid from rb3_controlplan t1 " + + "left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid " + + "where t1.PROCESSPUID = \'%s\' and t1.type =\'%s\' " + + " and t2.rb3_user = \'%s\' and t1.rb3_meopid = \'%s\' and t1.rb3_gcmc not like \'%%%%\')", processItem.getUid(),item.getType().toUpperCase(), + dataValueList.get(i).get(dataValueList.get(i).size() - 1),dataValueList.get(i).get(1)); + SqlUtilT.update(updateSql); + } + else if(dataValueList.get(i).get(4).equals("Ѳ")) + { + String updateSql =String.format("update RB3_CONTROLPLAN set rb3_sfwc = \'0\' where plmeid in (" + + "select t1.plmeid from rb3_controlplan t1 " + + "left join rb3_permissions t2 on t1.rb3_meopid = t2.rb3_meopid and t1.processpuid = t2.processpuid " + + "where t1.PROCESSPUID = \'%s\' and t1.type =\'%s\' " + + " and t2.rb3_inspectionuser = \'%s\' and t1.rb3_meopid = \'%s\' and t1.rb3_gcmc like \'%%%%\')", processItem.getUid(),item.getType().toUpperCase(), + dataValueList.get(i).get(dataValueList.get(i).size() - 1),dataValueList.get(i).get(1)); + SqlUtilT.update(updateSql); + } + } + List userIdList = new ArrayList<>(); + for (int i = 0; i < dataValueList.size(); i++) { + if(!userIdList.contains(dataValueList.get(i).get(dataValueList.get(i).size() - 1))) + { + userIdList.add(dataValueList.get(i).get(dataValueList.get(i).size() - 1)); + } + } + TCComponentProcessType tccomponentprocesstype = (TCComponentProcessType) session + .getTypeComponent("Job"); + TCComponentTaskTemplateType tccomponenttasktemplatetype = (TCComponentTaskTemplateType) session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate atccomponenttasktemplate = tccomponenttasktemplatetype + .find("WF_61շֹ", TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (atccomponenttasktemplate == null) { + MessageBox.post("δҵģ壡", "", MessageBox.ERROR); + return; + } + for (int i = 0; i < userIdList.size(); i++) { + List meopList = new ArrayList<>(); + // ȡԱ + TCComponentUserType type = (TCComponentUserType) session + .getTypeComponent("User"); + TCComponentUser[] user = null; + user = new TCComponentUser[] { type.find(userIdList.get(i)) }; + //Ƽƻ汾Ĺ + TCComponent form = ((TCComponentItemRevision)targetComponent).getRelatedComponent("IMAN_master_form_rev"); + TCProperty[] tcProperties = form.getTCProperties(new String[] { + "rb3_complete_user", "rb3_complete_date" }); + String[] users = tcProperties[0].getStringValueArray(); + String[] date = tcProperties[1].getStringValueArray(); + for (int j = users.length-1; j >= 0; j--) { + if(userIdList.get(i).equals(users[j])) + { + users = delete(j, users); + date = delete(j, date); + } + } + form.lock(); + tcProperties[0].setStringValueArray(users); + tcProperties[1].setStringValueArray(date); + form.save(); + form.unlock(); + form.refresh(); + for (int j = 0; j < dataValueList.size(); j++) { + if(!meopList.contains(dataValueList.get(j).get(1)) && dataValueList.get(j).get(dataValueList.get(j).size() - 1).equals(userIdList.get(i))) + { + meopList.add(dataValueList.get(j).get(1)); + } + } + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem[] meopItems = null; + if(meopList.size() >= 0) + { + //String[] meopId = dataList.get(i).get(0).toString().split(","); + meopItems = new TCComponentItem[meopList.size()]; + for (int j = 0; j < meopList.size(); j++) { + meopItems[j] = itemType.find(meopList.get(j)); + } + } + TCComponent[] components = null; + int[] componentType = null; + if(meopItems != null) + { + components = new TCComponent[meopItems.length+1]; + componentType = new int[meopItems.length+1]; + components[0] = ((TCComponentItemRevision)this.targetComponent); + componentType[0] = TCAttachmentType.TARGET; + for (int j = 1; j <= meopItems.length; j++) { + components[j] = meopItems[j-1]; + componentType[j] = TCAttachmentType.REFERENCE; + } + } + else + { + continue; + } + if (user != null && user.length > 0) { + for (int j = 0; j < user.length; j++) { + // һ ơģ塢Ŀ󡢸 + TCComponentProcess newProcess = (TCComponentProcess) tccomponentprocesstype + .create(product + .getStringProperty("item_id") + + "-Ƽƻ", this.targetComponent + .getProperty("object_name"), + atccomponenttasktemplate, + components, + componentType); + TMomMethodUtil.setProcess(session, newProcess, user[j]); + } + } + } + MessageBox.post("ɣ", "", MessageBox.ERROR); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + public String[] delete(int index,String array[]){ + //ɾǰһλ + for(int i=index;i processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + private CTMap tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (CTMap) table.getModel(); + this.tableHeader = table.getTableHeader(); + this.setName(""); + // 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("")) { + 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 +// if(value != null) +// { +// String valueStr = (boolean)value ? "true" : "false"; +// //System.out.println(valueStr); +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected((boolean)value); +// } +// else +// { +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected(false); +// } +// 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")); +// 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/tmom021/TableCellTextAreaRenderer.java b/src/com/connor/renben/process/plm/tmom021/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..1fbcd3b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/TableCellTextAreaRenderer.java @@ -0,0 +1,218 @@ +package com.connor.renben.process.plm.tmom021; + +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(Color.YELLOW); + 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ַֿ˳ʹDocumentinsertString + 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/tmom021/TextAreaCellEditor.java b/src/com/connor/renben/process/plm/tmom021/TextAreaCellEditor.java new file mode 100644 index 0000000..785d2b4 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom021/TextAreaCellEditor.java @@ -0,0 +1,193 @@ +package com.connor.renben.process.plm.tmom021; + +import java.awt.Component; +import java.util.EventObject; + +import javax.swing.JScrollPane; +import javax.swing.JTable; +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.classClass󣩣 + // ŵһCellEditorListenerʵ + listener = (CellEditorListener) listeners[i + 1]; + // changeEventȥ֪ͨ༭Ѿ༭ + // editingStoppedУJTablegetCellEditorValue()ȡصԪֵ + // Ұֵݸ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ַֿ˳ʹDocumentinsertString + 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/tmom022/TMom022SetThesaurusCommand.java b/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusCommand.java new file mode 100644 index 0000000..a71ccb1 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusCommand.java @@ -0,0 +1,152 @@ +package com.connor.renben.process.plm.tmom022; + +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 javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom012.CTMap; +import com.connor.renben.process.plm.tmom012.CTable; +import com.connor.renben.process.plm.tmom012.TMom012ControlPlanLibraryDialog; +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 TMom022SetThesaurusCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + private String commandId; + private String titleName = "ʿ"; + 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", "","ֵ","ڵID" }; + + public TMom022SetThesaurusCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + // TODO Auto-generated constructor stub + 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; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + String sql = String.format(pro + .getProperty("TM2THESAURUSTREESELECT")); + 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(); + } + } + } + + } + + // 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 { + // ȡ汾 + try { + InputStream input = null; + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + pro.load(input); + // ȡνṹڵ + getData(); + new Thread() { + @Override + public void run() { + TMom012ControlPlanLibraryDialog dislog = new TMom012ControlPlanLibraryDialog( + app, session, commandId, form, beans, header, + isOwning, titleName, titleLabel); + } + }.start(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusHandler.java b/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusHandler.java new file mode 100644 index 0000000..675720b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusHandler.java @@ -0,0 +1,63 @@ +package com.connor.renben.process.plm.tmom022; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom021.TMom021DeleteCompleteMarkerCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +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 TMom022SetThesaurusHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String commandId = arg0.getCommand().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); +// try { +// if(!session.getUser().getUserId().equals("admin")) +// { +// MessageBox.post("޹ʿȨޣ", "", MessageBox.ERROR); +// return null; +// } +// } catch (TCException e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + TMom022SetThesaurusCommand command = new TMom022SetThesaurusCommand( + app, session,commandId); + try { + TCPreferenceService service = session.getPreferenceService(); + String[] options = service.getStringArray(TCPreferenceService.TC_preference_site, "Cust_Thesaurus_Privilege"); + boolean hasPrivilege = false; + for(String option : options){ + if(option.equals(session.getUserName())){ + command.executeModal(); + hasPrivilege = true; + } + } + if(!hasPrivilege){ + MessageBox.post(rb.getString("wglqx12_display.TITLE"), "", MessageBox.ERROR); + } + //command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("glcksb22_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + + +} diff --git a/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusOperation.java b/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusOperation.java new file mode 100644 index 0000000..cdfe3eb --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom022/TMom022SetThesaurusOperation.java @@ -0,0 +1,96 @@ +package com.connor.renben.process.plm.tmom022; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +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.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom022SetThesaurusOperation extends AbstractAIFOperation { + + private List> dataValueList; + private TCSession session; + private List deleteRows; + + public TMom022SetThesaurusOperation(TCSession session, + List> dataValeList, List deleteRows) { + // TODO Auto-generated constructor stub + this.session = session; + this.dataValueList = dataValeList; + this.deleteRows = deleteRows; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + 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("TM2THESAURUSNODEDELETE"), + deleteRows.get(i)); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + // ѯźID + // ݿд + for (int i = 0; i < dataValueList.size(); i++) { + // ȡݿ + SqlUtilT.getTCConnection(); + List rowList = dataValueList.get(i); + if (rowList.get(0) != null && !rowList.get(0).equals("")) { + // ȡݿ + String updateSQL = String.format( + pro.getProperty("TM2THESAURUSNODEDUPDATE"), + rowList.get(0)); + SqlUtilT.update( + new String[] { + rowList.get(1),rowList.get(2),"" ,""}, + updateSQL); + } else { + String insertSQL = pro.getProperty("TM2THESAURUSNODEDINSERT"); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + rowList.get(1),rowList.get(2), rowList.get(3), "" + , ""}, insertSQL); + } + SqlUtilT.freeAll(); + } + //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/renben/process/plm/tmom023/TMom023GetGYTDialog.java b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTDialog.java new file mode 100644 index 0000000..61434d0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTDialog.java @@ -0,0 +1,155 @@ +package com.connor.renben.process.plm.tmom023; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.bean.CXListBean; +import com.connor.renben.process.plm.tmom008.TMom008OPDivisionOperation; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +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 TMom023GetGYTDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private Map map; + private JComboBox comboBox; + private TCComponentMEOP meop; + + private JButton okButton; + private JButton celButton; + private JPanel panel1; + private JPanel panel2; + private JRadioButton radioBtn1; + private JRadioButton radioBtn2; + private JPanel rootPanel; + + public TMom023GetGYTDialog() { + super(false); + } + + public TMom023GetGYTDialog(AbstractAIFApplication app,TCSession session,Map map, TCComponentMEOP meop) { + super(false); + this.app = app; + this.session = session; + this.map = map; + this.meop = meop; + init(); + + } + + public void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setPreferredSize(new Dimension(280, 120)); + this.setTitle(rb.getString("xzgytz23_display.TITLE")); + comboBox = new JComboBox(); + okButton = new JButton(rb.getString("qd_display.TITLE")); + celButton = new JButton(rb.getString("qx_display.TITLE")); + ButtonGroup bg = new ButtonGroup(); + for(String gytz_name:map.keySet()){ + comboBox.addItem(gytz_name); + } + bg.add(radioBtn1); + bg.add(radioBtn2); + + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + try { + okEvent(e); + } catch (IOException e1) { + MessageBox.post("δ֪", "ʧ", MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + celEvent(e); + } + }); + panel1 = new JPanel(new PropertyLayout()); + panel1.add("1.1.right.top.preferred.preferred", new JLabel(" ")); + panel1.add("2.1.right.top.preferred.preferred", new JLabel(rb.getString("gytz23_display.TITLE"))); + panel1.add("2.2.right.top.preferred.preferred", comboBox); + panel1.add("3.1.right.top.preferred.preferred", new JLabel(" ")); + panel2 = new JPanel(new FlowLayout()); + panel2.add(okButton); + panel2.add(new JLabel(" ")); + panel2.add(celButton); + + rootPanel = new JPanel(new BorderLayout()); + rootPanel.add(panel1, BorderLayout.CENTER); + rootPanel.add(panel2, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + /** + * ȷťҵ¼ + * + * @param e + * @throws IOException + */ + public void okEvent(ActionEvent e) throws IOException { + System.out.println(); + TMom023GetGYTOperation operation = new TMom023GetGYTOperation( + app,session,map.get(comboBox.getSelectedItem()),meop); + session.queueOperation(operation); + + this.dispose(); + } + /** + * ȡťҵ¼ + * + * @param e + */ + public void celEvent(ActionEvent e) { + + this.dispose(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTHandler.java b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTHandler.java new file mode 100644 index 0000000..153ed2c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTHandler.java @@ -0,0 +1,31 @@ +package com.connor.renben.process.plm.tmom023; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class TMom023GetGYTHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TMom023GetGYTZCommand command = new TMom023GetGYTZCommand(app, + session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ѡͼֽʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTOperation.java b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTOperation.java new file mode 100644 index 0000000..390a61c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTOperation.java @@ -0,0 +1,56 @@ +package com.connor.renben.process.plm.tmom023; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TCUtils; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom023GetGYTOperation extends AbstractAIFOperation { + private AbstractAIFApplication app; + private TCSession session; + private String item_id; + private TCComponentMEOP meop; + public TMom023GetGYTOperation(AbstractAIFApplication app, TCSession session,String item_id, TCComponentMEOP meop) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.item_id = item_id; + this.meop = meop; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + try { + TCUtils.openLogByPass(session, "ѡͼֽ"); + TMomMethodUtil.setByPass(session, true); + meop.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev").setProperty("rb3_gytz", item_id); + ((TCComponent)app.getTargetComponent()).refresh(); + + //updateProcess_Route(target.getProperty("item_id"),item_id); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + }finally { + TCUtils.closeLogByPass(session, "ѡͼֽ"); + TMomMethodUtil.setByPass(session, false); + } + } + + + +} diff --git a/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTZCommand.java b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTZCommand.java new file mode 100644 index 0000000..844dc73 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom023/TMom023GetGYTZCommand.java @@ -0,0 +1,138 @@ +package com.connor.renben.process.plm.tmom023; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.SavePermissions; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMLineType; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +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.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.schemas.structuremanagement._2012_02.incrementalchange.BomLineInfo; + +public class TMom023GetGYTZCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent targetComponent; + private Map map; + private TCComponentMEOP meop; + public TMom023GetGYTZCommand(AbstractAIFApplication app, + TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + @Override + public void executeModal() throws Exception { + this.targetComponent = app.getTargetComponent(); + if(this.targetComponent.getType().equals("BOMLine")){ + TCComponentBOMLine bomLine = (TCComponentBOMLine) this.targetComponent; + AIFComponentContext[] meops = bomLine.getChildren("bl_child_item"); + try { + meop = (TCComponentMEOP) meops[0].getComponent(); + } catch (Exception e) { + // TODO Auto-generated catch block + MessageBox.post("ѡ", "", MessageBox.ERROR); + e.printStackTrace(); + } + //ȡƷ +// InterfaceAIFComponent product = + TCComponent[] includeGYTZRev = meop.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponentItem product = null; + for(TCComponent getGYTZRev:includeGYTZRev){ + if(getGYTZRev.getType().equals("MEProcessRevision")){ + TCComponent gytzItem=((TCComponentItemRevision)getGYTZRev).getItem(); + AIFComponentContext[] includeProduct = gytzItem.whereReferenced(); + for(AIFComponentContext getProduct:includeProduct){ + if(getProduct.getComponent().getType().equals("RB3_Product")){ + product = (TCComponentItem) getProduct.getComponent(); + break; + } + } + break; + } + } + TCComponentItemRevision productRev = TMomMethodUtil.getLastItemRevision(product); + if(productRev==null){ + MessageBox.post("δҵѷIJƷ汾", "", MessageBox.ERROR); + return; + } + + TCComponent[] gytzs = productRev.getRelatedComponents("RB3_gytz"); + map = new HashMap(); + + //ӲƷͼ + map.put(productRev.getProperty("object_name"), productRev.getProperty("item_id")); + for(TCComponent gytz:gytzs){ + TCComponentItemRevision gytzRev = TMomMethodUtil.getLastItemRevision((TCComponentItem)gytz); + if(gytzRev!=null){ + String gytz_name = gytzRev.getProperty("item_id"); + if(hasGYTZ(gytz_name)){ + map.put(gytz.getProperty("object_name"), gytz_name); + } + else{ + MessageBox.post(gytz.getProperty("object_name")+"δҵѷĹͼֽ(.dwg)ļ", "", MessageBox.WARNING); + } + } + } + new Thread() { + @Override + public void run() { + new TMom023GetGYTDialog(app,session,map,meop); + } + }.start(); + super.executeModal(); + } + } + private boolean hasGYTZ(String gytz_item_id) { + try { + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + TCComponentItem item = itemType.find(gytz_item_id.split("/")[0]); + TCComponentItemRevision itemRev = TMomMethodUtil.getLastItemRevision(item); + AIFComponentContext[] aifccs = itemRev.getChildren(); + for(AIFComponentContext aifcc:aifccs ){ + if("RB3_AutoCAD".equals(aifcc.getComponent().getType())){ + String status = aifcc.getComponent().getProperty("release_status_list"); + if(status.length()!=0) + return true; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return false; + + + } +} diff --git a/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemCommand.java b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemCommand.java new file mode 100644 index 0000000..b1d0dcc --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemCommand.java @@ -0,0 +1,103 @@ +package com.connor.renben.process.plm.tmom024; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.SavePermissions; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMLineType; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +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.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.schemas.structuremanagement._2012_02.incrementalchange.BomLineInfo; + +public class TMom024SaveAsByItemCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private String type; + private String processPUID; + private InterfaceAIFComponent targetComponent; + private Map map; + private TCComponentMEOP meop; + public TMom024SaveAsByItemCommand(AbstractAIFApplication app, + TCSession session, String type) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.type = type; + } + @Override + public void executeModal() throws Exception { + this.targetComponent = app.getTargetComponent(); + String targetType = targetComponent.getType(); + + if(type.equals("CONTROLPLAN")){ + if(targetType.equals("RB3_SSCKZJHRevision")||targetType.equals("RB3_SCKZJHRevision")){//RB3_PFMEARevision + processPUID = getProcessPUID(targetComponent); + } + else{ + MessageBox.post("ѡƼƻƼƻ汾", "", MessageBox.ERROR); + return; + } + } + else{ + if(targetType.equals("RB3_PFMEARevision")){ + processPUID = getProcessPUID(targetComponent); + } + else{ + MessageBox.post("ѡPFMEA汾", "", MessageBox.ERROR); + return; + } + + } + new Thread() { + @Override + public void run() { + new TMom024SaveAsByItemDialog(app,session,type,processPUID); + } + }.start(); + super.executeModal(); + } + private String getProcessPUID(InterfaceAIFComponent target) { + TCComponentItemRevision itemRev = (TCComponentItemRevision) target; + try { + TCComponentItem item = itemRev.getItem(); + AIFComponentContext[] aifccs = item.whereReferenced(); + for(AIFComponentContext aifcc:aifccs){ + if(aifcc.getComponent().getType().equals("MEProcess")){ + return aifcc.getComponent().getUid(); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + + } +} diff --git a/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemDialog.java b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemDialog.java new file mode 100644 index 0000000..42dbba0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemDialog.java @@ -0,0 +1,169 @@ +package com.connor.renben.process.plm.tmom024; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.swing.ButtonGroup; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.bean.CXListBean; +import com.connor.renben.process.plm.tmom008.TMom008OPDivisionOperation; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom024SaveAsByItemDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private String type; + private String processPUID; + private JTextField from_item;; + + private JButton okButton; + private JButton celButton; + private JPanel panel1; + private JPanel panel2; + private JRadioButton radioBtn1; + private JRadioButton radioBtn2; + private JPanel rootPanel; + + public TMom024SaveAsByItemDialog() { + super(false); + } + + public TMom024SaveAsByItemDialog(AbstractAIFApplication app,TCSession session,String type, String processPUID) { + super(false); + this.app = app; + this.session = session; + this.type = type; + this.processPUID = processPUID; + init(); + + } + + public void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + this.setPreferredSize(new Dimension(400, 120)); + this.setTitle(rb.getString("xz24_display.TITLE")+(type.equals("CONTROLPLAN")?rb.getString("kzjh24_display.TITLE"):"PFMEA")); + from_item = new JTextField(20); + //from_item.setText("009078"); + //comboBox = new JComboBox(); + okButton = new JButton(rb.getString("qd_display.TITLE")); + celButton = new JButton(rb.getString("qx_display.TITLE")); + + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + try { + okEvent(e); + } catch (IOException e1) { + MessageBox.post("δ֪", "ʧ", MessageBox.ERROR); + e1.printStackTrace(); + } + } + }); + celButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + celEvent(e); + } + }); + panel1 = new JPanel(new PropertyLayout()); + panel1.add("1.1.right.top.preferred.preferred", new JLabel(" ")); + panel1.add("2.1.right.top.preferred.preferred", new JLabel(" "+(type.equals("CONTROLPLAN")?"ƼƻID":"PFMEA ID")+"")); + panel1.add("2.2.right.top.preferred.preferred", from_item); + panel1.add("3.1.right.top.preferred.preferred", new JLabel(" ")); + panel2 = new JPanel(new FlowLayout()); + panel2.add(okButton); + panel2.add(new JLabel(" ")); + panel2.add(celButton); + + rootPanel = new JPanel(new BorderLayout()); + rootPanel.add(panel1, BorderLayout.CENTER); + rootPanel.add(panel2, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + /** + * ȷťҵ¼ + * + * @param e + * @throws IOException + */ + public void okEvent(ActionEvent e) throws IOException { + String from_itemID = from_item.getText(); + TCComponentItem item = null; + TCComponentItemType itemType; + try { + itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + item = itemType.find(from_itemID); + if(item==null){ + MessageBox.post("δҵ"+from_itemID+"!", "", MessageBox.ERROR); + return; + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + int getConfir = ConfirmationDialog.post(" ",(type.equals("CONTROLPLAN")?"Ƽƻ":"PFMEA")+"ݽᱻǣǷ"); + if(getConfir==ConfirmationDialog.YES){ + TMom024SaveAsByItemOperation operation = new TMom024SaveAsByItemOperation(app,session,type,processPUID,item); + session.queueOperation(operation); + } + + this.dispose(); + } + /** + * ȡťҵ¼ + * + * @param e + */ + public void celEvent(ActionEvent e) { + + this.dispose(); + } + + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + + } +} diff --git a/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemHandler.java b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemHandler.java new file mode 100644 index 0000000..f3fce48 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemHandler.java @@ -0,0 +1,42 @@ +package com.connor.renben.process.plm.tmom024; + +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; +import com.teamcenter.rac.util.MessageBox; + +public class TMom024SaveAsByItemHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String commandId = arg0.getCommand().getId(); + String type = ""; + switch(commandId){ + case "com.connor.renben.process.plm.commands.SavaASByControlPlan": + type = "CONTROLPLAN"; + break; + case "com.connor.renben.process.plm.commands.SavaASByPFMEA": + type = "PFMEA"; + break; + default: + } + TMom024SaveAsByItemCommand command = new TMom024SaveAsByItemCommand(app, + session,type); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(""+(type.equals("CONTROLPLAN")?"Ƽƻ":"PFMEA")+"ʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemOperation.java b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemOperation.java new file mode 100644 index 0000000..f1c9adf --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom024/TMom024SaveAsByItemOperation.java @@ -0,0 +1,186 @@ +package com.connor.renben.process.plm.tmom024; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import javax.swing.JTextField; + +import org.apache.commons.dbutils.DbUtils; +import org.apache.commons.dbutils.QueryRunner; +import org.apache.commons.dbutils.handlers.ArrayListHandler; + + + +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.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEOP; +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.connor.renben.process.plm.sql.util.*; + +public class TMom024SaveAsByItemOperation extends AbstractAIFOperation { + private AbstractAIFApplication app; + private TCSession session; + private String type; + private String processPUID; + private TCComponentItem from_item; + + public TMom024SaveAsByItemOperation(AbstractAIFApplication app, TCSession session,String type, String processPUID,TCComponentItem from_item) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.type = type; + this.processPUID = processPUID; + this.from_item = from_item; + } + + @Override + public void executeOperation() throws Exception { +// test(); + //TODO Auto-generated method stub + System.out.println("Enter!"); + Map map_from = getProcessRoute(getProcessPUID(from_item),"RB3_GCMC"); + Map map_to = getProcessRoute(processPUID,"RB3_GCMC"); + Map map_meopID = getProcessRoute(processPUID, "RB3_MEOPID"); + if(map_from.equals(map_to)){ + //ȡĿƼƻ/PFMEAеݣ޸PLMEIDPROCESSPUIDRB3_MEOPIDΪԭƼƻ + Object[][] data = getControlPlanDataByProcessPUID(getProcessPUID(from_item),map_meopID); + //ͨԭƼƻPROCESSPUID + cleanDate(processPUID); + //װԭƼƻ + setData(data); + } + else{ + MessageBox.post("Ƽƻ·߲һ£޷棡", "", MessageBox.ERROR); + } + } + private void cleanDate(String processPUID2) { + // TODO Auto-generated method stub + QueryRunner queryRunner = new QueryRunner(true); + try { + Connection conn = SqlUtilT.getTCConnection(); + queryRunner.update(conn,"delete from "+(type.equals("CONTROLPLAN")?"RB3_CONTROLPLAN":"RB3_PFMEA")+" where processpuid = '"+processPUID2+"'"); + DbUtils.closeQuietly(conn); + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + //UUID.randomUUID().toString().replace("-", ""); + private void setData(Object[][] params2) { + // TODO Auto-generated method stub + System.out.println("Enter!"); +// Object[][] params = new Object[1][]; +// for(int i = 0 ; i < 1 ; i++){ +// params[i] = new Object[]{"1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23",24,"25",26,27,"28","29","30","31","32","33"}; +// } + QueryRunner queryRunner = new QueryRunner(true); + String sqlControlPlan = "INSERT INTO RB3_CONTROLPLAN VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + String sqlPFMEA = "INSERT INTO RB3_PFMEA VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + try { + Connection conn = SqlUtilT.getTCConnection(); + queryRunner.batch(conn, type.equals("CONTROLPLAN")?sqlControlPlan:sqlPFMEA, params2); + DbUtils.closeQuietly(conn); + //System.out.println(num); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ͨProcessPUIDȡƼƻ + * @param processPUID2 + * @param map_meopID + * @return + */ + private Object[][] getControlPlanDataByProcessPUID(String processPUID2, Map map_meopID) { + // TODO Auto-generated method stub + Object[][] params = null; + //ResultSet rs = null; + String sql = "select * from "+(type.equals("CONTROLPLAN")?"RB3_CONTROLPLAN":"RB3_PFMEA")+" where processpuid = '"+processPUID2+"'"; + Connection conn = SqlUtilT.getTCConnection(); + System.out.println(sql); + try { + //rs = SqlUtilT.read(sql); + QueryRunner queryRunner = new QueryRunner(true); + //queryRunner.batch(SqlUtilT.getConnectionTC10(), sql, params); + List list = queryRunner.query(conn, sql, new ArrayListHandler()); + params = new Object[list.size()][]; + for(int i = 0 ; i < list.size() ; i++){ + list.get(i)[0] = UUID.randomUUID().toString().replace("-", ""); + list.get(i)[1] = processPUID; + list.get(i)[2] = map_meopID.get(list.get(i)[3]); + params[i] = list.get(i); + } + DbUtils.closeQuietly(conn); + //test(params); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return params; + } + + private Map getProcessRoute(String processPUID2, String col) { + // TODO Auto-generated method stub + Map map = new HashMap<>(); + ResultSet rs = null; + String sql = "select distinct rb3_gybh,"+col+" from "+(type.equals("CONTROLPLAN")?"rb3_controlplan":"rb3_pfmea")+" where Processpuid = '"+processPUID2+"' order by to_number(rb3_gybh)"; + System.out.println(sql); + SqlUtilT.getTCConnection(); + try { + rs = SqlUtilT.read(sql); + while(rs.next()){ + map.put(rs.getString("RB3_GYBH"), rs.getString(col)); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally{ + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + return map; + } + private String getProcessPUID(TCComponentItem item) { + try{ + AIFComponentContext[] aifccs = item.whereReferenced(); + for(AIFComponentContext aifcc:aifccs){ + if(aifcc.getComponent().getType().equals("MEProcess")){ + return aifcc.getComponent().getUid(); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + +} diff --git a/src/com/connor/renben/process/plm/tmom025/PFMEA统计.xlsx b/src/com/connor/renben/process/plm/tmom025/PFMEA统计.xlsx new file mode 100644 index 0000000..e755c31 Binary files /dev/null and b/src/com/connor/renben/process/plm/tmom025/PFMEA统计.xlsx differ diff --git a/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsDialog.java b/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsDialog.java new file mode 100644 index 0000000..feb9be3 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsDialog.java @@ -0,0 +1,505 @@ +package com.connor.renben.process.plm.tmom025; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.InputStream; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelUtil; +import com.connor.renben.process.plm.util.MyTableModel; +import com.connor.renben.process.plm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.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.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom025PFMEAExpireStatisticsDialog extends AbstractAIFDialog implements ActionListener{ + private AbstractAIFUIApplication app; + private TCSession session; + private String groupName;//ǰıʶ + private SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + private String[] header=new String[]{"PFMEA汾","PFMEA","PFMEA","Ʒͺ","Ʒ","ͻ","",""}; + //private String[] queryName=new String[]{"ͺ"}; + private Object[][] cellData;// + private Vector> excelValue = new Vector>();//Excel + private String[] queryName;//ѯ + private String[] queryValue;//ֵ + private Map groupMap= new HashMap();//RB3_GROUPʵֵʾֵ + private StringBuffer errSb;// + private JFileChooser fileChooser;// ļѡ + private String foldPath = "C:\\";//Ĭϵַ + private String querySql = ""; + // ҳؼ + //ѯ + private JPanel queryPanel; + + private JLabel createDate;//ʱ + private DateButton startDate; + private DateButton endDate; + private JButton queryButton;//ѯ + //ʾ + private JPanel tablePanel; + private JTable showTable; + // + private JPanel buttonPanel; + private JButton okButton;// + private JButton celButton;//ر + + + public TMom025PFMEAExpireStatisticsDialog() { + super(false); + } + + public TMom025PFMEAExpireStatisticsDialog(AbstractAIFUIApplication app) + { + super(false); + this.app=app; + this.session=(TCSession)app.getSession(); + String currentGroupName = null; + try { + currentGroupName = this.session.getCurrentGroup().getFullName(); + } catch (TCException e) { + e.printStackTrace(); + } + int indexx = currentGroupName.lastIndexOf("."); + // ȡǰʶ + this.groupName = currentGroupName.substring(indexx + 1, currentGroupName.length()); + init(); + } + private void init() { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + setTitle(rb.getString("PDMEAtj25_display.TITLE")); + //ѯ + + + this.setPreferredSize(new Dimension(1024, 768)); + this.createDate=new JLabel(rb.getString("yqrq25_display.TITLE")); + this.startDate=new DateButton(dateFormat); + this.startDate.setDate(""); + this.endDate=new DateButton(dateFormat); + this.endDate.setDate(""); + this.queryButton=new JButton(rb.getString("cx19_display.TITLE")); + //ʾ + this.queryPanel=new JPanel(new PropertyLayout()); + this.queryPanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black),"ѯ")); + + this.queryPanel.add("1.1.left.top", this.createDate); + this.queryPanel.add("1.2.left.top", this.startDate); + this.queryPanel.add("1.3.left.top", this.endDate); + this.queryPanel.add("1.4.left.top", this.queryButton); + //ʾ + //ʼJTable + this.showTable=getjTable(showTable, null, header, cellData); + this.tablePanel=new JPanel(new BorderLayout()); + //this.tablePanel.setPreferredSize(new Dimension(200, 300)); + this.tablePanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black),"ѯ")); + this.tablePanel.add(new JScrollPane(this.showTable),BorderLayout.CENTER); + + this.buttonPanel=new JPanel(new FlowLayout()); + this.okButton=new JButton(rb.getString("dcbb25_display.TITLE")); + this.celButton=new JButton(rb.getString("gb25_display.TITLE")); + this.buttonPanel.add(okButton); + this.buttonPanel.add(celButton); + + this.setLayout(new BorderLayout()); + this.add(this.queryPanel,BorderLayout.NORTH); + this.add(this.tablePanel,BorderLayout.CENTER); + this.add(this.buttonPanel,BorderLayout.SOUTH); + this.createActionEvent(); + this.pack(); + + this.showDialog(); + // ʼļѡ + this.fileChooser = new JFileChooser(); + this.fileChooser.setCurrentDirectory(new File(foldPath)); + } + //Ӱť + public void createActionEvent() { + this.queryButton.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + } + + + + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + MyTableModel tableModel = null; + if (dtm == null) { + tableModel = new MyTableModel(values, titleNames); + } + return tableModel; + } + //ļѡ + private void foldPath() { + this.fileChooser.setFileSelectionMode(1); + // ļѡ + int state = this.fileChooser.showOpenDialog(null); + if (state == 1) { + return; + } else { + File f = fileChooser.getSelectedFile(); + this.foldPath = f.getAbsolutePath(); + } + } + + // 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)); + 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 List getItem(String[] queryName,String[] queryValue) + { + List components=new ArrayList(); + if(queryName.length==0 && queryValue.length==0) + { + queryName=new String[]{"ͺ"}; + queryValue=new String[]{"*"}; + } + //ȡѯ + // ȡѯ + try { + TCComponentQueryType queryType = (TCComponentQueryType) this.session + .getTypeComponent("ImanQuery"); + //ȡƷͳƲѯ + TCComponentQuery cptjQuery=(TCComponentQuery)queryType.find("ƷͳƲѯ"); + if(cptjQuery==null){ + MessageBox.post("δҵƷͳƲѯ", "", ERROR); + return null; + } + //ȡƷͳƲѯ + TCComponentQuery yscptjQuery=(TCComponentQuery)queryType.find("ƷͳƲѯ"); + if(yscptjQuery==null){ + MessageBox.post("δҵƷͳƲѯ", "", ERROR); + return null; + } + //ȡƷͳƲѯ + TCComponentQuery zhtjcptjQuery=(TCComponentQuery)queryType.find("ƷͳƲѯ"); + if(zhtjcptjQuery==null){ + MessageBox.post("δҵƷͳƲѯ", "", ERROR); + return null; + } + TCComponent[] cptjComponents = cptjQuery.execute(queryName, queryValue); + for (TCComponent tcComponent : cptjComponents) { + components.add(tcComponent); + } + TCComponent[] yscptjComponents=yscptjQuery.execute(queryName, queryValue); + for (TCComponent tcComponent : yscptjComponents) { + components.add(tcComponent); + } + TCComponent[] zhtjcptjComponents=zhtjcptjQuery.execute(queryName, queryValue); + for (TCComponent tcComponent : zhtjcptjComponents) { + components.add(tcComponent); + } + return components; + } catch (TCException e) { + MessageBox.post("ѯϵϵͳԱ", "", MessageBox.ERROR); + e.printStackTrace(); + } + return null; + } + //ȡҪ + public void getCellValue(List components) + { + ResultSet rs = null; + try { + InputStream input = new BufferedInputStream(TMom025PFMEAExpireStatisticsDialog.class.getResourceAsStream("sql.properties")); + Properties pro = new Properties(); + pro.load(input); + Iterator iterator = pro.stringPropertyNames().iterator(); + while (iterator.hasNext()) { + String key = iterator.next(); + System.out.println(key+":"+pro.getProperty(key)); + } + + String sql = pro.getProperty("CPTJSQL"); + sql = sql +this.querySql; + System.out.println(sql+"\n"); + + SqlUtilT.getTCConnection(); + rs = SqlUtilT + .read(sql); + List puid_List = new ArrayList(); + SimpleDateFormat format = new SimpleDateFormat("yyyy-M-dd"); + while(rs.next()){ + + puid_List.add(rs.getString("PUID")); + } + //puid_List.add("BkbxxkWK4iZo5B"); + //puid_List.add("BkbxxkWK4iZo5B"); + //puid_List.add("iRbxxkWK4iZo5B"); + //puid_List.add("W2RxxkWK4iZo5B"); + //InterfaceAIFComponent[] iaifc = TMomMethodUtil.searchComponentsCollection( + //this.session, "PFMEA",new String[]{"expiry_date"}, new String[]{""}); + //System.out.println(iaifc.length); + for(int i = 0 ; i < puid_List.size() ; i++){ + TCComponent PFMEARevM = (TCComponent)session + .stringToComponent(puid_List.get(i)); + String expory_date = PFMEARevM.getProperty("rb3_expiry_date"); + String pfmeaRev = ""; + String pfmeaName = ""; + String pfmeaOwning = ""; + String meprocess_id = ""; + String product_id = ""; + String product_name = ""; + String khmc = ""; + AIFComponentContext[] aifccs4 = PFMEARevM.whereReferenced(); + for(AIFComponentContext aifcc4: aifccs4){ + AIFComponentContext[] tccs = ((TCComponent)aifcc4.getComponent()).whereReferenced(); + pfmeaRev = aifcc4.getComponent().getProperty("object_name"); + for(AIFComponentContext tcc:tccs){ + if(tcc.getComponent().getType().equals("RB3_PFMEARevision")){ + pfmeaName = tcc.getComponent().getProperty("object_name"); + pfmeaOwning = tcc.getComponent().getProperty("owning_user"); + TCComponentItem pfmea_item = ((TCComponentItemRevision)tcc.getComponent()).getItem(); + AIFComponentContext[] aifccs5 = pfmea_item.whereReferenced(); + for(AIFComponentContext aifcc5 : aifccs5){ + if(aifcc5.getComponent().getType().equals("MEProcess")){ + meprocess_id = aifcc5.getComponent().getProperty("item_id"); + AIFComponentContext[] aifccs6 = ((TCComponent)aifcc5.getComponent()).whereReferenced(); + for(AIFComponentContext aifcc6 :aifccs6){ + if(aifcc6.getComponent().getType().equals("RB3_Product")){ + product_id = aifcc6.getComponent().getProperty("item_id"); + product_name = aifcc6.getComponent().getProperty("object_name"); + khmc = aifcc6.getComponent().getProperty("rb3_khmc"); + break; + } + } + break; + } + } + break; + } + } + } + Vector cellValue=new Vector(); + cellValue.add(pfmeaRev); + cellValue.add(pfmeaName); + cellValue.add(pfmeaOwning); + cellValue.add(product_id); + cellValue.add(product_name); + cellValue.add(khmc); + cellValue.add(meprocess_id); + cellValue.add(expory_date); + this.excelValue.add(cellValue); +// final int size = Integer.valueOf(this.excelValue.size()); +// boolean flag = true; +// if(this.excelValue.size()!=0){ +// for(int j = 0 ; j < size ; j++){ +// if(this.excelValue.get(j).get(0).equals(pfmeaRev)){ +// flag = false; +// } +// } +// if(flag){ +// this.excelValue.add(cellValue); +// } +// }else{ +// this.excelValue.add(cellValue); +// } + } + + + + + +// //webServiceӿڲѯ +// //һMobileCodeWS +// WebService1 factory = new WebService1(); +// //ݹһMobileCodeWSSoap +// WebService1Soap mobileCodeWSSoap = factory.getWebService1Soap(); +// //WebServiceṩgetMobileCodeInfoѯֻĹ +// String searchResult = mobileCodeWSSoap.getPersonInfoByPid(sql); +// System.out.println(searchResult); +// JSONArray json = JSONArray.fromObject(searchResult); // Ȱַת JSONArray +// //JSON +// for (int i = 0; i < json.size(); i++) { +// //ͬȽjsonַתΪjsonٽjsonתΪjavaʾ +// JSONObject obj = new JSONObject().fromObject(json.get(i));//jsonַתΪjson +// //jsonתΪjava +// //TMomProductBean productBean = (TMomProductBean)JSONObject.toBean(obj,TMomProductBean.class);//jsonתΪPerson +// System.out.println(obj.toString()); +// System.out.println(obj.toString()); +// //ݱ浽 +//// Vector cellValue=new Vector(); +//// cellValue.add(productBean.getXH()); +//// cellValue.add(productBean.getKHMC()); +//// cellValue.add(productBean.getKHXMH()); +//// cellValue.add(productBean.getCPMC()); +//// cellValue.add(productBean.getKHTH()); +//// cellValue.add(productBean.getCLBZ()); +//// cellValue.add(productBean.getSJRY()); +//// cellValue.add(productBean.getCXYJ()); +//// cellValue.add(productBean.getZXYJ()); +//// cellValue.add(productBean.getCJSJ()); +//// this.excelValue.add(cellValue); +// } + +// String sql = pro.getProperty("CPTJSQL"); +// sql = sql +this.querySql; +// try { +// System.out.println(sql); +// rs = SqlUtilT.read(sql); +// System.out.println("ѯϣ"); +// while (rs.next()) { +// Vector cellValue=new Vector(); +// cellValue.add(rs.getString("XH")); +// cellValue.add(rs.getString("KHMC")); +// cellValue.add(rs.getString("KHXMH")); +// cellValue.add(rs.getString("CPMC")); +// cellValue.add(rs.getString("KHTH")); +// cellValue.add(rs.getString("CLBZ")); +// cellValue.add(rs.getString("SJRY")); +// cellValue.add(rs.getString("CXYJ")); +// cellValue.add(rs.getString("ZXYJ")); +// cellValue.add(dateFormat.parse(rs.getString("CJSJ"))); +// this.excelValue.add(cellValue); +// } +// System.out.println("ȡϣ"); +// } catch (SQLException e) { +// e.printStackTrace(); +// } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + } + public void addData(Object[][] cellData2) { + DefaultTableModel tableModel = (DefaultTableModel) this.showTable + .getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter(this.getTableModel(null, this.header, cellData2)); + this.showTable.setRowSorter(sorter); + for (int i = 0; i < this.excelValue.size(); i++) { + tableModel.addRow(this.excelValue.get(i)); + } + // ݲ޸ + showTable.setEnabled(true); + // ± + showTable.invalidate(); + } + public void setQuery() + { + StringBuffer sb = new StringBuffer(); + //List queryValueList=new ArrayList(); + + if(this.startDate.getDate()!=null){ + sb.append(" and to_date(prb3_expiry_date,\'yyyy-mm-dd hh24:mi\') >= to_date(\'"+dateFormat.format(this.startDate.getDate())+"\',\'yyyy-mm-dd hh24:mi\')"); + } + if(this.endDate.getDate()!=null){ + sb.append(" and to_date(prb3_expiry_date,\'yyyy-mm-dd hh24:mi\') <= to_date(\'"+dateFormat.format(this.endDate.getDate())+"\',\'yyyy-mm-dd hh24:mi\')"); + } + + + + this.querySql=sb.toString(); + } + @Override + public void actionPerformed(ActionEvent arg0) { + Object source=arg0.getSource(); + ProgressBarThread thread = new ProgressBarThread("ƷͳƱ", + "ƷͳƱ..."); + if(source.equals(this.queryButton)){ + //this.disposeDialog(); + //this.dispose(); + this.excelValue.clear(); + //thread.start(); + this.setQuery(); + //List components=getItem(queryName,queryValue); + getCellValue(null); + this.cellData=new Object[this.excelValue.size()][]; + for (int i = 0; i < this.excelValue.size(); i++) { + this.cellData[i]=new Object[this.excelValue.get(i).size()]; + for (int j = 0; j < this.excelValue.get(i).size(); j++) { + this.cellData[i][j]=this.excelValue.get(i).get(j); + } + } + //this.showDialog(); + //± + this.addData(cellData); + thread.setBool(true); + } else if (source.equals(this.okButton)){ + this.foldPath(); + ExcelUtil excelUtil=new ExcelUtil(); + try { + String filePath=String.format("%s\\PFMEAͳ%s.xlsx", this.foldPath,new SimpleDateFormat("yyyyMMddhhmmss").format(new Date())); + InputStream is = TMom025PFMEAExpireStatisticsDialog.class.getResourceAsStream("PFMEAͳ.xlsx"); + thread.start(); + excelUtil.writeExcel(filePath, is,this.excelValue, new String[]{"PFMEAͳ"}); + thread.setBool(true); + MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + this.disposeDialog(); + this.dispose(); + } catch (Exception e) { + MessageBox.post("ExcelϵϵͳԱ", "", MessageBox.ERROR); + e.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.disposeDialog(); + this.dispose(); + } + } +} diff --git a/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsHandler.java b/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsHandler.java new file mode 100644 index 0000000..c45b0be --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsHandler.java @@ -0,0 +1,60 @@ +package com.connor.renben.process.plm.tmom025; + +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.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentFilter; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom025PFMEAExpireStatisticsHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + final AbstractAIFUIApplication app=AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + String currentUserID = null; + try { + currentUserID = session.getUser().getUserId(); + } catch (TCException e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + TCPreferenceService service = session.getPreferenceService(); + String[] value = service.getStringArray( + TCPreferenceService.TC_preference_site, "Cust_PFMEA_ExpireStatistics"); + if (value == null || value.length == 0) { + MessageBox.post("ûȨִд˲ϵԱ", "", MessageBox.ERROR); + return null; + } + Boolean isOk = false; + for (String userName : value) { + if (userName.equals(currentUserID)) { + isOk = true; + } + } + if (!isOk) { + MessageBox.post("ûȨִд˲ϵԱ", "", MessageBox.ERROR); + return null; + } + + new Thread() + { + @Override + public void run() { + new TMom025PFMEAExpireStatisticsDialog(app); + super.run(); + } + }.start(); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsOperation.java b/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsOperation.java new file mode 100644 index 0000000..d09985b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom025/TMom025PFMEAExpireStatisticsOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom025; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom025PFMEAExpireStatisticsOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom025/sql.properties b/src/com/connor/renben/process/plm/tmom025/sql.properties new file mode 100644 index 0000000..ab68a47 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom025/sql.properties @@ -0,0 +1 @@ +CPTJSQL=select puid,prb3_expiry_date from prb3_pfmearevmasters where prb3_expiry_date is not null \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempCommand.java b/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempCommand.java new file mode 100644 index 0000000..81f734b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempCommand.java @@ -0,0 +1,149 @@ +package com.connor.renben.process.plm.tmom026; + +import java.util.Arrays; +import java.util.List; + +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom026CheckDataTempCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp;//ѡеĿƼƻ汾 + private TCComponentItem meprocess;//ն + private TCComponentItem product;//Ʒ + + public TMom026CheckDataTempCommand(AbstractAIFApplication app, + TCSession session, InterfaceAIFComponent comp, TCComponentItem meprocess, TCComponentItem product) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.meprocess = meprocess; + this.product = product; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + final String result = getCmdString(); + System.out.println(result); + new Thread() { + @Override + public void run() { + TMom026CheckDataTempOperation operation = new TMom026CheckDataTempOperation(result.split("@")); + try { + operation.executeOperation(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }.start(); + super.executeModal(); + } + + /*** + * ȡ + * @return + */ + private String getCmdString() + { + String result = ""; + try { + //ȡƷͺšƷ + String productId = product.getStringProperty("item_id"); + String productName = product.getStringProperty("object_name"); + //ȡƼƻ + String controlType = ((TCComponentItemRevision)comp).getItem().getType(); + //ȡûID + String userId = session.getUser().getUserId(); + //ȡ + TCComponent[] meops = meprocess.getLatestItemRevision().getReferenceListProperty("ps_children"); + //AIFComponentContext[] meops = tcProperties.getReferenceValueArray() meprocess.getChildren(); + //ȡѡCust_Input_QMSйӦı + List checkTypeList = getCheckType("Cust_Input_QMS"); + + + //ϲ + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(productId); + stringBuffer.append("@"); + stringBuffer.append(productName); + stringBuffer.append("@"); + stringBuffer.append(controlType); + stringBuffer.append("@"); + stringBuffer.append(userId); + stringBuffer.append("@|@"); + + for (TCComponent aifComponentContext : meops) { + //ȡIDƺͲұ + String meopId = aifComponentContext.getProperty("item_id"); + String meopName = aifComponentContext.getProperty("object_name").split("/")[0]; + String no = aifComponentContext.getProperty("rb3_id"); + if(aifComponentContext instanceof TCComponentItemRevision) + { + TCComponentItemRevision meopRev = (TCComponentItemRevision)aifComponentContext; + no = meopRev.getItem().getProperty("rb3_id"); + } + //aifComponentContext.getProperty("rb3_id"); + + + stringBuffer.append(meopId); + stringBuffer.append("@"); + stringBuffer.append(meopName); + stringBuffer.append("@"); + stringBuffer.append(no); + stringBuffer.append("@-@"); + + String checkType = "0@-@1@-@2@-@3@|@"; + for (String string : checkTypeList) { + if(meopName.compareTo(string.split("-")[0]) == 0) + { + checkType = string.split("-")[1].replaceAll(",", "@-@"); + checkType = checkType + "@|@"; + } + } + stringBuffer.append(checkType); + } + + result = stringBuffer.toString().substring(0, stringBuffer.length()-3); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + return result; + } + + /** + * ȡı + * @param name ѡ + * @return Լı + */ + private List getCheckType(String name) { + // TODO Auto-generated method stub + String[] values = null; + if(name != null) + { + TCPreferenceService service = this.session.getPreferenceService(); + values = service.getStringArray(TCPreferenceService.TC_preference_site, name); + } + return Arrays.asList(values); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempHandler.java b/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempHandler.java new file mode 100644 index 0000000..73cd151 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempHandler.java @@ -0,0 +1,77 @@ +package com.connor.renben.process.plm.tmom026; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom024.TMom024SaveAsByItemCommand; +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.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 TMom026CheckDataTempHandler 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.getType().indexOf("KZJHRevision") > 0) + { + //ȡն + TCComponentItem meprocess = null; + TCComponentItem product = null; + try { + AIFComponentContext[] context = ((TCComponentItemRevision) comp) + .getItem().whereReferenced(); + for (int i = 0; i < context.length; i++) { + if (context[i].getComponent().getType().equals("MEProcess")) { + meprocess = (TCComponentItem) context[i].getComponent(); + } + } + + //ݹȡƷ + 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) + { + product = (TCComponentItem) productItems[i].getComponent(); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + TMom026CheckDataTempCommand command = new TMom026CheckDataTempCommand(app, + session,comp,meprocess,product); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("Ԥʧܣ", "", MessageBox.ERROR); + } + } + else + { + MessageBox.post("ѡпƼƻ汾", "", MessageBox.ERROR); + } + + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempOperation.java b/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempOperation.java new file mode 100644 index 0000000..ddf338f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom026/TMom026CheckDataTempOperation.java @@ -0,0 +1,1087 @@ +package com.connor.renben.process.plm.tmom026; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import com.connor.renben.process.plm.bean.CheckTable; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCProperty; + +public class TMom026CheckDataTempOperation extends AbstractAIFOperation { + + private String[] args; + + public TMom026CheckDataTempOperation(String[] args) { + // TODO Auto-generated constructor stub + this.args = args; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // getCheckTableBean(args[0],args[1],args[2],args[3],args[4],args[5],args[6]); + // System.out.println(args.length); + //System.out.println(args); + if(args.length <=0) + { + return; + } + String productID = args[0]; + String productName = args[1]; + String controlplanType = args[2]; + String assignUser = args[3]; + if(assignUser.equals("") || assignUser == null) + { + return; + } + //System.out.println("ݹIJ" + Arrays.toString(args)); + List assignUserList = new ArrayList(); + if(assignUser.indexOf(",") >= 0) + { + assignUser = assignUser.substring(0,assignUser.length()-1); + String[] assignUsers = assignUser.split(","); + + assignUserList = Arrays.asList(assignUsers); + } + else + { + assignUserList.add(assignUser); + } + System.out.println(controlplanType); + + + //ɾⱨмбȿƼƻжı͹ + deleteCheckData(productID); + + + String meopID = " "; + String meopName = " "; + String meopNO = " "; + try { + for (int i = 4; i < args.length; i++) { + + //System.out.println("" + args[i]); + + //System.out.println("I=============" + i); + if (args[i].equals("|")) { + meopID = args[i + 1]; + meopName = args[i + 2]; + meopNO = args[i + 3]; + + i = i + 3; + } + + if (args[i].equals("-")) { + //System.out.println(meopName);; + getCheckTableBean(args[i + 1], productID, productName, controlplanType, meopID, meopName, meopNO, assignUserList); + + i = i + 1; + System.out.println("ϴ=============" + i); + } + + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + + + /*** + * ɾⱨмбȿƼƻжı͹ + */ + private static void deleteCheckData(String productID) + { + //ѯмд˹б + ResultSet resultSet = null; + ResultSet resultSet2 = null; + try { + + // ȡݿ + SqlUtilT.getTCConnection(); + + //ѯмеĹͼⱨ + String sql =" SELECT RB3_MEOP_ID," + + " CASE " + + " WHEN RB3_TYPE = 0 THEN '׼'" + + " WHEN RB3_TYPE = 1 THEN '̼'" + + " WHEN RB3_TYPE = 2 THEN 'ĩ'" + + " ELSE 'Ѳ' END AS RB3_SMJY,RB3_TYPE" + + " from RB3_CHECK_TABLE_TEMP where RB3_MEOP_ID LIKE '" + productID +"%'" + + " GROUP by RB3_MEOP_ID,RB3_TYPE order by rb3_meop_id"; + + resultSet = SqlUtilT.read(sql); + //洢меĹͼⱨ + List> checkDateTypeList = new ArrayList>(); + while (resultSet.next()) + { + List data = new ArrayList(); + data.add(resultSet.getString("RB3_MEOP_ID")); + data.add(resultSet.getString("RB3_SMJY")); + data.add(resultSet.getString("RB3_TYPE")); + checkDateTypeList.add(data); + } + + //ѯƼƻеĹͼⱨ + String sql2 ="select rb3_meopid,RB3_smjy from RB3_CONTROLPLAN where rb3_meopid like '"+ productID + "%' and RB3_smjy is not null and RB3_smjy != ' '" + + " GROUP by rb3_meopid,RB3_smjy " + + " order by rb3_meopid "; + + resultSet2 = SqlUtilT.read(sql2); + + //洢ƼƻеĹͼⱨ + List> controlPlanTypeList = new ArrayList>(); + while (resultSet2.next()) + { + List data = new ArrayList(); + data.add(resultSet2.getString("RB3_MEOPID")); + + String type = resultSet2.getString("RB3_SMJY"); + + if(type.indexOf("׼") >= 0) + { + data.add("׼"); + } + else if(type.indexOf("̼") >= 0) + { + data.add("̼"); + } + else if(type.indexOf("ĩ") >= 0) + { + data.add("ĩ"); + } + else if(type.indexOf("Ѳ") >= 0) + { + data.add("Ѳ"); + } + else + { + continue; + } + controlPlanTypeList.add(data); + } + + //ԱмбȿƼƻжĹͱ + List> deleteList = new ArrayList>(); + for (List list : checkDateTypeList) { + boolean isDelete = true; + for (List controlPlanType : controlPlanTypeList) { + //źͱͶͬɾ + if(controlPlanType.get(0).equals(list.get(0)) && controlPlanType.get(1).equals(list.get(1))) + { + isDelete = false; + break; + } + } + if(isDelete) + { + deleteList.add(list); + } + } + + if(deleteList.size() > 0) + { + //ɾ + for (List list : deleteList) { + String deleteSql = "delete from RB3_CHECK_TABLE_TEMP where rb3_meop_id = '" + + list.get(0) + + "' and rb3_type = '" + + list.get(2) + "'"; + System.out.println("ɾSQL" + deleteSql); + SqlUtilT.delete(deleteSql); + } + } + else + { + return; + } + + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (resultSet != null) { + SqlUtilT.free(resultSet); + } + if (resultSet2 != null) { + SqlUtilT.free(resultSet2); + } + } + } + + + + + private static void getCheckTableBean(String type, String productID, + String productName, String controlplanType, String meopID, + String meopName, String meopNo, List assignUserList) { + int operateCode = Integer.valueOf(type); + String[] shousuobi_type = { "RB3_SJSJ", "RB3_GCSJ", "RB3_MJSJ" };// ׼̼ĩ + String shousuobi = null; // + StringBuilder sql = new StringBuilder() + .append("select PROCESSPUID,RB3_MEOPID,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff ,rb3_rl,rb3_pl,rb3_special,rb3_tstx,rb3_jqsb ,rb3_sjsj,rb3_gcsj,rb3_mjsj,rb3_hh ,rb3_fzr ,rb3_gcmc,rb3_tool_inspect from rb3_controlplan where rb3_meopid='" + + meopID + "' and type='" + controlplanType + "'");// and // RB3_smjy // like // '%׼%'"; + + switch (operateCode) { + case 0: + shousuobi = shousuobi_type[0]; + sql.append(" and rb3_smjy like '%׼%'"); + break; + case 1: + shousuobi = shousuobi_type[1]; + sql.append(" and rb3_smjy like '%̼%'"); + break; + case 2: + shousuobi = shousuobi_type[2]; + sql.append(" and rb3_smjy like '%ĩ%'"); + break; + case 3: + shousuobi = shousuobi_type[1]; + //sql.append(" and rb3_gcmc like '%飨%'"); + sql.append(" and rb3_smjy like '%Ѳ%'"); + break; + case 11: + shousuobi = shousuobi_type[1]; + //sql.append(" and rb3_gcmc like '%%' and rb3_gc is null"); + sql.append(" and rb3_smjy like '%Ѳ%' and rb3_gc is null"); + break; + case 12: + shousuobi = shousuobi_type[1]; + //sql.append(" and (rb3_gcmc like '%ռ%' or rb3_gcmc like '%ȫߴ%' or rb3_gcmc like '%ȫ%') and rb3_gc is null "); + sql.append(" and rb3_smjy like '%Ѳ%' and rb3_gc is null"); + break; + case 13: + shousuobi = shousuobi_type[1]; + //sql.append(" and rb3_gcmc like '%%' and rb3_cp is not null"); + sql.append(" and rb3_smjy like '%Ѳ%' and rb3_cp is not null"); + break; + case 14: + shousuobi = shousuobi_type[0]; + sql.delete(0, sql.length()); + sql.append("select distinct rb3_qptbh from (select rb3_qptbh,rb3_hh from rb3_controlplan where rb3_meopid='" + + meopID + + "' and type='" + + controlplanType + + "' and rb3_tool_inspect='1' and rb3_smjy like '%׼%'"); + break; + case 15: + shousuobi = shousuobi_type[2]; + sql.delete(0, sql.length()); + sql.append("select distinct rb3_qptbh from (select rb3_qptbh,rb3_hh from rb3_controlplan where rb3_meopid='" + + meopID + + "' and type='" + + controlplanType + + "' and rb3_tool_inspect='1' and rb3_smjy like '%ĩ%'"); + break; + case 16: + shousuobi = shousuobi_type[1]; + //sql.append(" and rb3_gcmc like '%ȫߴ%' and rb3_cp is not null"); + sql.append(" and rb3_smjy like '%Ѳ%' and rb3_cp is not null"); + break; + case 17: + shousuobi = shousuobi_type[1]; + //sql.append(" and rb3_gcmc like '%ߴȫ%' and rb3_cp is not null"); + sql.append(" and rb3_smjy like '%Ѳ%' and rb3_cp is not null"); + break; + default: + break; + } + sql.append(" and rb3_qptbh is not null order by rb3_hh"); + if (operateCode == 14 || operateCode == 15) + sql.append(")"); + //System.out.println(sql.toString()); + ResultSet rs = null; + SqlUtilT.getConnection(); + //ArrayList shousuobi_list = new ArrayList<>(); + try { + rs = SqlUtilT.read(sql.toString()); + if (operateCode == 14 || operateCode == 15) { + StringBuffer qptbhs = new StringBuffer(); + int QPCount = 0; + while (rs.next()) { + QPCount++; + qptbhs.append(rs.getString("RB3_QPTBH") + ","); + } + if (QPCount != 0) { + qptbhs.deleteCharAt(qptbhs.length() - 1); + String hd_sql = "select PROCESSPUID,RB3_MEOPID,rb3_qptbh,rb3_cp,rb3_cpgc,rb3_clff ,rb3_rl,rb3_pl,rb3_special,rb3_tstx,rb3_jqsb ,rb3_sjsj,rb3_gcsj,rb3_mjsj,rb3_hh ,rb3_fzr ,rb3_gcmc,rb3_tool_inspect from rb3_controlplan where rb3_meopid='" + + meopID + + "' and type='" + + controlplanType + + "' and rb3_qptbh in (" + + qptbhs + + ") and rb3_smjy like '%" + + (shousuobi.equals("RB3_SJSJ") ? "׼" : "ĩ") + + "%'"; + //System.out.println("hd_sql=====>" + hd_sql.toString()); + rs = SqlUtilT.read(hd_sql.toString()); + } + } + ArrayList> data = new ArrayList<>(); + ArrayList checkTables = new ArrayList<>(); + while (rs.next()) { + ArrayList arr = new ArrayList<>(); + String qptbh = getData(rs.getString("RB3_QPTBH")); + String cpgc = getData(rs.getString("RB3_CPGC")); + String cp = getData(rs.getString("RB3_CP")); + String clff = getData(rs.getString("RB3_CLFF")); + String fzr = getData(rs.getString("RB3_FZR")); + String rl = getData(rs.getString("RB3_RL")); + String pl = getData(rs.getString("RB3_PL")); + String hh = getData(rs.getString("RB3_HH")); + String tstx = getData(rs.getString("RB3_TSTX")); + String gc = getData(rs.getString(shousuobi)); + + arr.add(qptbh); + + //int num = 1; + // ҪΪ:x-x ιԼ¼/ιѲ ֶ + //try{ + if (!cpgc.isEmpty() && cpgc.indexOf("-") != -1) { + String ss = getNum(cpgc.split("-")[0]); + if(ss!=null && !ss.equals("0") ){ + cpgc = cpgc.substring(ss.length()+1, cpgc.length()); + if (ss.matches("\\d+")) { + //ֻһ"()""("ͷ ")"β ȥ"()" + if(cpgc.indexOf("(") == 0 && cpgc.indexOf(")") == cpgc.length()-1 && cpgc.split("\\(").length == 2){ + cpgc = cpgc.replace("(", ""); + cpgc = cpgc.replace(")", ""); + } + if(cpgc.indexOf("") == 0 && cpgc.indexOf("") == cpgc.length()-1 && cpgc.split("\\").length == 2){ + cpgc = cpgc.replace("", ""); + cpgc = cpgc.replace("", ""); + } + //num = Integer.valueOf(ss); + } + } + } + + + +// if (cpgc.indexOf("-") != -1) { +// String ss = getNum(cpgc.split("-")[0]); +// if(!ss.equals("0")){ +// cpgc = cpgc.substring(ss.length()+1, cpgc.length()); +// if (ss.matches("\\d+")) { +// num = Integer.valueOf(ss); +// } +// } +// } +// } +// catch(Exception e){ +// +// } + + CheckTable checkTable = new CheckTable(); + List maxAndMin = new ArrayList(); + maxAndMin = getCPGCMaxAndMix(cpgc, gc); +// if (maxAndMin.size() > 2) +// checkTable.setCpgc(maxAndMin.get(2)); +// else + checkTable.setCpgc(getData(rs.getString("RB3_CPGC"))); + checkTable.setType(String.valueOf(operateCode)); + checkTable.setProcessPuid(UUID.randomUUID().toString() + .replace("-", "")); + checkTable.setProductId(productID); + checkTable.setProductName(productName); + checkTable.setMeopName(meopName); + checkTable.setMeopNo(meopNo); + checkTable.setMeopId(meopID); + checkTable.setCp(cp); + checkTable.setSerialNo(qptbh); + checkTable.setMin(maxAndMin.get(0)); + checkTable.setMax(maxAndMin.get(1)); + checkTable.setAfterMin(maxAndMin.get(2)); + checkTable.setAfterMax(maxAndMin.get(3)); + checkTable.setPercentage(maxAndMin.get(4)); + checkTable.setAfterGcgc(maxAndMin.get(5)); + checkTable.setClff(clff); + checkTable.setFzr(fzr); + checkTable.setRl(rl); + checkTable.setPl(pl); + checkTable.setHh(hh); + checkTable.setTstx(tstx); +// if (shousuobi != null && !shousuobi.isEmpty()) { +// for (int i = 0; i < num; i++) { +// shousuobi_list.add(getData(rs.getString(shousuobi))); +// } +// } +// if (num == 1) { + checkTables.add(checkTable); +// } + +// else { +// for (int i = 0; i < num; i++) { +// ArrayList arr1 = (ArrayList) arr +// .clone(); +// String qp = arr1.get(arr1.size() - 1); +// arr1.remove(arr1.size() - 1); +// arr1.add(qp + "-" + (i + 1)); +// data.add(arr1); +// +// CheckTable checkTable1 = new CheckTable(); +// try { +// checkTable1 = checkTable.clone(); +// } catch (CloneNotSupportedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// checkTable1.setSerialNo(qp + "-" + (i + 1)); +// checkTables.add(checkTable1); +// +// } +// } + } +// System.out.println("Ʒ:" + productName + " :" + meopName + " :" +// + type + "" + " ϴ" + checkTables.size() + "¼"); + updateCheckTable(productID,meopID,type, checkTables, assignUserList); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + + } + + + public static void main2(String[] args) { + + ArrayList arr = getCPGCMaxAndMix("", " ");//R120HB(2.5/62.5)//Mr2>75% + //System.out.println(arr.get(0)); + //System.out.println(arr.get(1)); +// String cpgc = "4-(-11)"; +// int num = 0 ; +// if (cpgc.indexOf("-") != -1) { +// String ss = getNum(cpgc.split("-")[0]); +// System.out.println(ss); +// if(!ss.equals("0")&& !ss.isEmpty()){ +// cpgc = cpgc.substring(ss.length()+1, cpgc.length()); +// if (ss.matches("\\d+")) { +// //ֻһ"()""("ͷ ")"β ȥ"()" +// if(cpgc.indexOf("(") == 0 && cpgc.indexOf(")") == cpgc.length()-1 && cpgc.split("\\(").length == 2){ +// cpgc = cpgc.replace("(", ""); +// cpgc = cpgc.replace(")", ""); +// } +// num = Integer.valueOf(ss); +// } +// } +// } +// System.out.println(cpgc); +// System.out.println(num); + } + public static ArrayList getCPGCMaxAndMix(String str, String gc) {// \\192.168.23.60\\Ʒʱ֤\ϵͳͼֽ\ + String after_shousuo = null; + // position = 0; + ArrayList data = new ArrayList<>(); + try { + List list = new ArrayList<>(); + if (str.indexOf("") != -1) { + + String minNum = "0";//Сֵ + String maxNum = "";//ֵ + String percentage = "";//ռٷֱ + + String[] ss = str.split(""); + for (String s : ss) { + if (s.length() != 0) + { + list.add(s); + } + } + if (list.size() >= 1) { + BigDecimal b0 = null; + BigDecimal b1 = null; + // x ģʽ + if (list.size() == 1) { + + b0 = new BigDecimal(0); + b1 = new BigDecimal(getFirstNum(list.get(0))); + + maxNum = String.valueOf(b0.add(b1)); + } + // x y ģʽ + if (list.size() == 2) { + + b0 = new BigDecimal(getLeftFirstNum((list.get(0)))); + b1 = new BigDecimal(getFirstNum((list.get(1)))); + + + minNum = String.valueOf(b0.subtract(b1)); + maxNum = String.valueOf(b0.add(b1)); + //b1 = new BigDecimal(list.get(1)); + } + + + String v1 = null; + String v2 = null; + if (!" ".equals(gc)) { + BigDecimal b2 = null; + if (gc.indexOf("%") != -1) + { + percentage = getNum((Double.valueOf(gc + .split("%")[0]) / 100) + ""); + b2 = new BigDecimal(getNum((Double.valueOf(gc + .split("%")[0]) / 100) + "")); + } + else + { + percentage = getNum(gc); + b2 = new BigDecimal(getNum(gc)); + } + + v1 = String.valueOf(b0.subtract(new BigDecimal(Double + .toString(b1.multiply(b2).doubleValue())))); + v2 = String.valueOf(b0.add(new BigDecimal(Double + .toString(b1.multiply(b2).doubleValue())))); + data.add(v1);//ռСֵ + data.add(v2);//ռֵ + data.add(minNum);//ռǰСֵ + data.add(maxNum);//ռǰֵ + after_shousuo = str.replace(b1.toString(), + String.valueOf(b1.multiply(b2).doubleValue())); + data.add(percentage); + data.add(after_shousuo); + } else { + v1 = String.valueOf(b0.subtract(b1)); + v2 = String.valueOf(b0.add(b1)); + data.add(v1); + data.add(v2); + data.add(v1); + data.add(v2); + data.add(""); + data.add(""); + } + // int position1 = v1.length() - v1.indexOf(".")-1 ; + // int position2 = v2.length() - v2.indexOf(".")-1 ; + // position = position1>=position2?position1:position2; + + } + return data; + } + //String str1 = str.toUpperCase(); + else if (str.indexOf("~") != -1 || str.indexOf("") != -1) { + String v1 = null; + String v2 = null; + +// BigDecimal b0 = null; +// BigDecimal b1 = null; +// +// b0 = new BigDecimal(getLeftFirstNum(str.split("~")[0])); +// if(str.split("~")[0].indexOf("-") != -1) +// { +// b0 = new BigDecimal("-" + getLeftFirstNum(str.split("~")[0])); +// } +// b1 = new BigDecimal(getFirstNum(str.split("~")[1])); +// if(str.split("~")[1].indexOf("-") != -1) +// { +// b1 = new BigDecimal("-" + getLeftFirstNum(str.split("~")[1])); +// } +// //b1 = new BigDecimal(getFirstNum(str.split("~")[1])); +// +// +// if (!" ".equals(gc)) { +// BigDecimal b2 = null; +// if (gc.indexOf("%") != -1) +// b2 = new BigDecimal(getNum((Double.valueOf(gc +// .split("%")[0]) / 100) + "")); +// else +// b2 = new BigDecimal(getNum(gc)); +// v1 = String.valueOf(b0.subtract(new BigDecimal(Double +// .toString(b1.multiply(b2).doubleValue())))); +// v2 = String.valueOf(b0.add(new BigDecimal(Double +// .toString(b1.multiply(b2).doubleValue())))); +// data.add(v1); +// data.add(v2); +// after_shousuo = str.replace(b1.toString(), +// String.valueOf(b1.multiply(b2).doubleValue())); +// data.add(after_shousuo); +// } else { +// v1 = String.valueOf(b0.subtract(b1)); +// v2 = String.valueOf(b0.add(b1)); +// data.add(v1); +// data.add(v2); +// data.add(""); +// } + + + if (str.indexOf("~") != -1 || str.indexOf("") != -1) { + v1 = getNum(getLeftFirstNum(str.split("~")[0])); + v2 = getNum(getFirstNum(str.split("~")[1])); + if (str.split("~")[0].indexOf("-") != -1) + data.add("-" + v1); + else + data.add(v1); + if (str.split("~")[1].indexOf("-") != -1) + data.add("-" + v2); + else + data.add(v2); + } + + data.add(data.get(0)); + data.add(data.get(1)); + + data.add(""); + data.add(""); + // int position1 = v1.length() - v1.indexOf(".")-1 ; + // int position2 = v2.length() - v2.indexOf(".")-1 ; + // position = position1>=position2?position1:position2; + // after_shousuo = str.split("special")[0]; + return data; + } + else if (str.indexOf("") != -1 || str.indexOf("<") != -1 || str.indexOf("") != -1 ) { + String v1 = null; + + + String percentage = "";//ռٷֱ + + String maxNum = ""; + if (str.indexOf("") >= 0) + { + maxNum = getFirstNum(str.split("")[1]); + } + else if (str.indexOf("<") >= 0) + { + maxNum = getFirstNum(str.split("<")[1]); + } + else if (str.indexOf("") >= 0) + { + maxNum = getFirstNum(str.split("")[1]); + } + + if (!" ".equals(gc)) { + String s1 = getNum(str); + percentage = getNum(gc); + BigDecimal b1 = new BigDecimal(getFirstNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); + v1 = String.valueOf(b1.multiply(b2).doubleValue()); + v1 = String.valueOf(b1.multiply(b2).doubleValue()); + data.add("0"); + data.add(v1); + data.add("0"); + data.add(maxNum); + after_shousuo = str.replace(s1, v1); + data.add(percentage); + data.add(after_shousuo); + } else { + + if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + else if (str.indexOf("<") >= 0) + { + v1 = getFirstNum(str.split("<")[1]); + } + else if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + + //v1 = getFirstNum(str.substring(1, str.length())); + data.add("0"); + data.add(v1); + data.add("0"); + data.add(v1); + data.add(percentage); + data.add(""); + } + // position = v1.length() - v1.indexOf(".")-1 ; + return data; + } + else if ( str.indexOf("") != -1 || str.indexOf(">") != -1 || str.indexOf("") != -1) { + String v1 = null; + String percentage = "";//ռٷֱ + + String minNum = ""; + if (str.indexOf("") >= 0) + { + minNum = getFirstNum(str.split("")[1]); + } + else if (str.indexOf(">") >= 0) + { + minNum = getFirstNum(str.split(">")[1]); + } + else if (str.indexOf("") >= 0) + { + minNum = getFirstNum(str.split("")[1]); + } + + if (!" ".equals(gc) && !"0".equals(gc)) { + String s1 = getNum(str); + percentage = getNum(gc); + + BigDecimal b1 = new BigDecimal(getFirstNum(str)); + BigDecimal b2 = new BigDecimal(getNum(gc)); + // String val = + // String.valueOf(b1.multiply(b2).doubleValue()); + v1 = String.valueOf(b1.divide(b2, 10, + BigDecimal.ROUND_HALF_UP).doubleValue()); + data.add(v1); + data.add(" "); + data.add(minNum); + data.add(" "); + after_shousuo = str.replace(s1, v1); + data.add(percentage); + data.add(after_shousuo); + } else { + + if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + else if (str.indexOf(">") >= 0) + { + v1 = getFirstNum(str.split(">")[1]); + } + else if (str.indexOf("") >= 0) + { + v1 = getFirstNum(str.split("")[1]); + } + //v1 = getFirstNum(str.substring(str.indexOf(">")+1,str.length())); + + + //v1 = getFirstNum(str.substring(1, str.length())); + + data.add(v1); + data.add(" "); + data.add(v1); + data.add(" "); + data.add(percentage); + data.add(""); + } + // position = v1.length() - v1.indexOf(".")-1 ; + return data; + } + else if (isContainChinese(str)) { + data.add("OK"); + data.add("OK"); + data.add("OK"); + data.add("OK"); + data.add(""); + data.add(""); + return data; + } + else if(!haveTwoNum(str)) + { + String num = getLeftFirstNum(str); + String numStr = getLeftFirstNum(str);//ռǰֵ + String percentage = "";//ռٷֱ + if (!" ".equals(gc)) { + String s1 = getNum(str); + percentage = getNum(gc); + + BigDecimal b1 = new BigDecimal(num); + BigDecimal b2 = new BigDecimal(getNum(gc)); + //v1 = String.valueOf(b1.multiply(b2).doubleValue()); + num = String.valueOf(b1.multiply(b2).doubleValue()); + after_shousuo = str.replace(s1, num); + } + else + { + after_shousuo = ""; + } + if(str.indexOf("max") >=0 || str.indexOf("MAX") >=0 || str.indexOf("Max") >=0) + { + data.add("0"); + data.add(num); + data.add("0"); + data.add(numStr); + } + else if(str.indexOf("min") >=0 || str.indexOf("MIN") >=0 || str.indexOf("Min") >=0) + { + data.add(num); + data.add(""); + data.add(numStr); + data.add(""); + } + else + { + data.add("0"); + data.add(num); + data.add("0"); + data.add(numStr); + } + data.add(percentage); + data.add(after_shousuo); + } + else{ + data.add(""); + data.add(""); + data.add(""); + data.add(""); + data.add(""); + data.add(""); + return data; + } + + } catch (Exception e) { + System.out.println(e.toString()); + data.add(" "); + data.add(" "); + data.add(""); + data.add(""); + data.add(""); + data.add(""); + } + return data; + } + /** + * ȡұߵһ + * + * */ + public static String getLeftFirstNum(String str) + { + String ss = ""; + boolean isNum = false; + + for (int i = str.length() - 1; i >= 0; i--) + { + int intAsciiCode = str.charAt(i); + if ((intAsciiCode >= 48 && intAsciiCode <= 57) || intAsciiCode == 46) + { + ss = str.charAt(i)+ ss ; + isNum = true; + } + else + { + if (isNum) + { + break; + } + } + } + return ss; + + } + /** + * жǷһϵ + * + * */ + public static boolean haveTwoNum(String str) + { + //ȡұߵһ + String leftFirstNum = getLeftFirstNum(str); + if(leftFirstNum == null || str.equals("")) + { + return false; + } + //Ϊգұߵһֲ + String[] nums = str.split(leftFirstNum); + if(nums.length >= 1) + { + //ȡַֺұߵһ + String leftFirstNumber = getLeftFirstNum(nums[0]); + if(leftFirstNum != null && !leftFirstNumber.equals("")) + { + return true; + } + } + return false; + } + + private static String getFirstNum(String str) { + String ss = ""; + boolean isNum = false; + for (int i = 0; i < str.length(); i++) {// c < 48 || c > 57 + if ((str.charAt(i) >= 48 && str.charAt(i) <= 57) + || str.charAt(i) == 46) { + ss = ss + str.charAt(i); + isNum = true; + } else { + if (isNum) { + break; + } + } + } + return ss; + + } + + private static void updateCheckTable(String productID,String meopId,String type, + ArrayList checkTables, List assignUserList) { + int version = 0; + @SuppressWarnings("unchecked") + ArrayList cts = checkTables; + InputStream input = new BufferedInputStream( + TMom026CheckDataTempOperation.class.getResourceAsStream("sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ȡݿ + SqlUtilT.getTCConnection(); + ResultSet rs = null; + ResultSet rs1 = null; + //֪ͨڵѡ˶ӦĹ + ResultSet rsMeop = null; + String sql = null; + + // for(CheckTable ct:cts){ + // System.out.println(ct); + // } + + if (cts.size() != 0) { + String WHERE = "where rb3_meop_id = '" + meopId + + "' and rb3_type = '" + type + "'"; + sql = "select * from RB3_CHECK_TABLE_TEMP " + WHERE; + String latestVersion_sql = "select max(rb3_version) rb3_version from RB3_CHECK_TABLE_TEMP " + + WHERE; + // System.out.println(sql); + String userId = ""; + for (String assignUser : assignUserList) { + userId = userId + "'"+ assignUser +"',"; + } + System.out.print("ûID"+userId+"\n"); + + String meopSelectSql = "SELECT RB3_MEOPID,RB3_GCMC,RB3_USER_ID,TYPE FROM tc10.RB3_CONTROLSYNERGY_ORNULL_VIEW " + + "WHERE RB3_USER_ID IN ("+ userId.substring(0,userId.length()-1) +") AND RB3_MEOPID LIKE '"+ productID +"_%'"; + + //System.out.print("SQL䣺"+meopSelectSql+"\n"); + try { + rs = SqlUtilT.read(sql); + rs1 = SqlUtilT.read(latestVersion_sql); + rsMeop = SqlUtilT.read(meopSelectSql); + //ȡ֪ͨڵѡ˶ӦĹ + List meopList = new ArrayList(); + while (rsMeop.next()) + { + meopList.add(rsMeop.getString("RB3_MEOPID")); + } + + while (rs1.next()) { + String s_version = rs1.getString("RB3_VERSION"); + if (s_version != null) { + version = Integer.valueOf(s_version); + + // +// if(meopList.contains(meopId)) +// { + String deleteSql = "delete from RB3_CHECK_TABLE_TEMP where RB3_PRODUCT_ID = '" + + productID + + "' and rb3_meop_id = '" + + meopId + + "' and rb3_type = '" + + type + + "' and rb3_version = '" + version + "'"; + //System.out.println("deleteSql==============>"+deleteSql); + SqlUtilT.delete(deleteSql); +// } + version++; + } + break; + } + String insertSQL = pro.getProperty("INSERTCHECKTABLESQL"); + // System.out.println(insertSQL); + for (int i = 0; i < cts.size(); i++) { +// if(!meopList.contains(cts.get(i).getMeopId())) +// { +// continue; +// } + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), + cts.get(i).getProductId(), + cts.get(i).getProductName(), + cts.get(i).getMeopId(), + cts.get(i).getMeopName(), + cts.get(i).getSerialNo(), + cts.get(i).getCp(), cts.get(i).getCpgc(), + cts.get(i).getMax(), cts.get(i).getMin(), + cts.get(i).getClff(), cts.get(i).getRl(), + cts.get(i).getPl(), cts.get(i).getTstx(), + cts.get(i).getType(), + String.valueOf(version), + cts.get(i).getFzr(), + cts.get(i).getMeopNo(), cts.get(i).getHh(),"","" + ,cts.get(i).getAfterMin(),cts.get(i).getAfterMax(),cts.get(i).getPercentage() + ,cts.get(i).getAfterGcgc()}, insertSQL); + } + + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + } + } + } + + private static String getData(String str) { + if (str != null) + return str.split("\n")[0].split("\r")[0].replace(" ", ""); + return " "; + } + + private static String getNum(String ptCasinoMsg) { + String returnAmounts [] = new String [4]; + if(!ptCasinoMsg.equals("")){ + ptCasinoMsg = ptCasinoMsg.replace(" | ", " "); + String [] amounts = ptCasinoMsg.split(" "); + for(int i=0;i privilegeList = new ArrayList(); + + public TMom027EntrustmentFormCommand(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + } + + public boolean getPrivilege() { + try { + // ȡѡõȨ + String[] privileges = TMomMethodUtil.getPreferenceValues("Cust_EntrustmentForm_Privilege"); + TCComponentUser sessionUser = session.getUser(); + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + + Map privilegeMap = new HashMap(); + + for (int i = 0; i < privileges.length; i++) { + String[] privilegeNode = privileges[i].split("-"); + if (privilegeNode[1].indexOf(",") > 0) { + privilegeMap.put(privilegeNode[0], privilegeNode[1].split(",")); + } else { + privilegeMap.put(privilegeNode[0], new String[] { privilegeNode[1] }); + } + } + ((TCComponentItemRevision) this.comp).refresh(); + TCComponent[] items = ((TCComponentItemRevision) this.comp).getRelatedComponents("process_stage_list"); + if (items.length > 0) { + isHaveProcess = true; + for (int i = 0; i < items.length; i++) { + items[i].refresh(); + // ȡǰڽڵ + TCComponent[] taskItems = items[i].getRelatedComponents("fnd0StartedTasks"); + + for (int j = 0; j < taskItems.length; j++) { + // ȡǰڽڵ + String name = taskItems[j].getStringProperty("current_name"); + String type = taskItems[j].getStringProperty("task_type"); + // ȡ + TCComponent[] users = taskItems[j].getReferenceListProperty("valid_signoffs"); + + if (users.length > 0) { + for (TCComponent tcComponent : users) { + System.out.println("UID" + tcComponent.getUid()); + TCComponent user = tcComponent.getReferenceProperty("fnd0Performer"); + String userId = user.getStringProperty("user_id"); + System.out.println("ˣ" + userId); + if (sessionUser.getUserId().equals(userId)) { + String[] nodePrivilege = privilegeMap.get(name); + for (int k = 0; k < nodePrivilege.length; k++) { + privilegeList.add(nodePrivilege[k]); + } + break; + } + } + } + if(type.equals("EPMDoTask")) + { + //ȡִ + TCComponent user = taskItems[j].getReferenceProperty("fnd0Performer"); + String userId = user.getStringProperty("user_id"); + System.out.println("ˣ" + userId); + if (sessionUser.getUserId().equals(userId)) { + String[] nodePrivilege = privilegeMap.get(name); + for (int k = 0; k < nodePrivilege.length; k++) { + privilegeList.add(nodePrivilege[k]); + } + break; + } + } + + + } + } + } else { + // жǷǰ汾 + if (sessionUser.getUserId().equals(userName)) { + privilegeList.add("ίϢ"); + privilegeList.add("ĿϢ"); + privilegeList.add("ƷϢ"); + privilegeList.add("Ϣ"); + privilegeList.add("ί"); + privilegeList.add("Ʒ"); + privilegeList.add(""); + privilegeList.add("ϴ"); + privilegeList.add(""); + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + + // ѡжPUIDȡ + ResultSet rs = null; + InputStream input = null; + try { + bean.setPuid(comp.getUid()); + bean.setItemId(comp.getProperty("item_id")); + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_ENTRUSTMENTFORMSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + isHave = true; + bean.setP1(rs.getString("P1")); + bean.setP2(rs.getString("P2")); + bean.setP3(rs.getString("P3")); + bean.setP4(rs.getString("P4")); + bean.setP5(rs.getString("P5")); + bean.setP6(rs.getString("P6")); + bean.setP7(rs.getString("P7")); + bean.setP8(rs.getString("P8")); + bean.setP9(rs.getString("P9")); + bean.setP10(rs.getString("P10")); + bean.setP11(rs.getString("P11")); + bean.setP12(rs.getString("P12")); + bean.setP13(rs.getString("P13")); + bean.setP14(rs.getString("P14")); + bean.setP15(rs.getString("P15")); + bean.setP16(rs.getString("P16")); + bean.setP17(rs.getString("P17")); + bean.setP18(rs.getString("P18")); + bean.setP19(rs.getString("P19")); + bean.setP20(rs.getString("P20")); + bean.setP21(rs.getString("P21")); + bean.setP22(rs.getString("P22")); + bean.setP23(rs.getString("P23")); + bean.setP24(rs.getString("P24")); + bean.setP25(rs.getString("P25")); + bean.setP26(rs.getString("P26")); + bean.setP27(rs.getString("P27")); + bean.setP28(rs.getString("P28")); + bean.setP29(rs.getString("P29")); + bean.setP30(rs.getString("P30")); + bean.setP31(rs.getString("P31")); + bean.setP32(rs.getString("P32")); + bean.setP33(rs.getString("P33")); + bean.setP34(rs.getString("P34")); + bean.setP35(rs.getString("P35")); + bean.setP36(rs.getString("P36")); + bean.setP37(rs.getString("P37")); + bean.setP38(rs.getString("P38")); + bean.setP39(rs.getString("P39")); + bean.setP40(rs.getString("P40")); + bean.setP41(rs.getString("P41")); + bean.setP42(rs.getString("P42")); + bean.setP43(rs.getString("P43")); + bean.setP44(rs.getString("P44")); + bean.setP45(rs.getString("P45")); + bean.setP46(rs.getString("P46")); + bean.setP47(rs.getString("P47")); + bean.setP48(rs.getString("P48")); + bean.setP49(rs.getString("P49")); + bean.setP50(rs.getString("P50")); + bean.setP51(rs.getString("P51")); + bean.setP52(rs.getString("P52")); + bean.setP53(rs.getString("P53")); + bean.setP54(rs.getString("P54")); + bean.setP55(rs.getString("P55")); + bean.setP56(rs.getString("P56")); + bean.setP57(rs.getString("P57")); + bean.setP58(rs.getString("P58")); + bean.setP59(rs.getString("P59")); + bean.setP60(rs.getString("P60")); + bean.setP61(rs.getString("P61")); + bean.setP62(rs.getString("P62")); + bean.setP63(rs.getString("P63")); + bean.setP64(rs.getString("P64")); + bean.setP65(rs.getString("P65")); + bean.setP66(rs.getString("P66")); + bean.setP67(rs.getString("P67")); + bean.setP68(rs.getString("P68")); + bean.setP69(rs.getString("P69")); + bean.setP70(rs.getString("P70")); + bean.setP71(rs.getString("P71")); + bean.setP72(rs.getString("P72")); + + } + } 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(); + } + getPrivilege(); + new Thread() { + @Override + public void run() { + new TMom027EntrustmentFormDialog(app, session, comp, bean, isHave, privilegeList, isHaveProcess); + super.run(); + } + }.start(); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormDialog.java b/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormDialog.java new file mode 100644 index 0000000..868a60d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormDialog.java @@ -0,0 +1,1942 @@ +package com.connor.renben.process.plm.tmom027; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.ServiceUI; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.BorderFactory; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.JViewport; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.connor.renben.process.plm.util.TreeComboBox; +import com.spire.xls.Workbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.commands.userpreferences.IEOptionsPanel; +import com.teamcenter.rac.common.implicitco.ImplicitCheckOutOperation; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCReservationService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.scrollpage.ScrollPagePane; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom027EntrustmentFormDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp;// ѡеίе汾 + private TCComponentItemRevision itemRevision;// ѡеίе汾 + private EntrustmentFormBean bean; + private boolean isHave; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private List privilegeList;// ڵȨ + private boolean isHaveProcess; + + // ؼ + private JLabel idLabel;// ίе + private JTextField idField; + + private JLabel titleLabel;// + + // ѡ + private JTabbedPane tabbedPane; + + // ؼ + private JLabel p1Label;// + private JAutoCompleteComboBox p1ComboBox; + private JLabel p2Label;// ⲿ + private MultiComboBox p2ComboBox; + private JLabel p3Label;// ίеλ + private JTextField p3Field; + private JLabel p4Label;// ί + private JTextField p4Field; + private JLabel p5Label;// ίеַ + private JTextField p5Field; + private JLabel p6Label;// ίϵʽ + private JTextField p6Field; + private JLabel p7Label;// ί + private DateButton p7DateButton; + private JLabel p8Label;// ϣʱ + private DateButton p8DateButton; + private JLabel p9Label;// ; + private JTextField p9ComboBox; + private JLabel p10Label;// + private JAutoCompleteComboBox p10ComboBox; + private JLabel p11Label;// ͻ + private JTextField p11Field; + private JLabel p12Label;// Ŀ + private JTextField p12Field; + private JLabel p13Label;// ͻȼ + private JTextField p13Field; + private JLabel p14Label;// Ŀ + private JTextField p14Field; + private JLabel p15Label;// Ӧ + private TreeComboBox p15ComboBox; + private JLabel p16Label;// Ŀȼ + private JTextArea p16Field; + private JLabel p17Label;// Ʒ + private JTextField p17Field; + private JLabel p18Label;// Ϻ + private JTextField p18Field; + private JLabel p19Label;// Ʒ + private JAutoCompleteComboBox p19ComboBox; + private JLabel p20Label;// λ + private JAutoCompleteComboBox p20ComboBox; + private JLabel p21Label;// Ʒ + private JTextField p21Field; + private JLabel p22Label;// Ʒ״̬ + private JAutoCompleteComboBox p22ComboBox; + private JLabel p23Label;// + private JTextField p23Field; + private JLabel p24Label;// Ʒ + private JTextField p24Field; + private JLabel p25Label;// Ʒʽ + private JAutoCompleteComboBox p25ComboBox; + private JLabel p26Label;// ʹòλ + private JTextField p26Field; + private JLabel p27Label;// ʹû + private JTextField p27Field; + private JLabel p28Label;// غ + private JTextField p28Field; + private JLabel p29Label;// غ + private JTextField p29Field; + private JLabel p30Label;// תʽ + private JTextField p30Field; + private JLabel p31Label;// תٶ + private JTextField p31Field; + private JLabel p32Label;// ¶ + private JTextField p32Field; + private JLabel p33Label;// ί + private JTextArea p33Field; + private Button p33Button;// ίѡť + + private JLabel p34Label;// Ʒѵֳ + private JAutoCompleteComboBox p34Field; + private JLabel p35Label;// ʱ + private DateButton p35DateButton; + private JLabel p36Label;// + private JTextField p36Field; + private JLabel p37Label;// Ʒ˽ + private JAutoCompleteComboBox p37ComboBox; + private JLabel p38Label;// Ԥʱ + private DateButton p38DateButton; + private JLabel p39Label;// ˻ԭ + private JTextField p39ComboBox; + private JLabel p40Label;// + private JTextField p40Field; + private JLabel p41Label;// Э + private JTextField p41Field; + private JLabel p42Label;// ƻʼʱ + private DateButton p42DateButton; + private JLabel p43Label;// ƻʱ + private DateButton p43DateButton; + // ӡť + private Button print1Button;// ӡίе + private Button print2Button;// ӡƷʶ + + private JLabel p44Label;// ʵʱ + private DateButton p44DateButton; + private JLabel p45Label;// ˵ + private JTextField p45Field; + private JLabel p46Label;// ʱ + private DateButton p46DateButton; + private JLabel p47Label;// Ա + private JTextField p47Field; + private JLabel p48Label;// ˽ + private JTextField p48Field; + private JLabel p49Label;// Ʒ + private JAutoCompleteComboBox p49ComboBox; + + private JLabel p50Label;// Ʒѵֳ + private JAutoCompleteComboBox p50Field; + private JLabel p51Label;// ʱ + private DateButton p51DateButton; + private JLabel p52Label;// + private JTextField p52Field; + private JLabel p53Label;// Ʒ˽ + private JAutoCompleteComboBox p53ComboBox; + private JLabel p54Label;// Ԥʱ + private DateButton p54DateButton; + private JLabel p55Label;// ˻ԭ + private JTextField p55ComboBox; + private JLabel p56Label;// + private JTextField p56Field; + private JLabel p57Label;// Э + private JTextField p57Field; + private JLabel p58Label;// ƻʼʱ + private DateButton p58DateButton; + private JLabel p59Label;// ƻʱ + private DateButton p59DateButton; + // ӡť + private Button print3Button;// ӡίе + private Button print4Button;// ӡƷʶ + + private JLabel p60Label;// ʵʱ + private DateButton p60DateButton; + private JLabel p61Label;// ˵ + private JTextField p61Field; + private JLabel p62Label;// ʱ + private DateButton p62DateButton; + private JLabel p63Label;// Ա + private JTextField p63Field; + private JLabel p64Label;// ˽ + private JTextField p64Field; + private JLabel p65Label;// Ʒ + private JAutoCompleteComboBox p65ComboBox; + + private JLabel p66Label;// ע + private JTextField p66Field; + private JLabel p67Label;// λ + private JTextField p67Field; + private JLabel p68Label;// λ + private JTextField p68Field; + + private JPanel partPanel; + private JPanel partPanel1; + private JPanel partPanel2; + private JPanel partPanel3; + private JPanel partPanel4; + private JPanel partPanel5; + private JPanel partPanel6; + private JPanel partPanel7; + private JPanel partPanel8; + private JPanel partPanel9; + private JPanel partPanel10; + private JPanel partPanel11; + private JPanel partPanel12; + + // 水ť + private JPanel rootPanel; + private Button okButton; + private Button celButton; + + // ίݴ + private EntrustingContentDialog entrustingContentDialog; + + public TMom027EntrustmentFormDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + EntrustmentFormBean bean, boolean isHave, List privilegeList, boolean isHaveProcess) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.bean = bean; + this.isHave = isHave; + this.privilegeList = privilegeList; + this.isHaveProcess = isHaveProcess; + try { + this.itemRevision.refresh(); + if(this.itemRevision.getStringProperty("object_desc").compareTo("Ѵ") == 0) + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("gwtdzzbbj27_display.TITLE"), "", MessageBox.ERROR); + return; + } + else + { + init(); +// TCReservationService localTCReservationService = this.session.getReservationService(); +// localTCReservationService.siteCheckIn(new TCComponent[] {this.itemRevision}); + +// TCComponentForm form = null; + //ǩ +// ReservationService service=ReservationService.getService((TCSession)app.getSession()); +// service.checkin(new TCComponent[] {(TCComponent) app.getTargetComponent()}); + //ǩ +// new ReserveOperation(new AIFComponentContext(this.itemRevision, +// this.itemRevision, "context")).executeModeless(); + + this.itemRevision.lock(); + this.itemRevision.setStringProperty("object_desc", "Ѵ"); + this.itemRevision.save(); + this.itemRevision.refresh(); + this.itemRevision.unlock(); + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /*** + * ʼ + * + * @throws IOException + * @throws FileNotFoundException + */ + private void init() throws FileNotFoundException, Exception { + //ȡʻ + 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("jcfxwtd27_display.TITLE")); + this.setPreferredSize(new Dimension(980, 830)); + // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + //this.setAlwaysOnTop(true); // ö + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + try { + itemRevision.lock(); + itemRevision.setStringProperty("object_desc", ""); + itemRevision.save(); + itemRevision.refresh(); + itemRevision.unlock(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); + // ʼⲿֿؼ + JPanel titlePanel = new JPanel(new PropertyLayout()); + this.titleLabel = new JLabel(rb.getString("jcfxwtd27_display.TITLE"), JLabel.CENTER); + this.titleLabel.setFont(new Font("", 1, 18)); + this.titleLabel.setPreferredSize(new Dimension(950, 20)); + // TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + JLabel itemLabel = new JLabel(rb.getString("wtdbh27_display.TITLE") + this.comp.getProperty("item_id"), JLabel.RIGHT); + itemLabel.setPreferredSize(new Dimension(950, 20)); + titlePanel.add("1.1.left.top", itemLabel); + titlePanel.add("2.1.left.top", titleLabel); + + // ίϢһ + JPanel panel1 = new JPanel(new FlowLayout()); + this.p1Label = new JLabel(rb.getString("jclx27_display.TITLE")); + this.p1Label.setForeground(Color.RED); + this.p1Label.setPreferredSize(new Dimension(50, 30)); + this.p1ComboBox = new JAutoCompleteComboBox(); + this.p1ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p1ComboBox.setSelectedItem(bean.getP1()); + this.p2Label = new JLabel(rb.getString("jcbm27_display.TITLE")); + this.p2Label.setForeground(Color.RED); + this.p2Label.setPreferredSize(new Dimension(85, 30)); + File file = TMomMethodUtil.getFile(session, "ίеѡ", "MSExcelX"); + this.p2ComboBox = new MultiComboBox(new String[] { "", "Ϸ" }, + bean.getP2() == null ? new String[] { "" } : bean.getP2().split(",")); + this.p2ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p2ComboBox.editor.setText(bean.getP2()); + this.p3Label = new JLabel(rb.getString("wtdw27_display.TITLE")); + this.p3Label.setForeground(Color.RED); + this.p3Label.setPreferredSize(new Dimension(50, 30)); + this.p3Field = new JTextField(bean.getP3()); + this.p3Field.setPreferredSize(new Dimension(150, 30)); + this.p4Label = new JLabel(rb.getString("wtr27_display.TITLE")); + this.p4Label.setForeground(Color.RED); + this.p4Label.setPreferredSize(new Dimension(80, 30)); + this.p4Field = new JTextField(bean.getP4()); + this.p4Field.setPreferredSize(new Dimension(150, 30)); + panel1.add(this.p1Label); + panel1.add(this.p1ComboBox); + panel1.add(this.p2Label); + panel1.add(this.p2ComboBox); + panel1.add(this.p3Label); + panel1.add(this.p3Field); + panel1.add(this.p4Label); + panel1.add(this.p4Field); + + // ίϢڶ + JPanel panel2 = new JPanel(new FlowLayout()); + this.p5Label = new JLabel(rb.getString("wtdz27_display.TITLE")); + this.p5Label.setForeground(Color.RED); + this.p5Field = new JTextField(bean.getP5()); + this.p5Field.setPreferredSize(new Dimension(150, 30)); + this.p6Label = new JLabel(rb.getString("wtrlxfs27_display.TITLE")); + this.p6Label.setForeground(Color.RED); + this.p6Label.setPreferredSize(new Dimension(85, 30)); + this.p6Field = new JTextField(bean.getP6()); + this.p6Field.setPreferredSize(new Dimension(150, 30)); + this.p7Label = new JLabel(rb.getString("wtrq27_display.TITLE")); + this.p7Label.setForeground(Color.RED); + this.p7DateButton = new DateButton(dateFormat); + this.p7DateButton.setPreferredSize(new Dimension(150, 30)); + this.p7DateButton.setText(bean.getP7()); + this.p8Label = new JLabel(rb.getString("xwwcsj27_display.TITLE")); + this.p8Label.setForeground(Color.RED); + this.p8Label.setPreferredSize(new Dimension(80, 30)); + this.p8DateButton = new DateButton(dateFormat); + this.p8DateButton.setPreferredSize(new Dimension(150, 30)); + this.p8DateButton.setText(bean.getP8()); + panel2.add(this.p5Label); + panel2.add(this.p5Field); + panel2.add(this.p6Label); + panel2.add(this.p6Field); + panel2.add(this.p7Label); + panel2.add(this.p7DateButton); + panel2.add(this.p8Label); + panel2.add(this.p8DateButton); + // ίϢ + JPanel panel3 = new JPanel(new FlowLayout()); + this.p9Label = new JLabel(rb.getString("jcyt27_display.TITLE")); + this.p9Label.setForeground(Color.RED); + this.p9ComboBox = new JTextField(); + this.p9ComboBox.setPreferredSize(new Dimension(395, 30)); + this.p9ComboBox.setText(bean.getP9()); + this.p10Label = new JLabel(rb.getString("jcjg27_display.TITLE")); + this.p10Label.setForeground(Color.RED); + this.p10ComboBox = new JAutoCompleteComboBox(); + this.p10ComboBox.setPreferredSize(new Dimension(395, 30)); + this.p10ComboBox.setSelectedItem(bean.getP10()); + panel3.add(this.p9Label); + panel3.add(this.p9ComboBox); + panel3.add(this.p10Label); + panel3.add(this.p10ComboBox); + + partPanel = new JPanel(new PropertyLayout()); + partPanel + .setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "1.ίϢ Entrust information")); + partPanel.add("1.1.left.top", panel1); + partPanel.add("2.1.left.top", panel2); + partPanel.add("3.1.left.top", panel3); + + // ĿϢϢһ + JPanel panel4 = new JPanel(new FlowLayout()); + this.p11Label = new JLabel(rb.getString("khmc_display.TITLE")); + this.p11Label.setForeground(Color.RED); + this.p11Label.setPreferredSize(new Dimension(50, 30)); + this.p11Field = new JTextField(bean.getP11()); + this.p11Field.setPreferredSize(new Dimension(285, 30)); + this.p12Label = new JLabel(rb.getString("xmdj27_display.TITLE")); + this.p12Label.setForeground(Color.RED); + this.p12Label.setPreferredSize(new Dimension(50, 30)); + this.p12Field = new JTextField(bean.getP12()); + this.p12Field.setPreferredSize(new Dimension(100, 30)); + this.p13Label = new JLabel(rb.getString("khdj27_display.TITLE")); + this.p13Label.setForeground(Color.RED); + this.p13Label.setPreferredSize(new Dimension(50, 30)); + this.p13Field = new JTextField(bean.getP13()); + this.p13Field.setPreferredSize(new Dimension(100, 30)); + this.p14Label = new JLabel(rb.getString("xmbh27_display.TITLE")); + this.p14Label.setForeground(Color.RED); + this.p14Label.setPreferredSize(new Dimension(80, 30)); + this.p14Field = new JTextField(bean.getP14()); + this.p14Field.setPreferredSize(new Dimension(150, 30)); + panel4.add(this.p11Label); + panel4.add(this.p11Field); + panel4.add(this.p12Label); + panel4.add(this.p12Field); + panel4.add(this.p13Label); + panel4.add(this.p13Field); + panel4.add(this.p14Label); + panel4.add(this.p14Field); + + // ĿϢڶ + JPanel panel5 = new JPanel(new FlowLayout()); + this.p15Label = new JLabel(rb.getString("yyly27_display.TITLE")); + this.p15Label.setForeground(Color.RED); + this.p15Label.setPreferredSize(new Dimension(50, 60)); + this.p15ComboBox = new TreeComboBox(new String[] { bean.getP15() }, new String[] { bean.getP15() }, session); + this.p15ComboBox.setPreferredSize(new Dimension(395, 60)); + this.p15ComboBox.editor.setText(bean.getP15()); + this.p16Label = new JLabel(rb.getString("xmmc27_display.TITLE")); + this.p16Label.setForeground(Color.RED); + this.p16Label.setPreferredSize(new Dimension(50, 60)); + this.p16Field = new JTextArea(bean.getP16()); + JScrollPane scrollPane1 = new JScrollPane(); // jtaӹ + scrollPane1.setPreferredSize(new Dimension(395, 60)); + scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane1.setViewportView(this.p16Field); + // this.p16Field.setPreferredSize(new Dimension(395, 60)); + panel5.add(this.p15Label); + panel5.add(this.p15ComboBox); + panel5.add(this.p16Label); + panel5.add(scrollPane1); + + partPanel1 = new JPanel(new PropertyLayout()); + partPanel1.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "2.ĿϢ Item information")); + partPanel1.add("1.1.left.top", panel4); + partPanel1.add("2.1.left.top", panel5); + + // ƷϢһ + JPanel panel6 = new JPanel(new FlowLayout()); + this.p17Label = new JLabel(rb.getString("cph27_display.TITLE")); + this.p17Label.setForeground(Color.RED); + this.p17Label.setPreferredSize(new Dimension(50, 30)); + this.p17Field = new JTextField(bean.getP17()); + this.p17Field.setPreferredSize(new Dimension(395, 30)); + this.p18Label = new JLabel(rb.getString("wlh27_display.TITLE")); + this.p18Label.setForeground(Color.RED); + this.p18Label.setPreferredSize(new Dimension(45, 30)); + this.p18Field = new JTextField(bean.getP18()); + this.p18Field.setPreferredSize(new Dimension(395, 30)); + + panel6.add(this.p17Label); + panel6.add(this.p17Field); + panel6.add(this.p18Label); + panel6.add(this.p18Field); + + // ƷϢڶ + this.p19Label = new JLabel(rb.getString("cplx27_display.TITLE")); + this.p19Label.setForeground(Color.RED); + // this.p19Label.setPreferredSize(new Dimension(50, 30)); + this.p19ComboBox = new JAutoCompleteComboBox(); + this.p19ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p19ComboBox.setSelectedItem(bean.getP19()); + this.p20Label = new JLabel(rb.getString("scdw27_display.TITLE")); + this.p20Label.setForeground(Color.RED); + this.p20Label.setPreferredSize(new Dimension(85, 30)); + this.p20ComboBox = new JAutoCompleteComboBox(); + this.p20ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p20ComboBox.setSelectedItem(bean.getP20()); + JPanel panel7 = new JPanel(new FlowLayout()); + this.p21Label = new JLabel(rb.getString("ypsl27_display.TITLE")); + this.p21Label.setForeground(Color.RED); + this.p21Field = new JTextField(bean.getP21()); + this.p21Field.setPreferredSize(new Dimension(150, 30)); + this.p22Label = new JLabel(rb.getString("ypzt27_display.TITLE")); + this.p22Label.setForeground(Color.RED); + this.p22Label.setPreferredSize(new Dimension(80, 30)); + this.p22ComboBox = new JAutoCompleteComboBox(); + this.p22ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p22ComboBox.setSelectedItem(bean.getP22()); + + panel7.add(this.p19Label); + panel7.add(this.p19ComboBox); + panel7.add(this.p20Label); + panel7.add(this.p20ComboBox); + panel7.add(this.p21Label); + panel7.add(this.p21Field); + panel7.add(this.p22Label); + panel7.add(this.p22ComboBox); + // ƷϢ + this.p23Label = new JLabel(rb.getString("wldh27_display.TITLE")); + this.p23Label.setForeground(Color.RED); + if (bean.getP23() == null || bean.getP23().isEmpty()) { + this.p23Field = new JTextField("/"); + } else { + this.p23Field = new JTextField(bean.getP23()); + } + this.p23Field.setPreferredSize(new Dimension(393, 30)); + this.p24Label = new JLabel(rb.getString("ypbh27_display.TITLE")); + this.p24Label.setForeground(Color.RED); + this.p24Label.setPreferredSize(new Dimension(50, 30)); + if (bean.getP24() == null || bean.getP24().isEmpty()) { + this.p24Field = new JTextField("/"); + } else { + this.p24Field = new JTextField(bean.getP24()); + } + this.p24Field.setPreferredSize(new Dimension(150, 30)); + JPanel panel8 = new JPanel(new FlowLayout()); + this.p25Label = new JLabel(rb.getString("ypclfs27_display.TITLE")); + this.p25Label.setForeground(Color.RED); + this.p25Label.setPreferredSize(new Dimension(80, 30)); + this.p25ComboBox = new JAutoCompleteComboBox(); + this.p25ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p25ComboBox.setSelectedItem(bean.getP25()); + panel8.add(this.p23Label); + panel8.add(this.p23Field); + panel8.add(this.p24Label); + panel8.add(this.p24Field); + panel8.add(this.p25Label); + panel8.add(this.p25ComboBox); + + partPanel2 = new JPanel(new PropertyLayout()); + partPanel2 + .setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "3.ƷϢ Product information")); + partPanel2.add("1.1.left.top", panel6); + partPanel2.add("2.1.left.top", panel7); + partPanel2.add("3.1.left.top", panel8); + + // Ϣһ + JPanel panel9 = new JPanel(new FlowLayout()); + this.p26Label = new JLabel(rb.getString("sybw27_display.TITLE")); + this.p26Label.setPreferredSize(new Dimension(50, 30)); + this.p26Field = new JTextField(bean.getP26()); + this.p26Field.setPreferredSize(new Dimension(150, 30)); + this.p27Label = new JLabel(rb.getString("syhj27_display.TITLE")); + this.p27Label.setPreferredSize(new Dimension(85, 30)); + this.p27Field = new JTextField(bean.getP27()); + this.p27Field.setPreferredSize(new Dimension(150, 30)); + this.p28Label = new JLabel(rb.getString("gzzh27_display.TITLE")); + this.p28Label.setPreferredSize(new Dimension(50, 30)); + this.p28Field = new JTextField(bean.getP28()); + this.p28Field.setPreferredSize(new Dimension(150, 30)); + this.p29Label = new JLabel(rb.getString("zhlx27_display.TITLE")); + this.p29Label.setPreferredSize(new Dimension(80, 30)); + this.p29Field = new JTextField(bean.getP29()); + this.p29Field.setPreferredSize(new Dimension(150, 30)); + panel9.add(this.p26Label); + panel9.add(this.p26Field); + panel9.add(this.p27Label); + panel9.add(this.p27Field); + panel9.add(this.p28Label); + panel9.add(this.p28Field); + panel9.add(this.p29Label); + panel9.add(this.p29Field); + + // Ϣڶ + JPanel panel10 = new JPanel(new FlowLayout()); + this.p30Label = new JLabel(rb.getString("xzfs27_display.TITLE")); + this.p30Field = new JTextField(bean.getP30()); + this.p30Field.setPreferredSize(new Dimension(150, 30)); + this.p31Label = new JLabel(rb.getString("xzsd27_display.TITLE")); + this.p31Label.setPreferredSize(new Dimension(85, 30)); + this.p31Field = new JTextField(bean.getP31()); + this.p31Field.setPreferredSize(new Dimension(150, 30)); + this.p32Label = new JLabel(rb.getString("gzwd27_display.TITLE")); + this.p32Field = new JTextField(bean.getP32()); + this.p32Field.setPreferredSize(new Dimension(150, 30)); + panel10.add(this.p30Label); + panel10.add(this.p30Field); + panel10.add(this.p31Label); + panel10.add(this.p31Field); + panel10.add(this.p32Label); + panel10.add(this.p32Field); + + partPanel3 = new JPanel(new PropertyLayout()); + partPanel3.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), + "4.Ϣ Other information(עҪʱд֬ʱ)")); + partPanel3.add("1.1.left.top", panel9); + partPanel3.add("2.1.left.top", panel10); + + // ίݵһ + JPanel panel11 = new JPanel(new FlowLayout()); + // this.p33Label = new JLabel("תʽ"); + List p33Values = ExcelUtil07.readExcelByEntrustment(file, "ί"); + String[] p33Value = new String[0]; + if (bean.getP33() != null) { + p33Value = bean.getP33().split(","); + } + this.p33Field = new JTextArea(); + this.p33Field.setText(bean.getP33()); + this.p33Field.setLineWrap(true); + // this.p33Field.setWrapStyleWord(true); + // this.p33Field.setBorder(p32Field.getBorder()); + this.p33Button = new Button(rb.getString("xzwtnr27_display.TITLE")); + this.p33Button.setPreferredSize(new Dimension(100, 100)); + // this.p33CheckBox.setPreferredSize(new Dimension(400, 30)); + // panel10.add(this.p33Label); + JScrollPane jslp = new JScrollPane(); // jtaӹ + jslp.setPreferredSize(new Dimension(800, 100)); + jslp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp.setViewportView(this.p33Field); + panel11.add(jslp); + panel11.add(this.p33Button); + + // ίݵڶ + JPanel panel26 = new JPanel(new FlowLayout()); + this.p66Label = new JLabel(rb.getString("bz27_display.TITLE")); + this.p66Label.setPreferredSize(new Dimension(50, 30)); + this.p66Field = new JTextField(bean.getP66()); + this.p66Field.setPreferredSize(new Dimension(850, 30)); + + panel26.add(p66Label); + panel26.add(p66Field); + + partPanel4 = new JPanel(new PropertyLayout()); + partPanel4 + .setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "5.ί Entrusting content")); + partPanel4.add("1.1.left.top", panel11); + partPanel4.add("2.1.left.top", panel26); + + // ίϢ + JPanel mainPanel = new JPanel(new PropertyLayout()); + mainPanel.setPreferredSize(new Dimension(900, 300)); + mainPanel.add("1.1.left.top", partPanel); + mainPanel.add("2.1.left.top", partPanel1); + mainPanel.add("3.1.left.top", partPanel2); + mainPanel.add("4.1.left.top", partPanel3); + mainPanel.add("5.1.left.top", partPanel4); + + // *************************************************************************************************************************// + + // Ʒ˵һ + JPanel panel12 = new JPanel(new FlowLayout()); + this.p34Label = new JLabel(rb.getString("ypydxc27_display.TITLE")); + this.p34Label.setPreferredSize(new Dimension(85, 30)); + this.p34Field = new JAutoCompleteComboBox(new String[] { "", "", "" }); + if (bean.getP34() == null || bean.getP34().isEmpty()) { + this.p34Field.setSelectedItem(bean.getP34()); + } else { + this.p34Field.setSelectedItem(""); + } + this.p34Field.setPreferredSize(new Dimension(150, 30)); + this.p35Label = new JLabel(rb.getString("sysj27_display.TITLE")); + this.p35Label.setPreferredSize(new Dimension(85, 30)); + this.p35DateButton = new DateButton(dateFormat); + this.p35DateButton.setPreferredSize(new Dimension(150, 30)); + this.p35DateButton.setText(bean.getP35()); + this.p36Label = new JLabel(rb.getString("syr27_display.TITLE")); + this.p36Label.setPreferredSize(new Dimension(50, 30)); + this.p36Field = new JTextField(bean.getP36()); + this.p36Field.setPreferredSize(new Dimension(150, 30)); + this.p37Label = new JLabel(rb.getString("ypshjg27_display.TITLE")); + this.p37Label.setPreferredSize(new Dimension(80, 30)); + this.p37ComboBox = new JAutoCompleteComboBox(); + this.p37ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p37ComboBox.setSelectedItem(bean.getP37()); + panel12.add(this.p34Label); + panel12.add(this.p34Field); + panel12.add(this.p35Label); + panel12.add(this.p35DateButton); + panel12.add(this.p36Label); + panel12.add(this.p36Field); + panel12.add(this.p37Label); + panel12.add(this.p37ComboBox); + + // Ʒ˵ڶ + JPanel panel13 = new JPanel(new FlowLayout()); + this.p38Label = new JLabel(rb.getString("yqwcsj27_display.TITLE")); + this.p38Label.setPreferredSize(new Dimension(85, 30)); + this.p38DateButton = new DateButton(dateFormat); + this.p38DateButton.setPreferredSize(new Dimension(150, 30)); + this.p38DateButton.setText(bean.getP38()); + this.p39Label = new JLabel(rb.getString("thyy27_display.TITLE")); + this.p39Label.setPreferredSize(new Dimension(85, 30)); + this.p39ComboBox = new JTextField(); + this.p39ComboBox.setPreferredSize(new Dimension(600, 30)); + this.p39ComboBox.setText(bean.getP39()); + + panel13.add(this.p38Label); + panel13.add(this.p38DateButton); + panel13.add(this.p39Label); + panel13.add(this.p39ComboBox); + + partPanel5 = new JPanel(new PropertyLayout()); + partPanel5.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "6.Ʒ Sample audit")); + partPanel5.add("1.1.left.top", panel12); + partPanel5.add("2.1.left.top", panel13); + + // һ + JPanel panel14 = new JPanel(new FlowLayout()); + this.p40Label = new JLabel(rb.getString("jcrwzb27_display.TITLE")); + this.p40Label.setPreferredSize(new Dimension(85, 30)); + this.p40Field = new JTextField(bean.getP40()); + this.p40Field.setPreferredSize(new Dimension(150, 30)); + this.p41Label = new JLabel(rb.getString("jcrwxb27_display.TITLE")); + this.p41Label.setPreferredSize(new Dimension(85, 30)); + this.p41Field = new JTextField(bean.getP41()); + this.p41Field.setPreferredSize(new Dimension(125, 30)); + this.p42Label = new JLabel(rb.getString("jhkssj27_display.TITLE")); + this.p42Label.setPreferredSize(new Dimension(75, 30)); + this.p42DateButton = new DateButton(dateFormat); + this.p42DateButton.setPreferredSize(new Dimension(150, 30)); + this.p42DateButton.setText(bean.getP42()); + this.p43Label = new JLabel(rb.getString("jhwcsj27_display.TITLE")); + this.p43Label.setPreferredSize(new Dimension(80, 30)); + this.p43DateButton = new DateButton(dateFormat); + this.p43DateButton.setPreferredSize(new Dimension(150, 30)); + this.p43DateButton.setText(bean.getP43()); + panel14.add(this.p40Label); + panel14.add(this.p40Field); + panel14.add(this.p41Label); + panel14.add(this.p41Field); + panel14.add(this.p42Label); + panel14.add(this.p42DateButton); + panel14.add(this.p43Label); + panel14.add(this.p43DateButton); + + // ڶ + JPanel panel15 = new JPanel(new FlowLayout()); + this.print1Button = new Button(rb.getString("djdywtd27_display.TITLE")); + this.print1Button.setPreferredSize(new Dimension(465, 50)); + this.print2Button = new Button(rb.getString("djdyypbs27_display.TITLE")); + this.print2Button.setPreferredSize(new Dimension(465, 50)); + + panel15.add(this.print1Button); + panel15.add(this.print2Button); + + partPanel6 = new JPanel(new PropertyLayout()); + partPanel6.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "7. Inspection task assignment")); + partPanel6.add("1.1.left.top", panel14); + partPanel6.add("2.1.left.top", panel15); + + // һ + JPanel panel16 = new JPanel(new FlowLayout()); + this.p44Label = new JLabel(rb.getString("sjwcsj27_display.TITLE")); + this.p44Label.setPreferredSize(new Dimension(85, 30)); + this.p44DateButton = new DateButton(dateFormat); + this.p44DateButton.setPreferredSize(new Dimension(150, 30)); + this.p44DateButton.setText(bean.getP44()); + this.p45Label = new JLabel(rb.getString("jcjgsm27_display.TITLE")); + this.p45Label.setPreferredSize(new Dimension(85, 30)); + this.p45Field = new JTextField(bean.getP45()); + this.p45Field.setPreferredSize(new Dimension(600, 30)); + + panel16.add(this.p44Label); + panel16.add(this.p44DateButton); + panel16.add(this.p45Label); + panel16.add(this.p45Field); + + // һ + JPanel panel24 = new JPanel(new FlowLayout()); + this.p49Label = new JLabel(rb.getString("ypcz27_display.TITLE")); + this.p49Label.setPreferredSize(new Dimension(85, 30)); + this.p49ComboBox = new JAutoCompleteComboBox(); + this.p49ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p49ComboBox.setSelectedItem(bean.getP49()); + this.p67Label = new JLabel(rb.getString("cywz27_display.TITLE")); + this.p67Label.setPreferredSize(new Dimension(85, 30)); + this.p67Field = new JTextField(bean.getP67()); + this.p67Field.setPreferredSize(new Dimension(600, 30)); + panel24.add(this.p49Label); + panel24.add(this.p49ComboBox); + panel24.add(this.p67Label); + panel24.add(this.p67Field); + + partPanel7 = new JPanel(new PropertyLayout()); + partPanel7.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "8.ϴ Inspection result uploading")); + partPanel7.add("1.1.left.top", panel16); + partPanel7.add("2.1.left.top", panel24); + + // ˵һ + JPanel panel17 = new JPanel(new FlowLayout()); + this.p46Label = new JLabel(rb.getString("shsj27_display.TITLE")); + this.p46Label.setPreferredSize(new Dimension(85, 30)); + this.p46DateButton = new DateButton(dateFormat); + this.p46DateButton.setPreferredSize(new Dimension(150, 30)); + this.p46DateButton.setText(bean.getP46()); + this.p47Label = new JLabel(rb.getString("shy27_display.TITLE")); + this.p47Label.setPreferredSize(new Dimension(85, 30)); + this.p47Field = new JTextField(bean.getP47()); + this.p47Field.setPreferredSize(new Dimension(150, 30)); + this.p48Label = new JLabel(rb.getString("shjg27_display.TITLE")); + this.p48Label.setPreferredSize(new Dimension(50, 30)); + this.p48Field = new JTextField(bean.getP48()); + this.p48Field.setPreferredSize(new Dimension(390, 30)); + + panel17.add(this.p46Label); + panel17.add(this.p46DateButton); + panel17.add(this.p47Label); + panel17.add(this.p47Field); + panel17.add(this.p48Label); + panel17.add(this.p48Field); + // panel17.add(this.p49Label); + // panel17.add(this.p49ComboBox); + + partPanel8 = new JPanel(new PropertyLayout()); + partPanel8.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "9. Inspection result audit")); + partPanel8.add("1.1.left.top", panel17); + + // Ϸ + JPanel mainPanel1 = new JPanel(new PropertyLayout()); + mainPanel1.setPreferredSize(new Dimension(900, 300)); + mainPanel1.add("1.1.left.top", partPanel5); + mainPanel1.add("2.1.left.top", partPanel6); + mainPanel1.add("3.1.left.top", partPanel7); + mainPanel1.add("4.1.left.top", partPanel8); + + // Ʒ˵һ + JPanel panel18 = new JPanel(new FlowLayout()); + this.p50Label = new JLabel(rb.getString("ypydxc27_display.TITLE")); + this.p50Label.setPreferredSize(new Dimension(85, 30)); + this.p50Field = new JAutoCompleteComboBox(new String[] { "", "", "" }); + if (bean.getP50() == null || bean.getP50().isEmpty()) { + this.p50Field.setSelectedItem(bean.getP50()); + } else { + this.p50Field.setSelectedItem(""); + } + this.p50Field.setPreferredSize(new Dimension(150, 30)); + this.p51Label = new JLabel(rb.getString("sysj27_display.TITLE")); + this.p51Label.setPreferredSize(new Dimension(85, 30)); + this.p51DateButton = new DateButton(dateFormat); + this.p51DateButton.setPreferredSize(new Dimension(150, 30)); + this.p51DateButton.setText(bean.getP51()); + this.p52Label = new JLabel(rb.getString("syr27_display.TITLE")); + this.p52Label.setPreferredSize(new Dimension(50, 30)); + this.p52Field = new JTextField(bean.getP52()); + this.p52Field.setPreferredSize(new Dimension(150, 30)); + this.p53Label = new JLabel(rb.getString("ypshjg27_display.TITLE")); + this.p53Label.setPreferredSize(new Dimension(80, 30)); + this.p53ComboBox = new JAutoCompleteComboBox(); + this.p53ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p53ComboBox.setSelectedItem(bean.getP53()); + panel18.add(this.p50Label); + panel18.add(this.p50Field); + panel18.add(this.p51Label); + panel18.add(this.p51DateButton); + panel18.add(this.p52Label); + panel18.add(this.p52Field); + panel18.add(this.p53Label); + panel18.add(this.p53ComboBox); + + // Ʒ˵ڶ + JPanel panel19 = new JPanel(new FlowLayout()); + this.p54Label = new JLabel(rb.getString("yqwcsj27_display.TITLE")); + this.p54Label.setPreferredSize(new Dimension(85, 30)); + this.p54DateButton = new DateButton(dateFormat); + this.p54DateButton.setPreferredSize(new Dimension(150, 30)); + this.p54DateButton.setText(bean.getP54()); + this.p55Label = new JLabel(rb.getString("thyy27_display.TITLE")); + this.p55Label.setPreferredSize(new Dimension(85, 30)); + this.p55ComboBox = new JTextField(); + this.p55ComboBox.setPreferredSize(new Dimension(600, 30)); + this.p55ComboBox.setText(bean.getP55()); + + panel19.add(this.p54Label); + panel19.add(this.p54DateButton); + panel19.add(this.p55Label); + panel19.add(this.p55ComboBox); + + partPanel9 = new JPanel(new PropertyLayout()); + partPanel9.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "6.Ʒ Sample audit")); + partPanel9.add("1.1.left.top", panel18); + partPanel9.add("2.1.left.top", panel19); + + // һ + JPanel panel20 = new JPanel(new FlowLayout()); + this.p56Label = new JLabel(rb.getString("jcrwzb27_display.TITLE")); + this.p56Label.setPreferredSize(new Dimension(85, 30)); + this.p56Field = new JTextField(bean.getP56()); + this.p56Field.setPreferredSize(new Dimension(150, 30)); + this.p57Label = new JLabel(rb.getString("jcrwxb27_display.TITLE")); + this.p57Label.setPreferredSize(new Dimension(85, 30)); + this.p57Field = new JTextField(bean.getP57()); + this.p57Field.setPreferredSize(new Dimension(125, 30)); + this.p58Label = new JLabel(rb.getString("jhkssj27_display.TITLE")); + this.p58Label.setPreferredSize(new Dimension(75, 30)); + this.p58DateButton = new DateButton(dateFormat); + this.p58DateButton.setPreferredSize(new Dimension(150, 30)); + this.p58DateButton.setText(bean.getP58()); + this.p59Label = new JLabel(rb.getString("jhwcsj27_display.TITLE")); + this.p59Label.setPreferredSize(new Dimension(80, 30)); + this.p59DateButton = new DateButton(dateFormat); + this.p59DateButton.setPreferredSize(new Dimension(150, 30)); + this.p59DateButton.setText(bean.getP59()); + panel20.add(this.p56Label); + panel20.add(this.p56Field); + panel20.add(this.p57Label); + panel20.add(this.p57Field); + panel20.add(this.p58Label); + panel20.add(this.p58DateButton); + panel20.add(this.p59Label); + panel20.add(this.p59DateButton); + + // ڶ + JPanel panel21 = new JPanel(new FlowLayout()); + this.print3Button = new Button(rb.getString("djdywtd27_display.TITLE")); + this.print3Button.setPreferredSize(new Dimension(465, 50)); + this.print4Button = new Button(rb.getString("djdyypbs27_display.TITLE")); + this.print4Button.setPreferredSize(new Dimension(465, 50)); + + panel21.add(this.print3Button); + panel21.add(this.print4Button); + + partPanel10 = new JPanel(new PropertyLayout()); + partPanel10.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "7. Inspection task assignment")); + partPanel10.add("1.1.left.top", panel20); + partPanel10.add("2.1.left.top", panel21); + + // һ + JPanel panel22 = new JPanel(new FlowLayout()); + this.p60Label = new JLabel(rb.getString("sjwcsj27_display.TITLE")); + this.p60Label.setPreferredSize(new Dimension(85, 30)); + this.p60DateButton = new DateButton(dateFormat); + this.p60DateButton.setPreferredSize(new Dimension(150, 30)); + this.p60DateButton.setText(bean.getP60()); + this.p61Label = new JLabel(rb.getString("jcjgsm27_display.TITLE")); + this.p61Label.setPreferredSize(new Dimension(85, 30)); + this.p61Field = new JTextField(bean.getP61()); + this.p61Field.setPreferredSize(new Dimension(600, 30)); + + panel22.add(this.p60Label); + panel22.add(this.p60DateButton); + panel22.add(this.p61Label); + panel22.add(this.p61Field); + + JPanel panel25 = new JPanel(new FlowLayout()); + this.p65Label = new JLabel(rb.getString("ypcz27_display.TITLE")); + this.p65Label.setPreferredSize(new Dimension(80, 30)); + this.p65ComboBox = new JAutoCompleteComboBox(); + this.p65ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p65ComboBox.setSelectedItem(bean.getP65()); + this.p68Label = new JLabel(rb.getString("cywz27_display.TITLE")); + this.p68Label.setPreferredSize(new Dimension(85, 30)); + this.p68Field = new JTextField(bean.getP68()); + this.p68Field.setPreferredSize(new Dimension(600, 30)); + + panel25.add(this.p65Label); + panel25.add(this.p65ComboBox); + panel25.add(this.p68Label); + panel25.add(this.p68Field); + + partPanel11 = new JPanel(new PropertyLayout()); + partPanel11.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "8.ϴ Inspection result uploading")); + partPanel11.add("1.1.left.top", panel22); + partPanel11.add("2.1.left.top", panel25); + + // ˵һ + JPanel panel23 = new JPanel(new FlowLayout()); + this.p62Label = new JLabel(rb.getString("shsj27_display.TITLE")); + this.p62Label.setPreferredSize(new Dimension(85, 30)); + this.p62DateButton = new DateButton(dateFormat); + this.p62DateButton.setPreferredSize(new Dimension(150, 30)); + this.p62DateButton.setText(bean.getP62()); + this.p63Label = new JLabel(rb.getString("shy27_display.TITLE")); + this.p63Label.setPreferredSize(new Dimension(85, 30)); + this.p63Field = new JTextField(bean.getP63()); + this.p63Field.setPreferredSize(new Dimension(150, 30)); + this.p64Label = new JLabel(rb.getString("shjg27_display.TITLE")); + this.p64Label.setPreferredSize(new Dimension(50, 30)); + this.p64Field = new JTextField(bean.getP64()); + this.p64Field.setPreferredSize(new Dimension(390, 30)); + + panel23.add(this.p62Label); + panel23.add(this.p62DateButton); + panel23.add(this.p63Label); + panel23.add(this.p63Field); + panel23.add(this.p64Label); + panel23.add(this.p64Field); +// panel23.add(this.p65Label); +// panel23.add(this.p65ComboBox); + + partPanel12 = new JPanel(new PropertyLayout()); + partPanel12.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "9. Inspection result audit")); + partPanel12.add("1.1.left.top", panel23); + + // + JPanel mainPanel2 = new JPanel(new PropertyLayout()); + mainPanel2.setPreferredSize(new Dimension(900, 300)); + mainPanel2.add("1.1.left.top", partPanel9); + mainPanel2.add("2.1.left.top", partPanel10); + mainPanel2.add("3.1.left.top", partPanel11); + mainPanel2.add("4.1.left.top", partPanel12); + + tabbedPane = new JTabbedPane(); + + ScrollPagePane scrollPagePane = new ScrollPagePane(); + + scrollPagePane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPagePane.setViewportView(mainPanel); + tabbedPane.addTab(rb.getString("wtxx27_display.TITLE"), mainPanel); + tabbedPane.addTab(rb.getString("clfx27_display.TITLE"), mainPanel1); + tabbedPane.addTab(rb.getString("jljc27_display.TITLE"), mainPanel2); + + rootPanel = new JPanel(new FlowLayout()); + this.okButton = new Button(rb.getString("bc_display.TITLE")); + okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new Button(rb.getString("qx_display.TITLE")); + celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(celButton); + + tabbedPane.setPreferredSize(new Dimension(940, 800)); + JPanel mainPanel3 = new JPanel(new BorderLayout()); + mainPanel3.add(tabbedPane, BorderLayout.CENTER); + // ÿؼȨ + //setPrivilege(); + + // + addSelectItem(); + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + + ScrollPagePane scrollPane = new ScrollPagePane(mainPanel3); + scrollPane.getVerticalScrollBar().setUnitIncrement(50); + this.add(scrollPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /*** + * Ȩ + */ + + public void setPrivilege() { + setPanelEnabled(this.partPanel, false); + setPanelEnabled(this.partPanel1, false); + setPanelEnabled(this.partPanel2, false); + setPanelEnabled(this.partPanel3, false); + setPanelEnabled(this.partPanel4, false); + setPanelEnabled(this.partPanel5, false); + setPanelEnabled(this.partPanel6, false); + setPanelEnabled(this.partPanel7, false); + setPanelEnabled(this.partPanel8, false); + setPanelEnabled(this.partPanel9, false); + setPanelEnabled(this.partPanel10, false); + setPanelEnabled(this.partPanel11, false); + setPanelEnabled(this.partPanel12, false); + // жǷ񷢲 + boolean isRelease; + try { + isRelease = this.comp.getProperty("release_status_list") != ""; + if (isRelease) { + return; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + for (int i = 0; i < this.privilegeList.size(); i++) { + switch (this.privilegeList.get(i)) { + case "ίϢ": + setPanelEnabled(this.partPanel, true); + break; + case "ĿϢ": + setPanelEnabled(this.partPanel1, true); + break; + case "ƷϢ": + setPanelEnabled(this.partPanel2, true); + break; + case "Ϣ": + setPanelEnabled(this.partPanel3, true); + break; + case "ί": + setPanelEnabled(this.partPanel4, true); + break; + case "AƷ": + if (this.p2ComboBox.editor.getText().indexOf("Ϸ") >= 0) { + setPanelEnabled(this.partPanel5, true); + } + break; + case "A": + if (this.p2ComboBox.editor.getText().indexOf("Ϸ") >= 0) { + setPanelEnabled(this.partPanel6, true); + } + break; + case "Aϴ": + if (this.p2ComboBox.editor.getText().indexOf("Ϸ") >= 0) { + setPanelEnabled(this.partPanel7, true); + } + break; + case "A": + if (this.p2ComboBox.editor.getText().indexOf("Ϸ") >= 0) { + setPanelEnabled(this.partPanel8, true); + } + break; + case "BƷ": + if (this.p2ComboBox.editor.getText().indexOf("") >= 0) { + setPanelEnabled(this.partPanel9, true); + } + break; + case "B": + if (this.p2ComboBox.editor.getText().indexOf("") >= 0) { + setPanelEnabled(this.partPanel10, true); + } + break; + case "Bϴ": + if (this.p2ComboBox.editor.getText().indexOf("") >= 0) { + setPanelEnabled(this.partPanel11, true); + } + break; + case "B": + if (this.p2ComboBox.editor.getText().indexOf("") >= 0) { + setPanelEnabled(this.partPanel12, true); + } + break; + + default: + break; + } + } + if (!isHaveProcess) { + setPanelEnabled(this.partPanel, true); + setPanelEnabled(this.partPanel1, true); + setPanelEnabled(this.partPanel2, true); + setPanelEnabled(this.partPanel3, true); + setPanelEnabled(this.partPanel4, true); + setPanelEnabled(this.partPanel5, true); + setPanelEnabled(this.partPanel5, true); + setPanelEnabled(this.partPanel6, true); + setPanelEnabled(this.partPanel7, true); + setPanelEnabled(this.partPanel8, true); + setPanelEnabled(this.partPanel9, true); + setPanelEnabled(this.partPanel10, true); + setPanelEnabled(this.partPanel11, true); + setPanelEnabled(this.partPanel12, true); + } + } + + 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); + } + } + } + + // жϱ + public boolean isMust() { + if (!isMust(partPanel)) { + return isMust(partPanel); + } + if (!isMust(partPanel1)) { + return isMust(partPanel1); + } + if (!isMust(partPanel2)) { + return isMust(partPanel2); + } + return true; + } + + private boolean isMust(JPanel partPanel) { + for (int i = 0; i < partPanel.getComponentCount(); i++) { + if (partPanel.getComponent(i) instanceof JTextField) { + JTextField textField = (JTextField) partPanel.getComponent(i); + if (textField.getText() == null || textField.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof JAutoCompleteComboBox) { + JAutoCompleteComboBox completeComboBox = (JAutoCompleteComboBox) partPanel.getComponent(i); + if (completeComboBox.getText() == null || completeComboBox.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) partPanel.getComponent(i); + if (multiComboBox.editor.getText() == null || multiComboBox.editor.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof JPanel) { + JPanel chidPanel = (JPanel) partPanel.getComponent(i); + return isMust(chidPanel); + } + + } + + return true; + } + + /*** + * ѡ + */ + public void addSelectItem() { + // ȡѡļ + File file = TMomMethodUtil.getFile(session, "ίеѡ", "MSExcelX"); + if (file == null) { + return; + } + // ȡļȡӦѡ + try { + List p1Values = ExcelUtil07.readExcelByEntrustment(file, ""); + for (String string : p1Values) { + p1ComboBox.addItem(string); + } + + this.p1ComboBox.setSelectedItem(bean.getP1()); +// List p9Values = ExcelUtil07.readExcelByEntrustment(file, ";"); +// for (String string : p9Values) { +// p9ComboBox.addItem(string); +// } +// this.p9ComboBox.setSelectedItem(bean.getP9()); + List p10Values = ExcelUtil07.readExcelByEntrustment(file, ""); + for (String string : p10Values) { + p10ComboBox.addItem(string); + } + this.p10ComboBox.setSelectedItem(bean.getP10()); +// List p15Values = ExcelUtil07.readExcelByEntrustment(file, "Ӧ"); +// for (String string : p15Values) { +// p15ComboBox.addItem(string); +// } +// this.p15ComboBox.setSelectedItem(bean.getP15()); + List p19Values = ExcelUtil07.readExcelByEntrustment(file, "Ʒ"); + for (String string : p19Values) { + p19ComboBox.addItem(string); + } + this.p19ComboBox.setSelectedItem(bean.getP19()); + List p20Values = ExcelUtil07.readExcelByEntrustment(file, "λ"); + for (String string : p20Values) { + p20ComboBox.addItem(string); + } + this.p20ComboBox.setSelectedItem(bean.getP20()); + List p22Values = ExcelUtil07.readExcelByEntrustment(file, "Ʒ״̬"); + for (String string : p22Values) { + p22ComboBox.addItem(string); + } + this.p22ComboBox.setSelectedItem(bean.getP22()); + List p25Values = ExcelUtil07.readExcelByEntrustment(file, "Ʒʽ"); + for (String string : p25Values) { + p25ComboBox.addItem(string); + } + this.p25ComboBox.setSelectedItem(bean.getP25()); + List p37Values = ExcelUtil07.readExcelByEntrustment(file, "Ʒ˽"); + for (String string : p37Values) { + p37ComboBox.addItem(string); + } + this.p37ComboBox.setSelectedItem(bean.getP37()); +// List p39Values = ExcelUtil07.readExcelByEntrustment(file, "˻ԭ"); +// for (String string : p39Values) { +// p39ComboBox.addItem(string); +// } +// this.p39ComboBox.setSelectedItem(bean.getP39()); + for (String string : p25Values) { + p49ComboBox.addItem(string); + } + this.p49ComboBox.setSelectedItem(bean.getP49()); + for (String string : p37Values) { + p53ComboBox.addItem(string); + } + this.p53ComboBox.setSelectedItem(bean.getP53()); +// for (String string : p39Values) { +// p55ComboBox.addItem(string); +// } +// this.p55ComboBox.setSelectedItem(bean.getP55()); + for (String string : p25Values) { + p65ComboBox.addItem(string); + } + this.p65ComboBox.setSelectedItem(bean.getP65()); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + // Ӽ + public void createActionEvent() { + this.print1Button.addActionListener(this); + this.print2Button.addActionListener(this); + this.print3Button.addActionListener(this); + this.print4Button.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.p33Button.addActionListener(this); + } + + public void getData() { + // ȡд + this.bean.setP1(this.p1ComboBox.getSelectedItem() == null ? "" : this.p1ComboBox.getSelectedItem().toString()); + this.bean.setP2(this.p2ComboBox.editor.getText()); + this.bean.setP3(this.p3Field.getText()); + this.bean.setP4(this.p4Field.getText()); + this.bean.setP5(this.p5Field.getText()); + this.bean.setP6(this.p6Field.getText()); + this.bean.setP7(this.p7DateButton.getText()); + this.bean.setP8(this.p8DateButton.getText()); + this.bean.setP9(this.p9ComboBox.getText()); + this.bean.setP10( + this.p10ComboBox.getSelectedItem() == null ? "" : this.p10ComboBox.getSelectedItem().toString()); + this.bean.setP11(this.p11Field.getText()); + this.bean.setP12(this.p12Field.getText()); + this.bean.setP13(this.p13Field.getText()); + this.bean.setP14(this.p14Field.getText()); + this.bean.setP15(this.p15ComboBox.editor.getText()); + this.bean.setP16(this.p16Field.getText()); + this.bean.setP17(this.p17Field.getText()); + this.bean.setP18(this.p18Field.getText()); + this.bean.setP19( + this.p19ComboBox.getSelectedItem() == null ? "" : this.p19ComboBox.getSelectedItem().toString()); + this.bean.setP20( + this.p20ComboBox.getSelectedItem() == null ? "" : this.p20ComboBox.getSelectedItem().toString()); + this.bean.setP21(this.p21Field.getText()); + this.bean.setP22( + this.p22ComboBox.getSelectedItem() == null ? "" : this.p22ComboBox.getSelectedItem().toString()); + this.bean.setP23(this.p23Field.getText()); + this.bean.setP24(this.p24Field.getText()); + this.bean.setP25( + this.p25ComboBox.getSelectedItem() == null ? "" : this.p25ComboBox.getSelectedItem().toString()); + this.bean.setP26(this.p26Field.getText()); + this.bean.setP27(this.p27Field.getText()); + this.bean.setP28(this.p28Field.getText()); + this.bean.setP29(this.p29Field.getText()); + this.bean.setP30(this.p30Field.getText()); + this.bean.setP31(this.p31Field.getText()); + this.bean.setP32(this.p32Field.getText()); + this.bean.setP33(this.p33Field.getText()); + this.bean.setP34(this.p34Field.getSelectedItem() == null ? "" : this.p34Field.getSelectedItem().toString()); + this.bean.setP35(this.p35DateButton.getText()); + this.bean.setP36(this.p36Field.getText()); + this.bean.setP37( + this.p37ComboBox.getSelectedItem() == null ? "" : this.p37ComboBox.getSelectedItem().toString()); + this.bean.setP38(this.p38DateButton.getText()); + this.bean.setP39(this.p39ComboBox.getText()); + this.bean.setP40(this.p40Field.getText()); + this.bean.setP41(this.p41Field.getText()); + this.bean.setP42(this.p42DateButton.getText()); + this.bean.setP43(this.p43DateButton.getText()); + this.bean.setP44(this.p44DateButton.getText()); + this.bean.setP45(this.p45Field.getText()); + this.bean.setP46(this.p46DateButton.getText()); + this.bean.setP47(this.p47Field.getText()); + this.bean.setP48(this.p48Field.getText()); + this.bean.setP49( + this.p49ComboBox.getSelectedItem() == null ? "" : this.p49ComboBox.getSelectedItem().toString()); + this.bean.setP50(this.p50Field.getSelectedItem() == null ? "" : this.p50Field.getSelectedItem().toString()); + this.bean.setP51(this.p51DateButton.getText()); + this.bean.setP52(this.p52Field.getText()); + this.bean.setP53( + this.p53ComboBox.getSelectedItem() == null ? "" : this.p53ComboBox.getSelectedItem().toString()); + this.bean.setP54(this.p54DateButton.getText()); + this.bean.setP55(this.p55ComboBox.getText()); + this.bean.setP56(this.p56Field.getText()); + this.bean.setP57(this.p57Field.getText()); + this.bean.setP58(this.p58DateButton.getText()); + this.bean.setP59(this.p59DateButton.getText()); + this.bean.setP60(this.p60DateButton.getText()); + this.bean.setP61(this.p61Field.getText()); + this.bean.setP62(this.p62DateButton.getText()); + this.bean.setP63(this.p63Field.getText()); + this.bean.setP64(this.p64Field.getText()); + this.bean.setP65( + this.p65ComboBox.getSelectedItem() == null ? "" : this.p65ComboBox.getSelectedItem().toString()); + this.bean.setP66(this.p66Field.getText()); + this.bean.setP67(this.p67Field.getText()); + this.bean.setP68(this.p68Field.getText()); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + // жϱǷд + if (!isMust()) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("btxbnwk27_display.TITLE"), "", MessageBox.ERROR); + return; + } + + TMom027EntrustmentFormOperation operation = new TMom027EntrustmentFormOperation(this.bean, this.isHave); + try { + getData(); + operation.executeOperation(); + if (!isHave) { + isHave = true; + } + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + // MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + try { + this.itemRevision.lock(); + this.itemRevision.setStringProperty("object_desc", ""); + this.itemRevision.save(); + this.itemRevision.refresh(); + this.itemRevision.unlock(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + this.dispose(); + } else if (source.equals(this.print1Button)) { + printFileAction(); + } else if (source.equals(this.print2Button)) { + printFileAction(); + } else if (source.equals(this.print3Button)) { + printFileAction(); + } else if (source.equals(this.print4Button)) { + printFileAction(); + } else if (source.equals(this.p33Button)) { + // ʾίѡ + if (entrustingContentDialog == null) { + if (this.p33Field.getText() == null) { + entrustingContentDialog = new EntrustingContentDialog(new ArrayList()); + } else { + entrustingContentDialog = new EntrustingContentDialog( + Arrays.asList(this.p33Field.getText().split(","))); + } + } else { + entrustingContentDialog.valueList = Arrays.asList(this.p33Field.getText().split(",")); + entrustingContentDialog.show(); + entrustingContentDialog.setJTable(); + } + } + } + + /** + * ί + * + * @author Administrator + * + */ + private class EntrustingContentDialog extends JFrame { + private String[] header = new String[] { "1", "2", "3", "4" }; + private int index = -1; + private List> dataList = new ArrayList>(); + // ؼ + private JPanel titlePanel;// + private JLabel titleLabel; + + private JTextPane selectCellValuePane; + // ѯ + // private JTextField findMainField; + // private JButton findMainButton; + // + private CTMap map; + private CTable mainTable; + + private Button okButton; + + public List valueList; + +// private TableRowSorter mainSorter; + + private Map combineMap = new HashMap();// źϲԪ + + // ǩؼ + // private JTabbedPane tabbedPane; + + public EntrustingContentDialog(List valueList) { + // TODO Auto-generated constructor stub + super(); + // getData(); + this.valueList = valueList; + getData(); + getCombineMap(); + init(); + setJTable(); + comBine(); + } + + 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("wtnr27_display.TITLE")); + this.setPreferredSize(new Dimension(850, 600)); + //this.setAlwaysOnTop(true); // ö + // ʼⲿֿؼ + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel(rb.getString("wtnr27_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 findMainPanel = new JPanel(new PropertyLayout()); +// this.findMainField = new JTextField(); +// this.findMainField.setPreferredSize(new Dimension(100, 20)); +// this.findMainButton = new JButton(""); +// findMainPanel.add("1.1.left.top", this.findMainField); +// findMainPanel.add("1.2.left.top", this.findMainButton); + this.mainTable = getNewjTable(null, null, header, dataList.size()); + mainTable.setRowHeight(40); +// mainSorter = new TableRowSorter(this.mainTable.getModel()); +// this.mainTable.setRowSorter(mainSorter); // ΪJTable + +// this.findMainButton.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// if (findMainField.getText().length() == 0) { +// mainSorter.setRowFilter(null); +// } else { +// mainSorter.setRowFilter(RowFilter.regexFilter(findMainField.getText()));// ΪJTableûʽĹ +// } +// } +// }); + // + mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + map.setRow(mainTable.getSelectedRow()); + map.setColumn(mainTable.getSelectedColumn()); + + if (mainTable.getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()) != null) { + selectCellValuePane.setText(mainTable + .getValueAt(mainTable.getSelectedRow(), mainTable.getSelectedColumn()).toString()); + } else { + selectCellValuePane.setText(""); + } + } + } + }); + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane = new JScrollPane(mainTable); + scrollPane.getVerticalScrollBar().setUnitIncrement(50); + + selectCellValuePane = new JTextPane(); + selectCellValuePane.setPreferredSize(new Dimension(500, 40)); + + okButton = new Button(rb.getString("qd_display.TITLE")); + okButton.setPreferredSize(new Dimension(100, 40)); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + StringBuffer stringBuffer = new StringBuffer(); + for (int i = 0; i < mainTable.getRowCount(); i++) { + if (map.getValueAt(i, 3).equals("1")) { + stringBuffer.append(map.getValueAt(i, 0) + "-" + map.getValueAt(i, 1) + "-" + map.getValueAt(i, 2) + ",\n"); + // System.out.println(mainTable.getValueAt(i, 2)); + } + } + if (stringBuffer.length() > 0) { + p33Field.setText(stringBuffer.substring(0, stringBuffer.length() - 2)); + } + entrustingContentDialog.dispose(); + } + }); + + JPanel southPanel = new JPanel(new PropertyLayout()); +// southPanel.add("1.1.left.top", findMainPanel); + southPanel.add("1.1.left.top", new JScrollPane(selectCellValuePane)); + southPanel.add("1.2.right.top", okButton); + + this.setLayout(new BorderLayout()); + this.add(centerPanel, BorderLayout.NORTH); + this.add(scrollPane, BorderLayout.CENTER); + this.add(southPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /** + * ȡExcelе + */ + private void getData() { + // TODO Auto-generated method stub + File file = TMomMethodUtil.getFile(session, "ⲿżĿ", "MSExcelX"); + if (file == null) { + return; + } + List> resultList; + try { + resultList = ExcelUtil07.readEntrustingContentExcel(file); + if (resultList != null && resultList.size() > 0) { + dataList = resultList; + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * дݵJtable + */ + public void setJTable() { + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + for (int j = 0; j < header.length; j++) { + mainTable.setValueAt(rowList.get(j), i, j); + } + if (valueList.contains(mainTable.getValueAt(i, 0) + "-" + mainTable.getValueAt(i, 1) + "-" + mainTable.getValueAt(i, 2)) + || valueList.contains(" " + mainTable.getValueAt(i, 0) + "-" + mainTable.getValueAt(i, 1) + "-" + mainTable.getValueAt(i, 2)) + || valueList.contains("\n " + mainTable.getValueAt(i, 0) + "-" + mainTable.getValueAt(i, 1) + "-" + mainTable.getValueAt(i, 2)) + || valueList.contains("\n" + mainTable.getValueAt(i, 0) + "-" + mainTable.getValueAt(i, 1) + "-" + mainTable.getValueAt(i, 2))) { + mainTable.setValueAt("1", i, 3); + } else { + mainTable.setValueAt("0", i, 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()); + } + } + } + + public void getCombineMap() { + try { + if (dataList != null && dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + if (dataList.get(i).get(3) != null && !dataList.get(i).get(3).equals("")) { + String sombine = dataList.get(i).get(3).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]); + } + } 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]); + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) }; + } + this.combineMap.put(row, cloumn); + } + } + } + } + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + } + + // Jtableͨ÷ + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(true); + partsTable = new CTable(map); + // ʾȾ + 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; + } + } + +// private static void print() { +// try { +// File file = new File("C:/Users/Administrator/Desktop/ίеѡ.xlsx"); +// PDDocument document = PDDocument.load(file); +// // سɴӡļ +// PDFPrintable printable = new PDFPrintable(document); +// PrinterJob job = PrinterJob.getPrinterJob(); +// job.setPrintable(printable); +// job.print(); +// } catch (InvalidPasswordException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (PrinterException e) { +// e.printStackTrace(); +// } +// } + + /* ӡָļ */ + + private void printFileAction() { + // Excel + getData(); + // ȡģ + File file = TMomMethodUtil.getFile(session, "ίеģ", "MSExcelX"); + String outFilePath = System.getenv("TEMP") + "\\ίе.xlsx"; + //ʽί + if(!bean.getP33().isEmpty()) + { + if(bean.getP33().indexOf(",\n") > 0) + { + String[] values = bean.getP33().split(",\n"); + int j = 1; + StringBuffer valueStringBuffer = new StringBuffer(); + for (int i = 0; i < values.length; i++) { + if(bean.getP2().indexOf("") >= 0 && (values[i].indexOf("Ʒ") >= 0 || values[i].indexOf("") >= 0)) + { + valueStringBuffer.append(j+""+values[i].split("-")[2] +"\n"); + j++; + } + if(bean.getP2().indexOf("Ϸ") >= 0 && values[i].indexOf("") >= 0) + { + valueStringBuffer.append(j+""+values[i].split("-")[2] +"\n"); + j++; + } + } + bean.setP33(valueStringBuffer.toString()); + } + else + { + if(bean.getP2().indexOf("") >= 0 && (bean.getP33().indexOf("Ʒ") >= 0 || bean.getP33().indexOf("") >= 0)) + { + bean.setP33("1"+bean.getP33().split("-")[2] +"\n"); + } + if(bean.getP2().indexOf("Ϸ") >= 0 && bean.getP33().indexOf("") >= 0) + { + bean.setP33("1"+bean.getP33().split("-")[2] +"\n"); + } + } + } + try { + ExcelUtil07.writeEntrustmentFormToExcel(bean, file, outFilePath); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + File outputFile = new File(outFilePath); + + //ӡExcelļ + Workbook workbook = new Workbook(); + workbook.loadFromFile(outputFile.getAbsolutePath()); + + // PrinterJob + PrinterJob printerJob = PrinterJob.getPrinterJob(); + + //ָӡҳΪĬϴСͷ + PageFormat pageFormat = printerJob.defaultPage(); + + //شӡѡ + Paper paper = pageFormat.getPaper(); + paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); + pageFormat.setPaper(paper); + if(printerJob.printDialog()) + { + printerJob.setCopies(1); + printerJob.setPrintable(workbook, pageFormat); + + //ִдӡ + try { + printerJob.print(); + } catch (PrinterException e) { + e.printStackTrace(); + } + } + + +// // ӡԼ +// PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); +// // ôӡʽΪδȷļͣѡ AUTOSENSE +// DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; +// +// // еĿôӡ +// PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); +// +// // λĬϵĴӡ +// PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); +// +// // ʾӡԻ +// PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, flavor, pras); +// +// if (service != null) { +// try { +// DocPrintJob job = service.createPrintJob();// ӡҵ +// FileInputStream fis = new FileInputStream(outputFile);// ӡļ +// DocAttributeSet das = new HashDocAttributeSet(); +// Doc doc = new SimpleDoc(fis, flavor, das);// ӡļʽ +// job.print(doc, pras);// ļĴӡ +// } catch (Exception e) { +// e.printStackTrace(); +// +// } +// } + } + +} diff --git a/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormHandler.java b/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormHandler.java new file mode 100644 index 0000000..198c9d1 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormHandler.java @@ -0,0 +1,47 @@ +package com.connor.renben.process.plm.tmom027; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom027EntrustmentFormHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷίеİ汾 + if(comp.getType().indexOf("WTDRevision") > 0) + { + TMom027EntrustmentFormCommand command = new TMom027EntrustmentFormCommand(app, + session,comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txwtdsb27_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzwtdbb27_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormOperation.java b/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormOperation.java new file mode 100644 index 0000000..748e16a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom027/TMom027EntrustmentFormOperation.java @@ -0,0 +1,86 @@ +package com.connor.renben.process.plm.tmom027; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.util.MessageBox; + +public class TMom027EntrustmentFormOperation extends AbstractAIFOperation { + + private EntrustmentFormBean bean; + private boolean isHave; + + public TMom027EntrustmentFormOperation(EntrustmentFormBean bean, boolean isHave) { + // TODO Auto-generated constructor stub + this.bean = bean; + this.isHave = isHave; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // ȡݿ + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + SqlUtilT.getTCConnection(); + if (isHave) { + // + String updateSQL = String.format(pro.getProperty("RB3_ENTRUSTMENTFORMUPDATE"), bean.getPuid()); + SqlUtilT.update(new String[] { bean.getP1(), bean.getP2(), bean.getP3(), bean.getP4(), bean.getP5(), + bean.getP6(), bean.getP7(), bean.getP8(), bean.getP9(), bean.getP10(), bean.getP11(), + bean.getP12(), bean.getP13(), bean.getP14(), bean.getP15(), bean.getP16(), bean.getP17(), + bean.getP18(), bean.getP19(), bean.getP20(), bean.getP21(), bean.getP22(), bean.getP23(), + bean.getP24(), bean.getP25(), bean.getP26(), bean.getP27(), bean.getP28(), bean.getP29(), + bean.getP30(), bean.getP31(), bean.getP32(), bean.getP33(), bean.getP34(), bean.getP35(), + bean.getP36(), bean.getP37(), bean.getP38(), bean.getP39(), bean.getP40(), bean.getP41(), + bean.getP42(), bean.getP43(), bean.getP44(), bean.getP45(), bean.getP46(), bean.getP47(), + bean.getP48(), bean.getP49(), bean.getP50(), bean.getP51(), bean.getP52(), bean.getP53(), + bean.getP54(), bean.getP55(), bean.getP56(), bean.getP57(), bean.getP58(), bean.getP59(), + bean.getP60(), bean.getP61(), bean.getP62(), bean.getP63(), bean.getP64(), bean.getP65(), + bean.getP66(), bean.getP67(), bean.getP68() ,bean.getP69(), bean.getP70(), bean.getP71(),bean.getP72()}, updateSQL); + + } else { + // + String insertSQL = pro.getProperty("RB3_ENTRUSTMENTFORMINSERT"); + SqlUtilT.update(new String[] { bean.getPuid(), bean.getP1(), bean.getP2(), bean.getP3(), bean.getP4(), + bean.getP5(), bean.getP6(), bean.getP7(), bean.getP8(), bean.getP9(), bean.getP10(), + bean.getP11(), bean.getP12(), bean.getP13(), bean.getP14(), bean.getP15(), bean.getP16(), + bean.getP17(), bean.getP18(), bean.getP19(), bean.getP20(), bean.getP21(), bean.getP22(), + bean.getP23(), bean.getP24(), bean.getP25(), bean.getP26(), bean.getP27(), bean.getP28(), + bean.getP29(), bean.getP30(), bean.getP31(), bean.getP32(), bean.getP33(), bean.getP34(), + bean.getP35(), bean.getP36(), bean.getP37(), bean.getP38(), bean.getP39(), bean.getP40(), + bean.getP41(), bean.getP42(), bean.getP43(), bean.getP44(), bean.getP45(), bean.getP46(), + bean.getP47(), bean.getP48(), bean.getP49(), bean.getP50(), bean.getP51(), bean.getP52(), + bean.getP53(), bean.getP54(), bean.getP55(), bean.getP56(), bean.getP57(), bean.getP58(), + bean.getP59(), bean.getP60(), bean.getP61(), bean.getP62(), bean.getP63(), bean.getP64(), + bean.getP65(), bean.getP66(), bean.getP67(), bean.getP68() ,bean.getP69(), bean.getP70(), bean.getP71(), bean.getP72()}, insertSQL); + } + SqlUtilT.connection.commit(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom028/TMom028JobProcessFormInputCommand.java b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputCommand.java new file mode 100644 index 0000000..c1da47e --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputCommand.java @@ -0,0 +1,792 @@ +package com.connor.renben.process.plm.tmom028; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Array; +import java.sql.Date; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.UUID; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +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.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class TMom028JobProcessFormInputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc" }; // 豸 + private boolean isReImport=true;//Ƿµ룬µtrueôݾʹӿƼƻȡfalseݴϸ汾̳ + public TMom028JobProcessFormInputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,boolean isReImport) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.isReImport=isReImport; + } + + @Override + public void executeModal() throws Exception { + //жǷǩ + if(((TCComponent) comp).isCheckedOut()) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("zygykzzbj28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ûǩڴʱǩ + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } +// String RB3_SBMC=null;//豸 +// String RB3_SBXH=null;//豸ͺ +// RB3_SBMC=properties[4].getStringValue(); +// RB3_SBMC=properties[2].getStringValue(); + //ж豸ƺͺǷΪգΪԶȡ + boolean SbIsNull=false; + if(properties[4].getStringValue().equals("")||properties[2].getStringValue().equals("")) { + SbIsNull=true; + } + + + // TODO Auto-generated method stub + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + final List toolingDetailPlmeidList = new ArrayList(); + final List machiningParameterPlmeidList = new ArrayList(); + final List controlRequirementPlmeidList = new ArrayList(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rs.getString("PLMEID")); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(machiningParameterRs.getString("PLMEID")); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(controlRequirementRs.getString("PLMEID")); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + + + TCComponent[] Revisions=(((TCComponent) comp).getReferenceListProperty("revision_list")); + String revisionID=((TCComponent) comp).getProperty("item_revision_id"); + //汾ĶûݵǼ̳ϸ汾 + if(Revisions.length>1&&!revisionID.equals("A")&&controlRequirementData.size()==0 + &&machiningParameterData.size()==0&&toolingDetailData.size()==0&&!isReImport) { + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), 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("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rowList.get(0)); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), Revisions[Revisions.length-2].getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(rowList.get(0)); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), Revisions[Revisions.length-2].getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(rowList.get(0)); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + else { + if(toolingDetailData.size()<=0&&controlRequirementData.size()<=0 + &&machiningParameterData.size()<=0) + { + //ݵǰѡжȡ + //TCComponentItemRevision itemRevision = (TCComponentItemRevision)comp; + AIFComponentContext[] aifccs = itemRevision.getItem().whereReferenced(); + TCComponentMEOPRevision meop = null; + TCComponentMEProcessRevision meprocess = null; + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEOPRevision) { + meop = (TCComponentMEOPRevision)aifcc_MEOP.getComponent(); + break; + } + } + if(meop != null) + { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + for (TCComponent tcComponent : its) { + if (tcComponent instanceof TCComponentMEProcessRevision) { + meprocess = (TCComponentMEProcessRevision)tcComponent; + break; + } + } + } + if(meprocess == null) + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("wzdgy28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ȡװϢ + TCComponent[] components = meop.getRelatedComponents("ps_children"); + System.out.println("汾жԴ"+components.toString()); + if(components.length>0) + { + Integer rowIndex = 1; + for (int j = 0; j < components.length; j++) { + + if(components[j] instanceof TCComponentItemRevision) + { + TCComponentItemRevision item = (TCComponentItemRevision)components[j]; + //+++ + //ȡID + String ClassID=item.getClassificationClass(); + if(ClassID == null || ClassID.length()<3) { + continue; + } + //װķID12... + if(ClassID.substring(0,2).equals("12")) {//ֻȡơ + String[] values = new String[3]; + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + //ȡװ1201Ļȡ660605 + if(ClassID.substring(0,4).equals("1201")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==660605) { + values[2] = icsValue.getValue(); + } + } + }else { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==71000) {//ĹװȡIDΪ71000 + values[2] = icsValue.getValue(); + } + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + }else if(ClassID.substring(0,2).equals("13")) {//׺Ʒɰ֡ʯձʣķID13.... + String[] values = new String[3];//ȡơߴ硢 + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ȡ + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==130101) {//γߴidΪ130101 + values[1] = icsValue.getValue(); + } + if(icsValue.getId()==660606) {//׺ƷŵidΪ660606 + values[2] = icsValue.getValue(); + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if (ClassID.substring(0,2).equals("16")) {//Ʒչ֣ķID16.... + String[] values = new String[3];//ֻȡ + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if(SbIsNull==true&&ClassID.substring(0,2).equals("15")) {//ȡ豸Ϣ + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + //ȡ豸 + properties[4].setStringValue(item.getStringProperty("object_name")); + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==72001) {//豸ͺŵidΪ72001 + properties[2].setStringValue(icsValue.getValue()); + } + + } + SbIsNull=false; + } + //+++ +// //ȡ +// TCComponentICO[] icos = item.getLatestItemRevision().getClassificationObjects(); +// if (icos.length <= 0) { +// continue; +// } +// String[] values = new String[2]; +// // ȡ +// ICSProperty[] icsProps = icos[0].getICSProperties(true); +// // ȡ +// +// ICSPropertyDescription[] icsDs = icos[0].getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +// // System.out.println(icsD.getName()); +// if (icsD.getName().indexOf("װ") >= 0 || icsD.getName().indexOf("") >= 0) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// values[0] = value; +// } +// if (icsD.getName().indexOf("װ") >= 0 || icsD.getName().indexOf("׺Ʒ") >= 0) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// values[1] = value; +// } +// } +// List rowList = new ArrayList(); +// rowList.add(UUID.randomUUID().toString().replace("-", "")); +// rowList.add(rowIndex.toString()); +// rowList.add(values[0]); +// rowList.add(values[1]); +// rowList.add(""); +// toolingDetailData.add(rowList); +// rowIndex++; + } + } + } + + String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + String itemType = getControlType((TCComponentMEProcess)meprocess.getItem()); + + //+++ȡտƼƻѡ°汾ݸҵտΪʼ + TCComponent[] ControlComponents = meprocess.getItem().getReferenceListProperty("IMAN_reference"); + String controlUid=""; + for(int i=0;i= 0) { + TCComponent[] ControlRevisions=ControlComponents[i].getReferenceListProperty("revision_list"); + controlUid=ControlRevisions[ControlRevisions.length-1].getUid();//ѡ°汾UID + } + } + //++++ + + ResultSet rsData = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_CONTROLPLANDATASELECT"), meprocessUid,meopId,itemType,controlUid); + rsData = SqlUtilT.read(sql); + Integer rowIndex = 1; + Integer rowIndexM = 1; + Integer rowIndexC = 1; + int flag=0; + int sflag=0; + int zflag=0; + int xflag=0; + int BH=1; + Map map=new HashMap(); + //String ss=rsData.toString(); + List RowList = new ArrayList(); + System.out.print("========>"+sql); + while (rsData.next()) { + //ӿƼƻȡӹRB3_GC=ƣRB3_TSTX=ԣRB3_CPGC= + if(rsData.getString("RB3_GC")!=null) { + List machiningParameterrowList = new ArrayList(); + machiningParameterrowList.add(UUID.randomUUID().toString().replace("-", "")); + //rowList.add(rowIndex.toString()); + //machiningParameterrowList.add(rsData.getString("RB3_QPTBH"));//ÿƼƻŴ + machiningParameterrowList.add(rowIndexM.toString()); + machiningParameterrowList.add(rsData.getString("RB3_GC")); + machiningParameterrowList.add(rsData.getString("RB3_TSTX")); + machiningParameterrowList.add(rsData.getString("RB3_CPGC")); + machiningParameterData.add(machiningParameterrowList); + rowIndexM++; + } + + + + //2022.2.22Ϊֹδдδϲ±Ϊnullʱ޷תΪInteger+++++++ + if(rsData.getString("RB3_QPTBH")==null||rsData.getString("RB3_QPTBH").equals("")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qwskzjh28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //++++++++ + + //ŷıʱmapеݺϳ + if(map.size()>0&&RowList.size()>0&&Integer.valueOf(rsData.getString("RB3_QPTBH"))!=BH) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + System.out.println("1:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + //ӿƼƻȡƷԿҪ + //RB3_CP=ĿRB3_TSTX=ԣRB3_CPGC=ҪRB3_CLFF=鷽RB3_RL=׼/RB3_RL/RB3_PL=/Ѳ,RB3_FYJH=Ӧƻ + + if(rsData.getString("RB3_CP")!=null&&rsData.getString("RB3_KZFF")!=null) { + + if(rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("Ѳ")<0) { + if(true) { + continue; + } + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(UUID.randomUUID().toString().replace("-", "")); + //controlRequirementRowList.add(rowIndex.toString()); + controlRequirementRowList.add(String.valueOf(controlRequirementData.size()+1));//ÿƼƻŴ + controlRequirementRowList.add(rsData.getString("RB3_CP")); + controlRequirementRowList.add(rsData.getString("RB3_TSTX")); + controlRequirementRowList.add(rsData.getString("RB3_CPGC")); + controlRequirementRowList.add(rsData.getString("RB3_CLFF")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_FYJH")); + controlRequirementRowList.add("");//עֵֵ + System.out.println("3:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + rowIndexC++; + }else { + + if(rsData.getString("RB3_KZFF").indexOf("")>-1&&sflag==1) { + sflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1&&zflag==1) { + zflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1&&xflag==1){ + xflag=2; + } + if((map.size()>0&&RowList.size()>0&&(sflag>1||zflag>1||xflag>1))) { + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + System.out.println("2controlRequirementRowList:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + + } + + if(flag==0) { + RowList.add(UUID.randomUUID().toString().replace("-", ""));//տuid + RowList.add(String.valueOf(controlRequirementData.size()+1)); + RowList.add(rsData.getString("RB3_CP")); + RowList.add(rsData.getString("RB3_TSTX")); + RowList.add(rsData.getString("RB3_CPGC")); + RowList.add(rsData.getString("RB3_CLFF")); + RowList.add(rsData.getString("RB3_FYJH")); + RowList.add(""); + flag++; + } + System.out.println("RB3_KZFF:"+rsData.getString("RB3_KZFF")); + if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + sflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + zflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1) { + map.put("Ѳ", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + xflag++; + }else { + continue; + } + + } + } + BH=Integer.valueOf(rsData.getString("RB3_QPTBH")); + rowIndex++; + } + System.out.println("RowList:"+RowList); + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rsData != null) { + SqlUtilT.free(rsData); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + } + + + + new Thread() { + @Override + public void run() { + new TMom028JobProcessFormInputDialog(app, session, comp, toolingDetailData, machiningParameterData, + controlRequirementData, toolingDetailPlmeidList, machiningParameterPlmeidList, + controlRequirementPlmeidList, form, properties); + super.run(); + } + }.start(); + super.executeModal(); + } + + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private String getControlType(TCComponentMEProcess tccmep) throws Exception { + String kzjhType = null; + + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>"+kzjh); + if ("RB3_SCKZJH".equals(itemType)) + { + //жǷΪƼƻ + return itemType; + } + + if ("RB3_SSCKZJH".equals(itemType)) + { + return itemType; + } + + if ("RB3_YJKZJH".equals(itemType)) + { + return itemType; + } + } + } + return kzjhType; + } + + + //+++LOVֵʱȡֵֻţǶӦֵ +// TCComponentICO[] icos = item.getClassificationObjects();//ȡ +// if (icos.length <= 0) { +// continue; +// } +// ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ +// ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ +// for (ICSPropertyDescription icsName : icsDNames) { +// //ȡװ +// if (icsName.getName().indexOf("װ") >= 0 || icsName.getName().indexOf("") >= 0||icsName.getName().indexOf("ɰ״") >= 0||icsName.getName().indexOf("ʯ״") >= 0) { +// String value =""; +// for (ICSProperty icsValue : icsValues) { +// if (icsValue.getId() == icsName.getId()) { +// if(ClassID.substring(0,2).equals("13")) { +// //ȡlovֵicsValueicsValue.getValue()ȡֵѡʱgetValueȡֻ˳ţֻͨgetClassDisplayableValueȡ +// value = getClassDisplayableValue(icsValue.getValue(),icsName); +// }else { +// value = icsValue.getValue(); +// } +// } +// } +// values[0] = value; +// } + + + + /** + * ȡLOVʾֵ + * +++keyţȡţkey͵ֵvalueƥ䣬getValueOfKey(key)ԵStringֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(String value ,ICSPropertyDescription icsD) + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + for (String key : keys) { + if(value.equals(key)) + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputDialog.java b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputDialog.java new file mode 100644 index 0000000..248fd7a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputDialog.java @@ -0,0 +1,1306 @@ +package com.connor.renben.process.plm.tmom028; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.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.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +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.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.table.DefaultTableModel; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.connor.renben.process.plm.tmom010.TMom010SetPFMEADialog.AddRowsDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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.teamcenter.services.rac.core.ReservationService; + +public class TMom028JobProcessFormInputDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private TCComponentItemRevision itemRevision; + private List processRows=new ArrayList();;// ǰû޸ĵк + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList = new ArrayList(); + private List machiningParameterDeleteList = new ArrayList(); + private List controlRequirementDeleteList = new ArrayList(); + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem remItem; + // ؼ + private JLabel companyNameLabel; + private JTextField companyNameField; + private JLabel itemIdLabel; + private JTextField itemIdField; + private JLabel equipmentIdLabel; + private JTextField equipmentIdField; + private JLabel meopLabel; + private JLabel konghang;// + private JTextField meopField; + private JLabel equipmentNameLabel; + private JTextField equipmentNameField; + + // ѡ + private JTabbedPane tabbedPane; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc" }; // 豸 + private TCComponentDataset Dataset; + private TCComponentTcFile picFile; + private String outFilePathp=null; + private TCComponent[] comps; + private PicDialog picDialog; + + private String[] toolingDetailHeader = new String[] { "PLMEID", "", "Ŀ", "/ߴ", "/" }; + private CTable toolingDetailTable;// װϸ + private String[] machiningParameterHeader = new String[] { "PLMEID", "", "", "", "" }; + private CTable machiningParameterTable;// ӹ + private String[] controlRequirementHeader = new String[] { "PLMEID", "", "Ŀ", "", "Ҫ", "鷽", + "׼", "Լ", "Ѳ", "Ӧƻ","ע" }; + private CTable controlRequirementTable;// Ҫ + + // ť + private JPanel rootPanel; + private JButton reImportButton; + private JButton ImportHorizontal; + private JButton ImportVertical; + private JButton selectPicture; + private JButton okButton; + private JButton celButton; + + public TMom028JobProcessFormInputDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, TCComponent form, + TCProperty[] properties) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.form = form; + this.properties = properties; + this.itemRevision= (TCComponentItemRevision) this.comp; + 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("zygyk28_display.TITLE")); + this.setPreferredSize(new Dimension(980, 750)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + this.companyNameLabel = new JLabel(rb.getString("gsmc28_display.TITLE")); + this.companyNameLabel.setPreferredSize(new Dimension(80, 30)); + this.companyNameField = new JTextField(); + this.companyNameField.setPreferredSize(new Dimension(200, 30)); + this.itemIdLabel = new JLabel(rb.getString("ljdh28_display.TITLE")); + this.itemIdLabel.setPreferredSize(new Dimension(80, 30)); + this.itemIdField = new JTextField(); + this.itemIdField.setPreferredSize(new Dimension(200, 30)); + this.equipmentIdLabel = new JLabel(rb.getString("sbxh28_display.TITLE")); + this.equipmentIdLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentIdField = new JTextField(); + this.equipmentIdField.setPreferredSize(new Dimension(200, 30)); + this.meopLabel = new JLabel(rb.getString("bgx28_display.TITLE")); + this.meopLabel.setPreferredSize(new Dimension(80, 30)); + this.meopField = new JTextField(); + this.meopField.setPreferredSize(new Dimension(200, 30)); + this.equipmentNameLabel = new JLabel(rb.getString("sbmc28_display.TITLE")); + this.equipmentNameLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentNameField = new JTextField(); + this.equipmentNameField.setPreferredSize(new Dimension(200, 30)); + + JPanel titlePanel = new JPanel(new PropertyLayout()); + titlePanel.add("1.1.left.top", this.companyNameLabel); + titlePanel.add("1.2.left.top", this.companyNameField); + titlePanel.add("1.3.left.top", this.itemIdLabel); + titlePanel.add("1.4.left.top", this.itemIdField); + titlePanel.add("1.5.left.top", this.meopLabel); + titlePanel.add("1.6.left.top", this.meopField); + titlePanel.add("2.1.left.top", this.equipmentIdLabel); + titlePanel.add("2.2.left.top", this.equipmentIdField); + titlePanel.add("2.3.left.top", this.equipmentNameLabel); + titlePanel.add("2.4.left.top", this.equipmentNameField); + try { + if(comp.getProperty("release_status_list")!="") { + setPanelEnabled(titlePanel,false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + if (this.toolingDetailData.size() > 0) { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, this.toolingDetailData.size()); + } else { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, 1); + } + + this.toolingDetailTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (mouseevent.getClickCount() == 1) { + + ((CTMap) toolingDetailTable.getModel()).setRow(toolingDetailTable.getSelectedRow()); + ((CTMap) toolingDetailTable.getModel()).setColumn(toolingDetailTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfbj28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + menu.show(toolingDetailTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + if (this.machiningParameterData.size() > 0) { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, + this.machiningParameterData.size()); + } else { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, 1); + } + + this.machiningParameterTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + + ((CTMap) machiningParameterTable.getModel()).setRow(machiningParameterTable.getSelectedRow()); + ((CTMap) machiningParameterTable.getModel()).setColumn(machiningParameterTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(machiningParameterTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + if (this.controlRequirementData.size() > 0) { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, + this.controlRequirementData.size()); + } else { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, 1); + } + + this.controlRequirementTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) controlRequirementTable.getModel()).setRow(controlRequirementTable.getSelectedRow()); + ((CTMap) controlRequirementTable.getModel()).setColumn(controlRequirementTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(controlRequirementTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab(rb.getString("gzmx28_display.TITLE"), new JScrollPane(this.toolingDetailTable)); + tabbedPane.addTab(rb.getString("jgcs28_display.TITLE"), new JScrollPane(this.machiningParameterTable)); + tabbedPane.addTab(rb.getString("cptxkzyq28_display.TITLE"), new JScrollPane(this.controlRequirementTable)); + + setText(); + setToolingDetailTable(); + setMachiningParameterTable(); + setControlRequirementTable(); + + rootPanel = new JPanel(new FlowLayout()); + this.reImportButton=new JButton(rb.getString("cxdr_display.TITLE")); + this.reImportButton.setPreferredSize(new Dimension(100, 30)); + this.ImportHorizontal=new JButton(rb.getString("hbgykdc_display.TITLE")); + this.ImportHorizontal.setPreferredSize(new Dimension(150, 30)); + this.ImportVertical=new JButton(rb.getString("sbgykdc_display.TITLE")); + this.ImportVertical.setPreferredSize(new Dimension(150, 30)); + this.selectPicture=new JButton(rb.getString("xzdctp_display.TITLE")); + this.selectPicture.setPreferredSize(new Dimension(120, 30)); + this.okButton = new JButton(rb.getString("bc_display.TITLE")); + this.okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(reImportButton); + rootPanel.add(ImportHorizontal); + rootPanel.add(ImportVertical); + rootPanel.add(selectPicture); + rootPanel.add(okButton); + rootPanel.add(celButton); + + // ʼҼ˵ + menu = new JPopupMenu(); + + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + addRowsItem = new JMenuItem(rb.getString("tjdh_display.TITLE")); + remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); + + menu.add(addRowItem); + menu.add(addRowsItem); + menu.add(remItem); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /*** + * ÿؼֵ + */ + private void setText() { + this.companyNameField.setText(this.properties[0].getStringValue()); + this.itemIdField.setText(this.properties[1].getStringValue()); + this.equipmentIdField.setText(this.properties[2].getStringValue()); + this.meopField.setText(this.properties[3].getStringValue()); + this.equipmentNameField.setText(this.properties[4].getStringValue()); + } + + /*** + * ÿؼֵ + */ + private List getText() { + List valueList = new ArrayList(); + valueList.add(this.companyNameField.getText()); + valueList.add(this.itemIdField.getText()); + valueList.add(this.equipmentIdField.getText()); + //valueList.add(""); + valueList.add(this.meopField.getText()); + valueList.add(this.equipmentNameField.getText()); + //valueList.add(""); + return valueList; + } + + private void setToolingDetailTable() { + if (toolingDetailData.size() > 0) { + for (int i = 0; i < toolingDetailData.size(); i++) { + for (int j = 0; j < toolingDetailData.get(i).size(); j++) { + toolingDetailTable.setValueAt(toolingDetailData.get(i).get(j), i, j); + } + } + } else { + toolingDetailTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setMachiningParameterTable() { + if (machiningParameterData.size() > 0) { + for (int i = 0; i < machiningParameterData.size(); i++) { + for (int j = 0; j < machiningParameterData.get(i).size(); j++) { + machiningParameterTable.setValueAt(machiningParameterData.get(i).get(j), i, j); + } + } + } else { + machiningParameterTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setControlRequirementTable() { + if (controlRequirementData.size() > 0) { + for (int i = 0; i < controlRequirementData.size(); i++) { + for (int j = 0; j < controlRequirementData.get(i).size(); j++) { + controlRequirementTable.setValueAt(controlRequirementData.get(i).get(j), i, j); + } + } + } else { + controlRequirementTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + // Ӽ + public void createActionEvent() { + this.reImportButton.addActionListener(this); + this.ImportHorizontal.addActionListener(this); + this.ImportVertical.addActionListener(this); + this.selectPicture.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.remItem.addActionListener(this); + } + + public CTable getjTable(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); + + + partsTable = new CTable(map); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + //renderer.setProcessRows(processRows); + //renderer.setIsRelease(true); + try { + //˾޷༭ + if(comp.getProperty("release_status_list")!="") { + map.setEditable(false); + renderer.setBackground(new Color(220,220,220)); + }else { + map.setEditable(true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // //þ + 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; + } + + + + + //ÿؼȨ + 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); + } + } + } + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.okButton)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfbjbc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom028JobProcessFormInputOperation operation = new TMom028JobProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + + try { + operation.executeOperation(); + setPlmeidList(toolingDetailPlmeidList, toolingDetailTable); + setPlmeidList(machiningParameterPlmeidList, machiningParameterTable); + setPlmeidList(controlRequirementPlmeidList, controlRequirementTable); + + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + }else if (source.equals(this.reImportButton)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfcxdr28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + int i = JOptionPane.showConfirmDialog(null, rb.getString("cxdrhscxysj28_display.TITLE"), "µ", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + remAllRow(this.toolingDetailTable,"װϸ"); + remAllRow(this.machiningParameterTable,"ӹ"); + remAllRow(this.controlRequirementTable,"ƷԿҪ"); + dispose(); + TMom028JobProcessFormInputCommand command = new TMom028JobProcessFormInputCommand(app, + session,comp,true); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (i == JOptionPane.NO_OPTION) { + return; + } + } else if (source.equals(this.ImportHorizontal)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + try { + ImportCard(true); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + else if (source.equals(this.ImportVertical)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + try { + ImportCard(false); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + else if (source.equals(this.selectPicture)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfxz28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, rb.getString("yczdct28_display.TITLE"), "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + + } + else if (source.equals(this.addRowItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wftjh28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + addRow(1); + } else if (source.equals(this.addRowsItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wftjh28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + new AddRowsDialog(); + + } else if (source.equals(this.remItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfych28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + remRow(); + } else { + dispose(); + } + } + + //տ + private void ImportCard(boolean type) throws TCException { + // + saveData(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + if(type==true) { + String outFilePath = System.getenv("TEMP") + "\\"+"ҵտ.xlsx"; + File file = null; + file = TMomMethodUtil.getFile(session, "湤տ", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormAcrossToExcel(getData(), file, outFilePath,picFile,outFilePathp); + if (ExcelUtil07.getExcelToItem(session, itemRevision, + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "ҵտ", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + }else { + String outFilePath = System.getenv("TEMP") + "\\"+"ҵտ.xlsx"; + File file = null; + file = TMomMethodUtil.getFile(session, "湤տ", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormVerticalToExcel(getData(), file, outFilePath,picFile,outFilePathp); + if (ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision) app.getTargetComponent(), + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "ҵտ", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + + } + this.dispose(); + + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = System.getenv("TEMP") + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + + // + private void saveData(){ + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom028JobProcessFormInputOperation operation = new TMom028JobProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + try { + operation.executeOperation(); + // ȡ汾 + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + + + //޸ϢرȨ + private void closePermission() { + //رȨ޸ + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//ǩ + } + } + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + // 17 + int d=map.getColumnCount(); + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + //رȨ޸ + closePermission(); + } + + /** + * + */ + private void addRow(int index) { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + map.insertRow(table.getSelectedRow() + index); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + index, 0); + table.revalidate();// + table.repaint();//ػ + } + + + + /** + * Ƴ + */ + private void remRow() { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + + switch (this.tabbedPane.getSelectedIndex()) { + case 0: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.toolingDetailPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.toolingDetailDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + + break; + case 1: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.machiningParameterPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.machiningParameterDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + case 2: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.controlRequirementPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.controlRequirementDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + + default: + break; + } + + map.removeRow(table.getSelectedRow()); + table.revalidate();// + table.repaint();//ػ + } + + /** + * µʱƳϢ + */ + private void remAllRow(CTable table,String tableName) { + List deleteAllList=new ArrayList(); + for (int j = 0; j < table.getRowCount(); j++) { + deleteAllList.add(table.getValueAt(j, 0).toString()); + } + switch (tableName) { + case "װϸ": + for(int i=0;i-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + public class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } +} + diff --git a/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputHandler.java b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputHandler.java new file mode 100644 index 0000000..94dbf2d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputHandler.java @@ -0,0 +1,62 @@ +package com.connor.renben.process.plm.tmom028; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.spire.xls.ExcelVersion; +import com.spire.xls.ViewMode; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +public class TMom028JobProcessFormInputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (app.getTargetComponent() == null) { + MessageBox.post(rb.getString("wxzzygykbbdx28_display.TITLE"), "", MessageBox.ERROR); + return null; + } + // ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + // жѡжǷҵտİ汾 + if (comp.getType().indexOf("ZYGYKRevision") > 0) { + + TMom028JobProcessFormInputCommand command = new TMom028JobProcessFormInputCommand(app, session, comp, + false); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txzygyksb28_display.TITLE"), "", MessageBox.ERROR); + } + } else { + MessageBox.post(rb.getString("qxzzygykbb28_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputOperation.java b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputOperation.java new file mode 100644 index 0000000..0d3b02c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/TMom028JobProcessFormInputOperation.java @@ -0,0 +1,202 @@ +package com.connor.renben.process.plm.tmom028; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom028JobProcessFormInputOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList; + private List machiningParameterDeleteList; + private List controlRequirementDeleteList; + + public TMom028JobProcessFormInputOperation(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, + List toolingDetailDeleteList, List machiningParameterDeleteList, + List controlRequirementDeleteList, TCComponent form, TCProperty[] properties, + List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.toolingDetailDeleteList = toolingDetailDeleteList; + this.machiningParameterDeleteList = machiningParameterDeleteList; + this.controlRequirementDeleteList = controlRequirementDeleteList; + this.form = form; + this.properties = properties; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // + InputStream input = null; + try { + // + // жǷǰ汾 + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + TCComponentUser user = session.getUser(); + if (user.getUserId().equals(userName)) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.valueList.get(0)); + this.properties[1].setStringValue(this.valueList.get(1)); + this.properties[2].setStringValue(this.valueList.get(2)); + this.properties[3].setStringValue(this.valueList.get(3)); + this.properties[4].setStringValue(this.valueList.get(4)); + this.form.save(); + this.form.unlock(); + this.form.refresh(); + } + + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ɾ + for (int i = 0; i < this.toolingDetailDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILDELETE"), + toolingDetailDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.machiningParameterDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERDELETE"), + machiningParameterDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.controlRequirementDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTDELETE"), + controlRequirementDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + + // ȡݿ + SqlUtilT.getTCConnection(); + + for (int i = 0; i < toolingDetailData.size(); i++) { + List rowList = toolingDetailData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && toolingDetailPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),"" }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_TOOLINGDETAILINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),"" }, insertSQL); + } + + } + + for (int i = 0; i < machiningParameterData.size(); i++) { + List rowList = machiningParameterData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && machiningParameterPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),"" }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_MACHININGPARAMETERINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),"" }, insertSQL); + } + + } + + for (int i = 0; i < controlRequirementData.size(); i++) { + List rowList = controlRequirementData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && controlRequirementPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTUPDATE"), rowList.get(0)); + 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) }, updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), 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)}, insertSQL); + } + } + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom028/_new/TMom028JobProcessFormInputCommand.java b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputCommand.java new file mode 100644 index 0000000..4d13499 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputCommand.java @@ -0,0 +1,820 @@ +package com.connor.renben.process.plm.tmom028._new; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Array; +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.UUID; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +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.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class TMom028JobProcessFormInputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", + "rb3_xdgx", + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; // 豸 + private boolean isReImport=true;//Ƿµ룬µtrueôݾʹӿƼƻȡfalseݴϸ汾̳ + public TMom028JobProcessFormInputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,boolean isReImport) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.isReImport=isReImport; + } + + @Override + public void executeModal() throws Exception { + //жǷǩ + if(((TCComponent) comp).isCheckedOut()) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("zygykzzbj28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ûǩڴʱǩ + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } +// String RB3_SBMC=null;//豸 +// String RB3_SBXH=null;//豸ͺ +// RB3_SBMC=properties[4].getStringValue(); +// RB3_SBMC=properties[2].getStringValue(); + //ж豸ƺͺǷΪգΪԶȡ + boolean SbIsNull=false; + if(properties[4].getStringValue().equals("")||properties[2].getStringValue().equals("")) { + SbIsNull=true; + } + TMomMethodUtil.setBgxAndXdgx(properties[1],properties[3],properties[5],itemRevision); + + //properties[3].setStringValue(bgx); + + // TODO Auto-generated method stub + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + final List toolingDetailPlmeidList = new ArrayList(); + final List machiningParameterPlmeidList = new ArrayList(); + final List controlRequirementPlmeidList = new ArrayList(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rs.getString("PLMEID")); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(machiningParameterRs.getString("PLMEID")); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(controlRequirementRs.getString("PLMEID")); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + + + TCComponent[] Revisions=(((TCComponent) comp).getReferenceListProperty("revision_list")); + String revisionID=((TCComponent) comp).getProperty("item_revision_id"); + //汾ĶûݵǼ̳ϸ汾 + if(Revisions.length>1&&!revisionID.equals("A")&&controlRequirementData.size()==0 + &&machiningParameterData.size()==0&&toolingDetailData.size()==0&&!isReImport) { + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), 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("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rowList.get(0)); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), Revisions[Revisions.length-2].getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(rowList.get(0)); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), Revisions[Revisions.length-2].getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(rowList.get(0)); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + else { + if(toolingDetailData.size()<=0&&controlRequirementData.size()<=0 + &&machiningParameterData.size()<=0) + { + //ݵǰѡжȡ + //TCComponentItemRevision itemRevision = (TCComponentItemRevision)comp; + AIFComponentContext[] aifccs = itemRevision.getItem().whereReferenced(); + TCComponentMEOPRevision meop = null; + TCComponentMEProcessRevision meprocess = null; + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEOPRevision) { + meop = (TCComponentMEOPRevision)aifcc_MEOP.getComponent(); + break; + } + } + if(meop != null) + { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + for (TCComponent tcComponent : its) { + if (tcComponent instanceof TCComponentMEProcessRevision) { + meprocess = (TCComponentMEProcessRevision)tcComponent; + break; + } + } + } + if(meprocess == null) + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("wzdgy28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ȡװϢ + TCComponent[] components = meop.getRelatedComponents("ps_children"); + System.out.println("汾жԴ"+components.toString()); + if(components.length>0) + { + Integer rowIndex = 1; + for (int j = 0; j < components.length; j++) { + + if(components[j] instanceof TCComponentItemRevision) + { + TCComponentItemRevision item = (TCComponentItemRevision)components[j]; + //+++ + //ȡID + String ClassID=item.getClassificationClass(); + if(ClassID == null || ClassID.length()<3) { + continue; + } + //װķID12... + if(ClassID.substring(0,2).equals("12")) {//ֻȡơ + String[] values = new String[3]; + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + //ȡװ1201Ļȡ660605 + if(ClassID.substring(0,4).equals("1201")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==660605) { + values[2] = icsValue.getValue(); + } + } + }else { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==71000) {//ĹװȡIDΪ71000 + values[2] = icsValue.getValue(); + } + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + }else if(ClassID.substring(0,2).equals("13")) {//׺Ʒɰ֡ʯձʣķID13.... + String[] values = new String[3];//ȡơߴ硢 + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ȡ + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==130101) {//γߴidΪ130101 + values[1] = icsValue.getValue(); + } + if(icsValue.getId()==660606) {//׺ƷŵidΪ660606 + values[2] = icsValue.getValue(); + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if (ClassID.substring(0,2).equals("16")) {//Ʒչ֣ķID16.... + String[] values = new String[3];//ֻȡ + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if(SbIsNull==true&&ClassID.substring(0,2).equals("15")) {//ȡ豸Ϣ + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + //ȡ豸 + properties[4].setStringValue(item.getStringProperty("object_name")); + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==72001) {//豸ͺŵidΪ72001 + properties[2].setStringValue(icsValue.getValue()); + } + + } + SbIsNull=false; + } + //+++ +// //ȡ +// TCComponentICO[] icos = item.getLatestItemRevision().getClassificationObjects(); +// if (icos.length <= 0) { +// continue; +// } +// String[] values = new String[2]; +// // ȡ +// ICSProperty[] icsProps = icos[0].getICSProperties(true); +// // ȡ +// +// ICSPropertyDescription[] icsDs = icos[0].getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +// // System.out.println(icsD.getName()); +// if (icsD.getName().indexOf("װ") >= 0 || icsD.getName().indexOf("") >= 0) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// values[0] = value; +// } +// if (icsD.getName().indexOf("װ") >= 0 || icsD.getName().indexOf("׺Ʒ") >= 0) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// values[1] = value; +// } +// } +// List rowList = new ArrayList(); +// rowList.add(UUID.randomUUID().toString().replace("-", "")); +// rowList.add(rowIndex.toString()); +// rowList.add(values[0]); +// rowList.add(values[1]); +// rowList.add(""); +// toolingDetailData.add(rowList); +// rowIndex++; + } + } + } + + String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + String itemType = getControlType((TCComponentMEProcess)meprocess.getItem()); + + //+++ȡտƼƻѡ°汾ݸҵտΪʼ + TCComponent[] ControlComponents = meprocess.getItem().getReferenceListProperty("IMAN_reference"); + String controlUid=""; + for(int i=0;i= 0) { + TCComponent[] ControlRevisions=ControlComponents[i].getReferenceListProperty("revision_list"); + controlUid=ControlRevisions[ControlRevisions.length-1].getUid();//ѡ°汾UID + } + } + //++++ + + ResultSet rsData = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_CONTROLPLANDATASELECT"), meprocessUid,meopId,itemType,controlUid); + rsData = SqlUtilT.read(sql); + Integer rowIndex = 1; + Integer rowIndexM = 1; + Integer rowIndexC = 1; + int flag=0; + int sflag=0; + int zflag=0; + int xflag=0; + int BH=1; + Map map=new HashMap(); + //String ss=rsData.toString(); + List RowList = new ArrayList(); + System.out.print("========>"+sql); + while (rsData.next()) { + //ӿƼƻȡӹRB3_GC=ƣRB3_TSTX=ԣRB3_CPGC= + if(rsData.getString("RB3_GC")!=null) { + List machiningParameterrowList = new ArrayList(); + machiningParameterrowList.add(UUID.randomUUID().toString().replace("-", "")); + //rowList.add(rowIndex.toString()); + //machiningParameterrowList.add(rsData.getString("RB3_QPTBH"));//ÿƼƻŴ + machiningParameterrowList.add(rowIndexM.toString()); + machiningParameterrowList.add(rsData.getString("RB3_GC")); + machiningParameterrowList.add(rsData.getString("RB3_TSTX")); + machiningParameterrowList.add(rsData.getString("RB3_CPGC")); + machiningParameterData.add(machiningParameterrowList); + rowIndexM++; + } + + + + //2022.2.22Ϊֹδдδϲ±Ϊnullʱ޷תΪInteger+++++++ + if(rsData.getString("RB3_QPTBH")==null||rsData.getString("RB3_QPTBH").equals("")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qwskzjh28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //++++++++ + + //ŷıʱmapеݺϳ + if(map.size()>0&&RowList.size()>0&&Integer.valueOf(rsData.getString("RB3_QPTBH"))!=BH) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + System.out.println("1:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + //ӿƼƻȡƷԿҪ + //RB3_CP=ĿRB3_TSTX=ԣRB3_CPGC=ҪRB3_CLFF=鷽RB3_RL=׼/RB3_RL/RB3_PL=/Ѳ,RB3_FYJH=Ӧƻ + + if(rsData.getString("RB3_CP")!=null&&rsData.getString("RB3_KZFF")!=null) { + + if(rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("Ѳ")<0) { + if(true) { + continue; + } + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(UUID.randomUUID().toString().replace("-", "")); + //controlRequirementRowList.add(rowIndex.toString()); + controlRequirementRowList.add(String.valueOf(controlRequirementData.size()+1));//ÿƼƻŴ + controlRequirementRowList.add(rsData.getString("RB3_CP")); + controlRequirementRowList.add(rsData.getString("RB3_TSTX")); + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CPGC")); + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CLFF")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_FYJH")); + controlRequirementRowList.add("");//עֵֵ + System.out.println("3:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + rowIndexC++; + }else { + + if(rsData.getString("RB3_KZFF").indexOf("")>-1&&sflag==1) { + sflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1&&zflag==1) { + zflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1&&xflag==1){ + xflag=2; + } + if((map.size()>0&&RowList.size()>0&&(sflag>1||zflag>1||xflag>1))) { + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + System.out.println("2controlRequirementRowList:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + + } + + if(flag==0) { + RowList.add(UUID.randomUUID().toString().replace("-", ""));//տuid + RowList.add(String.valueOf(controlRequirementData.size()+1)); + RowList.add(rsData.getString("RB3_CP")); + RowList.add(rsData.getString("RB3_TSTX")); + RowList.add(rsData.getString("RB3_CPGC")); + RowList.add(rsData.getString("RB3_CLFF")); + RowList.add(rsData.getString("RB3_FYJH")); + RowList.add(""); + RowList.add(""); + RowList.add(""); + flag++; + } + System.out.println("RB3_KZFF:"+rsData.getString("RB3_KZFF")); + if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + sflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + zflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1) { + map.put("Ѳ", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + xflag++; + }else { + continue; + } + + } + } + BH=Integer.valueOf(rsData.getString("RB3_QPTBH")); + rowIndex++; + } + System.out.println("RowList:"+RowList); + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rsData != null) { + SqlUtilT.free(rsData); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + } + + + + new Thread() { + @Override + public void run() { + new TMom028JobProcessFormInputDialog(app, session, comp, toolingDetailData, machiningParameterData, + controlRequirementData, toolingDetailPlmeidList, machiningParameterPlmeidList, + controlRequirementPlmeidList, form, properties); + super.run(); + } + }.start(); + super.executeModal(); + } + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private String getControlType(TCComponentMEProcess tccmep) throws Exception { + String kzjhType = null; + + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>"+kzjh); + if ("RB3_SCKZJH".equals(itemType)) + { + //жǷΪƼƻ + return itemType; + } + + if ("RB3_SSCKZJH".equals(itemType)) + { + return itemType; + } + + if ("RB3_YJKZJH".equals(itemType)) + { + return itemType; + } + } + } + return kzjhType; + } + + + //+++LOVֵʱȡֵֻţǶӦֵ +// TCComponentICO[] icos = item.getClassificationObjects();//ȡ +// if (icos.length <= 0) { +// continue; +// } +// ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ +// ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ +// for (ICSPropertyDescription icsName : icsDNames) { +// //ȡװ +// if (icsName.getName().indexOf("װ") >= 0 || icsName.getName().indexOf("") >= 0||icsName.getName().indexOf("ɰ״") >= 0||icsName.getName().indexOf("ʯ״") >= 0) { +// String value =""; +// for (ICSProperty icsValue : icsValues) { +// if (icsValue.getId() == icsName.getId()) { +// if(ClassID.substring(0,2).equals("13")) { +// //ȡlovֵicsValueicsValue.getValue()ȡֵѡʱgetValueȡֻ˳ţֻͨgetClassDisplayableValueȡ +// value = getClassDisplayableValue(icsValue.getValue(),icsName); +// }else { +// value = icsValue.getValue(); +// } +// } +// } +// values[0] = value; +// } + + + + /** + * ȡLOVʾֵ + * +++keyţȡţkey͵ֵvalueƥ䣬getValueOfKey(key)ԵStringֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(String value ,ICSPropertyDescription icsD) + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + for (String key : keys) { + if(value.equals(key)) + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputDialog.java b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputDialog.java new file mode 100644 index 0000000..b23e9e9 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputDialog.java @@ -0,0 +1,1454 @@ +package com.connor.renben.process.plm.tmom028._new; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.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.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +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.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.table.DefaultTableModel; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.connor.renben.process.plm.tmom010.TMom010SetPFMEADialog.AddRowsDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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.teamcenter.services.rac.core.ReservationService; + +public class TMom028JobProcessFormInputDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private TCComponentItemRevision itemRevision; + private List processRows=new ArrayList();;// ǰû޸ĵк + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList = new ArrayList(); + private List machiningParameterDeleteList = new ArrayList(); + private List controlRequirementDeleteList = new ArrayList(); + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem remItem; + // ؼ + private JLabel companyNameLabel; + private JTextField companyNameField; + private JLabel itemIdLabel; + private JTextField itemIdField; + private JLabel equipmentIdLabel; + private JTextField equipmentIdField; + private JLabel meopLabel; + private JLabel konghang;// + private JTextField meopField; + private JLabel equipmentNameLabel; + private JTextField equipmentNameField; + + + private JLabel nextProcessLabel; + private JTextField nextProcessField; + private JLabel documentNumberLabel; + private JTextField documentNumbeField; + private JLabel versionLabel; + private JTextField versionField; + private JLabel productionLabel; + private JTextField productionField; + private JLabel establishmentLabel; + private JTextField establishmentField; + private JLabel examineLabel; + private JTextField examineField; + private JLabel approveLabel; + private JTextField approveField; + private JLabel releaseDateLabel; + private JTextField releaseDateField; + + // ѡ + private JTabbedPane tabbedPane; + private String[] properName = new String[] { + "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", // 豸 + "rb3_xdgx", + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; + private TCComponentDataset Dataset; + private TCComponentTcFile picFile; + private String outFilePathp=null; + private TCComponent[] comps; + private PicDialog picDialog; + + private String[] toolingDetailHeader = new String[] { "PLMEID", "", "Ŀ", "/ߴ", "/" }; + private CTable toolingDetailTable;// װϸ + private String[] machiningParameterHeader = new String[] { "PLMEID", "", "", "", "" }; + private CTable machiningParameterTable;// ӹ + private String[] controlRequirementHeader = new String[] { "PLMEID", "", "Ŀ", "","չ","", "Ҫ","鷽", + "׼", "Լ", "Ѳ", "Ӧƻ","ע" }; + private CTable controlRequirementTable;// Ҫ + + // ť + private JPanel rootPanel; + private JButton reImportButton; + private JButton ImportHorizontal; + private JButton ImportVertical; + private JButton selectPicture; + private JButton okButton; + private JButton celButton; + + public TMom028JobProcessFormInputDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, TCComponent form, + TCProperty[] properties) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.form = form; + this.properties = properties; + this.itemRevision= (TCComponentItemRevision) this.comp; + 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("zygyk28_display.TITLE")); + this.setPreferredSize(new Dimension(980, 750)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + this.companyNameLabel = new JLabel(rb.getString("gsmc28_display.TITLE")); + this.companyNameLabel.setPreferredSize(new Dimension(80, 30)); + this.companyNameField = new JTextField(); + this.companyNameField.setPreferredSize(new Dimension(200, 30)); + this.itemIdLabel = new JLabel(rb.getString("ljdh28_display.TITLE")); + this.itemIdLabel.setPreferredSize(new Dimension(80, 30)); + this.itemIdField = new JTextField(); + this.itemIdField.setPreferredSize(new Dimension(200, 30)); + this.equipmentIdLabel = new JLabel(rb.getString("sbxh28_display.TITLE")); + this.equipmentIdLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentIdField = new JTextField(); + this.equipmentIdField.setPreferredSize(new Dimension(200, 30)); + this.meopLabel = new JLabel(rb.getString("bgx28_display.TITLE")); + this.meopLabel.setPreferredSize(new Dimension(80, 30)); + this.meopField = new JTextField(); + this.meopField.setPreferredSize(new Dimension(200, 30)); + this.equipmentNameLabel = new JLabel(rb.getString("sbmc28_display.TITLE")); + this.equipmentNameLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentNameField = new JTextField(); + this.equipmentNameField.setPreferredSize(new Dimension(200, 30)); + + this.nextProcessLabel = new JLabel(rb.getString("xgx_display.TITLE")); + this.nextProcessLabel.setPreferredSize(new Dimension(80, 30)); + this.nextProcessField = new JTextField(); + this.nextProcessField.setPreferredSize(new Dimension(200, 30)); + this.documentNumberLabel = new JLabel(rb.getString("wjbh_display.TITLE")); + this.documentNumberLabel.setPreferredSize(new Dimension(80, 30)); + this.documentNumbeField = new JTextField(); + this.documentNumbeField.setPreferredSize(new Dimension(200, 30)); + this.versionLabel = new JLabel(rb.getString("bbh_display.TITLE")); + this.versionLabel.setPreferredSize(new Dimension(80, 30)); + this.versionField = new JTextField(); + this.versionField.setPreferredSize(new Dimension(200, 30)); + this.productionLabel = new JLabel(rb.getString("cxqy_display.TITLE")); + this.productionLabel.setPreferredSize(new Dimension(80, 30)); + this.productionField = new JTextField(); + this.productionField.setPreferredSize(new Dimension(200, 30)); + this.establishmentLabel = new JLabel(rb.getString("bz_display.TITLE")); + this.establishmentLabel.setPreferredSize(new Dimension(80, 30)); + this.establishmentField = new JTextField(); + this.establishmentField.setPreferredSize(new Dimension(200, 30)); + this.examineLabel = new JLabel(rb.getString("sh_display.TITLE")); + this.examineLabel.setPreferredSize(new Dimension(80, 30)); + this.examineField = new JTextField(); + this.examineField.setPreferredSize(new Dimension(200, 30)); + this.approveLabel = new JLabel(rb.getString("pz_display.TITLE")); + this.approveLabel.setPreferredSize(new Dimension(80, 30)); + this.approveField = new JTextField(); + this.approveField.setPreferredSize(new Dimension(200, 30)); + this.releaseDateLabel = new JLabel(rb.getString("fbrq_display.TITLE")); + this.releaseDateLabel.setPreferredSize(new Dimension(80, 30)); + this.releaseDateField = new JTextField(); + this.releaseDateField.setPreferredSize(new Dimension(200, 30)); + + +// private JLabel nextProcessLabel; +// private JTextField nextProcessField; +// private JLabel documentNumberLabel; +// private JTextField documentNumbeField; +// private JLabel versionLabel; +// private JTextField versionField; +// private JLabel productionLabel; +// private JTextField productionField; +// private JLabel establishmentLabel; +// private JTextField establishmentField; +// private JLabel examineLabel; +// private JTextField examineField; +// private JLabel approveLabel; +// private JTextField approveField; +// private JLabel releaseDateLabel; +// private JTextField releaseDateField; + + JPanel titlePanel = new JPanel(new PropertyLayout()); + titlePanel.add("1.1.left.top", this.companyNameLabel); + titlePanel.add("1.2.left.top", this.companyNameField); + titlePanel.add("1.3.left.top", this.itemIdLabel); + titlePanel.add("1.4.left.top", this.itemIdField); + titlePanel.add("1.5.left.top", this.meopLabel); + titlePanel.add("1.6.left.top", this.meopField); + titlePanel.add("2.1.left.top", this.equipmentIdLabel); + titlePanel.add("2.2.left.top", this.equipmentIdField); + titlePanel.add("2.3.left.top", this.equipmentNameLabel); + titlePanel.add("2.4.left.top", this.equipmentNameField); + titlePanel.add("2.5.left.top", this.nextProcessLabel); + titlePanel.add("2.6.left.top", this.nextProcessField); + titlePanel.add("3.1.left.top", this.documentNumberLabel); + titlePanel.add("3.2.left.top", this.documentNumbeField); + titlePanel.add("3.3.left.top", this.versionLabel); + titlePanel.add("3.4.left.top", this.versionField); + titlePanel.add("3.5.left.top", this.productionLabel); + titlePanel.add("3.6.left.top", this.productionField); + titlePanel.add("4.1.left.top", this.establishmentLabel); + titlePanel.add("4.2.left.top", this.establishmentField); + titlePanel.add("4.3.left.top", this.examineLabel); + titlePanel.add("4.4.left.top", this.examineField); + titlePanel.add("4.5.left.top", this.approveLabel); + titlePanel.add("4.6.left.top", this.approveField); + titlePanel.add("5.1.left.top", this.releaseDateLabel); + titlePanel.add("5.2.left.top", this.releaseDateField); + try { + if(comp.getProperty("release_status_list")!="") { + setPanelEnabled(titlePanel,false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + if (this.toolingDetailData.size() > 0) { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, this.toolingDetailData.size()); + } else { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, 1); + } + + this.toolingDetailTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (mouseevent.getClickCount() == 1) { + + ((CTMap) toolingDetailTable.getModel()).setRow(toolingDetailTable.getSelectedRow()); + ((CTMap) toolingDetailTable.getModel()).setColumn(toolingDetailTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfbj28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + menu.show(toolingDetailTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + if (this.machiningParameterData.size() > 0) { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, + this.machiningParameterData.size()); + } else { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, 1); + } + + this.machiningParameterTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + + ((CTMap) machiningParameterTable.getModel()).setRow(machiningParameterTable.getSelectedRow()); + ((CTMap) machiningParameterTable.getModel()).setColumn(machiningParameterTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(machiningParameterTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + if (this.controlRequirementData.size() > 0) { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, + this.controlRequirementData.size()); + } else { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, 1); + } + + this.controlRequirementTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) controlRequirementTable.getModel()).setRow(controlRequirementTable.getSelectedRow()); + ((CTMap) controlRequirementTable.getModel()).setColumn(controlRequirementTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(controlRequirementTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab(rb.getString("gzmx28_display.TITLE"), new JScrollPane(this.toolingDetailTable)); + tabbedPane.addTab(rb.getString("jgcs28_display.TITLE"), new JScrollPane(this.machiningParameterTable)); + tabbedPane.addTab(rb.getString("cptxkzyq28_display.TITLE"), new JScrollPane(this.controlRequirementTable)); + + setText(); + setToolingDetailTable(); + setMachiningParameterTable(); + setControlRequirementTable(); + + rootPanel = new JPanel(new FlowLayout()); + this.reImportButton=new JButton(rb.getString("cxdr_display.TITLE")); + this.reImportButton.setPreferredSize(new Dimension(100, 30)); + this.ImportHorizontal=new JButton(rb.getString("hbgykdc_display.TITLE")); + this.ImportHorizontal.setPreferredSize(new Dimension(150, 30)); + this.ImportVertical=new JButton(rb.getString("sbgykdc_display.TITLE")); + this.ImportVertical.setPreferredSize(new Dimension(150, 30)); + this.selectPicture=new JButton(rb.getString("xzdctp_display.TITLE")); + this.selectPicture.setPreferredSize(new Dimension(120, 30)); + this.okButton = new JButton(rb.getString("bc_display.TITLE")); + this.okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(reImportButton); + rootPanel.add(ImportHorizontal); + rootPanel.add(ImportVertical); + rootPanel.add(selectPicture); + rootPanel.add(okButton); + rootPanel.add(celButton); + + // ʼҼ˵ + menu = new JPopupMenu(); + + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + addRowsItem = new JMenuItem(rb.getString("tjdh_display.TITLE")); + remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); + + menu.add(addRowItem); + menu.add(addRowsItem); + menu.add(remItem); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /*** + * ÿؼֵ + */ + private void setText() { + this.companyNameField.setText(this.properties[0].getStringValue()); + this.itemIdField.setText(this.properties[1].getStringValue()); + this.equipmentIdField.setText(this.properties[2].getStringValue()); + this.meopField.setText(this.properties[3].getStringValue()); + this.equipmentNameField.setText(this.properties[4].getStringValue()); + + + this.nextProcessField.setText(this.properties[5].getStringValue()); + this.documentNumbeField.setText(this.properties[6].getStringValue()); + this.versionField.setText(this.properties[7].getStringValue()); + this.productionField.setText(this.properties[8].getStringValue()); + this.establishmentField.setText(this.properties[9].getStringValue()); + this.examineField.setText(this.properties[10].getStringValue()); + this.approveField.setText(this.properties[11].getStringValue()); + this.releaseDateField.setText(this.properties[12].getStringValue()); + } + + /*** + * ÿؼֵ + */ + private List getText() { + List valueList = new ArrayList(); + valueList.add(this.companyNameField.getText()); + valueList.add(this.itemIdField.getText()); + valueList.add(this.equipmentIdField.getText()); + //valueList.add(""); + valueList.add(this.meopField.getText()); + valueList.add(this.equipmentNameField.getText()); + //valueList.add(""); + + valueList.add(this.nextProcessField.getText()); + valueList.add(this.documentNumbeField.getText()); + valueList.add(this.versionField.getText()); + valueList.add(this.productionField.getText()); + valueList.add(this.establishmentField.getText()); + valueList.add(this.examineField.getText()); + valueList.add(this.approveField.getText()); + valueList.add(this.releaseDateField.getText()); + return valueList; + } + + private void setToolingDetailTable() { + if (toolingDetailData.size() > 0) { + for (int i = 0; i < toolingDetailData.size(); i++) { + for (int j = 0; j < toolingDetailData.get(i).size(); j++) { + toolingDetailTable.setValueAt(toolingDetailData.get(i).get(j), i, j); + } + } + } else { + toolingDetailTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setMachiningParameterTable() { + if (machiningParameterData.size() > 0) { + for (int i = 0; i < machiningParameterData.size(); i++) { + for (int j = 0; j < machiningParameterData.get(i).size(); j++) { + machiningParameterTable.setValueAt(machiningParameterData.get(i).get(j), i, j); + } + } + } else { + machiningParameterTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setControlRequirementTable() { + if (controlRequirementData.size() > 0) { + for (int i = 0; i < controlRequirementData.size(); i++) { + for (int j = 0; j < controlRequirementData.get(i).size(); j++) { + controlRequirementTable.setValueAt(controlRequirementData.get(i).get(j), i, j); + } + } + } else { + controlRequirementTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + // Ӽ + public void createActionEvent() { + this.reImportButton.addActionListener(this); + this.ImportHorizontal.addActionListener(this); + this.ImportVertical.addActionListener(this); + this.selectPicture.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.remItem.addActionListener(this); + } + + public CTable getjTable(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); + + + partsTable = new CTable(map); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + //renderer.setProcessRows(processRows); + //renderer.setIsRelease(true); + try { + //˾޷༭ + if(comp.getProperty("release_status_list")!="") { + map.setEditable(false); + renderer.setBackground(new Color(220,220,220)); + }else { + map.setEditable(true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // //þ + 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; + } + + + + + //ÿؼȨ + 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); + } + } + } + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.okButton)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfbjbc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom028JobProcessFormInputOperation operation = new TMom028JobProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + + try { + operation.executeOperation(); + setPlmeidList(toolingDetailPlmeidList, toolingDetailTable); + setPlmeidList(machiningParameterPlmeidList, machiningParameterTable); + setPlmeidList(controlRequirementPlmeidList, controlRequirementTable); + + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + }else if (source.equals(this.reImportButton)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfcxdr28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + int i = JOptionPane.showConfirmDialog(null, rb.getString("cxdrhscxysj28_display.TITLE"), "µ", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + remAllRow(this.toolingDetailTable,"װϸ"); + remAllRow(this.machiningParameterTable,"ӹ"); + remAllRow(this.controlRequirementTable,"ƷԿҪ"); + dispose(); + TMom028JobProcessFormInputCommand command = new TMom028JobProcessFormInputCommand(app, + session,comp,true); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (i == JOptionPane.NO_OPTION) { + return; + } + } else if (source.equals(this.ImportHorizontal)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + try { + ImportCard(true); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + else if (source.equals(this.ImportVertical)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + try { + ImportCard(false); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + else if (source.equals(this.selectPicture)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfxz28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, rb.getString("yczdct28_display.TITLE"), "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + + } + else if (source.equals(this.addRowItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wftjh28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + addRow(1); + } else if (source.equals(this.addRowsItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wftjh28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + new AddRowsDialog(); + + } else if (source.equals(this.remItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfych28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + remRow(); + } else { + dispose(); + } + } + + //տ + private void ImportCard(boolean type) throws TCException { + // + saveData(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + if(type==true) { + String outFilePath = System.getenv("TEMP") + "\\"+"ҵտ.xlsx"; + File file = null; + file = TMomMethodUtil.getFile_New(session, "湤տ£", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormAcrossToExcel_New(getData(), file, outFilePath,picFile,outFilePathp); + if (ExcelUtil07.getExcelToItem(session, itemRevision, + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "ҵտ", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + }else { + String outFilePath = System.getenv("TEMP") + "\\"+"ҵտ.xlsx"; + File file = null; + file = TMomMethodUtil.getFile_New(session, "湤տ£", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormVerticalToExcel_New(getData(), file, outFilePath,picFile,outFilePathp); + if (ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision) app.getTargetComponent(), + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "ҵտ", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + + } + this.dispose(); + + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = System.getenv("TEMP") + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + + // + private void saveData(){ + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom028JobProcessFormInputOperation operation = new TMom028JobProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + try { + operation.executeOperation(); + // ȡ汾 + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + + + bean.setXdgx(this.properties[5].getStringValue()); + bean.setWjbh(this.properties[6].getStringValue()); + bean.setBbh(this.properties[7].getStringValue()); + bean.setCxqy(this.properties[8].getStringValue()); + bean.setBz(this.properties[9].getStringValue()); + bean.setSh(this.properties[10].getStringValue()); + bean.setPz(this.properties[11].getStringValue()); + bean.setFbrq(this.properties[12].getStringValue()); + + List> result2FormatData = new ArrayList<>(); + + for (List row : controlRequirementData) { +// if (row.size() < 13) continue; // ȫ飬쳣 + + List newRow = new ArrayList<>(); + newRow.add(row.get(0)); // PLMEID + newRow.add(row.get(1)); // ID + newRow.add(row.get(2)); // PROJECT + newRow.add(row.get(3)); // SPECIALITY + newRow.add(row.get(5)); // MANAGEMENT_REQUIREMENTS + newRow.add(row.get(7)); // CHECK_METHOD + newRow.add(row.get(8)); // FIRST_INSPECTION + newRow.add(row.get(9)); // SELF_INSPECTION + newRow.add(row.get(10)); // ROUTING_INSPECTION + newRow.add(row.get(11)); // REACTION_PLAN + newRow.add(row.get(12)); // REMARKS + newRow.add(row.get(4)); // PROCESS_SPECIFICATIONS + newRow.add(row.get(6)); // MANAGEMENT_POINTS + + result2FormatData.add(newRow); + } + bean.setControlRequirementData(result2FormatData); + + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + return bean; + } + + + //޸ϢرȨ + private void closePermission() { + //رȨ޸ + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//ǩ + } + } + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + // 17 + int d=map.getColumnCount(); + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + //رȨ޸ + closePermission(); + } + + /** + * + */ + private void addRow(int index) { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + map.insertRow(table.getSelectedRow() + index); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + index, 0); + table.revalidate();// + table.repaint();//ػ + } + + + + /** + * Ƴ + */ + private void remRow() { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + + switch (this.tabbedPane.getSelectedIndex()) { + case 0: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.toolingDetailPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.toolingDetailDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + + break; + case 1: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.machiningParameterPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.machiningParameterDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + case 2: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.controlRequirementPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.controlRequirementDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + + default: + break; + } + + map.removeRow(table.getSelectedRow()); + table.revalidate();// + table.repaint();//ػ + } + + /** + * µʱƳϢ + */ + private void remAllRow(CTable table,String tableName) { + List deleteAllList=new ArrayList(); + for (int j = 0; j < table.getRowCount(); j++) { + deleteAllList.add(table.getValueAt(j, 0).toString()); + } + switch (tableName) { + case "װϸ": + for(int i=0;i-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + public class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } +} + diff --git a/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputHandler.java b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputHandler.java new file mode 100644 index 0000000..ef98a92 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputHandler.java @@ -0,0 +1,62 @@ +package com.connor.renben.process.plm.tmom028._new; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.spire.xls.ExcelVersion; +import com.spire.xls.ViewMode; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +public class TMom028JobProcessFormInputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (app.getTargetComponent() == null) { + MessageBox.post(rb.getString("wxzzygykbbdx28_display.TITLE"), "", MessageBox.ERROR); + return null; + } + // ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + // жѡжǷҵտİ汾 + if (comp.getType().indexOf("ZYGYKRevision") > 0) { + + TMom028JobProcessFormInputCommand command = new TMom028JobProcessFormInputCommand(app, session, comp, + false); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txzygyksb28_display.TITLE"), "", MessageBox.ERROR); + } + } else { + MessageBox.post(rb.getString("qxzzygykbb28_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputOperation.java b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputOperation.java new file mode 100644 index 0000000..31e95a6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/_new/TMom028JobProcessFormInputOperation.java @@ -0,0 +1,212 @@ +package com.connor.renben.process.plm.tmom028._new; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom028JobProcessFormInputOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList; + private List machiningParameterDeleteList; + private List controlRequirementDeleteList; + + public TMom028JobProcessFormInputOperation(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, + List toolingDetailDeleteList, List machiningParameterDeleteList, + List controlRequirementDeleteList, TCComponent form, TCProperty[] properties, + List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.toolingDetailDeleteList = toolingDetailDeleteList; + this.machiningParameterDeleteList = machiningParameterDeleteList; + this.controlRequirementDeleteList = controlRequirementDeleteList; + this.form = form; + this.properties = properties; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // + InputStream input = null; + try { + // + // жǷǰ汾 + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + TCComponentUser user = session.getUser(); + if (user.getUserId().equals(userName)) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.valueList.get(0)); + this.properties[1].setStringValue(this.valueList.get(1)); + this.properties[2].setStringValue(this.valueList.get(2)); + this.properties[3].setStringValue(this.valueList.get(3)); + this.properties[4].setStringValue(this.valueList.get(4)); + + this.properties[5].setStringValue(this.valueList.get(5)); + this.properties[6].setStringValue(this.valueList.get(6)); + this.properties[7].setStringValue(this.valueList.get(7)); + this.properties[8].setStringValue(this.valueList.get(8)); + this.properties[9].setStringValue(this.valueList.get(9)); + this.properties[10].setStringValue(this.valueList.get(10)); + this.properties[11].setStringValue(this.valueList.get(11)); + this.properties[12].setStringValue(this.valueList.get(12)); + + this.form.save(); + this.form.unlock(); + this.form.refresh(); + } + + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ɾ + for (int i = 0; i < this.toolingDetailDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILDELETE"), + toolingDetailDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.machiningParameterDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERDELETE"), + machiningParameterDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.controlRequirementDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTDELETE"), + controlRequirementDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + + // ȡݿ + SqlUtilT.getTCConnection(); + + for (int i = 0; i < toolingDetailData.size(); i++) { + List rowList = toolingDetailData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && toolingDetailPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),"" }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_TOOLINGDETAILINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),"" }, insertSQL); + } + + } + + for (int i = 0; i < machiningParameterData.size(); i++) { + List rowList = machiningParameterData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && machiningParameterPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),"" }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_MACHININGPARAMETERINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),"" }, insertSQL); + } + + } + + for (int i = 0; i < controlRequirementData.size(); i++) { + List rowList = controlRequirementData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && controlRequirementPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTUPDATE2"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), + rowList.get(5), rowList.get(7), rowList.get(8), rowList.get(9), + rowList.get(10),rowList.get(11),rowList.get(12), rowList.get(4),rowList.get(6),"" }, updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT2"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(5), rowList.get(7), + rowList.get(8), rowList.get(9), rowList.get(10),rowList.get(11),rowList.get(12), rowList.get(4),rowList.get(6),"" }, insertSQL); + } + } + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom028/copy/TMom028JobProcessFormInputCommand.java b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputCommand.java new file mode 100644 index 0000000..ff8a8e8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputCommand.java @@ -0,0 +1,827 @@ +package com.connor.renben.process.plm.tmom028.copy; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Array; +import java.sql.Date; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.UUID; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +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.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class TMom028JobProcessFormInputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", + "rb3_xdgx", + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; // 豸 + private boolean isReImport=true;//Ƿµ룬µtrueôݾʹӿƼƻȡfalseݴϸ汾̳ + public TMom028JobProcessFormInputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,boolean isReImport) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.isReImport=isReImport; + } + + @Override + public void executeModal() throws Exception { + //жǷǩ + if(((TCComponent) comp).isCheckedOut()) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("zygykzzbj28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ûǩڴʱǩ + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } +// String RB3_SBMC=null;//豸 +// String RB3_SBXH=null;//豸ͺ +// RB3_SBMC=properties[4].getStringValue(); +// RB3_SBMC=properties[2].getStringValue(); + //ж豸ƺͺǷΪգΪԶȡ + boolean SbIsNull=false; + if(properties[4].getStringValue().equals("")||properties[2].getStringValue().equals("")) { + SbIsNull=true; + } + + TMomMethodUtil.setBgxAndXdgx(properties[1],properties[3],properties[5],itemRevision); + // TODO Auto-generated method stub + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + final List toolingDetailPlmeidList = new ArrayList(); + final List machiningParameterPlmeidList = new ArrayList(); + final List controlRequirementPlmeidList = new ArrayList(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rs.getString("PLMEID")); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(machiningParameterRs.getString("PLMEID")); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("STEP_CONTENT")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(controlRequirementRs.getString("PLMEID")); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + + + TCComponent[] Revisions=(((TCComponent) comp).getReferenceListProperty("revision_list")); + String revisionID=((TCComponent) comp).getProperty("item_revision_id"); + //汾ĶûݵǼ̳ϸ汾 + if(Revisions.length>1&&!revisionID.equals("A")&&controlRequirementData.size()==0 + &&machiningParameterData.size()==0&&toolingDetailData.size()==0&&!isReImport) { + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), 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("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rowList.get(0)); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), Revisions[Revisions.length-2].getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(rowList.get(0)); + } + SqlUtilT.getTCConnection(); + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), Revisions[Revisions.length-2].getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("STEP_CONTENT")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(rowList.get(0)); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + } + else { + if(toolingDetailData.size()<=0&&controlRequirementData.size()<=0 + &&machiningParameterData.size()<=0) + { + //ݵǰѡжȡ + //TCComponentItemRevision itemRevision = (TCComponentItemRevision)comp; + AIFComponentContext[] aifccs = itemRevision.getItem().whereReferenced(); + TCComponentMEOPRevision meop = null; + TCComponentMEProcessRevision meprocess = null; + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEOPRevision) { + meop = (TCComponentMEOPRevision)aifcc_MEOP.getComponent(); + break; + } + } + if(meop != null) + { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + for (TCComponent tcComponent : its) { + if (tcComponent instanceof TCComponentMEProcessRevision) { + meprocess = (TCComponentMEProcessRevision)tcComponent; + break; + } + } + } + if(meprocess == null) + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("wzdgy28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ȡװϢ + TCComponent[] components = meop.getRelatedComponents("ps_children"); + System.out.println("汾жԴ"+components.toString()); + if(components.length>0) + { + Integer rowIndex = 1; + for (int j = 0; j < components.length; j++) { + + if(components[j] instanceof TCComponentItemRevision) + { + TCComponentItemRevision item = (TCComponentItemRevision)components[j]; + //+++ + //ȡID + String ClassID=item.getClassificationClass(); + if(ClassID == null || ClassID.length()<3) { + continue; + } + //װķID12... + if(ClassID.substring(0,2).equals("12")) {//ֻȡơ + String[] values = new String[3]; + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + //ȡװ1201Ļȡ660605 + if(ClassID.substring(0,4).equals("1201")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==660605) { + values[2] = icsValue.getValue(); + } + } + }else { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==71000) {//ĹװȡIDΪ71000 + values[2] = icsValue.getValue(); + } + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + }else if(ClassID.substring(0,2).equals("13")) {//׺Ʒɰ֡ʯձʣķID13.... + String[] values = new String[3];//ȡơߴ硢 + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ȡ + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==130101) {//γߴidΪ130101 + values[1] = icsValue.getValue(); + } + if(icsValue.getId()==660606) {//׺ƷŵidΪ660606 + values[2] = icsValue.getValue(); + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if (ClassID.substring(0,2).equals("16")) {//Ʒչ֣ķID16.... + String[] values = new String[3];//ֻȡ + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if(SbIsNull==true&&ClassID.substring(0,2).equals("15")) {//ȡ豸Ϣ + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + //ȡ豸 + properties[4].setStringValue(item.getStringProperty("object_name")); + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==72001) {//豸ͺŵidΪ72001 + properties[2].setStringValue(icsValue.getValue()); + } + + } + SbIsNull=false; + } + //+++ +// //ȡ +// TCComponentICO[] icos = item.getLatestItemRevision().getClassificationObjects(); +// if (icos.length <= 0) { +// continue; +// } +// String[] values = new String[2]; +// // ȡ +// ICSProperty[] icsProps = icos[0].getICSProperties(true); +// // ȡ +// +// ICSPropertyDescription[] icsDs = icos[0].getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +// // System.out.println(icsD.getName()); +// if (icsD.getName().indexOf("װ") >= 0 || icsD.getName().indexOf("") >= 0) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// values[0] = value; +// } +// if (icsD.getName().indexOf("װ") >= 0 || icsD.getName().indexOf("׺Ʒ") >= 0) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// values[1] = value; +// } +// } +// List rowList = new ArrayList(); +// rowList.add(UUID.randomUUID().toString().replace("-", "")); +// rowList.add(rowIndex.toString()); +// rowList.add(values[0]); +// rowList.add(values[1]); +// rowList.add(""); +// toolingDetailData.add(rowList); +// rowIndex++; + } + } + } + + String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + String itemType = getControlType((TCComponentMEProcess)meprocess.getItem()); + + //+++ȡտƼƻѡ°汾ݸҵտΪʼ + TCComponent[] ControlComponents = meprocess.getItem().getReferenceListProperty("IMAN_reference"); + String controlUid=""; + for(int i=0;i= 0) { + TCComponent[] ControlRevisions=ControlComponents[i].getReferenceListProperty("revision_list"); + controlUid=ControlRevisions[ControlRevisions.length-1].getUid();//ѡ°汾UID + } + } + //++++ + + ResultSet rsData = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_CONTROLPLANDATASELECT"), meprocessUid,meopId,itemType,controlUid); + rsData = SqlUtilT.read(sql); + Integer rowIndex = 1; + Integer rowIndexM = 1; + Integer rowIndexC = 1; + int flag=0; + int sflag=0; + int zflag=0; + int xflag=0; + int BH=1; + Map map=new HashMap(); + //String ss=rsData.toString(); + List RowList = new ArrayList(); + System.out.print("========>"+sql); + while (rsData.next()) { + //ӿƼƻȡӹRB3_GC=ƣRB3_TSTX=ԣRB3_CPGC= + if(rsData.getString("RB3_GC")!=null) { + List machiningParameterrowList = new ArrayList(); + machiningParameterrowList.add(UUID.randomUUID().toString().replace("-", "")); + //rowList.add(rowIndex.toString()); + //machiningParameterrowList.add(rsData.getString("RB3_QPTBH"));//ÿƼƻŴ + machiningParameterrowList.add(rowIndexM.toString()); +// machiningParameterrowList.add("");// + machiningParameterrowList.add(rsData.getString("RB3_GC")); + machiningParameterrowList.add(rsData.getString("RB3_TSTX")); + machiningParameterrowList.add(rsData.getString("RB3_CPGC")); + machiningParameterData.add(machiningParameterrowList); + rowIndexM++; + } + + + + //2022.2.22Ϊֹδдδϲ±Ϊnullʱ޷תΪInteger+++++++ + if(rsData.getString("RB3_QPTBH")==null||rsData.getString("RB3_QPTBH").equals("")) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("qwskzjh28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //++++++++ + + //ŷıʱmapеݺϳ + if(map.size()>0&&RowList.size()>0&&Integer.valueOf(rsData.getString("RB3_QPTBH"))!=BH) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(10)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + System.out.println("1:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + //ӿƼƻȡƷԿҪ + //RB3_CP=ĿRB3_TSTX=ԣRB3_CPGC=ҪRB3_CLFF=鷽RB3_RL=׼/RB3_RL/RB3_PL=/Ѳ,RB3_FYJH=Ӧƻ + + if(rsData.getString("RB3_CP")!=null&&rsData.getString("RB3_KZFF")!=null) { + + if(rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("Ѳ")<0) { + if(true) { + continue; + } + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(10)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(UUID.randomUUID().toString().replace("-", "")); + //controlRequirementRowList.add(rowIndex.toString()); + controlRequirementRowList.add(String.valueOf(controlRequirementData.size()+1));//ÿƼƻŴ + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CP")); + controlRequirementRowList.add(rsData.getString("RB3_TSTX")); + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CPGC")); + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CLFF")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_FYJH")); + controlRequirementRowList.add("");//עֵֵ + System.out.println("3:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + rowIndexC++; + }else { + + if(rsData.getString("RB3_KZFF").indexOf("")>-1&&sflag==1) { + sflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1&&zflag==1) { + zflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1&&xflag==1){ + xflag=2; + } + if((map.size()>0&&RowList.size()>0&&(sflag>1||zflag>1||xflag>1))) { + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(10)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + System.out.println("2controlRequirementRowList:"+controlRequirementRowList); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + + } + + if(flag==0) { + RowList.add(UUID.randomUUID().toString().replace("-", ""));//տuid + RowList.add(String.valueOf(controlRequirementData.size()+1)); + RowList.add(rsData.getString("RB3_CP")); + RowList.add(rsData.getString("RB3_TSTX")); + RowList.add(rsData.getString("RB3_CPGC")); + RowList.add(rsData.getString("RB3_CLFF")); + RowList.add(rsData.getString("RB3_FYJH")); + RowList.add(""); + RowList.add(""); + RowList.add(""); + RowList.add(""); + flag++; + } + System.out.println("RB3_KZFF:"+rsData.getString("RB3_KZFF")); + if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + sflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + zflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1) { + map.put("Ѳ", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + xflag++; + }else { + continue; + } + + } + } + BH=Integer.valueOf(rsData.getString("RB3_QPTBH")); + rowIndex++; + } + System.out.println("RowList:"+RowList); + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(10)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementRowList.add(RowList.get(7));//עֵֵ + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rsData != null) { + SqlUtilT.free(rsData); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + } + + + + new Thread() { + @Override + public void run() { + new TMom028JobProcessFormInputDialog(app, session, comp, toolingDetailData, machiningParameterData, + controlRequirementData, toolingDetailPlmeidList, machiningParameterPlmeidList, + controlRequirementPlmeidList, form, properties); + super.run(); + } + }.start(); + super.executeModal(); + } + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private String getControlType(TCComponentMEProcess tccmep) throws Exception { + String kzjhType = null; + + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>"+kzjh); + if ("RB3_SCKZJH".equals(itemType)) + { + //жǷΪƼƻ + return itemType; + } + + if ("RB3_SSCKZJH".equals(itemType)) + { + return itemType; + } + + if ("RB3_YJKZJH".equals(itemType)) + { + return itemType; + } + } + } + return kzjhType; + } + + + //+++LOVֵʱȡֵֻţǶӦֵ +// TCComponentICO[] icos = item.getClassificationObjects();//ȡ +// if (icos.length <= 0) { +// continue; +// } +// ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ +// ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ +// for (ICSPropertyDescription icsName : icsDNames) { +// //ȡװ +// if (icsName.getName().indexOf("װ") >= 0 || icsName.getName().indexOf("") >= 0||icsName.getName().indexOf("ɰ״") >= 0||icsName.getName().indexOf("ʯ״") >= 0) { +// String value =""; +// for (ICSProperty icsValue : icsValues) { +// if (icsValue.getId() == icsName.getId()) { +// if(ClassID.substring(0,2).equals("13")) { +// //ȡlovֵicsValueicsValue.getValue()ȡֵѡʱgetValueȡֻ˳ţֻͨgetClassDisplayableValueȡ +// value = getClassDisplayableValue(icsValue.getValue(),icsName); +// }else { +// value = icsValue.getValue(); +// } +// } +// } +// values[0] = value; +// } + + + + /** + * ȡLOVʾֵ + * +++keyţȡţkey͵ֵvalueƥ䣬getValueOfKey(key)ԵStringֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(String value ,ICSPropertyDescription icsD) + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + for (String key : keys) { + if(value.equals(key)) + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputDialog.java b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputDialog.java new file mode 100644 index 0000000..fde7fb8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputDialog.java @@ -0,0 +1,1410 @@ +package com.connor.renben.process.plm.tmom028.copy; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.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.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +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.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.table.DefaultTableModel; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.connor.renben.process.plm.tmom010.TMom010SetPFMEADialog.AddRowsDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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.teamcenter.services.rac.core.ReservationService; + +public class TMom028JobProcessFormInputDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private TCComponentItemRevision itemRevision; + private List processRows=new ArrayList();;// ǰû޸ĵк + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList = new ArrayList(); + private List machiningParameterDeleteList = new ArrayList(); + private List controlRequirementDeleteList = new ArrayList(); + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem addRowsItem; + private JMenuItem remItem; + // ؼ + private JLabel companyNameLabel; + private JTextField companyNameField; + private JLabel itemIdLabel; + private JTextField itemIdField; + private JLabel equipmentIdLabel; + private JTextField equipmentIdField; + private JLabel meopLabel; + private JLabel konghang;// + private JTextField meopField; + private JLabel equipmentNameLabel; + private JTextField equipmentNameField; + + + private JLabel nextProcessLabel; + private JTextField nextProcessField; + private JLabel documentNumberLabel; + private JTextField documentNumbeField; + private JLabel versionLabel; + private JTextField versionField; + private JLabel productionLabel; + private JTextField productionField; + private JLabel establishmentLabel; + private JTextField establishmentField; + private JLabel examineLabel; + private JTextField examineField; + private JLabel approveLabel; + private JTextField approveField; + private JLabel releaseDateLabel; + private JTextField releaseDateField; + + // ѡ + private JTabbedPane tabbedPane; + private String[] properName = new String[] { + "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", // 豸 + "rb3_xdgx", + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; + private TCComponentDataset Dataset; + private TCComponentTcFile picFile; + private String outFilePathp=null; + private TCComponent[] comps; + private PicDialog picDialog; + + private String[] toolingDetailHeader = new String[] { "PLMEID", "", "Ŀ", "/ߴ", "/" }; + private CTable toolingDetailTable;// װϸ + private String[] machiningParameterHeader = new String[] { "PLMEID", "", "", "", "" }; + private CTable machiningParameterTable;// ӹ + private String[] controlRequirementHeader = new String[] { "PLMEID", "","", "Ŀ", "","չ","", "Ҫ","鷽", + "׼", "Լ", "Ѳ", "Ӧƻ","ע" }; + private CTable controlRequirementTable;// Ҫ + + // ť + private JPanel rootPanel; + private JButton reImportButton; + private JButton ImportHorizontal; + //private JButton ImportVertical; + private JButton selectPicture; + private JButton okButton; + private JButton celButton; + + public TMom028JobProcessFormInputDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, TCComponent form, + TCProperty[] properties) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.form = form; + this.properties = properties; + this.itemRevision= (TCComponentItemRevision) this.comp; + 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("hzzcgyk_display.TITLE")); + this.setPreferredSize(new Dimension(980, 750)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + this.companyNameLabel = new JLabel(rb.getString("gsmc28_display.TITLE")); + this.companyNameLabel.setPreferredSize(new Dimension(80, 30)); + this.companyNameField = new JTextField(); + this.companyNameField.setPreferredSize(new Dimension(200, 30)); + this.itemIdLabel = new JLabel(rb.getString("ljdh28_display.TITLE")); + this.itemIdLabel.setPreferredSize(new Dimension(80, 30)); + this.itemIdField = new JTextField(); + this.itemIdField.setPreferredSize(new Dimension(200, 30)); + this.equipmentIdLabel = new JLabel(rb.getString("sbxh28_display.TITLE")); + this.equipmentIdLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentIdField = new JTextField(); + this.equipmentIdField.setPreferredSize(new Dimension(200, 30)); + this.meopLabel = new JLabel(rb.getString("bgx28_display.TITLE")); + this.meopLabel.setPreferredSize(new Dimension(80, 30)); + this.meopField = new JTextField(); + this.meopField.setPreferredSize(new Dimension(200, 30)); + this.equipmentNameLabel = new JLabel(rb.getString("sbmc28_display.TITLE")); + this.equipmentNameLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentNameField = new JTextField(); + this.equipmentNameField.setPreferredSize(new Dimension(200, 30)); + + this.nextProcessLabel = new JLabel(rb.getString("xgx_display.TITLE")); + this.nextProcessLabel.setPreferredSize(new Dimension(80, 30)); + this.nextProcessField = new JTextField(); + this.nextProcessField.setPreferredSize(new Dimension(200, 30)); + this.documentNumberLabel = new JLabel(rb.getString("wjbh_display.TITLE")); + this.documentNumberLabel.setPreferredSize(new Dimension(80, 30)); + this.documentNumbeField = new JTextField(); + this.documentNumbeField.setPreferredSize(new Dimension(200, 30)); + this.versionLabel = new JLabel(rb.getString("bbh_display.TITLE")); + this.versionLabel.setPreferredSize(new Dimension(80, 30)); + this.versionField = new JTextField(); + this.versionField.setPreferredSize(new Dimension(200, 30)); + this.productionLabel = new JLabel(rb.getString("cxqy_display.TITLE")); + this.productionLabel.setPreferredSize(new Dimension(80, 30)); + this.productionField = new JTextField(); + this.productionField.setPreferredSize(new Dimension(200, 30)); + this.establishmentLabel = new JLabel(rb.getString("bz_display.TITLE")); + this.establishmentLabel.setPreferredSize(new Dimension(80, 30)); + this.establishmentField = new JTextField(); + this.establishmentField.setPreferredSize(new Dimension(200, 30)); + this.examineLabel = new JLabel(rb.getString("sh_display.TITLE")); + this.examineLabel.setPreferredSize(new Dimension(80, 30)); + this.examineField = new JTextField(); + this.examineField.setPreferredSize(new Dimension(200, 30)); + this.approveLabel = new JLabel(rb.getString("pz_display.TITLE")); + this.approveLabel.setPreferredSize(new Dimension(80, 30)); + this.approveField = new JTextField(); + this.approveField.setPreferredSize(new Dimension(200, 30)); + this.releaseDateLabel = new JLabel(rb.getString("fbrq_display.TITLE")); + this.releaseDateLabel.setPreferredSize(new Dimension(80, 30)); + this.releaseDateField = new JTextField(); + this.releaseDateField.setPreferredSize(new Dimension(200, 30)); + + +// private JLabel nextProcessLabel; +// private JTextField nextProcessField; +// private JLabel documentNumberLabel; +// private JTextField documentNumbeField; +// private JLabel versionLabel; +// private JTextField versionField; +// private JLabel productionLabel; +// private JTextField productionField; +// private JLabel establishmentLabel; +// private JTextField establishmentField; +// private JLabel examineLabel; +// private JTextField examineField; +// private JLabel approveLabel; +// private JTextField approveField; +// private JLabel releaseDateLabel; +// private JTextField releaseDateField; + + JPanel titlePanel = new JPanel(new PropertyLayout()); + titlePanel.add("1.1.left.top", this.companyNameLabel); + titlePanel.add("1.2.left.top", this.companyNameField); + titlePanel.add("1.3.left.top", this.itemIdLabel); + titlePanel.add("1.4.left.top", this.itemIdField); + titlePanel.add("1.5.left.top", this.meopLabel); + titlePanel.add("1.6.left.top", this.meopField); + titlePanel.add("2.1.left.top", this.equipmentIdLabel); + titlePanel.add("2.2.left.top", this.equipmentIdField); + titlePanel.add("2.3.left.top", this.equipmentNameLabel); + titlePanel.add("2.4.left.top", this.equipmentNameField); + titlePanel.add("2.5.left.top", this.nextProcessLabel); + titlePanel.add("2.6.left.top", this.nextProcessField); + titlePanel.add("3.1.left.top", this.documentNumberLabel); + titlePanel.add("3.2.left.top", this.documentNumbeField); + titlePanel.add("3.3.left.top", this.versionLabel); + titlePanel.add("3.4.left.top", this.versionField); + titlePanel.add("3.5.left.top", this.productionLabel); + titlePanel.add("3.6.left.top", this.productionField); + titlePanel.add("4.1.left.top", this.establishmentLabel); + titlePanel.add("4.2.left.top", this.establishmentField); + titlePanel.add("4.3.left.top", this.examineLabel); + titlePanel.add("4.4.left.top", this.examineField); + titlePanel.add("4.5.left.top", this.approveLabel); + titlePanel.add("4.6.left.top", this.approveField); + titlePanel.add("5.1.left.top", this.releaseDateLabel); + titlePanel.add("5.2.left.top", this.releaseDateField); + try { + if(comp.getProperty("release_status_list")!="") { + setPanelEnabled(titlePanel,false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + if (this.toolingDetailData.size() > 0) { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, this.toolingDetailData.size()); + } else { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, 1); + } + + this.toolingDetailTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (mouseevent.getClickCount() == 1) { + + ((CTMap) toolingDetailTable.getModel()).setRow(toolingDetailTable.getSelectedRow()); + ((CTMap) toolingDetailTable.getModel()).setColumn(toolingDetailTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfbj28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + menu.show(toolingDetailTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + if (this.machiningParameterData.size() > 0) { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, + this.machiningParameterData.size()); + } else { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, 1); + } + + this.machiningParameterTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + + ((CTMap) machiningParameterTable.getModel()).setRow(machiningParameterTable.getSelectedRow()); + ((CTMap) machiningParameterTable.getModel()).setColumn(machiningParameterTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(machiningParameterTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + if (this.controlRequirementData.size() > 0) { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, + this.controlRequirementData.size()); + } else { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, 1); + } + + this.controlRequirementTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) controlRequirementTable.getModel()).setRow(controlRequirementTable.getSelectedRow()); + ((CTMap) controlRequirementTable.getModel()).setColumn(controlRequirementTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(controlRequirementTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab(rb.getString("gzmx28_display.TITLE"), new JScrollPane(this.toolingDetailTable)); + tabbedPane.addTab(rb.getString("jgcs28_display.TITLE"), new JScrollPane(this.machiningParameterTable)); + tabbedPane.addTab(rb.getString("cptxkzyq28_display.TITLE"), new JScrollPane(this.controlRequirementTable)); + + setText(); + setToolingDetailTable(); + setMachiningParameterTable(); + setControlRequirementTable(); + + rootPanel = new JPanel(new FlowLayout()); + this.reImportButton=new JButton(rb.getString("cxdr_display.TITLE")); + this.reImportButton.setPreferredSize(new Dimension(100, 30)); + this.ImportHorizontal=new JButton(rb.getString("hzzcgykdc_display.TITLE")); + this.ImportHorizontal.setPreferredSize(new Dimension(150, 30)); + this.selectPicture=new JButton(rb.getString("xzdctp_display.TITLE")); + this.selectPicture.setPreferredSize(new Dimension(120, 30)); + this.okButton = new JButton(rb.getString("bc_display.TITLE")); + this.okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(reImportButton); + rootPanel.add(ImportHorizontal); + rootPanel.add(selectPicture); + rootPanel.add(okButton); + rootPanel.add(celButton); + + // ʼҼ˵ + menu = new JPopupMenu(); + + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + addRowsItem = new JMenuItem(rb.getString("tjdh_display.TITLE")); + remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); + + menu.add(addRowItem); + menu.add(addRowsItem); + menu.add(remItem); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + /*** + * ÿؼֵ + */ + private void setText() { + this.companyNameField.setText(this.properties[0].getStringValue()); + this.itemIdField.setText(this.properties[1].getStringValue()); + this.equipmentIdField.setText(this.properties[2].getStringValue()); + this.meopField.setText(this.properties[3].getStringValue()); + this.equipmentNameField.setText(this.properties[4].getStringValue()); + + + this.nextProcessField.setText(this.properties[5].getStringValue()); + this.documentNumbeField.setText(this.properties[6].getStringValue()); + this.versionField.setText(this.properties[7].getStringValue()); + this.productionField.setText(this.properties[8].getStringValue()); + this.establishmentField.setText(this.properties[9].getStringValue()); + this.examineField.setText(this.properties[10].getStringValue()); + this.approveField.setText(this.properties[11].getStringValue()); + this.releaseDateField.setText(this.properties[12].getStringValue()); + } + + /*** + * ÿؼֵ + */ + private List getText() { + List valueList = new ArrayList(); + valueList.add(this.companyNameField.getText()); + valueList.add(this.itemIdField.getText()); + valueList.add(this.equipmentIdField.getText()); + //valueList.add(""); + valueList.add(this.meopField.getText()); + valueList.add(this.equipmentNameField.getText()); + //valueList.add(""); + + valueList.add(this.nextProcessField.getText()); + valueList.add(this.documentNumbeField.getText()); + valueList.add(this.versionField.getText()); + valueList.add(this.productionField.getText()); + valueList.add(this.establishmentField.getText()); + valueList.add(this.examineField.getText()); + valueList.add(this.approveField.getText()); + valueList.add(this.releaseDateField.getText()); + return valueList; + } + + private void setToolingDetailTable() { + if (toolingDetailData.size() > 0) { + for (int i = 0; i < toolingDetailData.size(); i++) { + for (int j = 0; j < toolingDetailData.get(i).size(); j++) { + toolingDetailTable.setValueAt(toolingDetailData.get(i).get(j), i, j); + } + } + } else { + toolingDetailTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setMachiningParameterTable() { + if (machiningParameterData.size() > 0) { + for (int i = 0; i < machiningParameterData.size(); i++) { + for (int j = 0; j < machiningParameterData.get(i).size(); j++) { + machiningParameterTable.setValueAt(machiningParameterData.get(i).get(j), i, j); + } + } + } else { + machiningParameterTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setControlRequirementTable() { + if (controlRequirementData.size() > 0) { + for (int i = 0; i < controlRequirementData.size(); i++) { + for (int j = 0; j < controlRequirementData.get(i).size(); j++) { + controlRequirementTable.setValueAt(controlRequirementData.get(i).get(j), i, j); + } + } + } else { + controlRequirementTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + // Ӽ + public void createActionEvent() { + this.reImportButton.addActionListener(this); + this.ImportHorizontal.addActionListener(this); +// this.ImportVertical.addActionListener(this); + this.selectPicture.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.addRowItem.addActionListener(this); + this.addRowsItem.addActionListener(this); + this.remItem.addActionListener(this); + } + + public CTable getjTable(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); + + + partsTable = new CTable(map); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + //renderer.setProcessRows(processRows); + //renderer.setIsRelease(true); + try { + //˾޷༭ + if(comp.getProperty("release_status_list")!="") { + map.setEditable(false); + renderer.setBackground(new Color(220,220,220)); + }else { + map.setEditable(true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // //þ + 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; + } + + + + + //ÿؼȨ + 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); + } + } + } + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.okButton)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfbjbc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom028JobProcessFormInputOperation operation = new TMom028JobProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + + try { + operation.executeOperation(); + setPlmeidList(toolingDetailPlmeidList, toolingDetailTable); + setPlmeidList(machiningParameterPlmeidList, machiningParameterTable); + setPlmeidList(controlRequirementPlmeidList, controlRequirementTable); + + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + }else if (source.equals(this.reImportButton)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfcxdr28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + int i = JOptionPane.showConfirmDialog(null, rb.getString("cxdrhscxysj28_display.TITLE"), "µ", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + remAllRow(this.toolingDetailTable,"װϸ"); + remAllRow(this.machiningParameterTable,"ӹ"); + remAllRow(this.controlRequirementTable,"ƷԿҪ"); + dispose(); + TMom028JobProcessFormInputCommand command = new TMom028JobProcessFormInputCommand(app, + session,comp,true); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (i == JOptionPane.NO_OPTION) { + return; + } + } else if (source.equals(this.ImportHorizontal)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + try { + ImportCard(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + else if (source.equals(this.selectPicture)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfxz28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, rb.getString("yczdct28_display.TITLE"), "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + + } + else if (source.equals(this.addRowItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wftjh28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + addRow(1); + } else if (source.equals(this.addRowsItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wftjh28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + new AddRowsDialog(); + + } else if (source.equals(this.remItem)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfych28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + remRow(); + } else { + dispose(); + } + } + + //տ + private void ImportCard() throws TCException { + // + saveData(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + + String outFilePath = System.getenv("TEMP") + "\\"+"ת֧йտ.xlsx"; + File file = null; + file = TMomMethodUtil.getFile_New(session, "ת֧йտ", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormVerticalToExcel_Copy(getData(), file, outFilePath,picFile,outFilePathp); + if (ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision) app.getTargetComponent(), + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "ת֧йտ", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + + + this.dispose(); + + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = System.getenv("TEMP") + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + + // + private void saveData(){ + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom028JobProcessFormInputOperation operation = new TMom028JobProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + try { + operation.executeOperation(); + // ȡ汾 + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + + bean.setXdgx(this.properties[5].getStringValue()); + bean.setWjbh(this.properties[6].getStringValue()); + bean.setBbh(this.properties[7].getStringValue()); + bean.setCxqy(this.properties[8].getStringValue()); + bean.setBz(this.properties[9].getStringValue()); + bean.setSh(this.properties[10].getStringValue()); + bean.setPz(this.properties[11].getStringValue()); + bean.setFbrq(this.properties[12].getStringValue()); + + List> resultFormatData = new ArrayList<>(); + + for (List row : controlRequirementData) { +// if (row.size() < 14) continue; // ֹԽ + + List newRow = new ArrayList<>(); + newRow.add(row.get(0)); // PLMEID + newRow.add(row.get(1)); // ID + newRow.add(row.get(3)); // PROJECT + newRow.add(row.get(4)); // SPECIALITY + newRow.add(row.get(6)); // MANAGEMENT_REQUIREMENTS + newRow.add(row.get(8)); // CHECK_METHOD + newRow.add(row.get(9)); // FIRST_INSPECTION + newRow.add(row.get(10)); // SELF_INSPECTION + newRow.add(row.get(11)); // ROUTING_INSPECTION + newRow.add(row.get(12)); // REACTION_PLAN + newRow.add(row.get(13)); // REMARKS + newRow.add(row.get(5)); // PROCESS_SPECIFICATIONS + newRow.add(row.get(7)); // MANAGEMENT_POINTS + newRow.add(row.get(2)); // STEP_CONTENT + resultFormatData.add(newRow); + } + bean.setControlRequirementData(resultFormatData); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); +// bean.setControlRequirementData(controlRequirementData); + return bean; + } + + + //޸ϢرȨ + private void closePermission() { + //رȨ޸ + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//ǩ + } + } + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + // 17 + int d=map.getColumnCount(); + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + //رȨ޸ + closePermission(); + } + + /** + * + */ + private void addRow(int index) { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + map.insertRow(table.getSelectedRow() + index); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + index, 0); + table.revalidate();// + table.repaint();//ػ + } + + + + /** + * Ƴ + */ + private void remRow() { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + + switch (this.tabbedPane.getSelectedIndex()) { + case 0: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.toolingDetailPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.toolingDetailDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + + break; + case 1: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.machiningParameterPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.machiningParameterDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + case 2: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.controlRequirementPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.controlRequirementDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + + default: + break; + } + + map.removeRow(table.getSelectedRow()); + table.revalidate();// + table.repaint();//ػ + } + + /** + * µʱƳϢ + */ + private void remAllRow(CTable table,String tableName) { + List deleteAllList=new ArrayList(); + for (int j = 0; j < table.getRowCount(); j++) { + deleteAllList.add(table.getValueAt(j, 0).toString()); + } + switch (tableName) { + case "װϸ": + for(int i=0;i-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + public class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } +} + diff --git a/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputHandler.java b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputHandler.java new file mode 100644 index 0000000..272118b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputHandler.java @@ -0,0 +1,62 @@ +package com.connor.renben.process.plm.tmom028.copy; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.spire.xls.ExcelVersion; +import com.spire.xls.ViewMode; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import static java.awt.image.BufferedImage.TYPE_INT_ARGB; + +public class TMom028JobProcessFormInputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (app.getTargetComponent() == null) { + MessageBox.post(rb.getString("wxzzcgykbbdx28_display.TITLE"), "", MessageBox.ERROR); + return null; + } + // ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + // жѡжǷǻת֧йտİ汾 + if (comp.getType().indexOf("HZZCGYKRevision") > 0) { + + TMom028JobProcessFormInputCommand command = new TMom028JobProcessFormInputCommand(app, session, comp, + false); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txhzzcgyksb28_display.TITLE"), "", MessageBox.ERROR); + } + } else { + MessageBox.post(rb.getString("qxzhzzcgykbb28_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputOperation.java b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputOperation.java new file mode 100644 index 0000000..e44b8dd --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom028/copy/TMom028JobProcessFormInputOperation.java @@ -0,0 +1,212 @@ +package com.connor.renben.process.plm.tmom028.copy; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom028JobProcessFormInputOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList; + private List machiningParameterDeleteList; + private List controlRequirementDeleteList; + + public TMom028JobProcessFormInputOperation(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, + List toolingDetailDeleteList, List machiningParameterDeleteList, + List controlRequirementDeleteList, TCComponent form, TCProperty[] properties, + List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.toolingDetailDeleteList = toolingDetailDeleteList; + this.machiningParameterDeleteList = machiningParameterDeleteList; + this.controlRequirementDeleteList = controlRequirementDeleteList; + this.form = form; + this.properties = properties; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // + InputStream input = null; + try { + // + // жǷǰ汾 + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + TCComponentUser user = session.getUser(); + if (user.getUserId().equals(userName)) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.valueList.get(0)); + this.properties[1].setStringValue(this.valueList.get(1)); + this.properties[2].setStringValue(this.valueList.get(2)); + this.properties[3].setStringValue(this.valueList.get(3)); + this.properties[4].setStringValue(this.valueList.get(4)); + + this.properties[5].setStringValue(this.valueList.get(5)); + this.properties[6].setStringValue(this.valueList.get(6)); + this.properties[7].setStringValue(this.valueList.get(7)); + this.properties[8].setStringValue(this.valueList.get(8)); + this.properties[9].setStringValue(this.valueList.get(9)); + this.properties[10].setStringValue(this.valueList.get(10)); + this.properties[11].setStringValue(this.valueList.get(11)); + this.properties[12].setStringValue(this.valueList.get(12)); + + this.form.save(); + this.form.unlock(); + this.form.refresh(); + } + + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ɾ + for (int i = 0; i < this.toolingDetailDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILDELETE"), + toolingDetailDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.machiningParameterDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERDELETE"), + machiningParameterDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.controlRequirementDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTDELETE"), + controlRequirementDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + + // ȡݿ + SqlUtilT.getTCConnection(); + + for (int i = 0; i < toolingDetailData.size(); i++) { + List rowList = toolingDetailData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && toolingDetailPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),"" }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_TOOLINGDETAILINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),"" }, insertSQL); + } + + } + + for (int i = 0; i < machiningParameterData.size(); i++) { + List rowList = machiningParameterData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && machiningParameterPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4),"" }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_MACHININGPARAMETERINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4),"" }, insertSQL); + } + + } + + for (int i = 0; i < controlRequirementData.size(); i++) { + List rowList = controlRequirementData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && controlRequirementPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTUPDATE2"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(3), rowList.get(4),rowList.get(6), + rowList.get(8), rowList.get(9), + rowList.get(10),rowList.get(11),rowList.get(12),rowList.get(13),rowList.get(5), rowList.get(7), rowList.get(2) }, updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT2"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), + rowList.get(3), rowList.get(4),rowList.get(6), + rowList.get(8), rowList.get(9), rowList.get(10),rowList.get(11),rowList.get(12),rowList.get(13), rowList.get(5), rowList.get(7), rowList.get(2) }, insertSQL); + } + } + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom029/TMom029AssembleProcessFormInputCommand.java b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputCommand.java new file mode 100644 index 0000000..893e44a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputCommand.java @@ -0,0 +1,703 @@ +package com.connor.renben.process.plm.tmom029; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +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.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class TMom029AssembleProcessFormInputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc" }; // 豸 + private boolean isReImport; + + public TMom029AssembleProcessFormInputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,boolean isReImport) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.isReImport=isReImport; + } + + @Override + public void executeModal() throws Exception { + //жǷǩ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(((TCComponent) comp).isCheckedOut()) { + MessageBox.post(rb.getString("zzbj29_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ûǩڴʱǩ + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } +// String RB3_SBMC=null;//豸 +// String RB3_SBXH=null;//豸ͺ +// RB3_SBMC=properties[4].getStringValue(); +// RB3_SBMC=properties[2].getStringValue(); + //ж豸ƺͺǷΪգΪԶȡ + boolean SbIsNull=false; + if(properties[4].getStringValue().equals("")||properties[2].getStringValue().equals("")) { + SbIsNull=true; + } + + + + // TODO Auto-generated method stub + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + final List toolingDetailPlmeidList = new ArrayList(); + final List machiningParameterPlmeidList = new ArrayList(); + final List controlRequirementPlmeidList = new ArrayList(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("P1")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rs.getString("PLMEID")); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + rowList.add(machiningParameterRs.getString("P1")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(machiningParameterRs.getString("PLMEID")); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(controlRequirementRs.getString("PLMEID")); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + + TCComponent[] Revisions=(((TCComponent) comp).getReferenceListProperty("revision_list")); + String revisionID=((TCComponent) comp).getProperty("item_revision_id"); + //汾ĶûݵǼ̳ϸ汾 + if(Revisions.length>1&&!revisionID.equals("A")&&controlRequirementData.size()==0 + &&machiningParameterData.size()==0&&toolingDetailData.size()==0&&!isReImport) { + + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), 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("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("P1")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rowList.get(0)); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), Revisions[Revisions.length-2].getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + rowList.add(machiningParameterRs.getString("P1")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(rowList.get(0)); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), Revisions[Revisions.length-2].getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(rowList.get(0)); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + }else if(toolingDetailData.size()<=0&&controlRequirementData.size()<=0 + &&machiningParameterData.size()<=0) + { + //ݵǰѡжȡ + AIFComponentContext[] aifccs = itemRevision.getItem().whereReferenced(); + TCComponentMEOPRevision meop = null; + TCComponentMEProcessRevision meprocess = null; + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEOPRevision) { + meop = (TCComponentMEOPRevision)aifcc_MEOP.getComponent(); + break; + } + } + if(meop != null) + { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + for (TCComponent tcComponent : its) { + if (tcComponent instanceof TCComponentMEProcessRevision) { + meprocess = (TCComponentMEProcessRevision)tcComponent; + break; + } + } + } + if(meprocess == null) + { + MessageBox.post(rb.getString("wzdgy29_display.TITLE"), "", MessageBox.ERROR); + return; + } + + //ȡװϢ + TCComponent[] components = meop.getRelatedComponents("ps_children"); + System.out.println("汾жԴ"+components.toString()); + if(components.length>0) + { + Integer rowIndex = 1; + for (int j = 0; j < components.length; j++) { + + if(components[j] instanceof TCComponentItemRevision) + { + TCComponentItemRevision item = (TCComponentItemRevision)components[j]; + //+++ + //ȡID + String ClassID=item.getClassificationClass(); + + //װķID12... + if(ClassID.substring(0,2).equals("12")) {//ֻȡơ + String[] values = new String[3]; + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + //ȡװ1201Ļȡ660605 + if(ClassID.substring(0,4).equals("1201")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==660605) { + values[2] = icsValue.getValue(); + } + } + }else { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==71000) {//ĹװȡIDΪ71000 + values[2] = icsValue.getValue(); + } + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + }else if(ClassID.substring(0,2).equals("13")) {//׺Ʒɰ֡ʯձʣķID13.... + String[] values = new String[3];//ȡơߴ硢 + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ȡ + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==130101) {//γߴidΪ130101 + values[1] = icsValue.getValue(); + } + if(icsValue.getId()==660606) {//׺ƷŵidΪ660606 + values[2] = icsValue.getValue(); + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if (ClassID.substring(0,2).equals("16")) {//Ʒչ֣ķID16.... + String[] values = new String[3];//ֻȡ + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if(SbIsNull==true&&ClassID.substring(0,2).equals("15")) {//ȡ豸Ϣ + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + //ȡ豸 + properties[4].setStringValue(item.getStringProperty("object_name")); + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==72001) {//豸ͺŵidΪ72001 + properties[2].setStringValue(icsValue.getValue()); + } + + } + SbIsNull=false; + } + //+++ + + } + } + } + String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + String itemType = getControlType((TCComponentMEProcess)meprocess.getItem()); + + //+++ȡտƼƻĵһ汾ݸҵտΪʼ + TCComponent[] ControlComponents = meprocess.getItem().getReferenceListProperty("IMAN_reference"); + String controlUid=""; + for(int i=0;i= 0) { + TCComponent[] ControlRevisions=ControlComponents[i].getReferenceListProperty("revision_list"); + controlUid=ControlRevisions[ControlRevisions.length-1].getUid();//ѡһ汾UID + } + } + //++++ + + ResultSet rsData = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_CONTROLPLANDATASELECT"), meprocessUid,meopId,itemType,controlUid); + rsData = SqlUtilT.read(sql); + Integer rowIndex = 1; + Integer rowIndexM = 1; + Integer rowIndexC = 1; + int flag=0; + int sflag=0; + int zflag=0; + int xflag=0; + int BH=1; + Map map=new HashMap(); + String ss=rsData.toString(); + List RowList = new ArrayList(); + System.out.print(ss); + while (rsData.next()) { + //ӿƼƻȡӹRB3_GC=ƣRB3_TSTX=ԣRB3_CPGC= + if(rsData.getString("RB3_GC")!=null) { + List machiningParameterrowList = new ArrayList(); + machiningParameterrowList.add(UUID.randomUUID().toString().replace("-", "")); + //rowList.add(rowIndex.toString()); + //machiningParameterrowList.add(rsData.getString("RB3_QPTBH"));//ÿƼƻŴ + machiningParameterrowList.add(rowIndexM.toString()); + machiningParameterrowList.add(rsData.getString("RB3_GC")); + machiningParameterrowList.add(rsData.getString("RB3_TSTX")); + machiningParameterrowList.add(rsData.getString("RB3_CPGC")); + machiningParameterData.add(machiningParameterrowList); + rowIndexM++; + } + + + //2022.2.22Ϊֹδдδϲ±Ϊnullʱ޷תΪInteger+++++++ + if(rsData.getString("RB3_QPTBH")==null||rsData.getString("RB3_QPTBH").equals("")) { + MessageBox.post(rb.getString("qwskzjh28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //++++++++ + + + //ŷıʱmapеݺϳ + if(map.size()>0&&RowList.size()>0&&Integer.valueOf(rsData.getString("RB3_QPTBH"))!=BH) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + //ӿƼƻȡƷԿҪ + //RB3_CP=ĿRB3_TSTX=ԣRB3_CPGC=ҪRB3_CLFF=鷽RB3_RL=׼/RB3_RL/RB3_PL=/Ѳ,RB3_FYJH=Ӧƻ + + if(rsData.getString("RB3_CP")!=null&&rsData.getString("RB3_KZFF")!=null) { + + if(rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("Ѳ")<0) { + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(UUID.randomUUID().toString().replace("-", "")); + //controlRequirementRowList.add(rowIndex.toString()); + controlRequirementRowList.add(String.valueOf(controlRequirementData.size()+1));//ÿƼƻŴ + controlRequirementRowList.add(rsData.getString("RB3_CP")); + controlRequirementRowList.add(rsData.getString("RB3_TSTX")); + controlRequirementRowList.add(rsData.getString("RB3_CPGC")); + controlRequirementRowList.add(rsData.getString("RB3_CLFF")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_FYJH")); + controlRequirementData.add(controlRequirementRowList); + rowIndexC++; + }else { + + if(rsData.getString("RB3_KZFF").indexOf("")>-1&&sflag==1) { + sflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1&&zflag==1) { + zflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1&&xflag==1){ + xflag=2; + } + if((map.size()>0&&RowList.size()>0&&(sflag>1||zflag>1||xflag>1))) { + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + + } + + if(flag==0) { + RowList.add(UUID.randomUUID().toString().replace("-", ""));//տuid + RowList.add(String.valueOf(controlRequirementData.size()+1)); + RowList.add(rsData.getString("RB3_CP")); + RowList.add(rsData.getString("RB3_TSTX")); + RowList.add(rsData.getString("RB3_CPGC")); + RowList.add(rsData.getString("RB3_CLFF")); + RowList.add(rsData.getString("RB3_FYJH")); + RowList.add(""); + flag++; + } + + if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + sflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + zflag++; + }else { + map.put("Ѳ", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + xflag++; + } + + } + } + BH=Integer.valueOf(rsData.getString("RB3_QPTBH")); + rowIndex++; + } + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rsData != null) { + SqlUtilT.free(rsData); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + + + new Thread() { + @Override + public void run() { + new TMom029AssembleProcessFormInputDialog(app, session, comp, toolingDetailData, machiningParameterData, + controlRequirementData, toolingDetailPlmeidList, machiningParameterPlmeidList, + controlRequirementPlmeidList, form, properties); + super.run(); + } + }.start(); + super.executeModal(); + } + + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private String getControlType(TCComponentMEProcess tccmep) throws Exception { + String kzjhType = null; + + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>"+kzjh); + if ("RB3_SCKZJH".equals(itemType)) + { + //жǷΪƼƻ + return itemType; + } + + if ("RB3_SSCKZJH".equals(itemType)) + { + return itemType; + } + + if ("RB3_YJKZJH".equals(itemType)) + { + return itemType; + } + } + } + return kzjhType; + } + + /** + * ȡLOVʾֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(String value ,ICSPropertyDescription icsD) + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + for (String key : keys) { + if(value.equals(key)) + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + + +} diff --git a/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputDialog.java b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputDialog.java new file mode 100644 index 0000000..f9ea79f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputDialog.java @@ -0,0 +1,1078 @@ +package com.connor.renben.process.plm.tmom029; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +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.List; +import java.util.Locale; +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.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom028.TMom028JobProcessFormInputCommand; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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.teamcenter.services.rac.core.ReservationService; + +public class TMom029AssembleProcessFormInputDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList = new ArrayList(); + private List machiningParameterDeleteList = new ArrayList(); + private List controlRequirementDeleteList = new ArrayList(); + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem remItem; + // ؼ + private JLabel companyNameLabel; + private JTextField companyNameField; + private JLabel itemIdLabel; + private JTextField itemIdField; + private JLabel equipmentIdLabel; + private JTextField equipmentIdField; + private JLabel meopLabel; + private JTextField meopField; + private JLabel nextMeopLabel; + private JTextField nextMeopField; + + // ѡ + private JTabbedPane tabbedPane; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc" }; // 豸 + private TCComponentDataset Dataset; + private TCComponentTcFile picFile; + private String outFilePathp=null; + private TCComponent[] comps; + private JButton selectPicture; + private PicDialog picDialog; + private JButton ImportCard; + private TCComponentItemRevision itemRevision; + + private String[] toolingDetailHeader = new String[] { "PLMEID", "", "", "ͼ", "", "" }; + private CTable toolingDetailTable;// װϸ + private String[] machiningParameterHeader = new String[] { "PLMEID", "", "װ䲽輰Ҫ", "豸/װ", "ͺ", "/" }; + private CTable machiningParameterTable;// ӹ + private String[] controlRequirementHeader = new String[] { "PLMEID", "", "Ŀ", "", "Ҫ", "鷽", + "׼", "Լ", "Ѳ", "Ӧƻ" }; + private CTable controlRequirementTable;// Ҫ + + // ť + private JPanel rootPanel; + private JButton reImportButton; + private JButton okButton; + private JButton celButton; + + public TMom029AssembleProcessFormInputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, TCComponent form, + TCProperty[] properties) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.form = form; + this.properties = properties; + this.itemRevision= (TCComponentItemRevision) this.comp; + 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("zpgyk29_display.TITLE")); + this.setPreferredSize(new Dimension(980, 750)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + + + this.companyNameLabel = new JLabel(rb.getString("gsmc29_display.TITLE")); + this.companyNameLabel.setPreferredSize(new Dimension(80, 30)); + this.companyNameField = new JTextField(); + this.companyNameField.setPreferredSize(new Dimension(200, 30)); + this.itemIdLabel = new JLabel(rb.getString("ljdh29_display.TITLE")); + this.itemIdLabel.setPreferredSize(new Dimension(80, 30)); + this.itemIdField = new JTextField(); + this.itemIdField.setPreferredSize(new Dimension(200, 30)); + this.equipmentIdLabel = new JLabel(rb.getString("sbxh29_display.TITLE")); + this.equipmentIdLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentIdField = new JTextField(); + this.equipmentIdField.setPreferredSize(new Dimension(200, 30)); + this.meopLabel = new JLabel(rb.getString("bgx28_display.TITLE")); + this.meopLabel.setPreferredSize(new Dimension(80, 30)); + this.meopField = new JTextField(); + this.meopField.setPreferredSize(new Dimension(200, 30)); + this.nextMeopLabel = new JLabel(rb.getString("sbmc28_display.TITLE")); + this.nextMeopLabel.setPreferredSize(new Dimension(80, 30)); + this.nextMeopField = new JTextField(); + this.nextMeopField.setPreferredSize(new Dimension(200, 30)); + + JPanel titlePanel = new JPanel(new PropertyLayout()); + titlePanel.add("1.1.left.top", this.companyNameLabel); + titlePanel.add("1.2.left.top", this.companyNameField); + titlePanel.add("1.3.left.top", this.itemIdLabel); + titlePanel.add("1.4.left.top", this.itemIdField); + titlePanel.add("1.5.left.top", this.equipmentIdLabel); + titlePanel.add("1.6.left.top", this.equipmentIdField); + titlePanel.add("2.1.left.top", this.meopLabel); + titlePanel.add("2.2.left.top", this.meopField); + titlePanel.add("2.3.left.top", this.nextMeopLabel); + titlePanel.add("2.4.left.top", this.nextMeopField); + + try { + if(comp.getProperty("release_status_list")!="") { + setPanelEnabled(titlePanel,false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + if (this.toolingDetailData.size() > 0) { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, this.toolingDetailData.size()); + } else { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, 1); + } + + this.toolingDetailTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) toolingDetailTable.getModel()).setRow(toolingDetailTable.getSelectedRow()); + ((CTMap) toolingDetailTable.getModel()).setColumn(toolingDetailTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(toolingDetailTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + if (this.machiningParameterData.size() > 0) { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, + this.machiningParameterData.size()); + } else { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, 1); + } + + this.machiningParameterTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) machiningParameterTable.getModel()).setRow(machiningParameterTable.getSelectedRow()); + ((CTMap) machiningParameterTable.getModel()).setColumn(machiningParameterTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(machiningParameterTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + if (this.controlRequirementData.size() > 0) { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, + this.controlRequirementData.size()); + } else { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, 1); + } + + this.controlRequirementTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) controlRequirementTable.getModel()).setRow(controlRequirementTable.getSelectedRow()); + ((CTMap) controlRequirementTable.getModel()).setColumn(controlRequirementTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(controlRequirementTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab(rb.getString("gzmx28_display.TITLE"), new JScrollPane(this.toolingDetailTable)); + tabbedPane.addTab(rb.getString("jgcs28_display.TITLE"), new JScrollPane(this.machiningParameterTable)); + tabbedPane.addTab(rb.getString("cptxkzyq28_display.TITLE"), new JScrollPane(this.controlRequirementTable)); + + setText(); + setToolingDetailTable(); + setMachiningParameterTable(); + setControlRequirementTable(); + + rootPanel = new JPanel(new FlowLayout()); + this.reImportButton=new JButton(rb.getString("cxdr_display.TITLE")); + this.reImportButton.setPreferredSize(new Dimension(100, 30)); + this.ImportCard=new JButton(rb.getString("zpgykdc_display.TITLE")); + this.ImportCard.setPreferredSize(new Dimension(150, 30)); + this.selectPicture=new JButton(rb.getString("xzdctp_display.TITLE")); + this.selectPicture.setPreferredSize(new Dimension(120, 30)); + this.okButton = new JButton(rb.getString("bc_display.TITLE")); + this.okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(reImportButton); + rootPanel.add(ImportCard); + rootPanel.add(selectPicture); + //rootPanel.add(new JLabel(" ")); + rootPanel.add(okButton); + //rootPanel.add(new JLabel(" ")); + rootPanel.add(celButton); + + // ʼҼ˵ + menu = new JPopupMenu(); + + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); + + menu.add(addRowItem); + menu.add(remItem); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + //رȨ޸ + closePermission(); + } + + //޸ϢرȨ + private void closePermission() { + //رȨ޸ + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//ǩ + } + } + + + /*** + * ÿؼֵ + */ + private void setText() { + this.companyNameField.setText(this.properties[0].getStringValue()); + this.itemIdField.setText(this.properties[1].getStringValue()); + this.equipmentIdField.setText(this.properties[2].getStringValue()); + this.meopField.setText(this.properties[3].getStringValue()); + this.nextMeopField.setText(this.properties[4].getStringValue()); + } + + /*** + * ÿؼֵ + */ + private List getText() { + List valueList = new ArrayList(); + valueList.add(this.companyNameField.getText()); + valueList.add(this.itemIdField.getText()); + valueList.add(this.equipmentIdField.getText()); + valueList.add(this.meopField.getText()); + valueList.add(this.nextMeopField.getText()); + return valueList; + } + + private void setToolingDetailTable() { + if (toolingDetailData.size() > 0) { + for (int i = 0; i < toolingDetailData.size(); i++) { + for (int j = 0; j < toolingDetailData.get(i).size(); j++) { + toolingDetailTable.setValueAt(toolingDetailData.get(i).get(j), i, j); + } + } + } else { + toolingDetailTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setMachiningParameterTable() { + if (machiningParameterData.size() > 0) { + for (int i = 0; i < machiningParameterData.size(); i++) { + for (int j = 0; j < machiningParameterData.get(i).size(); j++) { + machiningParameterTable.setValueAt(machiningParameterData.get(i).get(j), i, j); + } + } + } else { + machiningParameterTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setControlRequirementTable() { + if (controlRequirementData.size() > 0) { + for (int i = 0; i < controlRequirementData.size(); i++) { + for (int j = 0; j < controlRequirementData.get(i).size(); j++) { + controlRequirementTable.setValueAt(controlRequirementData.get(i).get(j), i, j); + } + } + } else { + controlRequirementTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + // Ӽ + public void createActionEvent() { + this.reImportButton.addActionListener(this); + this.ImportCard.addActionListener(this); + this.selectPicture.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.addRowItem.addActionListener(this); + this.remItem.addActionListener(this); + } + + public CTable getjTable(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); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + try { + //˾޷༭ + if(comp.getProperty("release_status_list")!="") { + map.setEditable(false); + }else { + map.setEditable(true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + // //þ + 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; + } + + //ÿؼȨ + 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); + } + } + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.okButton)) { + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom029AssembleProcessFormInputOperation operation = new TMom029AssembleProcessFormInputOperation(app, + session, comp, toolingDetailData, machiningParameterData, controlRequirementData, + toolingDetailPlmeidList, machiningParameterPlmeidList, controlRequirementPlmeidList, + toolingDetailDeleteList, machiningParameterDeleteList, controlRequirementDeleteList, form, + properties, valueList); + + try { + operation.executeOperation(); + setPlmeidList(toolingDetailPlmeidList, toolingDetailTable); + setPlmeidList(machiningParameterPlmeidList, machiningParameterTable); + setPlmeidList(controlRequirementPlmeidList, controlRequirementTable); + + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if (source.equals(this.reImportButton)) { + + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfcxdr28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + int i = JOptionPane.showConfirmDialog(null, rb.getString("cxdrhscxysj28_display.TITLE"), "µ", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + remAllRow(this.toolingDetailTable,"װϸ"); + remAllRow(this.machiningParameterTable,"ӹ"); + remAllRow(this.controlRequirementTable,"ƷԿҪ"); + dispose(); + TMom029AssembleProcessFormInputCommand command = new TMom029AssembleProcessFormInputCommand(app, + session,comp,true); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (i == JOptionPane.NO_OPTION) { + return; + } + + } else if (source.equals(this.ImportCard)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + ImportCard(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + }else if (source.equals(this.selectPicture)) { + + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfxz28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, rb.getString("yczdct28_display.TITLE"), "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + else if (source.equals(this.addRowItem)) { + addRow(1); + } else if (source.equals(this.remItem)) { + remRow(); + } else { + dispose(); + } + } + + + //տ + private void ImportCard() throws TCException { + // + saveData(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + String outFilePath = System.getenv("TEMP") + "\\"+"װ乤տ.xlsx"; + File file = null; + file = TMomMethodUtil.getFile(session, "װ乤տ", "MSExcelX"); + try { + ExcelUtil07.writeAssembleProcessFormToExcel(getData(), file, outFilePath,picFile,outFilePathp); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (ExcelUtil07.getExcelToItem(session, itemRevision, + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "տ", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + this.dispose(); + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = System.getenv("TEMP") + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + // + private void saveData(){ + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom029AssembleProcessFormInputOperation operation = new TMom029AssembleProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + try { + operation.executeOperation(); + // ȡ汾 + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + // 17 + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + /** + * + */ + private void addRow(int index) { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.revalidate(); + table.repaint(); + } + + /** + * Ƴ + */ + private void remRow() { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + + switch (this.tabbedPane.getSelectedIndex()) { + case 0: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.toolingDetailPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.toolingDetailDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + case 1: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.machiningParameterPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.machiningParameterDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + case 2: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.controlRequirementPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.controlRequirementDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + + default: + break; + } + map.removeRow(table.getSelectedRow()); + table.repaint(); + } + + /** + * µʱƳϢ + */ + private void remAllRow(CTable table,String tableName) { + List deleteAllList=new ArrayList(); + for (int j = 0; j < table.getRowCount(); j++) { + deleteAllList.add(table.getValueAt(j, 0).toString()); + } + switch (tableName) { + case "װϸ": + for(int i=0;i-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + public class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } +} diff --git a/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputHandler.java b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputHandler.java new file mode 100644 index 0000000..2ab112d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputHandler.java @@ -0,0 +1,51 @@ +package com.connor.renben.process.plm.tmom029; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom029AssembleProcessFormInputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzpgyk29_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷװ乤տİ汾 + if(comp.getType().indexOf("ZPGYKRevision") > 0) + { + TMom029AssembleProcessFormInputCommand command = new TMom029AssembleProcessFormInputCommand(app, + session,comp,false); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txsb29_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzbb29_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputOperation.java b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputOperation.java new file mode 100644 index 0000000..d9f18f1 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/TMom029AssembleProcessFormInputOperation.java @@ -0,0 +1,201 @@ +package com.connor.renben.process.plm.tmom029; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom029AssembleProcessFormInputOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList; + private List machiningParameterDeleteList; + private List controlRequirementDeleteList; + + public TMom029AssembleProcessFormInputOperation(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, + List toolingDetailDeleteList, List machiningParameterDeleteList, + List controlRequirementDeleteList, TCComponent form, TCProperty[] properties, + List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.toolingDetailDeleteList = toolingDetailDeleteList; + this.machiningParameterDeleteList = machiningParameterDeleteList; + this.controlRequirementDeleteList = controlRequirementDeleteList; + this.form = form; + this.properties = properties; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // + InputStream input = null; + try { + // + // жǷǰ汾 + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + TCComponentUser user = session.getUser(); + if (user.getUserId().equals(userName)) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.valueList.get(0)); + this.properties[1].setStringValue(this.valueList.get(1)); + this.properties[2].setStringValue(this.valueList.get(2)); + this.properties[3].setStringValue(this.valueList.get(3)); + this.properties[4].setStringValue(this.valueList.get(4)); + this.form.save(); + this.form.unlock(); + this.form.refresh(); + } + + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ɾ + for (int i = 0; i < this.toolingDetailDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILDELETE"), + toolingDetailDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.machiningParameterDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERDELETE"), + machiningParameterDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.controlRequirementDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTDELETE"), + controlRequirementDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + + // ȡݿ + SqlUtilT.getTCConnection(); + + for (int i = 0; i < toolingDetailData.size(); i++) { + List rowList = toolingDetailData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && toolingDetailPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4), rowList.get(5) }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_TOOLINGDETAILINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), rowList.get(5) }, insertSQL); + } + + } + + for (int i = 0; i < machiningParameterData.size(); i++) { + List rowList = machiningParameterData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && machiningParameterPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4), rowList.get(5) }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_MACHININGPARAMETERINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), rowList.get(5) }, insertSQL); + } + + } + + for (int i = 0; i < controlRequirementData.size(); i++) { + List rowList = controlRequirementData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && controlRequirementPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTUPDATE"), rowList.get(0)); + 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),"" }, updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), 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),"" }, insertSQL); + } + } + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom029/_new/TMom029AssembleProcessFormInputCommand.java b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputCommand.java new file mode 100644 index 0000000..8deb491 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputCommand.java @@ -0,0 +1,730 @@ +package com.connor.renben.process.plm.tmom029._new; + +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.HashMap; +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +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.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; + +public class TMom029AssembleProcessFormInputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", // 豸 + "rb3_xdgx", + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; + private boolean isReImport; + + public TMom029AssembleProcessFormInputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,boolean isReImport) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.isReImport=isReImport; + } + + @Override + public void executeModal() throws Exception { + //жǷǩ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(((TCComponent) comp).isCheckedOut()) { + MessageBox.post(rb.getString("zzbj29_display.TITLE"), "", MessageBox.ERROR); + return; + } + //ûǩڴʱǩ + new ReserveOperation(new AIFComponentContext(comp, + comp, "context")).executeModeless(); + + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } +// String RB3_SBMC=null;//豸 +// String RB3_SBXH=null;//豸ͺ +// RB3_SBMC=properties[4].getStringValue(); +// RB3_SBMC=properties[2].getStringValue(); + //ж豸ƺͺǷΪգΪԶȡ + boolean SbIsNull=false; + if(properties[4].getStringValue().equals("")||properties[2].getStringValue().equals("")) { + SbIsNull=true; + } + + TMomMethodUtil.setBgxAndXdgx(properties[1],properties[3],properties[5],itemRevision); + + // TODO Auto-generated method stub + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + final List toolingDetailPlmeidList = new ArrayList(); + final List machiningParameterPlmeidList = new ArrayList(); + final List controlRequirementPlmeidList = new ArrayList(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("P1")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rs.getString("PLMEID")); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + rowList.add(machiningParameterRs.getString("P1")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(machiningParameterRs.getString("PLMEID")); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(controlRequirementRs.getString("PLMEID")); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + + TCComponent[] Revisions=(((TCComponent) comp).getReferenceListProperty("revision_list")); + String revisionID=((TCComponent) comp).getProperty("item_revision_id"); + //汾ĶûݵǼ̳ϸ汾 + if(Revisions.length>1&&!revisionID.equals("A")&&controlRequirementData.size()==0 + &&machiningParameterData.size()==0&&toolingDetailData.size()==0&&!isReImport) { + + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), 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("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("P1")); + toolingDetailData.add(rowList); + toolingDetailPlmeidList.add(rowList.get(0)); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), Revisions[Revisions.length-2].getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + rowList.add(machiningParameterRs.getString("P1")); + machiningParameterData.add(rowList); + machiningParameterPlmeidList.add(rowList.get(0)); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), Revisions[Revisions.length-2].getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(rowList.get(0)); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + }else if(toolingDetailData.size()<=0&&controlRequirementData.size()<=0 + &&machiningParameterData.size()<=0) + { + //ݵǰѡжȡ + AIFComponentContext[] aifccs = itemRevision.getItem().whereReferenced(); + TCComponentMEOPRevision meop = null; + TCComponentMEProcessRevision meprocess = null; + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEOPRevision) { + meop = (TCComponentMEOPRevision)aifcc_MEOP.getComponent(); + break; + } + } + if(meop != null) + { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + for (TCComponent tcComponent : its) { + if (tcComponent instanceof TCComponentMEProcessRevision) { + meprocess = (TCComponentMEProcessRevision)tcComponent; + break; + } + } + } + if(meprocess == null) + { + MessageBox.post(rb.getString("wzdgy29_display.TITLE"), "", MessageBox.ERROR); + return; + } + + //ȡװϢ + TCComponent[] components = meop.getRelatedComponents("ps_children"); + System.out.println("汾жԴ"+components.toString()); + if(components.length>0) + { + Integer rowIndex = 1; + for (int j = 0; j < components.length; j++) { + + if(components[j] instanceof TCComponentItemRevision) + { + TCComponentItemRevision item = (TCComponentItemRevision)components[j]; + //+++ + //ȡID + String ClassID=item.getClassificationClass(); + + //װķID12... + if(ClassID.substring(0,2).equals("12")) {//ֻȡơ + String[] values = new String[3]; + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + //ȡװ1201Ļȡ660605 + if(ClassID.substring(0,4).equals("1201")) { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==660605) { + values[2] = icsValue.getValue(); + } + } + }else { + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==71000) {//ĹװȡIDΪ71000 + values[2] = icsValue.getValue(); + } + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + }else if(ClassID.substring(0,2).equals("13")) {//׺Ʒɰ֡ʯձʣķID13.... + String[] values = new String[3];//ȡơߴ硢 + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ȡ + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==130101) {//γߴidΪ130101 + values[1] = icsValue.getValue(); + } + if(icsValue.getId()==660606) {//׺ƷŵidΪ660606 + values[2] = icsValue.getValue(); + } + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if (ClassID.substring(0,2).equals("16")) {//Ʒչ֣ķID16.... + String[] values = new String[3];//ֻȡ + //ȡ + values[0] = item.getStringProperty("object_name"); + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(rowIndex.toString()); + rowList.add(values[0]); + rowList.add(values[1]==null?"":values[1]); + rowList.add(values[2]==null?"":values[2]); + toolingDetailData.add(rowList); + rowIndex++; + + }else if(SbIsNull==true&&ClassID.substring(0,2).equals("15")) {//ȡ豸Ϣ + TCComponentICO[] icos = item.getClassificationObjects();//ȡ + if (icos.length <= 0) { + continue; + } + //ȡ豸 + properties[4].setStringValue(item.getStringProperty("object_name")); + ICSProperty[] icsValues = icos[0].getICSProperties(true);//ȡԵֵ + //ICSPropertyDescription[] icsDNames = icos[0].getICSPropertyDescriptors();//ȡԵ + + for (ICSProperty icsValue : icsValues) { + if (icsValue.getId()==72001) {//豸ͺŵidΪ72001 + properties[2].setStringValue(icsValue.getValue()); + } + + } + SbIsNull=false; + } + //+++ + + } + } + } + String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + String itemType = getControlType((TCComponentMEProcess)meprocess.getItem()); + + //+++ȡտƼƻĵһ汾ݸҵտΪʼ + TCComponent[] ControlComponents = meprocess.getItem().getReferenceListProperty("IMAN_reference"); + String controlUid=""; + for(int i=0;i= 0) { + TCComponent[] ControlRevisions=ControlComponents[i].getReferenceListProperty("revision_list"); + controlUid=ControlRevisions[ControlRevisions.length-1].getUid();//ѡһ汾UID + } + } + //++++ + + ResultSet rsData = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_CONTROLPLANDATASELECT"), meprocessUid,meopId,itemType,controlUid); + rsData = SqlUtilT.read(sql); + Integer rowIndex = 1; + Integer rowIndexM = 1; + Integer rowIndexC = 1; + int flag=0; + int sflag=0; + int zflag=0; + int xflag=0; + int BH=1; + Map map=new HashMap(); + String ss=rsData.toString(); + List RowList = new ArrayList(); + System.out.print(ss); + while (rsData.next()) { + //ӿƼƻȡӹRB3_GC=ƣRB3_TSTX=ԣRB3_CPGC= + if(rsData.getString("RB3_GC")!=null) { + List machiningParameterrowList = new ArrayList(); + machiningParameterrowList.add(UUID.randomUUID().toString().replace("-", "")); + //rowList.add(rowIndex.toString()); + //machiningParameterrowList.add(rsData.getString("RB3_QPTBH"));//ÿƼƻŴ + machiningParameterrowList.add(rowIndexM.toString()); + machiningParameterrowList.add(rsData.getString("RB3_GC")); + machiningParameterrowList.add(rsData.getString("RB3_TSTX")); + machiningParameterrowList.add(rsData.getString("RB3_CPGC")); + machiningParameterData.add(machiningParameterrowList); + rowIndexM++; + } + + + //2022.2.22Ϊֹδдδϲ±Ϊnullʱ޷תΪInteger+++++++ + if(rsData.getString("RB3_QPTBH")==null||rsData.getString("RB3_QPTBH").equals("")) { + MessageBox.post(rb.getString("qwskzjh28_display.TITLE"), "", MessageBox.ERROR); + return; + } + //++++++++ + + + //ŷıʱmapеݺϳ + if(map.size()>0&&RowList.size()>0&&Integer.valueOf(rsData.getString("RB3_QPTBH"))!=BH) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + //ӿƼƻȡƷԿҪ + //RB3_CP=ĿRB3_TSTX=ԣRB3_CPGC=ҪRB3_CLFF=鷽RB3_RL=׼/RB3_RL/RB3_PL=/Ѳ,RB3_FYJH=Ӧƻ + + if(rsData.getString("RB3_CP")!=null&&rsData.getString("RB3_KZFF")!=null) { + + if(rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("")<0&& + rsData.getString("RB3_KZFF").indexOf("Ѳ")<0) { + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(UUID.randomUUID().toString().replace("-", "")); + //controlRequirementRowList.add(rowIndex.toString()); + controlRequirementRowList.add(String.valueOf(controlRequirementData.size()+1));//ÿƼƻŴ + controlRequirementRowList.add(rsData.getString("RB3_CP")); + controlRequirementRowList.add(rsData.getString("RB3_TSTX")); + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CPGC")); + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CLFF")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_FYJH")); + controlRequirementData.add(controlRequirementRowList); + rowIndexC++; + }else { + + if(rsData.getString("RB3_KZFF").indexOf("")>-1&&sflag==1) { + sflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1&&zflag==1) { + zflag=2; + }else if(rsData.getString("RB3_KZFF").indexOf("Ѳ")>-1&&xflag==1){ + xflag=2; + } + if((map.size()>0&&RowList.size()>0&&(sflag>1||zflag>1||xflag>1))) { + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + + } + + if(flag==0) { + RowList.add(UUID.randomUUID().toString().replace("-", ""));//տuid + RowList.add(String.valueOf(controlRequirementData.size()+1)); + RowList.add(rsData.getString("RB3_CP")); + RowList.add(rsData.getString("RB3_TSTX")); + RowList.add(rsData.getString("RB3_CPGC")); + RowList.add(rsData.getString("RB3_CLFF")); + RowList.add(rsData.getString("RB3_FYJH")); + RowList.add(""); + RowList.add(""); + RowList.add(""); + flag++; + } + + if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + sflag++; + }else if(rsData.getString("RB3_KZFF").indexOf("")>-1) { + map.put("", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + zflag++; + }else { + map.put("Ѳ", rsData.getString("RB3_RL")+"/"+rsData.getString("RB3_PL")); + xflag++; + } + + } + } + BH=Integer.valueOf(rsData.getString("RB3_QPTBH")); + rowIndex++; + } + if(map!=null&&map.size()>0&&RowList.size()>0) { + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(RowList.get(0));//ÿƼƻŴ + controlRequirementRowList.add(RowList.get(1)); + controlRequirementRowList.add(RowList.get(2)); + controlRequirementRowList.add(RowList.get(3)); + controlRequirementRowList.add(RowList.get(8)); + controlRequirementRowList.add(RowList.get(4)); + controlRequirementRowList.add(RowList.get(9)); + controlRequirementRowList.add(RowList.get(5)); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("")!=null?map.get(""):"/"); + controlRequirementRowList.add(map.get("Ѳ")!=null?map.get("Ѳ"):"/"); + controlRequirementRowList.add(RowList.get(6)); + controlRequirementData.add(controlRequirementRowList); + flag=0; + map.clear(); + RowList.clear(); + sflag=0; + zflag=0; + xflag=0; + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rsData != null) { + SqlUtilT.free(rsData); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + + + new Thread() { + @Override + public void run() { + new TMom029AssembleProcessFormInputDialog(app, session, comp, toolingDetailData, machiningParameterData, + controlRequirementData, toolingDetailPlmeidList, machiningParameterPlmeidList, + controlRequirementPlmeidList, form, properties); + super.run(); + } + }.start(); + super.executeModal(); + } + + /** + * ȡµĿƼƻ + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private String getControlType(TCComponentMEProcess tccmep) throws Exception { + String kzjhType = null; + + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>"+kzjh); + if ("RB3_SCKZJH".equals(itemType)) + { + //жǷΪƼƻ + return itemType; + } + + if ("RB3_SSCKZJH".equals(itemType)) + { + return itemType; + } + + if ("RB3_YJKZJH".equals(itemType)) + { + return itemType; + } + } + } + return kzjhType; + } + + /** + * ȡLOVʾֵ + * @param icsD + * @return + */ + public static String getClassDisplayableValue(String value ,ICSPropertyDescription icsD) + { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + for (String key : keys) { + if(value.equals(key)) + { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + + +} diff --git a/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputDialog.java b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputDialog.java new file mode 100644 index 0000000..21fe4d4 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputDialog.java @@ -0,0 +1,1206 @@ +package com.connor.renben.process.plm.tmom029._new; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +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.List; +import java.util.Locale; +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.JTabbedPane; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom028.TMom028JobProcessFormInputCommand; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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.teamcenter.services.rac.core.ReservationService; + +public class TMom029AssembleProcessFormInputDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList = new ArrayList(); + private List machiningParameterDeleteList = new ArrayList(); + private List controlRequirementDeleteList = new ArrayList(); + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem remItem; + // ؼ + private JLabel companyNameLabel; + private JTextField companyNameField; + private JLabel itemIdLabel; + private JTextField itemIdField; + private JLabel equipmentIdLabel; + private JTextField equipmentIdField; + private JLabel meopLabel; + private JTextField meopField; + private JLabel nextMeopLabel; + private JTextField nextMeopField; + + + private JLabel nextProcessLabel; + private JTextField nextProcessField; + private JLabel documentNumberLabel; + private JTextField documentNumbeField; + private JLabel versionLabel; + private JTextField versionField; + private JLabel productionLabel; + private JTextField productionField; + private JLabel establishmentLabel; + private JTextField establishmentField; + private JLabel examineLabel; + private JTextField examineField; + private JLabel approveLabel; + private JTextField approveField; + private JLabel releaseDateLabel; + private JTextField releaseDateField; + + // ѡ + private JTabbedPane tabbedPane; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", // 豸 + "rb3_xdgx", + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; + private TCComponentDataset Dataset; + private TCComponentTcFile picFile; + private String outFilePathp=null; + private TCComponent[] comps; + private JButton selectPicture; + private PicDialog picDialog; + private JButton ImportCard; + private TCComponentItemRevision itemRevision; + + private String[] toolingDetailHeader = new String[] { "PLMEID", "", "", "ͼ", "", "" }; + private CTable toolingDetailTable;// װϸ + private String[] machiningParameterHeader = new String[] { "PLMEID", "", "װ䲽輰Ҫ", "豸/װ", "ͺ", "/" }; + private CTable machiningParameterTable;// ӹ + private String[] controlRequirementHeader = new String[] { "PLMEID", "", "Ŀ", "", "չ","", "Ҫ", "鷽", + "׼", "Լ", "Ѳ", "Ӧƻ" }; + private CTable controlRequirementTable;// Ҫ + + // ť + private JPanel rootPanel; + private JButton reImportButton; + private JButton okButton; + private JButton celButton; + + public TMom029AssembleProcessFormInputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, TCComponent form, + TCProperty[] properties) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.form = form; + this.properties = properties; + this.itemRevision= (TCComponentItemRevision) this.comp; + 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("zpgyk29_display.TITLE")); + this.setPreferredSize(new Dimension(980, 750)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + + + this.companyNameLabel = new JLabel(rb.getString("gsmc29_display.TITLE")); + this.companyNameLabel.setPreferredSize(new Dimension(80, 30)); + this.companyNameField = new JTextField(); + this.companyNameField.setPreferredSize(new Dimension(200, 30)); + this.itemIdLabel = new JLabel(rb.getString("ljdh29_display.TITLE")); + this.itemIdLabel.setPreferredSize(new Dimension(80, 30)); + this.itemIdField = new JTextField(); + this.itemIdField.setPreferredSize(new Dimension(200, 30)); + this.equipmentIdLabel = new JLabel(rb.getString("sbxh29_display.TITLE")); + this.equipmentIdLabel.setPreferredSize(new Dimension(80, 30)); + this.equipmentIdField = new JTextField(); + this.equipmentIdField.setPreferredSize(new Dimension(200, 30)); + this.meopLabel = new JLabel(rb.getString("bgx28_display.TITLE")); + this.meopLabel.setPreferredSize(new Dimension(80, 30)); + this.meopField = new JTextField(); + this.meopField.setPreferredSize(new Dimension(200, 30)); + this.nextMeopLabel = new JLabel(rb.getString("sbmc28_display.TITLE")); + this.nextMeopLabel.setPreferredSize(new Dimension(80, 30)); + this.nextMeopField = new JTextField(); + this.nextMeopField.setPreferredSize(new Dimension(200, 30)); + + this.nextProcessLabel = new JLabel(rb.getString("xgx_display.TITLE")); + this.nextProcessLabel.setPreferredSize(new Dimension(80, 30)); + this.nextProcessField = new JTextField(); + this.nextProcessField.setPreferredSize(new Dimension(200, 30)); + this.documentNumberLabel = new JLabel(rb.getString("wjbh_display.TITLE")); + this.documentNumberLabel.setPreferredSize(new Dimension(80, 30)); + this.documentNumbeField = new JTextField(); + this.documentNumbeField.setPreferredSize(new Dimension(200, 30)); + this.versionLabel = new JLabel(rb.getString("bbh_display.TITLE")); + this.versionLabel.setPreferredSize(new Dimension(80, 30)); + this.versionField = new JTextField(); + this.versionField.setPreferredSize(new Dimension(200, 30)); + this.productionLabel = new JLabel(rb.getString("cxqy_display.TITLE")); + this.productionLabel.setPreferredSize(new Dimension(80, 30)); + this.productionField = new JTextField(); + this.productionField.setPreferredSize(new Dimension(200, 30)); + this.establishmentLabel = new JLabel(rb.getString("bz_display.TITLE")); + this.establishmentLabel.setPreferredSize(new Dimension(80, 30)); + this.establishmentField = new JTextField(); + this.establishmentField.setPreferredSize(new Dimension(200, 30)); + this.examineLabel = new JLabel(rb.getString("sh_display.TITLE")); + this.examineLabel.setPreferredSize(new Dimension(80, 30)); + this.examineField = new JTextField(); + this.examineField.setPreferredSize(new Dimension(200, 30)); + this.approveLabel = new JLabel(rb.getString("pz_display.TITLE")); + this.approveLabel.setPreferredSize(new Dimension(80, 30)); + this.approveField = new JTextField(); + this.approveField.setPreferredSize(new Dimension(200, 30)); + this.releaseDateLabel = new JLabel(rb.getString("fbrq_display.TITLE")); + this.releaseDateLabel.setPreferredSize(new Dimension(80, 30)); + this.releaseDateField = new JTextField(); + this.releaseDateField.setPreferredSize(new Dimension(200, 30)); + + JPanel titlePanel = new JPanel(new PropertyLayout()); + titlePanel.add("1.1.left.top", this.companyNameLabel); + titlePanel.add("1.2.left.top", this.companyNameField); + titlePanel.add("1.3.left.top", this.itemIdLabel); + titlePanel.add("1.4.left.top", this.itemIdField); + titlePanel.add("1.5.left.top", this.equipmentIdLabel); + titlePanel.add("1.6.left.top", this.equipmentIdField); + titlePanel.add("2.1.left.top", this.meopLabel); + titlePanel.add("2.2.left.top", this.meopField); + titlePanel.add("2.3.left.top", this.nextMeopLabel); + titlePanel.add("2.4.left.top", this.nextMeopField); + + titlePanel.add("2.5.left.top", this.nextProcessLabel); + titlePanel.add("2.6.left.top", this.nextProcessField); + titlePanel.add("3.1.left.top", this.documentNumberLabel); + titlePanel.add("3.2.left.top", this.documentNumbeField); + titlePanel.add("3.3.left.top", this.versionLabel); + titlePanel.add("3.4.left.top", this.versionField); + titlePanel.add("3.5.left.top", this.productionLabel); + titlePanel.add("3.6.left.top", this.productionField); + titlePanel.add("4.1.left.top", this.establishmentLabel); + titlePanel.add("4.2.left.top", this.establishmentField); + titlePanel.add("4.3.left.top", this.examineLabel); + titlePanel.add("4.4.left.top", this.examineField); + titlePanel.add("4.5.left.top", this.approveLabel); + titlePanel.add("4.6.left.top", this.approveField); + titlePanel.add("5.1.left.top", this.releaseDateLabel); + titlePanel.add("5.2.left.top", this.releaseDateField); + try { + if(comp.getProperty("release_status_list")!="") { + setPanelEnabled(titlePanel,false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + if (this.toolingDetailData.size() > 0) { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, this.toolingDetailData.size()); + } else { + this.toolingDetailTable = getjTable(null, null, toolingDetailHeader, 1); + } + + this.toolingDetailTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) toolingDetailTable.getModel()).setRow(toolingDetailTable.getSelectedRow()); + ((CTMap) toolingDetailTable.getModel()).setColumn(toolingDetailTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(toolingDetailTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + if (this.machiningParameterData.size() > 0) { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, + this.machiningParameterData.size()); + } else { + this.machiningParameterTable = getjTable(null, null, machiningParameterHeader, 1); + } + + this.machiningParameterTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) machiningParameterTable.getModel()).setRow(machiningParameterTable.getSelectedRow()); + ((CTMap) machiningParameterTable.getModel()).setColumn(machiningParameterTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(machiningParameterTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + if (this.controlRequirementData.size() > 0) { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, + this.controlRequirementData.size()); + } else { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, 1); + } + + this.controlRequirementTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) controlRequirementTable.getModel()).setRow(controlRequirementTable.getSelectedRow()); + ((CTMap) controlRequirementTable.getModel()).setColumn(controlRequirementTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(controlRequirementTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab(rb.getString("gzmx28_display.TITLE"), new JScrollPane(this.toolingDetailTable)); + tabbedPane.addTab(rb.getString("jgcs28_display.TITLE"), new JScrollPane(this.machiningParameterTable)); + tabbedPane.addTab(rb.getString("cptxkzyq28_display.TITLE"), new JScrollPane(this.controlRequirementTable)); + + setText(); + setToolingDetailTable(); + setMachiningParameterTable(); + setControlRequirementTable(); + + rootPanel = new JPanel(new FlowLayout()); + this.reImportButton=new JButton(rb.getString("cxdr_display.TITLE")); + this.reImportButton.setPreferredSize(new Dimension(100, 30)); + this.ImportCard=new JButton(rb.getString("zpgykdc_display.TITLE")); + this.ImportCard.setPreferredSize(new Dimension(150, 30)); + this.selectPicture=new JButton(rb.getString("xzdctp_display.TITLE")); + this.selectPicture.setPreferredSize(new Dimension(120, 30)); + this.okButton = new JButton(rb.getString("bc_display.TITLE")); + this.okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(reImportButton); + rootPanel.add(ImportCard); + rootPanel.add(selectPicture); + //rootPanel.add(new JLabel(" ")); + rootPanel.add(okButton); + //rootPanel.add(new JLabel(" ")); + rootPanel.add(celButton); + + // ʼҼ˵ + menu = new JPopupMenu(); + + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); + + menu.add(addRowItem); + menu.add(remItem); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + //رȨ޸ + closePermission(); + } + + //޸ϢرȨ + private void closePermission() { + //رȨ޸ + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//ǩ + } + } + + + /*** + * ÿؼֵ + */ + private void setText() { + this.companyNameField.setText(this.properties[0].getStringValue()); + this.itemIdField.setText(this.properties[1].getStringValue()); + this.equipmentIdField.setText(this.properties[2].getStringValue()); + this.meopField.setText(this.properties[3].getStringValue()); + this.nextMeopField.setText(this.properties[4].getStringValue()); + + this.nextProcessField.setText(this.properties[5].getStringValue()); + this.documentNumbeField.setText(this.properties[6].getStringValue()); + this.versionField.setText(this.properties[7].getStringValue()); + this.productionField.setText(this.properties[8].getStringValue()); + this.establishmentField.setText(this.properties[9].getStringValue()); + this.examineField.setText(this.properties[10].getStringValue()); + this.approveField.setText(this.properties[11].getStringValue()); + this.releaseDateField.setText(this.properties[12].getStringValue()); + } + + /*** + * ÿؼֵ + */ + private List getText() { + List valueList = new ArrayList(); + valueList.add(this.companyNameField.getText()); + valueList.add(this.itemIdField.getText()); + valueList.add(this.equipmentIdField.getText()); + valueList.add(this.meopField.getText()); + valueList.add(this.nextMeopField.getText()); + + valueList.add(this.nextProcessField.getText()); + valueList.add(this.documentNumbeField.getText()); + valueList.add(this.versionField.getText()); + valueList.add(this.productionField.getText()); + valueList.add(this.establishmentField.getText()); + valueList.add(this.examineField.getText()); + valueList.add(this.approveField.getText()); + valueList.add(this.releaseDateField.getText()); + return valueList; + } + + private void setToolingDetailTable() { + if (toolingDetailData.size() > 0) { + for (int i = 0; i < toolingDetailData.size(); i++) { + for (int j = 0; j < toolingDetailData.get(i).size(); j++) { + toolingDetailTable.setValueAt(toolingDetailData.get(i).get(j), i, j); + } + } + } else { + toolingDetailTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setMachiningParameterTable() { + if (machiningParameterData.size() > 0) { + for (int i = 0; i < machiningParameterData.size(); i++) { + for (int j = 0; j < machiningParameterData.get(i).size(); j++) { + machiningParameterTable.setValueAt(machiningParameterData.get(i).get(j), i, j); + } + } + } else { + machiningParameterTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + private void setControlRequirementTable() { + if (controlRequirementData.size() > 0) { + for (int i = 0; i < controlRequirementData.size(); i++) { + for (int j = 0; j < controlRequirementData.get(i).size(); j++) { + controlRequirementTable.setValueAt(controlRequirementData.get(i).get(j), i, j); + } + } + } else { + controlRequirementTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + // Ӽ + public void createActionEvent() { + this.reImportButton.addActionListener(this); + this.ImportCard.addActionListener(this); + this.selectPicture.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.addRowItem.addActionListener(this); + this.remItem.addActionListener(this); + } + + public CTable getjTable(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); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + try { + //˾޷༭ + if(comp.getProperty("release_status_list")!="") { + map.setEditable(false); + }else { + map.setEditable(true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + // //þ + 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; + } + + //ÿؼȨ + 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); + } + } + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.okButton)) { + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom029AssembleProcessFormInputOperation operation = new TMom029AssembleProcessFormInputOperation(app, + session, comp, toolingDetailData, machiningParameterData, controlRequirementData, + toolingDetailPlmeidList, machiningParameterPlmeidList, controlRequirementPlmeidList, + toolingDetailDeleteList, machiningParameterDeleteList, controlRequirementDeleteList, form, + properties, valueList); + + try { + operation.executeOperation(); + setPlmeidList(toolingDetailPlmeidList, toolingDetailTable); + setPlmeidList(machiningParameterPlmeidList, machiningParameterTable); + setPlmeidList(controlRequirementPlmeidList, controlRequirementTable); + + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if (source.equals(this.reImportButton)) { + + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfcxdr28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + int i = JOptionPane.showConfirmDialog(null, rb.getString("cxdrhscxysj28_display.TITLE"), "µ", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + remAllRow(this.toolingDetailTable,"װϸ"); + remAllRow(this.machiningParameterTable,"ӹ"); + remAllRow(this.controlRequirementTable,"ƷԿҪ"); + dispose(); + TMom029AssembleProcessFormInputCommand command = new TMom029AssembleProcessFormInputCommand(app, + session,comp,true); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (i == JOptionPane.NO_OPTION) { + return; + } + + } else if (source.equals(this.ImportCard)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + ImportCard(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + }else if (source.equals(this.selectPicture)) { + + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfxz28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, rb.getString("yczdct28_display.TITLE"), "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + else if (source.equals(this.addRowItem)) { + addRow(1); + } else if (source.equals(this.remItem)) { + remRow(); + } else { + dispose(); + } + } + + + //տ + private void ImportCard() throws TCException { + // + saveData(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + String outFilePath = System.getenv("TEMP") + "\\"+"װ乤տ.xlsx"; + File file = null; + file = TMomMethodUtil.getFile_New(session, "װ乤տ£", "MSExcelX"); + try { + ExcelUtil07.writeAssembleProcessFormToExcel_New(getData(), file, outFilePath,picFile,outFilePathp); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (ExcelUtil07.getExcelToItem(session, itemRevision, + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "տ", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + this.dispose(); + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + + bean.setXdgx(this.properties[5].getStringValue()); + bean.setWjbh(this.properties[6].getStringValue()); + bean.setBbh(this.properties[7].getStringValue()); + bean.setCxqy(this.properties[8].getStringValue()); + bean.setBz(this.properties[9].getStringValue()); + bean.setSh(this.properties[10].getStringValue()); + bean.setPz(this.properties[11].getStringValue()); + bean.setFbrq(this.properties[12].getStringValue()); + + List> result2FormatData = new ArrayList<>(); + + for (List row : controlRequirementData) { +// if (row.size() < 12) continue; // ȫ飬쳣 + + List newRow = new ArrayList<>(); + newRow.add(row.get(0)); // PLMEID + newRow.add(row.get(1)); // ID + newRow.add(row.get(2)); // PROJECT + newRow.add(row.get(3)); // SPECIALITY + newRow.add(row.get(5)); // MANAGEMENT_REQUIREMENTS + newRow.add(row.get(7)); // CHECK_METHOD + newRow.add(row.get(8)); // FIRST_INSPECTION + newRow.add(row.get(9)); // SELF_INSPECTION + newRow.add(row.get(10)); // ROUTING_INSPECTION + newRow.add(row.get(11)); // REACTION_PLAN +// newRow.add(row.get(12)); // REMARKS + newRow.add(row.get(4)); // PROCESS_SPECIFICATIONS + newRow.add(row.get(6)); // MANAGEMENT_POINTS + + result2FormatData.add(newRow); + } + bean.setControlRequirementData(result2FormatData); + + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); +// bean.setControlRequirementData(controlRequirementData); + return bean; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = System.getenv("TEMP") + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + // + private void saveData(){ + if (toolingDetailTable.getSelectedRow() >= 0 && toolingDetailTable.getSelectedColumn() >= 0) { + (toolingDetailTable.getCellEditor(toolingDetailTable.getSelectedRow(), toolingDetailTable.getSelectedColumn())).stopCellEditing(); + } + if (machiningParameterTable.getSelectedRow() >= 0 && machiningParameterTable.getSelectedColumn() >= 0) { + (machiningParameterTable.getCellEditor(machiningParameterTable.getSelectedRow(), machiningParameterTable.getSelectedColumn())).stopCellEditing(); + } + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.toolingDetailData = getTableValue(this.toolingDetailTable); + this.machiningParameterData = getTableValue(this.machiningParameterTable); + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom029AssembleProcessFormInputOperation operation = new TMom029AssembleProcessFormInputOperation(app, session, comp, + toolingDetailData, machiningParameterData, controlRequirementData, toolingDetailPlmeidList, + machiningParameterPlmeidList, controlRequirementPlmeidList, toolingDetailDeleteList, + machiningParameterDeleteList, controlRequirementDeleteList, form, properties, valueList); + try { + operation.executeOperation(); + // ȡ汾 + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + // 17 + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + /** + * + */ + private void addRow(int index) { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.revalidate(); + table.repaint(); + } + + /** + * Ƴ + */ + private void remRow() { + // TODO Auto-generated method stub + CTable table = toolingDetailTable; + switch (this.tabbedPane.getSelectedIndex()) { + case 1: + table = machiningParameterTable; + break; + case 2: + table = controlRequirementTable; + break; + + default: + break; + } + CTMap map = ((CTMap) table.getModel()); + + switch (this.tabbedPane.getSelectedIndex()) { + case 0: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.toolingDetailPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.toolingDetailDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + case 1: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.machiningParameterPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.machiningParameterDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + case 2: + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.controlRequirementPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.controlRequirementDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + break; + + default: + break; + } + map.removeRow(table.getSelectedRow()); + table.repaint(); + } + + /** + * µʱƳϢ + */ + private void remAllRow(CTable table,String tableName) { + List deleteAllList=new ArrayList(); + for (int j = 0; j < table.getRowCount(); j++) { + deleteAllList.add(table.getValueAt(j, 0).toString()); + } + switch (tableName) { + case "װϸ": + for(int i=0;i-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + public class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } +} diff --git a/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputHandler.java b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputHandler.java new file mode 100644 index 0000000..42fc0ae --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputHandler.java @@ -0,0 +1,51 @@ +package com.connor.renben.process.plm.tmom029._new; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom029AssembleProcessFormInputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzpgyk29_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷװ乤տİ汾 + if(comp.getType().indexOf("ZPGYKRevision") > 0) + { + TMom029AssembleProcessFormInputCommand command = new TMom029AssembleProcessFormInputCommand(app, + session,comp,false); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txsb29_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzbb29_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputOperation.java b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputOperation.java new file mode 100644 index 0000000..bc112e4 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom029/_new/TMom029AssembleProcessFormInputOperation.java @@ -0,0 +1,211 @@ +package com.connor.renben.process.plm.tmom029._new; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom029AssembleProcessFormInputOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + private List toolingDetailPlmeidList; + private List machiningParameterPlmeidList; + private List controlRequirementPlmeidList; + + private List toolingDetailDeleteList; + private List machiningParameterDeleteList; + private List controlRequirementDeleteList; + + public TMom029AssembleProcessFormInputOperation(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> toolingDetailData, List> machiningParameterData, + List> controlRequirementData, List toolingDetailPlmeidList, + List machiningParameterPlmeidList, List controlRequirementPlmeidList, + List toolingDetailDeleteList, List machiningParameterDeleteList, + List controlRequirementDeleteList, TCComponent form, TCProperty[] properties, + List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + this.toolingDetailPlmeidList = toolingDetailPlmeidList; + this.machiningParameterPlmeidList = machiningParameterPlmeidList; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.toolingDetailDeleteList = toolingDetailDeleteList; + this.machiningParameterDeleteList = machiningParameterDeleteList; + this.controlRequirementDeleteList = controlRequirementDeleteList; + this.form = form; + this.properties = properties; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // + InputStream input = null; + try { + // + // жǷǰ汾 + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + TCComponentUser user = session.getUser(); + if (user.getUserId().equals(userName)) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.valueList.get(0)); + this.properties[1].setStringValue(this.valueList.get(1)); + this.properties[2].setStringValue(this.valueList.get(2)); + this.properties[3].setStringValue(this.valueList.get(3)); + this.properties[4].setStringValue(this.valueList.get(4)); + + + this.properties[5].setStringValue(this.valueList.get(5)); + this.properties[6].setStringValue(this.valueList.get(6)); + this.properties[7].setStringValue(this.valueList.get(7)); + this.properties[8].setStringValue(this.valueList.get(8)); + this.properties[9].setStringValue(this.valueList.get(9)); + this.properties[10].setStringValue(this.valueList.get(10)); + this.properties[11].setStringValue(this.valueList.get(11)); + this.properties[12].setStringValue(this.valueList.get(12)); + this.form.save(); + this.form.unlock(); + this.form.refresh(); + } + + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ɾ + for (int i = 0; i < this.toolingDetailDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILDELETE"), + toolingDetailDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.machiningParameterDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERDELETE"), + machiningParameterDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + for (int i = 0; i < this.controlRequirementDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTDELETE"), + controlRequirementDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + + // ȡݿ + SqlUtilT.getTCConnection(); + + for (int i = 0; i < toolingDetailData.size(); i++) { + List rowList = toolingDetailData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && toolingDetailPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_TOOLINGDETAILUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4), rowList.get(5) }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_TOOLINGDETAILINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), rowList.get(5) }, insertSQL); + } + + } + + for (int i = 0; i < machiningParameterData.size(); i++) { + List rowList = machiningParameterData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && machiningParameterPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_MACHININGPARAMETERUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4), rowList.get(5) }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_MACHININGPARAMETERINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4), rowList.get(5) }, insertSQL); + } + + } + + for (int i = 0; i < controlRequirementData.size(); i++) { + List rowList = controlRequirementData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && controlRequirementPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTUPDATE2"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), + rowList.get(5), rowList.get(7), rowList.get(8), + rowList.get(9),rowList.get(10),rowList.get(11),"", rowList.get(4),rowList.get(6) ,""}, updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT2"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3),rowList.get(5), + rowList.get(7), rowList.get(8), rowList.get(9),rowList.get(10),rowList.get(11),"",rowList.get(4),rowList.get(6),"" }, insertSQL); + } + } + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom030/TMom030OperationReferenceBookInputCommand.java b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputCommand.java new file mode 100644 index 0000000..7a50a1d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputCommand.java @@ -0,0 +1,316 @@ +package com.connor.renben.process.plm.tmom030; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +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 TMom030OperationReferenceBookInputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ(ŲƷ) + "rb3_bgx", // + }; // 豸 + private boolean isReImport = true; + + public TMom030OperationReferenceBookInputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, boolean isReImport) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.isReImport = isReImport; + } + + @Override + public void executeModal() throws Exception { + // жǷǩ + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (((TCComponent) comp).isCheckedOut()) { + MessageBox.post(rb.getString("zzbj29_display.TITLE"), "", MessageBox.ERROR); + return; + } + // ûǩڴʱǩ + new ReserveOperation(new AIFComponentContext(comp, comp, "context")).executeModeless(); + + // TODO Auto-generated method stub + // ѡжPUIDȡ + final List> controlRequirementData = new ArrayList>(); + final List controlRequirementPlmeidList = new ArrayList(); + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + String sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("REMARKS"));// дڱע + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD"));// ۲дڼⷽ + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION"));// ƵдѲFIRST_INSPECTION + rowList.add(controlRequirementRs.getString("SELF_INSPECTION"));// дԼSELF_INSPECTION + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(controlRequirementRs.getString("PLMEID")); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + TCComponent[] Revisions = (((TCComponent) comp).getReferenceListProperty("revision_list")); + String revisionID = ((TCComponent) comp).getProperty("item_revision_id"); + // 汾ĶûݵǼ̳ϸ汾 + if (Revisions.length > 1 && !revisionID.equals("A") && controlRequirementData.size() == 0 && !isReImport) { + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + String sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), + Revisions[Revisions.length - 2].getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + String string = controlRequirementRs.getString("ID"); + if(string == null || "".equals(string.trim())) { + continue; + } + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("REMARKS"));// дڱע + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD"));// ۲дڼⷽ + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION"));// ƵдѲFIRST_INSPECTION + rowList.add(controlRequirementRs.getString("SELF_INSPECTION"));// дԼSELF_INSPECTION + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + controlRequirementData.add(rowList); + controlRequirementPlmeidList.add(rowList.get(0)); + } + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } else if (controlRequirementPlmeidList.size() <= 0) { + // ݵǰѡжȡ + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + AIFComponentContext[] aifccs = itemRevision.getItem().whereReferenced(); + TCComponentMEOPRevision meop = null; + TCComponentMEProcessRevision meprocess = null; + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEOPRevision) { + meop = (TCComponentMEOPRevision) aifcc_MEOP.getComponent(); + break; + } + } + if (meop != null) { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + for (TCComponent tcComponent : its) { + if (tcComponent instanceof TCComponentMEProcessRevision) { + meprocess = (TCComponentMEProcessRevision) tcComponent; + break; + } + } + } + if (meprocess == null) { + MessageBox.post(rb.getString("wzdgx30_display.TITLE"), "", MessageBox.ERROR); + return; + } + String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + String itemType = getControlType((TCComponentMEProcess) meprocess.getItem()); + System.out.println("itemType:" + itemType); + + // +++ȡտƼƻĵһ汾ݸҵտΪʼ + TCComponent[] ControlComponents = meprocess.getItem().getReferenceListProperty("IMAN_reference"); + String controlUid = ""; + for (int i = 0; i < ControlComponents.length; i++) { + if (ControlComponents[i].getType().indexOf("RB3_SSCKZJH") >= 0) { + TCComponent[] ControlRevisions = ControlComponents[i].getReferenceListProperty("revision_list"); + controlUid = ControlRevisions[ControlRevisions.length - 1].getUid();// ѡһ汾UID + System.out.println("controlUid:" + controlUid); + break; + } + } + // ++++ + + ResultSet rsData = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + System.out.println("meprocessUid:" + meprocessUid); + System.out.println("meopId:" + meopId); + System.out.println("meopId:" + meopId); + System.out.println("itemType:" + itemType); + System.out.println("controlUid:" + controlUid); + String sql = String.format(pro.getProperty("RB3_CONTROLPLANDATASELECT"), meprocessUid, meopId, itemType, + controlUid); + System.out.println("sql:" + sql); + rsData = SqlUtilT.read(sql); + Integer rowIndex = 1; + while (rsData.next()) { + // ӿƼƻȡƷԿҪ + // RB3_CP=ĿRB3_TSTX=ԣRB3_CPGC=ҪRB3_CLFF=鷽RB3_RL=׼/RB3_RL/RB3_PL=/Ѳ,RB3_FYJH=Ӧƻ + + List controlRequirementRowList = new ArrayList(); + controlRequirementRowList.add(UUID.randomUUID().toString().replace("-", "")); + controlRequirementRowList.add(rowIndex.toString()); + controlRequirementRowList.add(""); + controlRequirementRowList.add(rsData.getString("RB3_CP")); + controlRequirementRowList.add(rsData.getString("RB3_TSTX")); + controlRequirementRowList.add(rsData.getString("RB3_CPGC")); + controlRequirementRowList.add(rsData.getString("RB3_CLFF")); + controlRequirementRowList.add(rsData.getString("RB3_PL")); + controlRequirementRowList.add(rsData.getString("RB3_RL")); + controlRequirementRowList.add(rsData.getString("RB3_FYJH")); + controlRequirementData.add(controlRequirementRowList); + rowIndex++; + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rsData != null) { + SqlUtilT.free(rsData); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + + new Thread() { + @Override + public void run() { + new TMom030OperationReferenceBookInputDialog(app, session, comp, controlRequirementData, + controlRequirementPlmeidList, form, properties); + super.run(); + } + }.start(); + super.executeModal(); + } + + /** + * ȡµĿƼƻ + * + * @param item2 ѡеĹ + * @return + * @throws Exception + */ + private String getControlType(TCComponentMEProcess tccmep) throws Exception { + String kzjhType = null; + + AIFComponentContext[] tccmepChildrens = tccmep.getChildren(); + for (AIFComponentContext tccmepChildren : tccmepChildrens) { + if (tccmepChildren.getComponent() instanceof TCComponentItem) { + TCComponentItem kzjh = (TCComponentItem) tccmepChildren.getComponent(); + String itemType = kzjh.getType(); + System.out.println("kzjh=========================>" + kzjh); + System.out.println("itemType:" + itemType); + if ("RB3_SCKZJH".equals(itemType)) { + // жǷΪƼƻ + return itemType; + } + + if ("RB3_SSCKZJH".equals(itemType)) { + return itemType; + } + + if ("RB3_YJKZJH".equals(itemType)) { + return itemType; + } + } + } + return kzjhType; + } +} diff --git a/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputDialog.java b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputDialog.java new file mode 100644 index 0000000..cfe7069 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputDialog.java @@ -0,0 +1,964 @@ +package com.connor.renben.process.plm.tmom030; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +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.List; +import java.util.Locale; +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.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.JViewport; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom028.TMom028JobProcessFormInputCommand; +import com.connor.renben.process.plm.tmom029.TMom029AssembleProcessFormInputOperation; +import com.connor.renben.process.plm.tmom029.TMom029AssembleProcessFormInputDialog.PicDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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.teamcenter.services.rac.core.ReservationService; + +public class TMom030OperationReferenceBookInputDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + + private List> controlRequirementData; + + private List controlRequirementPlmeidList; + + private List controlRequirementDeleteList = new ArrayList(); + + // Ҽ˵ + private static JPopupMenu menu; + // Ҽ˵ + private JMenuItem addRowItem; + private JMenuItem remItem; + // ؼ + private JLabel companyNameLabel; + private JTextField companyNameField; + private JLabel itemIdLabel; + private JTextField itemIdField; + private JLabel productNameLabel; + private JTextField productNameField; + private JLabel meopLabel; + private JTextField meopField; + private JLabel nextMeopLabel; + private JTextField nextMeopField; + + // ѡ + private JTabbedPane tabbedPane; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + }; // 豸 + private TCComponentDataset Dataset; + private TCComponentTcFile picFile; + private String outFilePathp=null; + private TCComponent[] comps; + private JButton selectPicture; + private PicDialog picDialog; + private JButton ImportCard; + private TCComponentItemRevision itemRevision; + + private String[] controlRequirementHeader = new String[] { "PLMEID", "", "", "Ŀ","", "Ҫ", " /", + "Ƶ", "", "Ӧƻ" }; + private CTable controlRequirementTable;// Ҫ + + // ť + private JPanel rootPanel; + private JButton reImportButton; + private JButton okButton; + private JButton celButton; + + public TMom030OperationReferenceBookInputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> controlRequirementData, + List controlRequirementPlmeidList, TCComponent form, + TCProperty[] properties) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.controlRequirementData = controlRequirementData; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.form = form; + this.properties = properties; + this.itemRevision= (TCComponentItemRevision) this.comp; + init(); + } + + private void init() { + //MessageBox.post(controlRequirementData.toString(),"",MessageBox.ERROR); + //ȡʻ + 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("zyjzs30_display.TITLE")); + this.setPreferredSize(new Dimension(980, 750)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + + + this.companyNameLabel = new JLabel(rb.getString("gsmc10_display.TITLE")); + this.companyNameLabel.setPreferredSize(new Dimension(80, 30)); + this.companyNameField = new JTextField(); + this.companyNameField.setPreferredSize(new Dimension(200, 30)); + this.itemIdLabel = new JLabel(rb.getString("ljdh28_display.TITLE")); + this.itemIdLabel.setPreferredSize(new Dimension(80, 30)); + this.itemIdField = new JTextField(); + this.itemIdField.setPreferredSize(new Dimension(200, 30)); + this.productNameLabel = new JLabel(rb.getString("sbxh28_display.TITLE")); + this.productNameLabel.setPreferredSize(new Dimension(80, 30)); + this.productNameField = new JTextField(); + this.productNameField.setPreferredSize(new Dimension(200, 30)); + this.meopLabel = new JLabel(rb.getString("bgx28_display.TITLE")); + this.meopLabel.setPreferredSize(new Dimension(80, 30)); + this.meopField = new JTextField(); + this.meopField.setPreferredSize(new Dimension(200, 30)); +// this.nextMeopLabel = new JLabel(rb.getString("xdgx28_display.TITLE")); +// this.nextMeopLabel.setPreferredSize(new Dimension(80, 30)); +// this.nextMeopField = new JTextField(); +// this.nextMeopField.setPreferredSize(new Dimension(200, 30)); + + JPanel titlePanel = new JPanel(new PropertyLayout()); + titlePanel.add("1.1.left.top", this.companyNameLabel); + titlePanel.add("1.2.left.top", this.companyNameField); + titlePanel.add("1.3.left.top", this.itemIdLabel); + titlePanel.add("1.4.left.top", this.itemIdField); + titlePanel.add("1.5.left.top", this.productNameLabel); + titlePanel.add("1.6.left.top", this.productNameField); + titlePanel.add("2.1.left.top", this.meopLabel); + titlePanel.add("2.2.left.top", this.meopField); +// titlePanel.add("2.3.left.top", this.nextMeopLabel); +// titlePanel.add("2.4.left.top", this.nextMeopField); + try { + if(comp.getProperty("release_status_list")!="") { + setPanelEnabled(titlePanel,false); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + + if (this.controlRequirementData.size() > 0) { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, + this.controlRequirementData.size()); + } else { + this.controlRequirementTable = getjTable(null, null, controlRequirementHeader, 1); + } + + this.controlRequirementTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap) controlRequirementTable.getModel()).setRow(controlRequirementTable.getSelectedRow()); + ((CTMap) controlRequirementTable.getModel()).setColumn(controlRequirementTable.getSelectedColumn()); + } + if (mouseevent.getButton() == MouseEvent.BUTTON3) { + menu.show(controlRequirementTable, mouseevent.getX(), mouseevent.getY()); + } + } + }); + + //++++Ӽ + this.controlRequirementTable.getModel().addTableModelListener(new TableModelListener() { + @Override + public void tableChanged(TableModelEvent e) { + if (e.getType() == TableModelEvent.UPDATE){ + int row = controlRequirementTable.getSelectedRow(); + int col = controlRequirementTable.getSelectedColumn(); + if(row>-1&&col>-1) { + + String value=String.valueOf(controlRequirementTable.getValueAt(row, col)); + System.out.println("޸ĺ=>" + value.getBytes().length); + if(value.getBytes().length>512) { + MessageBox.post(""+(row+1)+"У"+col+""+"дʧܳ"+(value.getBytes().length-512), "", MessageBox.ERROR); + } + + } + + } + } + }); + //+++++ + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab(rb.getString("cptxkzyq28_display.TITLE"), new JScrollPane(this.controlRequirementTable)); + + setText(); + setControlRequirementTable(); + + rootPanel = new JPanel(new FlowLayout()); + this.reImportButton=new JButton(rb.getString("cxdr_display.TITLE")); + this.reImportButton.setPreferredSize(new Dimension(100, 30)); + this.ImportCard=new JButton(rb.getString("zyjzsdc_display.TITLE")); + this.ImportCard.setPreferredSize(new Dimension(150, 30)); + this.selectPicture=new JButton(rb.getString("xzdctp_display.TITLE")); + this.selectPicture.setPreferredSize(new Dimension(120, 30)); + this.okButton = new JButton(rb.getString("bc_display.TITLE")); + this.okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(reImportButton); + rootPanel.add(ImportCard); + rootPanel.add(selectPicture); + //rootPanel.add(new JLabel(" ")); + rootPanel.add(okButton); + //rootPanel.add(new JLabel(" ")); + rootPanel.add(celButton); + + // ʼҼ˵ + menu = new JPopupMenu(); + + addRowItem = new JMenuItem(rb.getString("tjh_display.TITLE")); + remItem = new JMenuItem(rb.getString("ych12_display.TITLE")); + + menu.add(addRowItem); + menu.add(remItem); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + super.dispose(); + //رȨ޸ + closePermission(); + } + + //޸ϢرȨ + private void closePermission() { + //رȨ޸ + if(((TCComponent) comp).isCheckedOut()) { + ReservationService service=ReservationService.getService((TCSession)app.getSession()); + service.checkin(new TCComponent[] {(TCComponent) this.comp});//ǩ + } + } + + + /*** + * ÿؼֵ + */ + private void setText() { + this.companyNameField.setText(this.properties[0].getStringValue()); + this.itemIdField.setText(this.properties[1].getStringValue()); + this.productNameField.setText(this.properties[2].getStringValue()); + this.meopField.setText(this.properties[3].getStringValue()); + //this.nextMeopField.setText(this.properties[4].getStringValue()); + } + + /*** + * ÿؼֵ + */ + private List getText() { + List valueList = new ArrayList(); + valueList.add(this.companyNameField.getText()); + valueList.add(this.itemIdField.getText()); + //valueList.add(this.equipmentIdField.getText()); + valueList.add(this.productNameField.getText()); + valueList.add(this.meopField.getText()); + //valueList.add("a"); + //valueList.add(this.nextMeopField.getText()); + return valueList; + } + + private void setControlRequirementTable() { + if (controlRequirementData.size() > 0) { + for (int i = 0; i < controlRequirementData.size(); i++) { + for (int j = 0; j < controlRequirementData.get(i).size(); j++) { + controlRequirementTable.setValueAt(controlRequirementData.get(i).get(j), i, j); + } + } + } else { + controlRequirementTable.setValueAt(UUID.randomUUID().toString().replace("-", ""), 0, 0); + } + } + + // Ӽ + public void createActionEvent() { + this.reImportButton.addActionListener(this); + this.okButton.addActionListener(this); + this.ImportCard.addActionListener(this); + this.selectPicture.addActionListener(this); + this.celButton.addActionListener(this); + this.addRowItem.addActionListener(this); + this.remItem.addActionListener(this); + } + + public CTable getjTable(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); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + renderer.setIsRelease(true); + try { + //˾޷༭ + if(comp.getProperty("release_status_list")!="") { + map.setEditable(false); + }else { + map.setEditable(true); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // //þ + 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; + } + + //ÿؼȨ + 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); + } + } + } + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.okButton)) { + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + + + TMom030OperationReferenceBookInputOperation operation = new TMom030OperationReferenceBookInputOperation(app, + session, comp, controlRequirementData, controlRequirementPlmeidList, controlRequirementDeleteList, form, + properties, valueList); + + try { + operation.executeOperation(); + setPlmeidList(controlRequirementPlmeidList, controlRequirementTable); + + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else if (source.equals(this.reImportButton)) {//޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfcxdr28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + int i = JOptionPane.showConfirmDialog(null,rb.getString("cxdrhscxysj28_display.TITLE"), "µ", JOptionPane.YES_NO_OPTION); + if (i == JOptionPane.YES_OPTION) { + remAllRow(this.controlRequirementTable,"ƷԿҪ"); + dispose(); + TMom030OperationReferenceBookInputCommand command = new TMom030OperationReferenceBookInputCommand(app, + session,comp,true); + try { + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (i == JOptionPane.NO_OPTION) { + return; + } + + } + else if (source.equals(this.ImportCard)) { + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("qxzljdc28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + ImportCard(); + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + + }else if (source.equals(this.selectPicture)) { + + //޷༭м + try { + if(comp.getProperty("release_status_list")!="") { + MessageBox.post(rb.getString("wfxz28_display.TITLE"),"ʧ",MessageBox.ERROR); + return; + } + } catch (Exception e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + + + } + else if (source.equals(this.addRowItem)) { + addRow(1); + } else if (source.equals(this.remItem)) { + remRow(); + } else { + dispose(); + } + } + + //տ + private void ImportCard() throws TCException { + // + saveData(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + String outFilePath = System.getenv("TEMP") + "\\"+"׼.xlsx"; + File file = null; + file = TMomMethodUtil.getFile(session, "׼", "MSExcelX"); + try { + ExcelUtil07.writeOperationReferenceBookToExcel(getData(), file, outFilePath,picFile,outFilePathp); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (ExcelUtil07.getExcelToItem(session,itemRevision, + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "ҵ׼", "TC_Attaches", + "MSExcelX", true); + } + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + this.dispose(); + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + //bean.setSbmc(this.properties[4].getStringValue()); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = System.getenv("TEMP") + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + // + private void saveData(){ + if (controlRequirementTable.getSelectedRow() >= 0 && controlRequirementTable.getSelectedColumn() >= 0) { + (controlRequirementTable.getCellEditor(controlRequirementTable.getSelectedRow(), controlRequirementTable.getSelectedColumn())).stopCellEditing(); + } + this.controlRequirementData = getTableValue(this.controlRequirementTable); + + List valueList = getText(); + + TMom030OperationReferenceBookInputOperation operation = new TMom030OperationReferenceBookInputOperation(app, session, comp, + controlRequirementData, + controlRequirementPlmeidList, + controlRequirementDeleteList, form, properties, valueList); + try { + operation.executeOperation(); + // ȡ汾 + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + // 17 + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + /** + * + */ + private void addRow(int index) { + // TODO Auto-generated method stub + CTable table = controlRequirementTable; + CTMap map = ((CTMap) table.getModel()); + map.insertRow(table.getSelectedRow() + 1); + table.setValueAt(UUID.randomUUID().toString().replace("-", ""), table.getSelectedRow() + 1, 0); + table.revalidate(); + table.repaint(); + } + + /** + * Ƴ + */ + private void remRow() { + // TODO Auto-generated method stub + CTable table = controlRequirementTable; + CTMap map = ((CTMap) table.getModel()); + + if (map.getValueAt(table.getSelectedRow(), 0) != null + && this.controlRequirementPlmeidList.contains(map.getValueAt(table.getSelectedRow(), 0))) { + this.controlRequirementDeleteList.add(map.getValueAt(table.getSelectedRow(), 0).toString()); + } + map.removeRow(table.getSelectedRow()); + table.repaint(); + } + /** + * µʱƳϢ + */ + private void remAllRow(CTable table,String tableName) { + List deleteAllList=new ArrayList(); + for (int j = 0; j < table.getRowCount(); j++) { + deleteAllList.add(table.getValueAt(j, 0).toString()); + } + switch (tableName) { + case "װϸ": + for(int i=0;i-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + public class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } + +} + + + diff --git a/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputHandler.java b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputHandler.java new file mode 100644 index 0000000..3f1a97d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputHandler.java @@ -0,0 +1,51 @@ +package com.connor.renben.process.plm.tmom030; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom030OperationReferenceBookInputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzyjzs30_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷҵ׼İ汾 + if(comp.getType().indexOf("ZYJZSRevision") > 0) + { + TMom030OperationReferenceBookInputCommand command = new TMom030OperationReferenceBookInputCommand(app, + session,comp,false); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txzyjzssb30_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("bb30_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputOperation.java b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputOperation.java new file mode 100644 index 0000000..8e60244 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom030/TMom030OperationReferenceBookInputOperation.java @@ -0,0 +1,132 @@ +package com.connor.renben.process.plm.tmom030; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom030OperationReferenceBookInputOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + + private List> controlRequirementData; + + private List controlRequirementPlmeidList; + + private List controlRequirementDeleteList; + + public TMom030OperationReferenceBookInputOperation(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> controlRequirementData, + List controlRequirementPlmeidList, List controlRequirementDeleteList, TCComponent form, + TCProperty[] properties, List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.controlRequirementData = controlRequirementData; + this.controlRequirementPlmeidList = controlRequirementPlmeidList; + this.controlRequirementDeleteList = controlRequirementDeleteList; + this.form = form; + this.properties = properties; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // + InputStream input = null; + try { + // + // жǷǰ汾 + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + TCComponentUser user = session.getUser(); + if (user.getUserId().equals(userName)) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.valueList.get(0)); + this.properties[1].setStringValue(this.valueList.get(1)); + this.properties[2].setStringValue(this.valueList.get(2)); + this.properties[3].setStringValue(this.valueList.get(3)); + //this.properties[4].setStringValue(this.valueList.get(4)); + this.form.save(); + this.form.unlock(); + this.form.refresh(); + } + + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ɾ + for (int i = 0; i < this.controlRequirementDeleteList.size(); i++) { + // ȡݿ + String deleteSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTDELETE"), + controlRequirementDeleteList.get(i)); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteSQL); + SqlUtilT.freeAll(); + } + + // ȡݿ + SqlUtilT.getTCConnection(); + + for (int i = 0; i < controlRequirementData.size(); i++) { + List rowList = controlRequirementData.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") + && controlRequirementPlmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTUPDATE"), rowList.get(0)); + SqlUtilT.getTCConnection(); + SqlUtilT.update(new String[] { rowList.get(1),rowList.get(3), rowList.get(4), + rowList.get(5), rowList.get(6), rowList.get(7), rowList.get(8),"", + rowList.get(9) , rowList.get(2)}, updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_CONTROLREQUIREMENTINSERT"); + SqlUtilT.getTCConnection(); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), + rowList.get(3), rowList.get(4), rowList.get(5), rowList.get(6), rowList.get(7), + rowList.get(8), "",rowList.get(9), rowList.get(2) }, insertSQL); + } + } + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom031/TMom031JobProcessFormOutputCommand.java b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputCommand.java new file mode 100644 index 0000000..c1bb3d2 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputCommand.java @@ -0,0 +1,148 @@ +package com.connor.renben.process.plm.tmom031; + +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom031JobProcessFormOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private String fileSource; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_xdgx" }; // µ + + public TMom031JobProcessFormOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,String fileSource) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.fileSource = fileSource; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //ȡ + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + controlRequirementData.add(rowList); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + new Thread() { + @Override + public void run() { + + new TMom031JobProcessFormOutputDialog(app, + session,comp,properties,fileSource,toolingDetailData,machiningParameterData,controlRequirementData); + super.run(); + } + }.start(); + + + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputDialog.java b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputDialog.java new file mode 100644 index 0000000..0d88d5b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputDialog.java @@ -0,0 +1,503 @@ +package com.connor.renben.process.plm.tmom031; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.naming.InitialContext; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.WindowConstants; +import javax.swing.table.DefaultTableModel; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.tmom039.TMom039EntrustmentFormDialog2; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentSRP0MROSupervisor; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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; + +public class TMom031JobProcessFormOutputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision;// ѡеİ汾 + private String fileSource; + private TCProperty[] properties; + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + //ͼ + private TCComponentTcFile picFile; + private PicDialog picDialog; + private TCComponent[] comps; + private String outFilePathp=null; + private TCComponentDataset Dataset; + + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JButton pictureButton; + private JTextField pathText; + private JTextField fleName; + + + public TMom031JobProcessFormOutputDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + TCProperty[] properties, String fileSource, List> toolingDetailData, + List> machiningParameterData, List> controlRequirementData) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.properties = properties; + this.fileSource = fileSource; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + 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:\\"));// ļѡijʼĿ¼Ϊd + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.pictureButton = new JButton(rb.getString("tk_display.TITLE")); + this.pictureButton.setPreferredSize(new Dimension(100, 30)); + // Ӽ + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //رմʱѵͼƬɾ + if(outFilePathp!=null&&new File(outFilePathp).exists()) { + new File(outFilePathp).delete(); + } + } + }); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.pictureButton.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(fileSource); + 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(this.pictureButton); + 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(); + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + + /** + * ͼѡť¼ + * + * @param e + */ + public void selectpictureButtonEvent() { + //MessageBox.post(, "", MessageBox.ERROR); + TCComponentFolder fileFolder; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(getPuid()==null) { + MessageBox.post(rb.getString("wpzxydsxx28_display.TITLE"), "", MessageBox.ERROR); + }else { + fileFolder = (TCComponentFolder)session + .stringToComponent(getPuid()); + if(fileFolder!=null) { + comps = fileFolder.getReferenceListProperty("contents"); + picDialog=new PicDialog(comps,this.pathText.getText(),fileFolder.getStringProperty("object_name")); + }else { + MessageBox.post(rb.getString("wzdtk28_display.TITLE"), "", MessageBox.ERROR); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } + else if(source.equals(this.pictureButton)) { + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + else if (source.equals(this.okButton)) { + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + // Excel + // ȡģ + String outFilePath = this.pathText.getText() + "\\"+this.fleName.getText()+".xlsx"; + File file = null; + if(fileSource.compareTo("湤տ") == 0) + { + file = TMomMethodUtil.getFile(session, "湤տ", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormVerticalToExcel(getData(), file, outFilePath,picFile,outFilePathp); + //picjugde=false; + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } + else + { + file = TMomMethodUtil.getFile(session, "湤տ", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormAcrossToExcel(getData(), file, outFilePath,picFile,outFilePathp); + //picjugde=false; + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + //ѡRB3_PICTURE_LIBRARYֵҸͼļеUID + public String getPuid() { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("RB3_PICTURE_LIBRARY"); + if (modelFiles == null) + { + System.out.println("δҵѡ"); + return null; + } + String puid = null; + for (int i = 0; i < modelFiles.length; i++) { + if(session.getCurrentGroup().toString().indexOf(modelFiles[i].split("-")[0])>-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = this.pathText.getText() + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + private class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= 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 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/renben/process/plm/tmom031/TMom031JobProcessFormOutputHandler.java b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputHandler.java new file mode 100644 index 0000000..aff70ce --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputHandler.java @@ -0,0 +1,67 @@ +package com.connor.renben.process.plm.tmom031; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom030.TMom030OperationReferenceBookInputCommand; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom031JobProcessFormOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String commandId = arg0.getCommand().getId(); + String fileSource = null; + switch (commandId) { + case "com.connor.renben.process.plm.commands.JobProcessVerticalFormOutput": + fileSource="湤տ"; + break; + case "com.connor.renben.process.plm.commands.JobProcessAcrossFormOutput": + fileSource="幤տ"; + break; + default: + break; + } + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzygykbbdx28_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷҵտİ汾 + if(comp.getType().indexOf("ZYGYKRevision") > 0) + { + TMom031JobProcessFormOutputCommand command = new TMom031JobProcessFormOutputCommand(app, + session,comp,fileSource); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("sb31_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzzygykbb28_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputOperation.java b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputOperation.java new file mode 100644 index 0000000..8bb8dc6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/TMom031JobProcessFormOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom031; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom031JobProcessFormOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputCommand.java b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputCommand.java new file mode 100644 index 0000000..9e2d4fd --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputCommand.java @@ -0,0 +1,167 @@ +package com.connor.renben.process.plm.tmom031.copy; + +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.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +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 TMom031JobProcessFormOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private String fileSource; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { + "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", + "rb3_xdgx", // µ + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; + + public TMom031JobProcessFormOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp,String fileSource) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.fileSource = fileSource; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //ȡ + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + controlRequirementData.add(rowList); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + TMomMethodUtil.setBgxAndXdgx(properties[1],properties[3],properties[5],itemRevision); + + new Thread() { + @Override + public void run() { + + new TMom031JobProcessFormOutputDialog(app, + session,comp,properties,fileSource,toolingDetailData,machiningParameterData,controlRequirementData); + super.run(); + } + }.start(); + + + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputDialog.java b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputDialog.java new file mode 100644 index 0000000..b9d1cfc --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputDialog.java @@ -0,0 +1,511 @@ +package com.connor.renben.process.plm.tmom031.copy; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.naming.InitialContext; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.WindowConstants; +import javax.swing.table.DefaultTableModel; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.tmom039.TMom039EntrustmentFormDialog2; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentSRP0MROSupervisor; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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; + +public class TMom031JobProcessFormOutputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision;// ѡеİ汾 + private String fileSource; + private TCProperty[] properties; + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + //ͼ + private TCComponentTcFile picFile; + private PicDialog picDialog; + private TCComponent[] comps; + private String outFilePathp=null; + private TCComponentDataset Dataset; + + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JButton pictureButton; + private JTextField pathText; + private JTextField fleName; + + + public TMom031JobProcessFormOutputDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + TCProperty[] properties, String fileSource, List> toolingDetailData, + List> machiningParameterData, List> controlRequirementData) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.properties = properties; + this.fileSource = fileSource; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + 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:\\"));// ļѡijʼĿ¼Ϊd + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.pictureButton = new JButton(rb.getString("tk_display.TITLE")); + this.pictureButton.setPreferredSize(new Dimension(100, 30)); + // Ӽ + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //رմʱѵͼƬɾ + if(outFilePathp!=null&&new File(outFilePathp).exists()) { + new File(outFilePathp).delete(); + } + } + }); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.pictureButton.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(fileSource); + 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(this.pictureButton); + 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(); + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + + /** + * ͼѡť¼ + * + * @param e + */ + public void selectpictureButtonEvent() { + //MessageBox.post(, "", MessageBox.ERROR); + TCComponentFolder fileFolder; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(getPuid()==null) { + MessageBox.post(rb.getString("wpzxydsxx28_display.TITLE"), "", MessageBox.ERROR); + }else { + fileFolder = (TCComponentFolder)session + .stringToComponent(getPuid()); + if(fileFolder!=null) { + comps = fileFolder.getReferenceListProperty("contents"); + picDialog=new PicDialog(comps,this.pathText.getText(),fileFolder.getStringProperty("object_name")); + }else { + MessageBox.post(rb.getString("wzdtk28_display.TITLE"), "", MessageBox.ERROR); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setXdgx(this.properties[5].getStringValue()); + bean.setWjbh(this.properties[6].getStringValue()); + bean.setBbh(this.properties[7].getStringValue()); + bean.setCxqy(this.properties[8].getStringValue()); + bean.setBz(this.properties[9].getStringValue()); + bean.setSh(this.properties[10].getStringValue()); + bean.setPz(this.properties[11].getStringValue()); + bean.setFbrq(this.properties[12].getStringValue()); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } + else if(source.equals(this.pictureButton)) { + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + else if (source.equals(this.okButton)) { + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + // Excel + // ȡģ + String outFilePath = this.pathText.getText() + "\\"+this.fleName.getText()+".xlsx"; + File file = null; + if(fileSource.compareTo("湤տ") == 0) + { + file = TMomMethodUtil.getFile_New(session, "湤տ£", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormVerticalToExcel_New(getData(), file, outFilePath,picFile,outFilePathp); + //picjugde=false; + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } + else + { + file = TMomMethodUtil.getFile_New(session, "湤տ£", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormAcrossToExcel_New(getData(), file, outFilePath,picFile,outFilePathp); + //picjugde=false; + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + //ѡRB3_PICTURE_LIBRARYֵҸͼļеUID + public String getPuid() { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("RB3_PICTURE_LIBRARY"); + if (modelFiles == null) + { + System.out.println("δҵѡ"); + return null; + } + String puid = null; + for (int i = 0; i < modelFiles.length; i++) { + if(session.getCurrentGroup().toString().indexOf(modelFiles[i].split("-")[0])>-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = this.pathText.getText() + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + private class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= 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 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/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputHandler.java b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputHandler.java new file mode 100644 index 0000000..347b648 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputHandler.java @@ -0,0 +1,67 @@ +package com.connor.renben.process.plm.tmom031.copy; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom030.TMom030OperationReferenceBookInputCommand; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom031JobProcessFormOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String commandId = arg0.getCommand().getId(); + String fileSource = null; + switch (commandId) { + case "com.connor.renben.process.plm.commands.JobProcessVerticalFormOutputNew": + fileSource="湤տ"; + break; + case "com.connor.renben.process.plm.commands.JobProcessAcrossFormOutputNew": + fileSource="湤տ"; + break; + default: + break; + } + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzygykbbdx28_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷҵտİ汾 + if(comp.getType().indexOf("ZYGYKRevision") > 0) + { + TMom031JobProcessFormOutputCommand command = new TMom031JobProcessFormOutputCommand(app, + session,comp,fileSource); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("sb31_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzzygykbb28_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputOperation.java b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputOperation.java new file mode 100644 index 0000000..5c718bd --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/copy/TMom031JobProcessFormOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom031.copy; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom031JobProcessFormOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputCommand.java b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputCommand.java new file mode 100644 index 0000000..44b7bdf --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputCommand.java @@ -0,0 +1,165 @@ +package com.connor.renben.process.plm.tmom031.hzzc; + +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.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +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 TMom031JobProcessFormOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { + "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", + "rb3_xdgx", // µ + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; + + public TMom031JobProcessFormOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //ȡ + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + toolingDetailData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + machiningParameterData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("REMARKS")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + rowList.add(controlRequirementRs.getString("STEP_CONTENT")); + controlRequirementData.add(rowList); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + TMomMethodUtil.setBgxAndXdgx(properties[1],properties[3],properties[5],itemRevision); + new Thread() { + @Override + public void run() { + + new TMom031JobProcessFormOutputDialog(app, + session,comp,properties,toolingDetailData,machiningParameterData,controlRequirementData); + super.run(); + } + }.start(); + + + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputDialog.java b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputDialog.java new file mode 100644 index 0000000..57ce5c0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputDialog.java @@ -0,0 +1,509 @@ +package com.connor.renben.process.plm.tmom031.hzzc; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.naming.InitialContext; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.WindowConstants; +import javax.swing.table.DefaultTableModel; + +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.tmom039.TMom039EntrustmentFormDialog2; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentSRP0MROSupervisor; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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; + +public class TMom031JobProcessFormOutputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision;// ѡеİ汾 + private TCProperty[] properties; + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + //ͼ + private TCComponentTcFile picFile; + private PicDialog picDialog; + private TCComponent[] comps; + private String outFilePathp=null; + private TCComponentDataset Dataset; + + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton fileButton; + private JButton pictureButton; + private JTextField pathText; + private JTextField fleName; + + + public TMom031JobProcessFormOutputDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + TCProperty[] properties, List> toolingDetailData, + List> machiningParameterData, List> controlRequirementData) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.properties = properties; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + 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:\\"));// ļѡijʼĿ¼Ϊd + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.pictureButton = new JButton(rb.getString("tk_display.TITLE")); + this.pictureButton.setPreferredSize(new Dimension(100, 30)); + // Ӽ + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //رմʱѵͼƬɾ + if(outFilePathp!=null&&new File(outFilePathp).exists()) { + new File(outFilePathp).delete(); + } + } + }); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.pictureButton.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("ת֧йտ"); + 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(this.pictureButton); + 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(); + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + + /** + * ͼѡť¼ + * + * @param e + */ + public void selectpictureButtonEvent() { + //MessageBox.post(, "", MessageBox.ERROR); + TCComponentFolder fileFolder; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(getPuid()==null) { + MessageBox.post(rb.getString("wpzxydsxx28_display.TITLE"), "", MessageBox.ERROR); + }else { + fileFolder = (TCComponentFolder)session + .stringToComponent(getPuid()); + if(fileFolder!=null) { + comps = fileFolder.getReferenceListProperty("contents"); + picDialog=new PicDialog(comps,this.pathText.getText(),fileFolder.getStringProperty("object_name")); + }else { + MessageBox.post(rb.getString("wzdtk28_display.TITLE"), "", MessageBox.ERROR); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JobProcessFormBean getData() + { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setXdgx(this.properties[5].getStringValue()); + bean.setWjbh(this.properties[6].getStringValue()); + bean.setBbh(this.properties[7].getStringValue()); + bean.setCxqy(this.properties[8].getStringValue()); + bean.setBz(this.properties[9].getStringValue()); + bean.setSh(this.properties[10].getStringValue()); + bean.setPz(this.properties[11].getStringValue()); + bean.setFbrq(this.properties[12].getStringValue()); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } + else if(source.equals(this.pictureButton)) { + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + else if (source.equals(this.okButton)) { + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + // Excel + // ȡģ + String outFilePath = this.pathText.getText() + "\\"+this.fleName.getText()+".xlsx"; + File file = null; +// if(fileSource.compareTo("湤տ") == 0) +// { + file = TMomMethodUtil.getFile_New(session, "ת֧йտ", "MSExcelX"); + try { + ExcelUtil07.writeJobProcessFormVerticalToExcel_Copy(getData(), file, outFilePath,picFile,outFilePathp); + //picjugde=false; + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } +// } +// else +// { +// file = TMomMethodUtil.getFile_New(session, "湤տ£", "MSExcelX"); +// try { +// ExcelUtil07.writeJobProcessFormAcrossToExcel_New(getData(), file, outFilePath,picFile,outFilePathp); +// //picjugde=false; +// MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); +// this.dispose(); +// } catch (IOException ex) { +// // TODO Auto-generated catch block +// ex.printStackTrace(); +// } +// } + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + //ѡRB3_PICTURE_LIBRARYֵҸͼļеUID + public String getPuid() { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("RB3_PICTURE_LIBRARY"); + if (modelFiles == null) + { + System.out.println("δҵѡ"); + return null; + } + String puid = null; + for (int i = 0; i < modelFiles.length; i++) { + if(session.getCurrentGroup().toString().indexOf(modelFiles[i].split("-")[0])>-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + + //ع淶ϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = this.pathText.getText() + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + + private class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(this.LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= 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 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/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputHandler.java b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputHandler.java new file mode 100644 index 0000000..6d7844b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputHandler.java @@ -0,0 +1,53 @@ +package com.connor.renben.process.plm.tmom031.hzzc; + + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom031JobProcessFormOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzcgykbbdx28_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷҵտİ汾 + if(comp.getType().indexOf("HZZCGYKRevision") > 0) + { + TMom031JobProcessFormOutputCommand command = new TMom031JobProcessFormOutputCommand(app, + session,comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("txhzzcgyksb28_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzhzzcgykbb28_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputOperation.java b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputOperation.java new file mode 100644 index 0000000..375a66b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom031/hzzc/TMom031JobProcessFormOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom031.hzzc; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom031JobProcessFormOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputCommand.java b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputCommand.java new file mode 100644 index 0000000..95677f9 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputCommand.java @@ -0,0 +1,146 @@ +package com.connor.renben.process.plm.tmom032; + +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom032AssembleProcessFormOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_xdgx" }; // µ + + public TMom032AssembleProcessFormOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // ȡ + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("P1")); + toolingDetailData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + rowList.add(machiningParameterRs.getString("P1")); + machiningParameterData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + controlRequirementData.add(rowList); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + new Thread() { + @Override + public void run() { + + new TMom032AssembleProcessFormOutputDialog(app, session, comp, properties, toolingDetailData, + machiningParameterData, controlRequirementData); + super.run(); + } + }.start(); + + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputDialog.java b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputDialog.java new file mode 100644 index 0000000..42fd83a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputDialog.java @@ -0,0 +1,517 @@ +package com.connor.renben.process.plm.tmom032; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +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 java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; + +import org.apache.soap.util.Bean; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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; + +public class TMom032AssembleProcessFormOutputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision;// ѡеίе汾 + private TCProperty[] properties; + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + //ͼ + private TCComponentTcFile picFile; + private PicDialog picDialog; + private TCComponent[] comps; + private String outFilePathp=null; + private TCComponentDataset Dataset; + + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + + public TMom032AssembleProcessFormOutputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, TCProperty[] properties, List> toolingDetailData, + List> machiningParameterData, List> controlRequirementData) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.properties = properties; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + 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, 150)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.pictureButton = new JButton(rb.getString("tk_display.TITLE")); + this.pictureButton.setPreferredSize(new Dimension(100, 30)); + // Ӽ + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //رմʱѵͼƬɾ + if(outFilePathp!=null&&new File(outFilePathp).exists()) { + new File(outFilePathp).delete(); + } + } + }); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.pictureButton.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(rb.getString("zpgyk29_display.TITLE")); + 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(this.pictureButton); + 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(); + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + /** + * ͼѡť¼ + * + * @param e + */ + public void selectpictureButtonEvent() { + //MessageBox.post(, "", MessageBox.ERROR); + TCComponentFolder fileFolder; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(getPuid()==null) { + MessageBox.post(rb.getString("wpzxydsxx28_display.TITLE"), "", MessageBox.ERROR); + }else { + fileFolder = (TCComponentFolder)session + .stringToComponent(getPuid()); + if(fileFolder!=null) { + comps = fileFolder.getReferenceListProperty("contents"); + picDialog=new PicDialog(comps,this.pathText.getText(),fileFolder.getStringProperty("object_name")); + }else { + MessageBox.post(rb.getString("wzdtk28_display.TITLE"), "", MessageBox.ERROR); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JobProcessFormBean getData() { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } + else if(source.equals(this.pictureButton)) { + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + + else if (source.equals(this.okButton)) { + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + // Excel + // ȡģ + String outFilePath = this.pathText.getText() + "\\" + this.fleName.getText() + ".xlsx"; + File file = TMomMethodUtil.getFile(session, "װ乤տ", "MSExcelX"); + try { + ExcelUtil07.writeAssembleProcessFormToExcel(getData(), file, outFilePath,picFile,outFilePathp); + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + + //ѡȡտͼpuid + public String getPuid() { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("RB3_PICTURE_LIBRARY"); + if (modelFiles == null) + { + System.out.println("δҵѡ"); + return null; + } + String puid = null; + for (int i = 0; i < modelFiles.length; i++) { + if(session.getCurrentGroup().toString().indexOf(modelFiles[i].split("-")[0])>-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + + //ظӹϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = this.pathText.getText() + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + private class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= 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 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(); + } + } + } + } + } + //ͼƬ + public 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/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputHandler.java b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputHandler.java new file mode 100644 index 0000000..8bbf3d0 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputHandler.java @@ -0,0 +1,52 @@ +package com.connor.renben.process.plm.tmom032; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom031.TMom031JobProcessFormOutputCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom032AssembleProcessFormOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzpgyk29_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷװ乤տİ汾 + if(comp.getType().indexOf("ZPGYKRevision") > 0) + { + TMom032AssembleProcessFormOutputCommand command = new TMom032AssembleProcessFormOutputCommand(app, + session,comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("sb32_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzbb29_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputOperation.java b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputOperation.java new file mode 100644 index 0000000..6ae1b04 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/TMom032AssembleProcessFormOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom032; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom032AssembleProcessFormOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputCommand.java b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputCommand.java new file mode 100644 index 0000000..5ea46af --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputCommand.java @@ -0,0 +1,162 @@ +package com.connor.renben.process.plm.tmom032.copy; + +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom032AssembleProcessFormOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_sbmc", // 豸 + "rb3_xdgx", + "rb3_wjbh", + "rb3_bbh", + "rb3_cxqy", + "rb3_bz", + "rb3_sh", + "rb3_pz", + "rb3_fbrq" + }; + + public TMom032AssembleProcessFormOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // ȡ + // ѡжPUIDȡ + final List> toolingDetailData = new ArrayList>(); + final List> machiningParameterData = new ArrayList>(); + final List> controlRequirementData = new ArrayList>(); + ResultSet rs = null; + ResultSet machiningParameterRs = null; + ResultSet controlRequirementRs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TOOLINGDETAILSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("NAME")); + rowList.add(rs.getString("SPECIFICATION")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("P1")); + toolingDetailData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_MACHININGPARAMETERSELECT"), comp.getUid()); + machiningParameterRs = SqlUtilT.read(sql); + while (machiningParameterRs.next()) { + List rowList = new ArrayList(); + rowList.add(machiningParameterRs.getString("PLMEID")); + rowList.add(machiningParameterRs.getString("ID")); + rowList.add(machiningParameterRs.getString("NAME")); + rowList.add(machiningParameterRs.getString("SPECIALITY")); + rowList.add(machiningParameterRs.getString("VALUE")); + rowList.add(machiningParameterRs.getString("P1")); + machiningParameterData.add(rowList); + } + + sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + controlRequirementRs = SqlUtilT.read(sql); + while (controlRequirementRs.next()) { + List rowList = new ArrayList(); + rowList.add(controlRequirementRs.getString("PLMEID")); + rowList.add(controlRequirementRs.getString("ID")); + rowList.add(controlRequirementRs.getString("PROJECT")); + rowList.add(controlRequirementRs.getString("SPECIALITY")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(controlRequirementRs.getString("CHECK_METHOD")); + rowList.add(controlRequirementRs.getString("FIRST_INSPECTION")); + rowList.add(controlRequirementRs.getString("SELF_INSPECTION")); + rowList.add(controlRequirementRs.getString("ROUTING_INSPECTION")); + rowList.add(controlRequirementRs.getString("REACTION_PLAN")); + rowList.add(controlRequirementRs.getString("PROCESS_SPECIFICATIONS")); + rowList.add(controlRequirementRs.getString("MANAGEMENT_POINTS")); + controlRequirementData.add(rowList); + } + + } catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (machiningParameterRs != null) { + SqlUtilT.free(machiningParameterRs); + } + if (controlRequirementRs != null) { + SqlUtilT.free(controlRequirementRs); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + TMomMethodUtil.setBgxAndXdgx(properties[1],properties[3],properties[5],itemRevision); + new Thread() { + @Override + public void run() { + + new TMom032AssembleProcessFormOutputDialog(app, session, comp, properties, toolingDetailData, + machiningParameterData, controlRequirementData); + super.run(); + } + }.start(); + + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputDialog.java b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputDialog.java new file mode 100644 index 0000000..29502e5 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputDialog.java @@ -0,0 +1,525 @@ +package com.connor.renben.process.plm.tmom032.copy; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +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 java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; + +import org.apache.soap.util.Bean; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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; + +public class TMom032AssembleProcessFormOutputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision;// ѡеίе汾 + private TCProperty[] properties; + private List> toolingDetailData; + private List> machiningParameterData; + private List> controlRequirementData; + + //ͼ + private TCComponentTcFile picFile; + private PicDialog picDialog; + private TCComponent[] comps; + private String outFilePathp=null; + private TCComponentDataset Dataset; + + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + + public TMom032AssembleProcessFormOutputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, TCProperty[] properties, List> toolingDetailData, + List> machiningParameterData, List> controlRequirementData) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.properties = properties; + this.toolingDetailData = toolingDetailData; + this.machiningParameterData = machiningParameterData; + this.controlRequirementData = controlRequirementData; + 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, 150)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.pictureButton = new JButton(rb.getString("tk_display.TITLE")); + this.pictureButton.setPreferredSize(new Dimension(100, 30)); + // Ӽ + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //رմʱѵͼƬɾ + if(outFilePathp!=null&&new File(outFilePathp).exists()) { + new File(outFilePathp).delete(); + } + } + }); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.pictureButton.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(rb.getString("zpgyk29_display.TITLE")); + 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(this.pictureButton); + 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(); + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + /** + * ͼѡť¼ + * + * @param e + */ + public void selectpictureButtonEvent() { + //MessageBox.post(, "", MessageBox.ERROR); + TCComponentFolder fileFolder; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(getPuid()==null) { + MessageBox.post(rb.getString("wpzxydsxx28_display.TITLE"), "", MessageBox.ERROR); + }else { + fileFolder = (TCComponentFolder)session + .stringToComponent(getPuid()); + if(fileFolder!=null) { + comps = fileFolder.getReferenceListProperty("contents"); + picDialog=new PicDialog(comps,this.pathText.getText(),fileFolder.getStringProperty("object_name")); + }else { + MessageBox.post(rb.getString("wzdtk28_display.TITLE"), "", MessageBox.ERROR); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JobProcessFormBean getData() { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setXdgx(this.properties[5].getStringValue()); + bean.setWjbh(this.properties[6].getStringValue()); + bean.setBbh(this.properties[7].getStringValue()); + bean.setCxqy(this.properties[8].getStringValue()); + bean.setBz(this.properties[9].getStringValue()); + bean.setSh(this.properties[10].getStringValue()); + bean.setPz(this.properties[11].getStringValue()); + bean.setFbrq(this.properties[12].getStringValue()); + bean.setToolingDetailData(toolingDetailData); + bean.setMachiningParameterData(machiningParameterData); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } + else if(source.equals(this.pictureButton)) { + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + + else if (source.equals(this.okButton)) { + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + // Excel + // ȡģ + String outFilePath = this.pathText.getText() + "\\" + this.fleName.getText() + ".xlsx"; + File file = TMomMethodUtil.getFile_New(session, "װ乤տ£", "MSExcelX"); + try { + ExcelUtil07.writeAssembleProcessFormToExcel_New(getData(), file, outFilePath,picFile,outFilePathp); + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + + //ѡȡտͼpuid + public String getPuid() { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("RB3_PICTURE_LIBRARY"); + if (modelFiles == null) + { + System.out.println("δҵѡ"); + return null; + } + String puid = null; + for (int i = 0; i < modelFiles.length; i++) { + if(session.getCurrentGroup().toString().indexOf(modelFiles[i].split("-")[0])>-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + + //ظӹϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = this.pathText.getText() + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + private class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= 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 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(); + } + } + } + } + } + //ͼƬ + public 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/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputHandler.java b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputHandler.java new file mode 100644 index 0000000..eecc389 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputHandler.java @@ -0,0 +1,52 @@ +package com.connor.renben.process.plm.tmom032.copy; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom031.TMom031JobProcessFormOutputCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom032AssembleProcessFormOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzpgyk29_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷװ乤տİ汾 + if(comp.getType().indexOf("ZPGYKRevision") > 0) + { + TMom032AssembleProcessFormOutputCommand command = new TMom032AssembleProcessFormOutputCommand(app, + session,comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("sb32_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("qxzbb29_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputOperation.java b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputOperation.java new file mode 100644 index 0000000..9b0e06f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom032/copy/TMom032AssembleProcessFormOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom032.copy; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom032AssembleProcessFormOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputCommand.java b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputCommand.java new file mode 100644 index 0000000..08402d4 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputCommand.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom033; + +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom033OperationReferenceBookOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_xdgx" }; // µ + + public TMom033OperationReferenceBookOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // ȡ + // ѡжPUIDȡ + final List> controlRequirementData = new ArrayList>(); + ResultSet rs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("REMARKS")); + rowList.add(rs.getString("PROJECT")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(rs.getString("CHECK_METHOD")); + rowList.add(rs.getString("FIRST_INSPECTION")); + rowList.add(rs.getString("SELF_INSPECTION")); + rowList.add(rs.getString("REACTION_PLAN")); + controlRequirementData.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(); + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + new Thread() { + @Override + public void run() { + new TMom033OperationReferenceBookOutputDialog(app, session, comp, properties, controlRequirementData); + super.run(); + } + }.start(); + + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputDialog.java b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputDialog.java new file mode 100644 index 0000000..62d2959 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputDialog.java @@ -0,0 +1,505 @@ +package com.connor.renben.process.plm.tmom033; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +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 java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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; + +public class TMom033OperationReferenceBookOutputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision;// ѡеίе汾 + private TCProperty[] properties; + private List> controlRequirementData; + + //ͼ + private TCComponentTcFile picFile; + private PicDialog picDialog; + private TCComponent[] comps; + private String outFilePathp=null; + private TCComponentDataset Dataset; + + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + + public TMom033OperationReferenceBookOutputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, TCProperty[] properties, List> controlRequirementData) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.properties = properties; + this.controlRequirementData = controlRequirementData; + 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, 150)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.pictureButton = new JButton(rb.getString("tk_display.TITLE")); + this.pictureButton.setPreferredSize(new Dimension(100, 30)); + // Ӽ + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //رմʱѵͼƬɾ + if(outFilePathp!=null&&new File(outFilePathp).exists()) { + new File(outFilePathp).delete(); + } + } + }); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.pictureButton.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(rb.getString("jyjzs33_display.TITLE")); + 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(this.pictureButton); + 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(); + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + /** + * ͼѡť¼ + * + * @param e + */ + public void selectpictureButtonEvent() { + //MessageBox.post(, "", MessageBox.ERROR); + TCComponentFolder fileFolder; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(getPuid()==null) { + MessageBox.post(rb.getString("wpzxydsxx28_display.TITLE"), "", MessageBox.ERROR); + }else { + fileFolder = (TCComponentFolder)session + .stringToComponent(getPuid()); + if(fileFolder!=null) { + comps = fileFolder.getReferenceListProperty("contents"); + picDialog=new PicDialog(comps,this.pathText.getText(),fileFolder.getStringProperty("object_name")); + }else { + MessageBox.post(rb.getString("wzdtk28_display.TITLE"), "", MessageBox.ERROR); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JobProcessFormBean getData() { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } + else if(source.equals(this.pictureButton)) { + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + else if (source.equals(this.okButton)) { + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + // Excel + // ȡģ + String outFilePath = this.pathText.getText() + "\\" + this.fleName.getText() + ".xlsx"; + File file = TMomMethodUtil.getFile(session, "׼", "MSExcelX"); + try { + ExcelUtil07.writeOperationReferenceBookToExcel(getData(), file, outFilePath,picFile,outFilePathp); + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + + //ѡȡտͼpuid + public String getPuid() { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("RB3_PICTURE_LIBRARY"); + if (modelFiles == null) + { + System.out.println("δҵѡ"); + return null; + } + String puid = null; + // String sss=session.getCurrentGroup().toString(); + for (int i = 0; i < modelFiles.length; i++) { + if((session.getCurrentGroup().toString()).indexOf(modelFiles[i].split("-")[0])>-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + //ظӹϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = this.pathText.getText() + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= 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 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(); + } + } + } + } + } + //ͼƬ + public 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/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputHandler.java b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputHandler.java new file mode 100644 index 0000000..962e4e2 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputHandler.java @@ -0,0 +1,52 @@ +package com.connor.renben.process.plm.tmom033; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom032.TMom032AssembleProcessFormOutputCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom033OperationReferenceBookOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzyjzs30_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷҵ׼İ汾 + if(comp.getType().indexOf("ZYJZSRevision") > 0) + { + TMom033OperationReferenceBookOutputCommand command = new TMom033OperationReferenceBookOutputCommand(app, + session,comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("dcsb33_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("bb30_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputOperation.java b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputOperation.java new file mode 100644 index 0000000..161e306 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/TMom033OperationReferenceBookOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom033; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom033OperationReferenceBookOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputCommand.java b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputCommand.java new file mode 100644 index 0000000..b8093dd --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputCommand.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.tmom033.copy; + +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 com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom033OperationReferenceBookOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_gsmc", // ˾ + "rb3_ljdh", // + "rb3_sbxh", // 豸ͺ + "rb3_bgx", // + "rb3_xdgx" }; // µ + + public TMom033OperationReferenceBookOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // ȡ + // ѡжPUIDȡ + final List> controlRequirementData = new ArrayList>(); + ResultSet rs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_CONTROLREQUIREMENTSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("ID")); + rowList.add(rs.getString("REMARKS")); + rowList.add(rs.getString("PROJECT")); + rowList.add(rs.getString("SPECIALITY")); + rowList.add(rs.getString("MANAGEMENT_REQUIREMENTS")); + rowList.add(rs.getString("CHECK_METHOD")); + rowList.add(rs.getString("FIRST_INSPECTION")); + rowList.add(rs.getString("SELF_INSPECTION")); + rowList.add(rs.getString("REACTION_PLAN")); + controlRequirementData.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(); + } + + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + new Thread() { + @Override + public void run() { + new TMom033OperationReferenceBookOutputDialog(app, session, comp, properties, controlRequirementData); + super.run(); + } + }.start(); + + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputDialog.java b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputDialog.java new file mode 100644 index 0000000..c558992 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputDialog.java @@ -0,0 +1,505 @@ +package com.connor.renben.process.plm.tmom033.copy; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +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 java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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; + +public class TMom033OperationReferenceBookOutputDialog extends AbstractAIFDialog implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision;// ѡеίе汾 + private TCProperty[] properties; + private List> controlRequirementData; + + //ͼ + private TCComponentTcFile picFile; + private PicDialog picDialog; + private TCComponent[] comps; + private String outFilePathp=null; + private TCComponentDataset Dataset; + + // ؼ + private JPanel mainPanel; + private JFileChooser jfc; + private JButton okButton; + private JButton celButton; + private JButton pictureButton; + private JButton fileButton; + private JTextField pathText; + private JTextField fleName; + + public TMom033OperationReferenceBookOutputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, TCProperty[] properties, List> controlRequirementData) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.properties = properties; + this.controlRequirementData = controlRequirementData; + 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, 150)); + jfc = new JFileChooser(); + jfc.setCurrentDirectory(new File("c:\\"));// ļѡijʼĿ¼Ϊd + this.okButton = new JButton(rb.getString("dc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.fileButton = new JButton("..."); + this.pictureButton = new JButton(rb.getString("tk_display.TITLE")); + this.pictureButton.setPreferredSize(new Dimension(100, 30)); + // Ӽ + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + //رմʱѵͼƬɾ + if(outFilePathp!=null&&new File(outFilePathp).exists()) { + new File(outFilePathp).delete(); + } + } + }); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.fileButton.addActionListener(this); + this.pictureButton.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(rb.getString("jyjzs33_display.TITLE")); + 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(this.pictureButton); + 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(); + } + + /** + * ļѡť¼ + * + * @param e + */ + public void selectFileButtonEvent(ActionEvent e) { + jfc.setFileSelectionMode(1);// 趨ֻѡļ + int state = jfc.showOpenDialog(null);// ˾ǴļѡĴ + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// fΪѡ񵽵Ŀ¼ + pathText.setText(f.getAbsolutePath()); + } + } + /** + * ͼѡť¼ + * + * @param e + */ + public void selectpictureButtonEvent() { + //MessageBox.post(, "", MessageBox.ERROR); + TCComponentFolder fileFolder; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(getPuid()==null) { + MessageBox.post(rb.getString("wpzxydsxx28_display.TITLE"), "", MessageBox.ERROR); + }else { + fileFolder = (TCComponentFolder)session + .stringToComponent(getPuid()); + if(fileFolder!=null) { + comps = fileFolder.getReferenceListProperty("contents"); + picDialog=new PicDialog(comps,this.pathText.getText(),fileFolder.getStringProperty("object_name")); + }else { + MessageBox.post(rb.getString("wzdtk28_display.TITLE"), "", MessageBox.ERROR); + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JobProcessFormBean getData() { + JobProcessFormBean bean = new JobProcessFormBean(); + bean.setGsmc(this.properties[0].getStringValue()); + bean.setLjdh(this.properties[1].getStringValue()); + bean.setSbxh(this.properties[2].getStringValue()); + bean.setBgx(this.properties[3].getStringValue()); + bean.setSbmc(this.properties[4].getStringValue()); + bean.setControlRequirementData(controlRequirementData); + return bean; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if (source.equals(this.fileButton)) { + selectFileButtonEvent(e); + } + else if(source.equals(this.pictureButton)) { + if(isExsist()==0) { + selectpictureButtonEvent(); + }else {//ӹϵ´ͼƬʱͼƬ + int isReplace= JOptionPane.showConfirmDialog(null, "ѴڵͼǷѡ", "ʾ", JOptionPane.YES_NO_OPTION); + if(isReplace == JOptionPane.YES_OPTION){ + try { + itemRevision.remove("IMAN_specification",itemRevision.getReferenceListProperty("IMAN_specification")); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + selectpictureButtonEvent(); + }else { + return; + } + } + } + else if (source.equals(this.okButton)) { + int reNum=isExsist(); + if(reNum==0) { + MessageBox.post(rb.getString("qxxzdct_display.TITLE"), "", MessageBox.ERROR); + return; + }else if(reNum>1) { + MessageBox.post(rb.getString("dzt28_display.TITLE"), "", MessageBox.ERROR); + return; + } + printPic(); + // Excel + // ȡģ + String outFilePath = this.pathText.getText() + "\\" + this.fleName.getText() + ".xlsx"; + File file = TMomMethodUtil.getFile(session, "׼", "MSExcelX"); + try { + ExcelUtil07.writeOperationReferenceBookToExcel(getData(), file, outFilePath,picFile,outFilePathp); + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + this.dispose(); + } catch (IOException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + this.dispose(); + } + } + + //ѡȡտͼpuid + public String getPuid() { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("RB3_PICTURE_LIBRARY"); + if (modelFiles == null) + { + System.out.println("δҵѡ"); + return null; + } + String puid = null; + // String sss=session.getCurrentGroup().toString(); + for (int i = 0; i < modelFiles.length; i++) { + if((session.getCurrentGroup().toString()).indexOf(modelFiles[i].split("-")[0])>-1) + { + puid = modelFiles[i].split("-")[1]; + return puid; + } + } + return null; + } + //ظӹϵµͼƬĿ + public int isExsist() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return compData.length; + } + + //ӹϵͼƬӡ + public void printPic() { + TCComponent[] compData = null; + try { + compData=itemRevision.getReferenceListProperty("IMAN_specification"); + Dataset=(TCComponentDataset) compData[0]; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + outFilePathp = this.pathText.getText() + "\\"+picFile.toString(); + CopyPic(picFile.getFmsFile(),outFilePathp); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private class PicDialog extends JFrame { + private CTMap pmap; + private CTable pmainTable; + private int tag; + private String pathname; + private String LibraryName; + boolean select=true; + private String[] header = new String[] { "ͼƬб"}; + private TCComponent[] comps; + public PicDialog(TCComponent[] comps,String pathname,String LibraryName) { + // TODO Auto-generated constructor stub + super(); + this.comps=comps; + this.pathname=pathname; + this.LibraryName=LibraryName; + pinit(); + } + private void pinit() { + this.setTitle(LibraryName); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + pmainTable = getNewjTable(null, null,header, 1); + pmainTable.setRowHeight(40); + pmainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(pmainTable); + for(int i=0;i= 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 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(); + } + } + } + } + } + //ͼƬ + public 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/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputHandler.java b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputHandler.java new file mode 100644 index 0000000..aa4952c --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputHandler.java @@ -0,0 +1,52 @@ +package com.connor.renben.process.plm.tmom033.copy; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom032.TMom032AssembleProcessFormOutputCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom033OperationReferenceBookOutputHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(app.getTargetComponent()==null) { + MessageBox.post(rb.getString("wxzzyjzs30_display.TITLE"), "", MessageBox.ERROR); + return null; + } + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷҵ׼İ汾 + if(comp.getType().indexOf("ZYJZSRevision") > 0) + { + TMom033OperationReferenceBookOutputCommand command = new TMom033OperationReferenceBookOutputCommand(app, + session,comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("dcsb33_display.TITLE"), "", MessageBox.ERROR); + } + } + else + { + MessageBox.post(rb.getString("bb30_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputOperation.java b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputOperation.java new file mode 100644 index 0000000..c0a0fe8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom033/copy/TMom033OperationReferenceBookOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom033.copy; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom033OperationReferenceBookOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectCommand.java b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectCommand.java new file mode 100644 index 0000000..eccad1d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectCommand.java @@ -0,0 +1,120 @@ +package com.connor.renben.process.plm.tmom034; + +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.connor.renben.process.plm.tmom028.TMom028JobProcessFormInputDialog; +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom034PackagingProjectCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private String[] properName = new String[] { "rb3_ItemId", // + "rb3_ItemName", // + "rb3_supplier", // Ӧ + "rb3_supplierId", // Ӧ̴ + "rb3_assembly", // ܳɴ/ + "rb3_itemNum", // λ/ + "rb3_itemSpecification", // mm + "rb3_itemWeight", // kg + "rb3_desc", // װװϡȼҪ + "rb3_location" }; // ǩʽλ + private List> dataList = new ArrayList>(); + private List plmeidList = new ArrayList(); + + public TMom034PackagingProjectCommand(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + ResultSet rs = null; + InputStream input = null; + try { + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_PACKAGINGPROJECTSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("PLMEID")); + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("P3")); + rowList.add(rs.getString("P4")); + dataList.add(rowList); + plmeidList.add(rs.getString("PLMEID")); + } + if (dataList.size() <= 0) { + // ȡѡֵ + String[] data = TMomMethodUtil.getPreferenceValues("Cust_PackagingProject"); + for (int i = 0; i < data.length; i++) { + List rowList = new ArrayList(); + rowList.add(UUID.randomUUID().toString().replace("-", "")); + rowList.add(data[i]); + rowList.add(""); + rowList.add(""); + rowList.add(""); + dataList.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(); + } + // ȡ汾 + TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + form = itemRevision.getRelatedComponent("IMAN_master_form_rev"); + if (form != null) { + properties = form.getTCProperties(properName); + } + new Thread() { + @Override + public void run() { + new TMom034PackagingProjectDialog(app, session, comp, dataList, plmeidList,form,properties); + super.run(); + } + }.start(); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectDialog.java b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectDialog.java new file mode 100644 index 0000000..f3cadb1 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectDialog.java @@ -0,0 +1,471 @@ +package com.connor.renben.process.plm.tmom034; + +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.scrollpage.ScrollPagePane; + +public class TMom034PackagingProjectDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + + // ؼʼ + private JLabel itemIdLabel; + private JTextField itemIdField; + private JLabel itemNameLabel; + private JTextField itemNameField; + private JLabel supplierLabel; + private JTextField supplierField; + private JLabel supplierIdLabel; + private JTextField supplierIdField; + private JLabel assemblyLabel; + private JTextField assemblyField; + private JLabel itemNumLabel; + private JTextField itemNumField; + private JLabel itemSpecificationLabel; + private JTextField itemSpecificationField; + private JLabel itemWeightLabel; + private JTextField itemWeightField; + private JLabel descLabel; + private JTextField descField; + private JLabel locationLabel; + private JTextField locationField; + private TCComponentItemRevision itemRevision; + + + //ȡʻԱ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + + // װ׼ + private String[] handers = new String[] { "PLMEID", rb.getString("gysjfdygc34_display.TITLE"), + rb.getString("yjbz34_display.TITLE"), rb.getString("ejbz34_display.TITLE"), rb.getString("sjbz34_display.TITLE") }; + private CTMap map; + private CTable mainTable; + private List> dataList; + private List plmeidList; + + private JPanel rootPanel; + + private JButton okButton; + private JButton celButton; + private JButton outputButton; + private JButton outputButton2; + private JButton selectWay; + private String outputWayString=null; + + public TMom034PackagingProjectDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + List> dataList, List plmeidList, TCComponent form, + TCProperty[] properties) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.dataList = dataList; + this.plmeidList = plmeidList; + this.form = form; + this.properties = properties; + this.itemRevision= (TCComponentItemRevision) this.comp; + init(); + setTable(); + } + + 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("bzbz34_display.TITLE")); + this.setPreferredSize(new Dimension(1070, 750)); + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + dispose(); + } + }); + //this.setAlwaysOnTop(true); + this.itemIdLabel = new JLabel(rb.getString("ljh34_display.TITLE")); + this.itemIdLabel.setPreferredSize(new Dimension(110, 30)); + this.itemIdField = new JTextField(); + this.itemIdField.setPreferredSize(new Dimension(150, 30)); + this.itemNameLabel = new JLabel(rb.getString("ljmc34_display.TITLE")); + this.itemNameLabel.setPreferredSize(new Dimension(110, 30)); + this.itemNameField = new JTextField(); + this.itemNameField.setPreferredSize(new Dimension(150, 30)); + this.supplierLabel = new JLabel(rb.getString("gys34_display.TITLE")); + this.supplierLabel.setPreferredSize(new Dimension(95, 30)); + this.supplierField = new JTextField(); + this.supplierField.setPreferredSize(new Dimension(150, 30)); + this.supplierIdLabel = new JLabel(rb.getString("gysdh34_display.TITLE")); + this.supplierIdLabel.setPreferredSize(new Dimension(90, 30)); + this.supplierIdField = new JTextField(); + this.supplierIdField.setPreferredSize(new Dimension(150, 30)); + + JPanel panel1 = new JPanel(new FlowLayout()); + panel1.add(this.itemIdLabel); + panel1.add(this.itemIdField); + panel1.add(this.itemNameLabel); + panel1.add(this.itemNameField); + panel1.add(this.supplierLabel); + panel1.add(this.supplierField); + panel1.add(this.supplierIdLabel); + panel1.add(this.supplierIdField); + + JPanel panel2 = new JPanel(new FlowLayout()); + this.assemblyLabel = new JLabel(rb.getString("syzcdmmc34_display.TITLE")); + this.assemblyLabel.setToolTipText(rb.getString("syzcdmmc34_display.TITLE")); + this.assemblyLabel.setPreferredSize(new Dimension(110, 30)); + this.assemblyField = new JTextField(); + this.assemblyField.setPreferredSize(new Dimension(150, 30)); + this.itemNumLabel = new JLabel(rb.getString("ljdw(tg)34_display.TITLE")); + this.itemNumLabel.setToolTipText(rb.getString("ljdw(tg)34_display.TITLE")); + this.itemNumLabel.setPreferredSize(new Dimension(110, 30)); + this.itemNumField = new JTextField(); + this.itemNumField.setPreferredSize(new Dimension(150, 30)); + this.itemSpecificationLabel = new JLabel(rb.getString("ljgg34_display.TITLE")); + this.itemSpecificationLabel.setToolTipText(rb.getString("ljgg34_display.TITLE")); + this.itemSpecificationLabel.setPreferredSize(new Dimension(95, 30)); + this.itemSpecificationField = new JTextField(); + this.itemSpecificationField.setPreferredSize(new Dimension(150, 30)); + this.itemWeightLabel = new JLabel(rb.getString("ljzl34_display.TITLE")); + this.itemWeightLabel.setToolTipText(rb.getString("ljzl34_display.TITLE")); + this.itemWeightLabel.setPreferredSize(new Dimension(90, 30)); + this.itemWeightField = new JTextField(); + this.itemWeightField.setPreferredSize(new Dimension(150, 30)); + + panel2.add(this.assemblyLabel); + panel2.add(this.assemblyField); + panel2.add(this.itemNumLabel); + panel2.add(this.itemNumField); + panel2.add(this.itemSpecificationLabel); + panel2.add(this.itemSpecificationField); + panel2.add(this.itemWeightLabel); + panel2.add(this.itemWeightField); + + JPanel panel3 = new JPanel(new FlowLayout()); + this.descLabel = new JLabel(rb.getString("bzbzclfhdjyms34_display.TITLE")); + this.descLabel.setToolTipText(rb.getString("bzbzclfhdjyms34_display.TITLE")); + this.descLabel.setPreferredSize(new Dimension(180, 30)); + this.descField = new JTextField(); + this.descField.setPreferredSize(new Dimension(350, 30)); + this.locationLabel = new JLabel(rb.getString("bqgshwz34_display.TITLE")); + this.locationLabel.setToolTipText(rb.getString("bqgshwz34_display.TITLE")); + this.locationLabel.setPreferredSize(new Dimension(95, 30)); + this.locationField = new JTextField(); + this.locationField.setPreferredSize(new Dimension(400, 30)); + + panel3.add(this.descLabel); + panel3.add(this.descField); + panel3.add(this.locationLabel); + panel3.add(this.locationField); + + JPanel partPanel = new JPanel(new PropertyLayout()); + partPanel.add("1.1.left.top", panel1); + partPanel.add("2.1.left.top", panel2); + partPanel.add("3.1.left.top", panel3); + + this.mainTable = getjTable(null, null, handers, dataList.size()); + + this.mainTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + map.setRow(mainTable.getSelectedRow()); + map.setColumn(mainTable.getSelectedColumn()); + } + } + }); + + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "װ׼")); + mainPanel.add(new ScrollPagePane(this.mainTable), BorderLayout.CENTER); + + this.okButton = new JButton(rb.getString("bc_display.TITLE")); + this.celButton = new JButton(rb.getString("qx_display.TITLE")); + this.outputButton = new JButton(rb.getString("dc_display.TITLE")); + this.selectWay = new JButton(rb.getString("xzlj_display.TITLE")); + this.outputButton2 = new JButton(rb.getString("dc_display.TITLE")); + rootPanel = new JPanel(new FlowLayout()); + rootPanel.add(okButton); + rootPanel.add(celButton); + rootPanel.add(outputButton2); +// rootPanel.add(outputButton); +// rootPanel.add(selectWay); + this.setText(); + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(partPanel, BorderLayout.NORTH); + this.add(mainPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + + + } + + /*** + * ÿؼֵ + */ + private void setText() { + this.itemIdField.setText(this.properties[0].getStringValue()); + this.itemNameField.setText(this.properties[1].getStringValue()); + this.supplierField.setText(this.properties[2].getStringValue()); + this.supplierIdField.setText(this.properties[3].getStringValue()); + this.assemblyField.setText(this.properties[4].getStringValue()); + this.itemNumField.setText(this.properties[5].getStringValue()); + this.itemSpecificationField.setText(this.properties[6].getStringValue()); + this.itemWeightField.setText(this.properties[7].getStringValue()); + this.descField.setText(this.properties[8].getStringValue()); + this.locationField.setText(this.properties[9].getStringValue()); + } + + /*** + * ȡؼֵ + */ + private List getText() { + List valueList = new ArrayList(); + valueList.add(this.itemIdField.getText()); + valueList.add(this.itemNameField.getText()); + valueList.add(this.supplierField.getText()); + valueList.add(this.supplierIdField.getText()); + valueList.add(this.assemblyField.getText()); + valueList.add(this.itemNumField.getText()); + valueList.add(this.itemSpecificationField.getText()); + valueList.add(this.itemWeightField.getText()); + valueList.add(this.descField.getText()); + valueList.add(this.locationField.getText()); + return valueList; + } + // Ӽ + public void createActionEvent() { + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.outputButton.addActionListener(this); + this.outputButton2.addActionListener(this); + this.selectWay.addActionListener(this); + } + + private void setTable() { + if (this.dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + for (int j = 0; j < dataList.get(i).size(); j++) { + mainTable.setValueAt(dataList.get(i).get(j), i, j); + } + } + } + } + + public CTable getjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + + map.setEditable(true); + partsTable = new CTable(map); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(s2, 100); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + // //þ + 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; + } + + private void setPlmeidList(List plmeidList, CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + for (int j = 0; j < table.getRowCount(); j++) { + if (!plmeidList.contains(table.getValueAt(j, 0))) { + plmeidList.add(table.getValueAt(j, 0).toString()); + } + } + } + + private List> getTableValue(CTable table) { + // TODO Auto-generated method stub + List> dataValeList = new ArrayList>(); + + CTMap map = ((CTMap) table.getModel()); + for (int j = 0; j < table.getRowCount(); j++) { + List rowValue = new ArrayList(); + // 17 + for (int j2 = 0; j2 < map.getColumnCount(); j2++) { + rowValue.add((String) table.getValueAt(j, j2)); + } + dataValeList.add(rowValue); + } + // for (int i = 0; i < processRowList.size(); i++) { + // List rows = processRowList.get(i); + // } + return dataValeList; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + if (mainTable.getSelectedRow() >= 0 && mainTable.getSelectedColumn() >= 0) { + (mainTable.getCellEditor(mainTable.getSelectedRow(), mainTable.getSelectedColumn())).stopCellEditing(); + } + this.dataList = getTableValue(this.mainTable); + + List valueList = getText(); + + TMom034PackagingProjectOperation operation = new TMom034PackagingProjectOperation(app, session, comp, + dataList, plmeidList, form, + properties, valueList); + try { + operation.executeOperation(); + setPlmeidList(plmeidList, mainTable); + + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if(source.equals(this.celButton)){ + this.dispose(); + }else if(source.equals(this.outputButton)){ + if(this.outputWayString==null) { + MessageBox.post(rb.getString("dclj34_display.TITLE"),"",MessageBox.ERROR); + }else { + String outputWay=this.outputWayString+"\\װ.xlsx"; + OutputData(outputWay); + } + }else if(source.equals(this.outputButton2)){ + String outputWay=System.getenv("TEMP") + "\\"+"װ.xlsx"; + OutputData(outputWay); + }else if(source.equals(this.selectWay)){ + selectPath(); + } + } + +//ȡӡ + public void OutputData(String outFilePath) { + List> TableDatas = getTableValue(this.mainTable);// + List mainValueData = getText();// + File file=null; + file=TMomMethodUtil.getFile(session, "װ", "MSExcelX"); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + try { + ExcelUtil07.writePackagingSchemeToExcel(mainValueData,TableDatas, file, outFilePath); + if (ExcelUtil07.getExcelToItem(session, (TCComponentItemRevision) app.getTargetComponent(), + "TC_Attaches", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "TC_Attaches", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, "װ", "TC_Attaches", + "MSExcelX", true); + } + MessageBox.post(rb.getString("dcexcelcg28_display.TITLE"), "ɹ", MessageBox.INFORMATION); + if(outFilePath!=null) { + new File(outFilePath).delete(); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +//ѡ񵼳· + public void selectPath() { + int result = 0; + String pathway=null; + JFileChooser fileChooser = new JFileChooser(); + FileSystemView fsv = FileSystemView.getFileSystemView(); //עˣҪһ + System.out.println(fsv.getHomeDirectory()); //õ· + fileChooser.setCurrentDirectory(fsv.getHomeDirectory()); + fileChooser.setDialogTitle("ѡ񵼳·"); + fileChooser.setApproveButtonText("ȷ"); + fileChooser.setFileSelectionMode(1); + Component chatFrame=null; + result = fileChooser.showOpenDialog(chatFrame); + if (JFileChooser.APPROVE_OPTION == result) { + pathway = fileChooser.getSelectedFile().getPath(); + } + this.outputWayString=pathway; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectHandler.java b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectHandler.java new file mode 100644 index 0000000..4f7cebf --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectHandler.java @@ -0,0 +1,48 @@ +package com.connor.renben.process.plm.tmom034; + +import java.util.Locale; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom034PackagingProjectHandler 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(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + if(comp==null) { + MessageBox.post(rb.getString("qxzbzbb34_display.TITLE"), "", MessageBox.ERROR); + return null; + } + // жѡжǷǰװİ汾 + if (comp.getType().indexOf("BZFARevision") > 0) { + TMom034PackagingProjectCommand command = new TMom034PackagingProjectCommand(app, session, comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post(rb.getString("bjsb34_display.TITLE"), "", MessageBox.ERROR); + } + } else { + MessageBox.post(rb.getString("bb34_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectOperation.java b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectOperation.java new file mode 100644 index 0000000..374e8d8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom034/TMom034PackagingProjectOperation.java @@ -0,0 +1,118 @@ +package com.connor.renben.process.plm.tmom034; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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.TCComponentUser; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom034PackagingProjectOperation extends AbstractAIFOperation { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponent form; + private TCProperty[] properties; + private List valueList; + private List> dataList; + private List plmeidList; + + public TMom034PackagingProjectOperation(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + List> dataList, List plmeidList, TCComponent form, TCProperty[] properties, + List valueList) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.dataList = dataList; + this.plmeidList = plmeidList; + this.form = form; + this.properties = properties; + this.valueList = valueList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // + InputStream input = null; + try { + + // + // жǷǰ汾 + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + TCComponentUser user = session.getUser(); + if (user.getUserId().equals(userName)) { + // TMomMethodUtil.setByPass(session, true); + this.form.lock(); + this.properties[0].setStringValue(this.valueList.get(0)); + this.properties[1].setStringValue(this.valueList.get(1)); + this.properties[2].setStringValue(this.valueList.get(2)); + this.properties[3].setStringValue(this.valueList.get(3)); + this.properties[4].setStringValue(this.valueList.get(4)); + this.properties[5].setStringValue(this.valueList.get(5)); + this.properties[6].setStringValue(this.valueList.get(6)); + this.properties[7].setStringValue(this.valueList.get(7)); + this.properties[8].setStringValue(this.valueList.get(8)); + this.properties[9].setStringValue(this.valueList.get(9)); + this.form.save(); + this.form.unlock(); + this.form.refresh(); + } + + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + // ȡݿ + SqlUtilT.getTCConnection(); + + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + + if (rowList.get(0) != null && !rowList.get(0).equals("") && plmeidList.contains(rowList.get(0))) { + // ȡݿ + String updateSQL = String.format(pro.getProperty("RB3_PACKAGINGPROJECTUPDATE"), rowList.get(0)); + SqlUtilT.update(new String[] { rowList.get(1), rowList.get(2), rowList.get(3), rowList.get(4) }, + updateSQL); + } else { + String insertSQL = pro.getProperty("RB3_PACKAGINGPROJECTINSERT"); + SqlUtilT.write2(new String[] { rowList.get(0), comp.getUid(), rowList.get(1), rowList.get(2), + rowList.get(3), rowList.get(4) }, insertSQL); + } + + } + SqlUtilT.connection.commit(); + input.close(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom035/TMom035EntrustmentSumCommand.java b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumCommand.java new file mode 100644 index 0000000..c8866ee --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumCommand.java @@ -0,0 +1,30 @@ +package com.connor.renben.process.plm.tmom035; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCSession; + +public class TMom035EntrustmentSumCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + + public TMom035EntrustmentSumCommand(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 + + new Thread() { + @Override + public void run() { + new TMom035EntrustmentSumDialog(app, session); + super.run(); + } + }.start(); + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumDialog.java b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumDialog.java new file mode 100644 index 0000000..071b8d3 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumDialog.java @@ -0,0 +1,112 @@ +package com.connor.renben.process.plm.tmom035; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Locale; +import java.util.ResourceBundle; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCSession; + +public class TMom035EntrustmentSumDialog extends JFrame implements ActionListener { + //ȡʻ + Locale defaultLocale=Locale.getDefault(); + ResourceBundle rb=ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message",defaultLocale); + private AbstractAIFApplication app; + private TCSession session; + + // ѡ + private JTabbedPane tabbedPane; + private String[] sumHeader = new String[] { rb.getString("zt35_display.TITLE"), rb.getString("wtdsh35_display.TITLE"), rb.getString("gzfp35_display.TITLE"), rb.getString("scjl35_display.TITLE") }; + private CTable sumTable;//ǰ״̬ + private String[] checkHeader = new String[] { rb.getString("wtrq35_display.TITLE"), rb.getString("wtdh35_display.TITLE"), rb.getString("wtdw35_display.TITLE"), rb.getString("jclx35_display.TITLE"), rb.getString("xmdj35_display.TITLE"), rb.getString("ycwcrq35_display.TITLE") }; + private CTable checkTable;// ίеƷ + private String[] allocationHeader = new String[] { rb.getString("wtrq35_display.TITLE"), rb.getString("wtdh35_display.TITLE"), rb.getString("wtdw35_display.TITLE"), rb.getString("jclx35_display.TITLE"), rb.getString("xmdj35_display.TITLE"), rb.getString("jhwcrq35_display.TITLE") }; + private CTable allocationTable;// + private String[] resultHeader = new String[] { rb.getString("wtrq35_display.TITLE"), rb.getString("wtdh35_display.TITLE"), rb.getString("wtdw35_display.TITLE"), rb.getString("jclx35_display.TITLE"), rb.getString("xmdj35_display.TITLE"), rb.getString("zbry35_display.TITLE"), rb.getString("jhwcrq35_display.TITLE") }; + private CTable resultTable;// ϴ + + public TMom035EntrustmentSumDialog(AbstractAIFApplication app, TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + init(); + } + + //ʼ + private void init() { + // TODO Auto-generated method stub + this.setTitle(rb.getString("lcjs35_display.TITLE")); + this.setPreferredSize(new Dimension(980, 750)); + + this.sumTable = getjTable(null, null, sumHeader, 1); + this.checkTable = getjTable(null, null, checkHeader, 1); + this.allocationTable = getjTable(null, null, allocationHeader, 1); + this.resultTable = getjTable(null, null, resultHeader, 1); + + tabbedPane = new JTabbedPane(); + + tabbedPane.addTab(rb.getString("dqzt35_display.TITLE"), new JScrollPane(this.sumTable)); + tabbedPane.addTab(rb.getString("wtdhypsh35_display.TITLE"), new JScrollPane(this.checkTable)); + tabbedPane.addTab(rb.getString("gzfp35_display.TITLE"), new JScrollPane(this.allocationTable)); + tabbedPane.addTab(rb.getString("scjg35_display.TITLE"), new JScrollPane(this.resultTable)); + + this.setLayout(new BorderLayout()); +// this.add(titlePanel, BorderLayout.NORTH); + this.add(tabbedPane, BorderLayout.CENTER); +// this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + public CTable getjTable(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); + Adapter adapter = new Adapter(partsTable); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(40); + // +// partsTable.HiddenCell(0); +// partsTable.HiddenCell(titleNames.length - 1); +// partsTable.HiddenCell(titleNames.length - 2); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + // //þ + 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 e) { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumHandler.java b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumHandler.java new file mode 100644 index 0000000..1724de2 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumHandler.java @@ -0,0 +1,30 @@ +package com.connor.renben.process.plm.tmom035; + +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 TMom035EntrustmentSumHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + TMom035EntrustmentSumCommand command = new TMom035EntrustmentSumCommand(app,session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumOperation.java b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumOperation.java new file mode 100644 index 0000000..9a0d902 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom035/TMom035EntrustmentSumOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom035; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom035EntrustmentSumOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyCommand.java b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyCommand.java new file mode 100644 index 0000000..4c5f131 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyCommand.java @@ -0,0 +1,75 @@ +package com.connor.renben.process.plm.tmom036; + +import java.io.File; +import java.util.List; +import java.util.Map; + +import com.connor.renben.process.plm.util.ParseXMLUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + +public class TMom036UpdateItemPropertyCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + + + public TMom036UpdateItemPropertyCommand(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 + //ȡļ + + ParseXMLUtil xml=new ParseXMLUtil(); + File file=xml.getSXX("RB3_CPHPJFS", session); + + attrMap =xml.parseXMLCode(file); + if(attrMap == null || attrMap.size() <= 0) { + MessageBox.post("ѡRB3_CPHPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + File file2=xml.getSXX("RB3_THPJFS", session); + attrMap2 =xml.parseXMLCode(file2); + if(attrMap2 == null || attrMap2.size() <= 0) { + MessageBox.post("ѡRB3_THPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + File file3=xml.getSXX("RB3_BSHPJFS", session); + attrMap3 =xml.parseXMLCode(file3); + if(attrMap3 == null || attrMap3.size() <= 0) { + MessageBox.post("ѡRB3_BSHPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + File file4=xml.getSXX("RB3_SMPJFS", session); + attrMap4 =xml.parseXMLCode(file4); + if(attrMap4 == null || attrMap4.size() <= 0) { + MessageBox.post("ѡRB3_SMPJFSδã飡", "WARNING", + MessageBox.WARNING); + return; + } + + new Thread() { + @Override + public void run() { + new TMom036UpdateItemPropertyDialog(app, session,attrMap, attrMap2, attrMap3, attrMap4); + super.run(); + } + }.start(); + + super.executeModal(); + } +} diff --git a/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyDialog.java b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyDialog.java new file mode 100644 index 0000000..45d8813 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyDialog.java @@ -0,0 +1,323 @@ +package com.connor.renben.process.plm.tmom036; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.ControlPlanComboBoxBean; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class TMom036UpdateItemPropertyDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private String[] columns = new String[] { "PUID", "ID", "", "汾", "Ʒ", "ͼ", "ʶ", "˵" }; + private String[] properNames = new String[] { "item_id", "object_name", "item_revision_id", "object_desc", "object_desc", "object_desc", "object_desc" }; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm"); + + private String[] searchKeys; + private String[] searchValues; + + // ؼ + private JLabel typeLabel; + private JAutoCompleteComboBox typeComboBox; + private JLabel userLabel; + private JTextField userTextField; + private JLabel groupLabel; + private JTextField groupTextField; + private JLabel startDateLabel; + private DateButton startDateButton; + private JLabel endDateLabel; + private DateButton endDateButton; + + private CTMap map; + private CTable itemDataTable;// ѯĶ + + private JButton queryButton;// ѯ + private JButton okButton;// ȷ + private JButton closeButton;// ȡ + + public TMom036UpdateItemPropertyDialog(AbstractAIFApplication app, TCSession session, + Map> attrMap, Map> attrMap2, Map> attrMap3, + Map> attrMap4) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.attrMap = attrMap; + this.attrMap2 = attrMap2; + this.attrMap3 = attrMap3; + this.attrMap4 = attrMap4; + init(); + } + + /*** + * ʼ + */ + private void init() { + // TODO Auto-generated method stub + this.setTitle(""); + this.setPreferredSize(new Dimension(980, 750)); + + this.typeLabel = new JLabel(""); + this.typeLabel.setPreferredSize(new Dimension(100, 30)); + ControlPlanComboBoxBean[] boxBeans = TMomMethodUtil.getComboxItem(session,"RB3_UpdateItemProperty_ItemType"); + if(boxBeans != null) + { + this.typeComboBox = new JAutoCompleteComboBox(boxBeans); + } + else + { + this.typeComboBox = new JAutoCompleteComboBox(); + } + this.typeComboBox.setPreferredSize(new Dimension(150, 30)); + this.userLabel = new JLabel("û"); + this.userLabel.setPreferredSize(new Dimension(100, 30)); + this.userTextField = new JTextField(); + this.userTextField.setPreferredSize(new Dimension(150, 30)); + this.groupLabel = new JLabel(""); + this.groupLabel.setPreferredSize(new Dimension(100, 30)); + this.groupTextField = new JTextField(); + this.groupTextField.setPreferredSize(new Dimension(150, 30)); + this.startDateLabel = new JLabel("ʱ"); + this.startDateLabel.setPreferredSize(new Dimension(100, 30)); + this.startDateButton = new DateButton(dateFormat); + this.startDateButton.setPreferredSize(new Dimension(150, 30)); + this.endDateLabel = new JLabel("ʱ"); + this.endDateLabel.setPreferredSize(new Dimension(100, 30)); + this.endDateButton = new DateButton(dateFormat); + this.endDateButton.setPreferredSize(new Dimension(150, 30)); + + this.queryButton = new JButton("ѯ"); + this.queryButton.setPreferredSize(new Dimension(100, 30)); + + JPanel mainPanel = new JPanel(new PropertyLayout()); + mainPanel.add("1.1.left.top", typeLabel); + mainPanel.add("1.2.left.top", typeComboBox); + mainPanel.add("2.1.left.top", userLabel); + mainPanel.add("2.2.left.top", userTextField); + mainPanel.add("3.1.left.top", groupLabel); + mainPanel.add("3.2.left.top", groupTextField); + mainPanel.add("4.1.left.top", startDateLabel); + mainPanel.add("4.2.left.top", startDateButton); + mainPanel.add("5.1.left.top", endDateLabel); + mainPanel.add("5.2.left.top", endDateButton); + mainPanel.add("6.1.left.top", queryButton); + + JPanel tablePanel = new JPanel(); + // ʽ + this.itemDataTable = getjTable(null, null, columns, 1); + + // ӹ + JScrollPane scrollPane = new JScrollPane(this.itemDataTable); + scrollPane.getVerticalScrollBar().setUnitIncrement(10); + tablePanel.add(scrollPane, BorderLayout.CENTER); + + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(mainPanel); + splitPane.setRightComponent(scrollPane); + + JPanel rootPanel = new JPanel(new FlowLayout()); + + this.okButton = new JButton("ȷ"); + this.closeButton = new JButton("ȡ"); + + rootPanel.add(okButton); + rootPanel.add(closeButton); + + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); +// this.add(titlePanel, BorderLayout.NORTH); + this.add(splitPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + // Ӽ + public void createActionEvent() { + this.queryButton.addActionListener(this); + this.okButton.addActionListener(this); + this.closeButton.addActionListener(this); + } + + public CTable getjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(true); + partsTable = new CTable(map); + Adapter adapter = new Adapter(partsTable); + partsTable.setRowHeight(40); + // + partsTable.HiddenCell(0); + + // //ʾȾ + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + // //þ + 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; + } + + + private void setDataTable(List> dataList) { + if (dataList.size() > 0) { + for (int i = 0; i < dataList.size(); i++) { + for (int j = 0; j < dataList.get(i).size(); j++) { + this.itemDataTable.setValueAt(dataList.get(i).get(j), i, j); + } + } + } + } + + private void getSearchKeyValues() { + List keyList = new ArrayList(); + List valueList = new ArrayList(); + if (!this.typeComboBox.getText().isEmpty()) { + keyList.add("Type"); + valueList.add(this.typeComboBox.getText()); + } + if (!this.userTextField.getText().isEmpty()) { + keyList.add("OwningUser"); + valueList.add(this.userTextField.getText()); + } + if (!this.groupTextField.getText().isEmpty()) { + keyList.add("OwningGroup"); + valueList.add(this.groupTextField.getText()); + } + if (!this.startDateButton.getText().isEmpty() && this.startDateButton.getDate() != null) { + keyList.add("CreatedAfter"); + valueList.add(this.startDateButton.getText()); + } + if (!this.endDateButton.getText().isEmpty() && this.endDateButton.getDate() != null) { + keyList.add("CreatedBefore"); + valueList.add(this.endDateButton.getText()); + } + + if (keyList.size() > 0) { + this.searchKeys = new String[keyList.size()]; + this.searchValues = new String[keyList.size()]; + for (int i = 0; i < keyList.size(); i++) { + searchKeys[i] = keyList.get(i); + searchValues[i] = valueList.get(i); + } + } + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.queryButton)) { + // ȡѯͶӦֵ + getSearchKeyValues(); + if (this.searchKeys.length > 0) { + // òѯ + InterfaceAIFComponent[] checkComponents = TMomMethodUtil.searchComponentsCollection(session, "...", + searchKeys, this.searchValues); + if (checkComponents.length <= 0) { + MessageBox.post("δҵĶ", "", MessageBox.ERROR); + return; + } else { + List> dataList = new ArrayList>(); + for (int i = this.itemDataTable.getRowCount() - 1; i >= 0; i--) { + + this.map.removeRow(i); + } + for (int i = 0; i < checkComponents.length; i++) { + List rowList = new ArrayList(); + this.map.insertRow(0); + //ȡ + TCComponentItemRevision itemRevision = (TCComponentItemRevision)checkComponents[i]; + try { + TCProperty[] properties = itemRevision.getTCProperties(properNames); + rowList.add(itemRevision.getUid()); + for (int j = 0; j < properties.length; j++) { + + rowList.add(properties[j].getStringValue()); + } + dataList.add(rowList); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + //this.itemDataTable = getjTable(null, null, this.columns, dataList.size()); + setDataTable(dataList); + } + } else { + MessageBox.post("ѯ", "", MessageBox.ERROR); + return; + } + } else if (source.equals(this.okButton)) { + //ȡѡ + int[] rows = this.itemDataTable.getSelectedRows(); + if(rows.length <= 0) + { + MessageBox.post("ѡҪ޸ĵУ", "", MessageBox.ERROR); + return; + } + //UID + List uidList = new ArrayList(); + for (int i = 0; i < rows.length; i++) { + uidList.add(this.itemDataTable.getValueAt(rows[0], 0).toString()); + } + TMom036UpdateItemPropertyOperation operation = new TMom036UpdateItemPropertyOperation(session,uidList,attrMap, attrMap2, attrMap3, attrMap4); + try { + operation.executeOperation(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else { + this.dispose(); + } + } + +} diff --git a/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyHandler.java b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyHandler.java new file mode 100644 index 0000000..10090ae --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyHandler.java @@ -0,0 +1,31 @@ +package com.connor.renben.process.plm.tmom036; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.tmom035.TMom035EntrustmentSumCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class TMom036UpdateItemPropertyHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + TMom036UpdateItemPropertyCommand command = new TMom036UpdateItemPropertyCommand(app,session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyOperation.java b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyOperation.java new file mode 100644 index 0000000..3440a61 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom036/TMom036UpdateItemPropertyOperation.java @@ -0,0 +1,135 @@ +package com.connor.renben.process.plm.tmom036; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; + +public class TMom036UpdateItemPropertyOperation extends AbstractAIFOperation { + + private TCSession session; + private Map> attrMap; + private Map> attrMap2; + private Map> attrMap3; + private Map> attrMap4; + private List uidList; + + public TMom036UpdateItemPropertyOperation(TCSession session, List uidList, + Map> attrMap, Map> attrMap2, Map> attrMap3, + Map> attrMap4) { + // TODO Auto-generated constructor stub + this.session = session; + this.attrMap = attrMap; + this.attrMap2 = attrMap2; + this.attrMap3 = attrMap3; + this.attrMap4 = attrMap4; + this.uidList = uidList; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + TCClassificationService classService = session.getClassificationService(); + for (int i = 0; i < uidList.size(); i++) { + TCComponent comp = session.stringToComponent(uidList.get(i)); + if (comp == null || !(comp instanceof TCComponentItemRevision)) { + continue; + } + // ȡӦķID + TCComponentICO[] icos = comp.getClassificationObjects(); + if (icos.length <= 0) { + continue; + } + String icoUid = icos[0].getUid(); + classService.loadICOs(new String[] { icoUid }, ""); + // ID + String classId = icos[0].getClassId(); + + List>> attraMapList = new ArrayList>>(); + attraMapList.add(attrMap); + attraMapList.add(attrMap2); + attraMapList.add(attrMap3); + attraMapList.add(attrMap4); + for (int k = 0; k < attraMapList.size(); k++) { + // ȡ + List propName = attraMapList.get(k).get(classId); + if (propName != null && propName.size() > 0) { + + // ȡķ + ICSProperty[] icsProps = icos[0].getICSProperties(true); + ICSPropertyDescription[] icsDs = icos[0].getICSPropertyDescriptors(); + + String propNames = propName.get(0); + // ַ + String[] classPropNames = new String[] { propNames }; + if (propNames.indexOf(";") > 0) { + classPropNames = propNames.split(";"); + } + StringBuffer stringBuffer = new StringBuffer(); + + for (int j = 0; j < classPropNames.length; j++) { + + String name1 = ""; + String name2 = ""; + + if (classPropNames[j].indexOf("+") > 0) { + name1 = classPropNames[j].split("[+]")[0]; + name2 = classPropNames[j].split("[+]")[1]; + } else { + name1 = classPropNames[j]; + name2 = classPropNames[j]; + } + + for (ICSPropertyDescription icsD : icsDs) { + String value = ""; + for (ICSProperty icsProperty : icsProps) { + if (icsProperty.getId() == icsD.getId() + && (icsD.getName().equals(name1) || icsD.getName().equals(name2))) { + value = icsProperty.getValue(); + if (!value.isEmpty()) { + stringBuffer.append(value + "-"); + } + } + } + } + } + //ö + if(stringBuffer.toString().isEmpty()) + { + continue; + } + comp.lock(); + switch (k) { + case 0: + comp.setProperty("object_desc", stringBuffer.substring(0,stringBuffer.length() - 1)); + break; + case 1: + comp.setProperty("object_desc", stringBuffer.substring(0,stringBuffer.length() - 1)); + break; + case 2: + comp.setProperty("object_desc", stringBuffer.substring(0,stringBuffer.length() - 1)); + break; + case 3: + comp.setProperty("object_desc", stringBuffer.substring(0,stringBuffer.length() - 1)); + break; + + default: + break; + } + comp.save(); + comp.unlock(); + comp.refresh(); + } + } + } + } + +} diff --git a/src/com/connor/renben/process/plm/tmom037/NewCodeItemDialog.java b/src/com/connor/renben/process/plm/tmom037/NewCodeItemDialog.java new file mode 100644 index 0000000..ef1c2a6 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom037/NewCodeItemDialog.java @@ -0,0 +1,315 @@ +/** + * @author tyl + * @Action ini + * 2011-4-4 + */ +package com.connor.renben.process.plm.tmom037; + +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.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.util.ParseXMLUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AifrcpPlugin; +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.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + +public class NewCodeItemDialog extends AbstractAIFDialog { + + public NewCodeItemDialog() throws Exception { + + init(); + } +// protected NewCodeItemDialog(IShellProvider parentShell) { +// super(parentShell); +// init(); +// // TODO Auto-generated constructor stub +// } + + private List>> attrMap = new ArrayList>>(); + // private Map>[] attrMap = new Map>[4]; + private List list; + private Set key; + + private AbstractAIFApplication app; + private TCSession session; + private JTextField field1; + private JTextField field2; + private JTextField field3; + private String text1; + private String text2; + private String text3; + private String text4; + private DateButton t4tableb; + private DateButton t5tableb; + private String text5; + private JLabel t4table; + private JLabel t5table; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private String[] st; + private String value = ""; + private String[] stt; + + public void init() throws Exception { + session = (TCSession) AifrcpPlugin.getSessionService().getDefaultSession(); + + this.setTitle(""); + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(440, 400)); + JButton jButton = new JButton("ok"); + JButton jButton2 = new JButton("cel"); + field1 = new JTextField(15); + field2 = new JTextField(15); + field3 = new JTextField(15); +// field4 = new JTextField(15); +// field5 = new JTextField(15); + + this.add("1.1.center.top", new JLabel(":")); + this.add("1.2.center.top", field1); + + this.add("2.1.center.top", new JLabel("ûȨ:")); + this.add("2.2.center.top", field2); + + this.add("3.1.center.top", new JLabel("Ȩ:")); + this.add("3.2.center.top", field3); + + t4table = new JLabel("ʱ:"); + this.add("4.1.center.top", t4table); + t4tableb = new DateButton(dateFormat); + t4tableb.setPreferredSize(new Dimension(218, 30)); + this.add("4.2.center.top", t4tableb); + + t5table = new JLabel("ʱ:"); + this.add("5.1.center.top", t5table); + t5tableb = new DateButton(dateFormat); + t5tableb.setPreferredSize(new Dimension(218, 30)); + this.add("5.2.center.top", t5tableb); + + this.add("6.1.center.top", jButton); + this.add("6.2.center.top", jButton2); + List resultDataList = new ArrayList(); + + jButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + text1 = field1.getText(); + text2 = field2.getText(); + text3 = field3.getText(); + text4 = t4tableb.getText(); + text5 = t5tableb.getText(); + setVisible(false); + InterfaceAIFComponent[] search = TMomMethodUtil.searchComponentsCollection(session, "...", + new String[] { "Type", "OwningUser", "OwningGroup", "CreatedBefore", "CreatedAfter" }, + new String[] { text1, text2, text3, text4, text5 }); + + if (search != null && search.length > 0) { + String shuchu = ""; + for (int i = 0; i < search.length; i++) { + shuchu = shuchu + search[i].toString() + ";"; + } + System.out.print("ѯΪ"+shuchu); +// MessageBox.post("ܹ" + shuchu, "ʾ1", MessageBox.INFORMATION); + for (int i = 0; i < search.length; i++) { + // **************************************************************************** + TCComponentItemRevision itemRevision = (TCComponentItemRevision) search[i]; + TCComponentICO[] icos; + try { + // ͵ + icos = itemRevision.getClassificationObjects(); + if(icos==null || icos.length <= 0) {continue;} + TCClassificationService classService = session.getClassificationService(); + String icoUid = icos[0].getUid(); + classService.loadICOs(new String[] { icoUid }, ""); + // icos[0].delete(); + // ȡ + ICSProperty[] icsProps = icos[0].getICSProperties(true); + for (int n = 0; n < attrMap.size(); n++) { + value=""; + // keyֵ:icos[0].getClassId() + key = attrMap.get(n).keySet(); + list = new ArrayList<>(key); +// for(int n=0;n s = attrMap.get(n).get(icos[0].getClassId()); + if (s == null) { + continue; + } + st = s.get(0).split(";"); + stt = new String[st.length]; + // String[] ss = new String[100]; + for (int m = 0; m < st.length; m++) { + String[] sss = st[m].split("[+]"); + st[m] = sss[0]; + stt[m]=sss[1]; + } + // MessageBox.post("aa", "ʾ1", MessageBox.INFORMATION); + // ȡ + ICSPropertyDescription[] icsDs = icos[0].getICSPropertyDescriptors(); + // int i1=0; + for (int j = 0; j < st.length; j++) { + value = ""; + for (ICSPropertyDescription icsD : icsDs) { + // st1[i1-1] + // i1++; + if( icsD.getName().equals(st[j])||icsD.getName().equals(stt[j])) { + for (ICSProperty icsProperty : icsProps) { + if (icsProperty.getId() == icsD.getId()) { + value += icsProperty.getValue(); + value += "-"; + if (icsD.isKeyLOV()) { + value += getClassDisplayableValue(value, icsD); + value += "-"; + // value = value+"-"+getClassDisplayableValue(value, icsD); + } + } + } + if (value.isEmpty()) { + continue; + } + } + }} + if(value!="")value = value.substring(0, value.length() - 1); + MessageBox.post(value, "ʾ1", MessageBox.INFORMATION); + //System.out.print("ƴӺֵΪ"+value); + TCComponent com = (TCComponent) search[i]; + TCProperty tcProperty; + if(n==0) { + //˱ʶƴӷʽ + tcProperty = com.getTCProperty("rb3_bsh"); + tcProperty.setStringValue(value); + } + if(n==1) { + // ˱ͼƴӷʽ + tcProperty = com.getTCProperty("rb3_th"); + tcProperty.setStringValue(value); + } + if(n==2) { + // ˱˵ƴӷʽ + tcProperty = com.getTCProperty("rb3_sm2"); + tcProperty.setStringValue(value); + } + if(n==3) { + // ˱Ʒƴӷʽ + tcProperty = com.getTCProperty("rb3_cph"); + tcProperty.setStringValue(value); + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + // System.out.print("***************"+resultDataList); + // ******************************************************************************* + } + // MessageBox.post("ܹ"+shuchu, "ʾ1", MessageBox.INFORMATION); + } else { + MessageBox.post("ʲôûѵ", "ʾ1", MessageBox.INFORMATION); + } + } + }); + jButton2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + this.pack(); + this.centerToScreen(); + this.setVisible(true); + + // MessageBox.post("ίеڱ༭", "", MessageBox.ERROR); + + ParseXMLUtil xml = new ParseXMLUtil(); + // ˱ʶƴӷʽ Q6vBYipKJxNqRC + // getSXXԸѡҵֵֵļUIDȻ󷵻ļ + File file = xml.getSXX("RB3_CPHPJFS", session); + attrMap.add(0, xml.parseXMLCode(file)); +// key1 = attrMap.keySet(); +// List listkey1 = new ArrayList<>(key1); +// //System.out.println("**********"+key1); +// List s = attrMap.get("110602"); +// st1=s.get(0).split(";"); +// //String[] ss = new String[100]; +// for(int i=0;i set3 = attrMap4.keySet(); +// List key3 = new ArrayList<>(set3); +// for(int i=0;i s3 = attrMap4.get(key3.get(i)); +// String[] st=s3.get(0).split(";"); +// for(int j=0;j extends JFrame implements ActionListener { + private CTable mainTable; + private String[] header = new String[] {"", ""}; + public CTMap map; + public List dataList=new ArrayList(); + public List numList=new ArrayList(); + public String FilePath; + // 水ť + private JPanel rootPanel; + private Button okButton; + public TMom039EntrustmentFormDialog() { + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * ʼ + * + * @throws IOException + * @throws FileNotFoundException + */ + private void init() throws FileNotFoundException, Exception { + getaddress(); + this.setTitle("exe"); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + mainTable = getNewjTable(null, null,header, 1); + mainTable.setRowHeight(40); + mainTable.getColumnModel().getColumn(0).setPreferredWidth(20); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(mainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } + + diff --git a/src/com/connor/renben/process/plm/tmom039/TMom039EntrustmentFormDialog2.java b/src/com/connor/renben/process/plm/tmom039/TMom039EntrustmentFormDialog2.java new file mode 100644 index 0000000..c51986d --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom039/TMom039EntrustmentFormDialog2.java @@ -0,0 +1,257 @@ +package com.connor.renben.process.plm.tmom039; +//36 +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.ServiceUI; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.BorderFactory; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; + +//import com.connor.renben.process.plm.tmom027.TMom027EntrustmentFormDialog.EntrustingContentDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.connor.renben.process.plm.util.TreeComboBox; +import com.spire.xls.Workbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.commands.userpreferences.IEOptionsPanel; +import com.teamcenter.rac.common.implicitco.ImplicitCheckOutOperation; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCReservationService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.scrollpage.ScrollPagePane; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom039EntrustmentFormDialog2 extends JFrame implements ActionListener { + private CTable mainTable2; + private String[] header2 = new String[] {"", ""}; + public CTMap map2; + public List dataList2=new ArrayList(); + public int[] numList2=new int[1000]; + public String filee; + // 水ť + private JPanel rootPanel; + private Button okButton; + public TMom039EntrustmentFormDialog2(String file) { + try { + this.filee=file; + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * ʼ + * + * @throws IOException + * @throws FileNotFoundException + */ + private void init() throws FileNotFoundException, Exception { + getaddress2(filee); + this.setTitle("exeб"); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + mainTable2 = getNewjTable2(null, null,header2, 1); + mainTable2.setRowHeight(40); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(mainTable2); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + } + + diff --git a/src/com/connor/renben/process/plm/tmom039/TMom039EntrustmentFormHandler.java b/src/com/connor/renben/process/plm/tmom039/TMom039EntrustmentFormHandler.java new file mode 100644 index 0000000..4df87e7 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom039/TMom039EntrustmentFormHandler.java @@ -0,0 +1,25 @@ +package com.connor.renben.process.plm.tmom039; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom039EntrustmentFormHandler 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(); + TMom039EntrustmentFormDialog dialog = new TMom039EntrustmentFormDialog(); + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormDialog.java b/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormDialog.java new file mode 100644 index 0000000..0451eee --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormDialog.java @@ -0,0 +1,309 @@ +package com.connor.renben.process.plm.tmom0392; +//36 +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.UnsupportedEncodingException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.ServiceUI; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.BorderFactory; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; + +//import com.connor.renben.process.plm.tmom027.TMom027EntrustmentFormDialog.EntrustingContentDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.connor.renben.process.plm.util.TreeComboBox; +import com.spire.xls.Workbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.commands.userpreferences.IEOptionsPanel; +import com.teamcenter.rac.common.implicitco.ImplicitCheckOutOperation; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCReservationService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.scrollpage.ScrollPagePane; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom0392EntrustmentFormDialog extends JFrame implements ActionListener { + private CTable mainTable; + private String[] header = new String[] {"", ""}; + public CTMap map; + public List dataList=new ArrayList(); + public List numList=new ArrayList(); + public String FilePath; + // 水ť + private JPanel rootPanel; + private Button okButton; + public String filename; + public List TxtRead=new ArrayList<>(); + public TMom0392EntrustmentFormDialog() { + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * ʼ + * + * @throws IOException + * @throws FileNotFoundException + */ + private void init() throws FileNotFoundException, Exception { + getaddress(); + this.setTitle("exe"); + this.setPreferredSize(new Dimension(500, 600)); + // TODO Auto-generated method stub + mainTable = getNewjTable(null, null,header, 1); + mainTable.setRowHeight(40); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(mainTable); + for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + } + + diff --git a/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormDialog2.java b/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormDialog2.java new file mode 100644 index 0000000..0d3d04a --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormDialog2.java @@ -0,0 +1,322 @@ +package com.connor.renben.process.plm.tmom0392; +//36 +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStreamReader; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.ServiceUI; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.BorderFactory; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; + +//import com.connor.renben.process.plm.tmom027.TMom027EntrustmentFormDialog.EntrustingContentDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.connor.renben.process.plm.util.TreeComboBox; +import com.spire.xls.Workbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.commands.userpreferences.IEOptionsPanel; +import com.teamcenter.rac.common.implicitco.ImplicitCheckOutOperation; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCReservationService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.scrollpage.ScrollPagePane; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom0392EntrustmentFormDialog2 extends JFrame implements ActionListener { + private CTable mainTable2; + private String[] header2 = new String[] {"", ""}; + public CTMap map2; + public List dataList2=new ArrayList(); + public List numList2=new ArrayList(); + public String filee; + public String filename; + // 水ť + private JPanel rootPanel; + private Button okButton; + public List TxtRead=new ArrayList<>(); + public boolean flag=false; + public TMom0392EntrustmentFormDialog2(String file,String filename,List TxtRead) { + try { + this.TxtRead=TxtRead; + this.filee=file; + this.filename=filename; + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + public TMom0392EntrustmentFormDialog2(String file,List TxtRead){ + try { + this.TxtRead=TxtRead; + this.filee=file; + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /*** + * ʼ + * + * @throws IOException + * @throws FileNotFoundException + */ + private void init() throws FileNotFoundException, Exception { +// for(int i=0;i= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + } + + diff --git a/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormHandler.java b/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormHandler.java new file mode 100644 index 0000000..428978b --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom0392/TMom0392EntrustmentFormHandler.java @@ -0,0 +1,25 @@ +package com.connor.renben.process.plm.tmom0392; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom0392EntrustmentFormHandler 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(); + TMom0392EntrustmentFormDialog dialog = new TMom0392EntrustmentFormDialog(); + return null; + } +} diff --git a/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormCommand.java b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormCommand.java new file mode 100644 index 0000000..49fb67f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormCommand.java @@ -0,0 +1,289 @@ +package com.connor.renben.process.plm.tmom040; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom040EntrustmentFormCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp;// ѡеίе汾 + private String V0Uid;// ѡеίе汾ijʼ汾V0uid̳б + private String revisionID = "";//¼汾ID + // жݿǷѴ + private boolean isHave=false; + private boolean isHaveProcess = false; + private EntrustmentFormBean bean = new EntrustmentFormBean(); + private List privilegeList = new ArrayList(); + private List> dataList1 = new ArrayList>(); + private List> dataList2 = new ArrayList>(); + private List plmeidList = new ArrayList(); + public TMom040EntrustmentFormCommand(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp,String V0Uid) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.V0Uid = V0Uid; + } + + public boolean getPrivilege() { + try { + // ȡѡõȨѡCust_AnalysisEntrustmentForm_Privilege + String[] privileges = TMomMethodUtil.getPreferenceValues("Cust_AnalysisEntrustmentForm_Privilege"); + TCComponentUser sessionUser = session.getUser(); + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + + Map privilegeMap = new HashMap(); + + for (int i = 0; i < privileges.length; i++) { + String[] privilegeNode = privileges[i].split("-"); + if (privilegeNode[1].indexOf(",") > 0) { + privilegeMap.put(privilegeNode[0], privilegeNode[1].split(",")); + } else { + privilegeMap.put(privilegeNode[0], new String[] { privilegeNode[1] }); + } + } + ((TCComponentItemRevision) this.comp).refresh(); + TCComponent[] items = ((TCComponentItemRevision) this.comp).getRelatedComponents("process_stage_list"); + if (items.length > 0) { + isHaveProcess = true; + for (int i = 0; i < items.length; i++) { + items[i].refresh(); + // ȡǰڽڵ + TCComponent[] taskItems = items[i].getRelatedComponents("fnd0StartedTasks"); + + for (int j = 0; j < taskItems.length; j++) { + // ȡǰڽڵ + String name = taskItems[j].getStringProperty("current_name"); + String type = taskItems[j].getStringProperty("task_type"); + // ȡ + TCComponent[] users = taskItems[j].getReferenceListProperty("valid_signoffs"); + + if (users.length > 0) { + for (TCComponent tcComponent : users) { + System.out.println("UID" + tcComponent.getUid()); + TCComponent user = tcComponent.getReferenceProperty("fnd0Performer"); + String userId = user.getStringProperty("user_id"); + System.out.println("ˣ" + userId); + if (sessionUser.getUserId().equals(userId)) { + String[] nodePrivilege = privilegeMap.get(name); + for (int k = 0; k < nodePrivilege.length; k++) { + privilegeList.add(nodePrivilege[k]); + } + break; + }}} + if(type.equals("EPMDoTask")) + { + //ȡִ + TCComponent user = taskItems[j].getReferenceProperty("fnd0Performer"); + String userId = user.getStringProperty("user_id"); + System.out.println("ˣ" + userId); + if (sessionUser.getUserId().equals(userId)) { + String[] nodePrivilege = privilegeMap.get(name); + for (int k = 0; k < nodePrivilege.length; k++) { + privilegeList.add(nodePrivilege[k]); + } + break; + + } + } + } + + } + } else { + // жǷǰ汾 + if (sessionUser.getUserId().equals(userName)) { + privilegeList.add("Ϣ1"); + privilegeList.add("1"); + privilegeList.add("ĿнϢ1"); + privilegeList.add("1"); + privilegeList.add("У1"); + privilegeList.add("Ϣ2"); + privilegeList.add("2"); + privilegeList.add("ֵŶӳԤ"); + privilegeList.add("ĿнϢ2"); + privilegeList.add("ҵʵʩ"); + privilegeList.add("2"); + privilegeList.add("У2"); + + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + + @Override + public void executeModal() throws Exception { + revisionID=comp.getProperty("item_revision_id"); + // TODO Auto-generated method stub + + // ѡжPUIDȡ + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet rs3 = null; + InputStream input = null; + + try { + bean.setPuid(comp.getUid()); + bean.setItemId(comp.getProperty("item_id")); + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_ENTRUSTMENTFORMSELECTA"), comp.getUid(),revisionID); + String sql2 = String.format(pro.getProperty("RB3_ENTRUSTMENTSELECTTYPE"),"1" ,V0Uid); + String sql3 = String.format(pro.getProperty("RB3_ENTRUSTMENTSELECTTYPE"),"2" ,V0Uid); + rs = SqlUtilT.read(sql); + rs2 = SqlUtilT.read(sql2); + rs3 = SqlUtilT.read(sql3); + while(rs2.next()) { + List rowList = new ArrayList(); + rowList.add(rs2.getString("PLMEID")); + rowList.add(rs2.getString("PUID")); + + rowList.add(rs2.getString("P1")); + rowList.add(rs2.getString("P2")); + rowList.add(rs2.getString("TYPE")); + dataList1.add(rowList); + } + while(rs3.next()) { + List rowList = new ArrayList(); + rowList.add(rs3.getString("PLMEID")); + rowList.add(rs3.getString("PUID")); + rowList.add(rs3.getString("P1")); + rowList.add(rs3.getString("P2")); + rowList.add(rs3.getString("TYPE")); + dataList2.add(rowList); + } + + while (rs.next()) { + isHave = true; + bean.setP1(rs.getString("P1")); + bean.setP2(rs.getString("P2")); + bean.setP3(rs.getString("P3")); + bean.setP4(rs.getString("P4")); + bean.setP5(rs.getString("P5")); + bean.setP6(rs.getString("P6")); + bean.setP7(rs.getString("P7")); + bean.setP8(rs.getString("P8")); + bean.setP9(rs.getString("P9")); + bean.setP10(rs.getString("P10")); + bean.setP11(rs.getString("P11")); + bean.setP12(rs.getString("P12")); + bean.setP13(rs.getString("P13")); + bean.setP14(rs.getString("P14")); + bean.setP15(rs.getString("P15")); + bean.setP16(rs.getString("P16")); + bean.setP17(rs.getString("P17")); + bean.setP18(rs.getString("P18")); + bean.setP19(rs.getString("P19")); + bean.setP20(rs.getString("P20")); + bean.setP21(rs.getString("P21")); + bean.setP22(rs.getString("P22")); + bean.setP23(rs.getString("P23")); + bean.setP24(rs.getString("P24")); + bean.setP25(rs.getString("P25")); + bean.setP26(rs.getString("P26")); + bean.setP27(rs.getString("P27")); + bean.setP28(rs.getString("P28")); + bean.setP29(rs.getString("P29")); + bean.setP30(rs.getString("P30")); + bean.setP31(rs.getString("P31")); + bean.setP32(rs.getString("P32")); + bean.setP33(rs.getString("P33")); + bean.setP34(rs.getString("P34")); + bean.setP35(rs.getString("P35")); + bean.setP36(rs.getString("P36")); + bean.setP37(rs.getString("P37")); + bean.setP38(rs.getString("P38")); + bean.setP39(rs.getString("P39")); + bean.setP40(rs.getString("P40")); + bean.setP41(rs.getString("P41")); + bean.setP42(rs.getString("P42")); + bean.setP43(rs.getString("P43")); + bean.setP44(rs.getString("P44")); + bean.setP45(rs.getString("P45")); + bean.setP46(rs.getString("P46")); + bean.setP47(rs.getString("P47")); + bean.setP48(rs.getString("P48")); + bean.setP49(rs.getString("P49")); + bean.setP50(rs.getString("P50")); + bean.setP51(rs.getString("P51")); + bean.setP52(rs.getString("P52")); + bean.setP53(rs.getString("P53")); + bean.setP54(rs.getString("P54")); + bean.setP55(rs.getString("P55")); + bean.setP56(rs.getString("P56")); + bean.setP57(rs.getString("P57")); + bean.setP58(rs.getString("P58")); + bean.setP59(rs.getString("P59")); + bean.setP60(rs.getString("P60")); + bean.setP61(rs.getString("P61")); + bean.setP62(rs.getString("P62")); + bean.setP63(rs.getString("P63")); + bean.setP64(rs.getString("P64")); + bean.setP65(rs.getString("P65")); + bean.setP66(rs.getString("P66")); + bean.setP67(rs.getString("P67")); + bean.setP68(rs.getString("P68")); + bean.setP69(rs.getString("P69")); + bean.setP70(rs.getString("P70")); + bean.setP71(rs.getString("P71")); + bean.setP72(rs.getString("P72"));//P72¼汾iditem_revision_id + + } + } 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(); + } + getPrivilege(); + new Thread() { + @Override + public void run() { + new TMom040EntrustmentFormDialog(app, session, comp, bean, isHave, privilegeList, isHaveProcess,dataList1,dataList2); + super.run(); + } + }.start(); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormDialog.java b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormDialog.java new file mode 100644 index 0000000..2c5c020 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormDialog.java @@ -0,0 +1,2354 @@ +package com.connor.renben.process.plm.tmom040; +//36 +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.UUID; + +import javax.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.ServiceUI; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.BorderFactory; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.JViewport; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +//import com.connor.renben.process.plm.tmom027.TMom027EntrustmentFormDialog.EntrustingContentDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.connor.renben.process.plm.util.TreeComboBox; +import com.spire.xls.Workbook; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.commands.userpreferences.IEOptionsPanel; +import com.teamcenter.rac.common.implicitco.ImplicitCheckOutOperation; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCReservationService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.scrollpage.ScrollPagePane; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom040EntrustmentFormDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp;// ѡеίе汾 + private TCComponentItemRevision itemRevision;// ѡеίе汾 + private EntrustmentFormBean bean; + private boolean isHave; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private List privilegeList;// ڵȨ + private boolean isHaveProcess; + + // ؼ + private JLabel idLabel;// ίе + private JTextField idField; + + private JLabel titleLabel;// + + // ѡ + private JTabbedPane tabbedPane; + + // ؼ + private JLabel p1Label;// ͻ + private JTextField p1Field; + private JLabel p2Label;// ĿŶ + private JAutoCompleteComboBox p2ComboBox; + private JLabel p3Label;// Ŀ + private JTextField p3Field; + private JLabel p4Label;// Ŀ + private JTextField p4Field; + private JLabel p5Label;// Ŀȼ + private JAutoCompleteComboBox p5ComboBox; + private JLabel p6Label;// ƲŶ + private JAutoCompleteComboBox p6ComboBox; + private JLabel p7Label;// Ŀ + private JTextField p7Field; + private JLabel p8Label;// Ƹ + private JTextField p8Field; + private JLabel p9Label;// Ŀ + private JAutoCompleteComboBox p9ComboBox; + private JLabel p10Label;// ʱ + private DateButton p10DateButton; + private JLabel p11Label;// ϴηԱ + private JTextField p11Field; + private JLabel p12Label;// ϴαʱ + private DateButton p12DateButton; + private JLabel p13Label;// ĵ + private JTextArea p13Field; + private JLabel p14Label;// ԭ + private JTextArea p14Field; + private JLabel p15Label;// нŶ + private JAutoCompleteComboBox p15ComboBox; + private JLabel p31Label;// Ŀίʱ + private DateButton p31DateButton; + private JLabel p16Label;// н + private JAutoCompleteComboBox p16ComboBox; + private JLabel p17Label;// ĿĴ + private JAutoCompleteComboBox p17ComboBox; + private JLabel p18Label;//Э + private JAutoCompleteComboBox p18ComboBox; + private JLabel p19Label;// ƻʼʱ + private DateButton p19DateButton; + private JLabel p20Label;// Romax + private JTextField p20Field; + private JLabel p21Label;// + private JAutoCompleteComboBox p21ComboBox; + private JLabel p22Label;// Ԫ + private JTextField p22Field; + private JLabel p23Label;// ƻʱ + private DateButton p23DateButton; + private JLabel p24Label;// + private JTextField p24Field; + private JLabel p25Label;// + private JTextField p25Field; + private JLabel p26Label;// ϴʱ + private DateButton p26DateButton; + private JLabel p27Label;// У + private JAutoCompleteComboBox p27ComboBox; + private JLabel p28Label;// Уʱ + private DateButton p28DateButton; + private JLabel p29Label;//УԽ + private JAutoCompleteComboBox p29ComboBox; + private JLabel p30Label;// ˻ԭ + private JTextArea p30Field; + private JLabel p32Lable;//ͻ + private JTextField p32Field; + private JLabel p33Lable;//ĿŶ + private JAutoCompleteComboBox p33ComboBox; + private JLabel p34Lable;//Ŀ + private JTextField p34Field; + private JLabel p35Lable;//Ŀ + private JTextField p35Field; + private JLabel p36Lable;//Ŀȼ + private JAutoCompleteComboBox p36ComboBox; + private JLabel p37Lable;//ƲŶ + private JAutoCompleteComboBox p37ComboBox; + private JLabel p38Lable;//Ŀ + private JTextField p38Field; + private JLabel p39Lable;//Ƹ + private JTextField p39Field; + private JLabel p40Lable;//Ŀ + private JAutoCompleteComboBox p40ComboBox; + private JLabel p41Lable;//ʱ + private DateButton p41DateButton; + private JLabel p42Lable;//Ԥ + private JAutoCompleteComboBox p42ComboBox; + private JLabel p43Lable;//Ԥʱ + private DateButton p43DateButton; + private JLabel p44Lable;//Ԥ + private JAutoCompleteComboBox p44ComboBox; + private JLabel p45Lable;//˻ԭ + private JTextArea p45Field; + private JLabel p46Lable;//нŶ + private JAutoCompleteComboBox p46ComboBox; + private JLabel p47Lable;//Ŀίʱ + private DateButton p47DateButton; + private JLabel p48Lable;//н + private JAutoCompleteComboBox p48ComboBox; + private JLabel p49Lable;//ίе + private JTextField p49Field; + private JLabel p50Lable;//Э + private JAutoCompleteComboBox p50ComboBox; + private JLabel p51Lable;//ƻʼʱ + private DateButton p51DateButton; + private JLabel p52Lable;//Romax + private JTextField p52Field; + private JLabel p53Lable;// + private JAutoCompleteComboBox p53ComboBox; + private JLabel p54Lable;//Ԫ + private JTextField p54Field; + private JLabel p55Lable;//ƻʱ + private DateButton p55DateButton; + private JLabel p56Lable;//ģ + private JAutoCompleteComboBox p56ComboBox; + private JLabel p57Lable;//ʱ + private DateButton p57DateButton; + private JLabel p58Lable;// + private JAutoCompleteComboBox p58ComboBox; + private JLabel p59Lable;//ƻʱ + private DateButton p59DateButton; + private JLabel p60Lable;//˻ԭ + private JTextArea p60Field; + private JLabel p61Lable;// + private JTextField p61Field; + private JLabel p62Lable;// + private JTextField p62Field; + private JLabel p63Lable;//ϴʱ + private DateButton p63DateButton; + private JLabel p64Lable;//У + private JAutoCompleteComboBox p64ComboBox; + private JLabel p65Lable;//Уʱ + private DateButton p65DateButton; + private JLabel p66Lable;//УԽ + private JAutoCompleteComboBox p66ComboBox; + private JLabel p67Lable;//˻ԭ + private JTextArea p67Field; + private JLabel p68Lable;//ʹòλ + private JAutoCompleteComboBox p68ComboBox; + private JLabel jsxmLable;//ʾĿ + private JTextArea jsxmLableField; + private JLabel zlsrLable;//ʾ + private JTextArea zlsrLableField; + private JLabel kgxxxLable;//ʾ + private JTextArea kgxxxLableField; + public JLabel p70Lable;//Ŀ + private JLabel p71Lable;//ɹѡϢ + private MultiComboBox p71ComboBox; + //P72洢汾iditem_revision_id + private CTable mainTable; + private CTable mainTable2; + + private String[] header = new String[] { "һ" ,""}; + private String[] header2 = new String[] { "һ" ,""}; + private int index = -1; + private List> dataList1 = new ArrayList>(); + private List> dataList2 = new ArrayList>(); + private List> dataList11 = new ArrayList>(); + private List> dataList22 = new ArrayList>(); + + private CTMap map; + private CTMap map2; + + public List valueList; + public List valueList2; + private String item=""; + private JPanel partPanel; + private JPanel partPanel1; + private JPanel partPanel2; + private JPanel partPanel3; + private JPanel partPanel4; + private JPanel partPanel5; + private JPanel partPanel6; + private JPanel partPanel7; + private JPanel partPanel8; + private JPanel partPanel9; + private JPanel partPanel10; + public JPanel partPanel11; +// private JPanel partPanel12; +// private JPanel partPanel13; + // 水ť + private JPanel rootPanel; + private Button okButton; + private Button celButton; + private DefaultTableModel itemDataTable; + // ίݴ + //private EntrustingContentDialog entrustingContentDialog; + public TMom040EntrustmentFormDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + EntrustmentFormBean bean, boolean isHave, List privilegeList, boolean isHaveProcess,List> dataList1,List> dataList2) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.bean = bean; + this.isHave = isHave; + this.privilegeList = privilegeList; + this.isHaveProcess = isHaveProcess; + this.dataList1=dataList1; + this.dataList2=dataList2; + try { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + this.itemRevision.refresh(); + if(this.itemRevision.getStringProperty("object_desc").compareTo("Ѵ") == 0) + { + MessageBox.post(rb.getString("zzbj40_display.TITLE"), "", MessageBox.ERROR); + return; + } + else + { + init(); +// TCReservationService localTCReservationService = this.session.getReservationService(); +// localTCReservationService.siteCheckIn(new TCComponent[] {this.itemRevision}); + +// TCComponentForm form = null; + //ǩ +// ReservationService service=ReservationService.getService((TCSession)app.getSession()); +// service.checkin(new TCComponent[] {(TCComponent) app.getTargetComponent()}); + //ǩ +// new ReserveOperation(new AIFComponentContext(this.itemRevision, +// this.itemRevision, "context")).executeModeless(); + + this.itemRevision.lock(); + this.itemRevision.setStringProperty("object_desc", "Ѵ"); + this.itemRevision.save(); + this.itemRevision.refresh(); + this.itemRevision.unlock(); + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /*** + * ʼ + * + * @throws IOException + * @throws FileNotFoundException + */ + private void init() throws FileNotFoundException, Exception { + // ȡʻ + 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("fxwtd40_display.TITLE")); + this.setPreferredSize(new Dimension(980, 830)); + // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + //this.setAlwaysOnTop(true); // ö + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + try { + itemRevision.lock(); + itemRevision.setStringProperty("object_desc", ""); + itemRevision.save(); + itemRevision.refresh(); + itemRevision.unlock(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); + // ʼⲿֿؼ + JPanel titlePanel = new JPanel(new PropertyLayout()); + this.titleLabel = new JLabel(rb.getString("CEAwtd40_display.TITLE"), JLabel.CENTER); + this.titleLabel.setFont(new Font("", 1, 18)); + this.titleLabel.setPreferredSize(new Dimension(950, 20)); + // TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + JLabel itemLabel = new JLabel(rb.getString("wtdbh40_display.TITLE") + this.comp.getProperty("item_id"), JLabel.RIGHT); + itemLabel.setPreferredSize(new Dimension(950, 20)); + titlePanel.add("1.1.left.top", itemLabel); + titlePanel.add("2.1.left.top", titleLabel); + + // ίϢһ + JPanel panel1 = new JPanel(new FlowLayout()); + this.p1Label = new JLabel(rb.getString("kemc40_display.TITLE")); + this.p1Label.setPreferredSize(new Dimension(60,30)); + this.p1Field=new JTextField(bean.getP1()); + this.p1Field.setPreferredSize(new Dimension(150,30)); + this.p2Label = new JLabel(rb.getString("xmsstd40_display.TITLE")); + this.p2Label.setPreferredSize(new Dimension(105, 30)); + this.p2ComboBox = new JAutoCompleteComboBox(); + this.p2ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p2ComboBox.setSelectedItem(bean.getP2()); + this.p3Label = new JLabel(rb.getString("xmmc40_display.TITLE")); + this.p3Label.setPreferredSize(new Dimension(60,30)); + this.p3Field = new JTextField(bean.getP3()); + this.p3Field.setPreferredSize(new Dimension(150, 30)); + this.p4Label = new JLabel(rb.getString("xmjl40_display.TITLE")); + this.p4Label.setPreferredSize(new Dimension(80, 30)); + this.p4Field = new JTextField(bean.getP4()); + this.p4Field.setPreferredSize(new Dimension(150, 30)); + panel1.add(this.p1Label); + panel1.add(this.p1Field); + panel1.add(this.p2Label); + panel1.add(this.p2ComboBox); + panel1.add(this.p3Label); + panel1.add(this.p3Field); + panel1.add(this.p4Label); + panel1.add(this.p4Field); + + // ίϢڶ + JPanel panel2 = new JPanel(new FlowLayout()); + this.p5Label = new JLabel(rb.getString("xmdj40_display.TITLE")); + this.p5Label.setPreferredSize(new Dimension(60,30)); + this.p5ComboBox = new JAutoCompleteComboBox(); + this.p5ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p5ComboBox.setSelectedItem(bean.getP5()); + this.p6Label = new JLabel(rb.getString("sjbsstd40_display.TITLE")); + this.p6Label.setPreferredSize(new Dimension(105,30)); + this.p6ComboBox=new JAutoCompleteComboBox(); + this.p6ComboBox.setPreferredSize(new Dimension(150,30)); + this.p6ComboBox.setSelectedItem(bean.getP6()); + this.p7Label = new JLabel(rb.getString("xmbh40_display.TITLE")); + this.p7Label.setPreferredSize(new Dimension(60,30)); + this.p7Field=new JTextField(bean.getP7()); + this.p7Field.setPreferredSize(new Dimension(150,30)); + this.p8Label = new JLabel(rb.getString("sjfzr40_display.TITLE")); + this.p8Label.setPreferredSize(new Dimension(80,30)); + this.p8Field=new JTextField(bean.getP8()); + this.p8Field.setPreferredSize(new Dimension(150,30)); + panel2.add(this.p5Label); + panel2.add(this.p5ComboBox); + panel2.add(this.p6Label); + panel2.add(this.p6ComboBox); + panel2.add(this.p7Label); + panel2.add(this.p7Field); + panel2.add(this.p8Label); + panel2.add(this.p8Field); + // ίϢ + JPanel panel3 = new JPanel(new FlowLayout()); + this.p9Label = new JLabel(rb.getString("xmlx40_display.TITLE")); + this.p9Label.setPreferredSize(new Dimension(60,30)); + this.p9ComboBox = new JAutoCompleteComboBox(); + this.p9ComboBox.setPreferredSize(new Dimension(150,30)); + this.p9ComboBox.setSelectedItem(bean.getP9()); + this.p10Label = new JLabel(rb.getString("qwwcsj40_display.TITLE")); + this.p10Label.setPreferredSize(new Dimension(105, 30)); + this.p10DateButton = new DateButton(dateFormat); + this.p10DateButton.setPreferredSize(new Dimension(150, 30)); + this.p10DateButton.setText(bean.getP10()); + panel3.add(this.p9Label); + panel3.add(this.p9ComboBox); + panel3.add(this.p10Label); + panel3.add(this.p10DateButton); + + partPanel = new JPanel(new PropertyLayout()); + partPanel + .setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), rb.getString("jbxx40_display.TITLE"))); + partPanel.add("1.1.left.top", panel1); + partPanel.add("2.1.left.top", panel2); + partPanel.add("3.1.left.top", panel3); + partPanel.setPreferredSize(new Dimension(1000, 160)); + + // ĿϢϢһ + JPanel panel4 = new JPanel(new FlowLayout()); + JPanel panel41 = new JPanel(new FlowLayout()); + JPanel panel42 = new JPanel(new FlowLayout()); + this.p11Label = new JLabel(rb.getString("scfxry40_display.TITLE")); + //this.p11Label.setForeground(Color.RED); + //this.p11Label.setPreferredSize(new Dimension(80, 30)); + this.p11Field = new JTextField(bean.getP11()); + this.p11Field.setPreferredSize(new Dimension(150, 30)); + this.p12Label = new JLabel(rb.getString("scbgsj40_display.TITLE")); + //this.p12Label.setForeground(Color.RED); + //this.p12Label.setPreferredSize(new Dimension(80, 30)); + this.p12DateButton=new DateButton(dateFormat); + this.p12DateButton.setPreferredSize(new Dimension(150,30)); + this.p12DateButton.setText(bean.getP12()); + this.p13Label = new JLabel(rb.getString("ggd40_display.TITLE")); + //this.p13Label.setForeground(Color.RED); + this.p13Label.setPreferredSize(new Dimension(80, 30)); + this.p13Field = new JTextArea(bean.getP13()); + JScrollPane scrollPane1 = new JScrollPane(); // jtaӹ + scrollPane1.setPreferredSize(new Dimension(600, 80)); + scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane1.setViewportView(this.p13Field); + this.p14Label = new JLabel(rb.getString("ggyy40_display.TITLE")); + //this.p14Label.setForeground(Color.RED); + this.p14Label.setPreferredSize(new Dimension(80, 30)); + this.p14Field = new JTextArea(bean.getP14()); + JScrollPane scrollPane2 = new JScrollPane(); // jtaӹ + scrollPane2.setPreferredSize(new Dimension(600, 80)); + scrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane2.setViewportView(this.p14Field); + panel4.add(this.p11Label); + panel4.add(this.p11Field); + panel4.add(this.p12Label); + panel4.add(this.p12DateButton); + panel41.add(this.p13Label); + panel41.add(scrollPane1); + panel42.add(this.p14Label); + panel42.add(scrollPane2); + + partPanel1 = new JPanel(new PropertyLayout()); + partPanel1.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), rb.getString("srzl40_display.TITLE"))); + partPanel1.add("1.1.left.top", panel4); + partPanel1.add("2.1.left.top", panel41); + partPanel1.add("3.1.left.top", panel42); + partPanel1.setPreferredSize(new Dimension(1000, 270)); + + + JPanel mainPanel = new JPanel(new PropertyLayout()); + mainPanel.setPreferredSize(new Dimension(900, 300)); + mainPanel.add("1.1.left.top", partPanel); + mainPanel.add("2.1.left.top", partPanel1); + + + +//*********************************************************************** + // ĿнϢһ + JPanel panel5 = new JPanel(new FlowLayout()); + this.p15Label = new JLabel(rb.getString("cjtd40_display.TITLE")); + //this.p15Label.setForeground(Color.RED); + this.p15Label.setPreferredSize(new Dimension(80, 30)); + this.p15ComboBox = new JAutoCompleteComboBox(); + this.p15ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p15ComboBox.setText(bean.getP15()); + this.p31Label = new JLabel(rb.getString("xmwtsj40_display.TITLE")); + //this.p31Label.setForeground(Color.RED); + //this.p31Label.setPreferredSize(new Dimension(80, 30)); + this.p31DateButton=new DateButton(dateFormat); + this.p31DateButton.setPreferredSize(new Dimension(150, 30)); + this.p31DateButton.setText(bean.getP31()); + this.p16Label = new JLabel(rb.getString("cjr40_display.TITLE")); + //this.p16Label.setForeground(Color.RED); + this.p16Label.setPreferredSize(new Dimension(80, 30)); + this.p16ComboBox=new JAutoCompleteComboBox(); + this.p16ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p16ComboBox.setSelectedItem(bean.getP16()); + this.p17Label = new JLabel(rb.getString("xmggcs40_display.TITLE")); + //this.p17Label.setForeground(Color.RED); + //this.p17Label.setPreferredSize(new Dimension(80, 30)); + this.p17ComboBox=new JAutoCompleteComboBox(); + this.p17ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p17ComboBox.setSelectedItem(bean.getP17()); + panel5.add(this.p15Label); + panel5.add(this.p15ComboBox); + panel5.add(this.p31Label); + panel5.add(this.p31DateButton); + panel5.add(this.p16Label); + panel5.add(this.p16ComboBox); + panel5.add(this.p17Label); + panel5.add(this.p17ComboBox); + + + // ĿнϢڶ + JPanel panel6 = new JPanel(new FlowLayout()); + this.p18Label = new JLabel(rb.getString("xbr40_display.TITLE")); + //this.p18Label.setForeground(Color.RED); + this.p18Label.setPreferredSize(new Dimension(80, 30)); + this.p18ComboBox = new JAutoCompleteComboBox(); + this.p18ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p18ComboBox.setSelectedItem(bean.getP18()); + this.p19Label = new JLabel(rb.getString("jhkssj40_display.TITLE")); + //this.p19Label.setForeground(Color.RED); + this.p19DateButton = new DateButton(dateFormat); + this.p19DateButton.setPreferredSize(new Dimension(150, 30)); + this.p19DateButton.setText(bean.getP19()); + this.p20Label = new JLabel(rb.getString("Romaxjf40_display.TITLE")); + //this.p20Label.setForeground(Color.RED); + this.p20Label.setPreferredSize(new Dimension(80, 30)); + this.p20Field =new JTextField(bean.getP20()); + this.p20Field.setPreferredSize(new Dimension(150, 30)); + this.p21Label = new JLabel(rb.getString("jsxqts40_display.TITLE")); + //this.p21Label.setForeground(Color.RED); + this.p21ComboBox =new JAutoCompleteComboBox(); + this.p21ComboBox.setPreferredSize(new Dimension(150, 30)); + this.p21ComboBox.setSelectedItem(bean.getP21()); + panel6.add(this.p18Label); + panel6.add(this.p18ComboBox); + panel6.add(this.p19Label); + panel6.add(this.p19DateButton); + panel6.add(this.p20Label); + panel6.add(this.p20Field); + panel6.add(this.p21Label); + panel6.add(this.p21ComboBox); + + // ĿнϢ + JPanel panel7 = new JPanel(new FlowLayout()); + this.p22Label = new JLabel(rb.getString("yxyjf40_display.TITLE")); + //this.p22Label.setForeground(Color.RED); + this.p22Label.setPreferredSize(new Dimension(80, 30)); + this.p22Field = new JTextField(bean.getP22()); + this.p22Field.setPreferredSize(new Dimension(150, 30)); + this.p23Label = new JLabel(rb.getString("jswcsj40_display.TITLE")); + //this.p23Label.setForeground(Color.RED); + this.p23DateButton=new DateButton(dateFormat); + this.p23DateButton.setPreferredSize(new Dimension(150,30)); + this.p23DateButton.setText(bean.getP23()); + panel7.add(this.p22Label); + panel7.add(this.p22Field); + panel7.add(this.p23Label); + panel7.add(this.p23DateButton); + + partPanel2 = new JPanel(new PropertyLayout()); + partPanel2.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), rb.getString("xmcjxx40_display.TITLE"))); + partPanel2.add("1.1.left.top", panel5); + partPanel2.add("2.1.left.top", panel6); + partPanel2.add("3.1.left.top", panel7); + partPanel2.setPreferredSize(new Dimension(1000, 160)); + + + + + // һ + JPanel panel8 = new JPanel(new FlowLayout()); + this.p24Label = new JLabel(rb.getString("bghjgmc40_display.TITLE")); + //this.p24Label.setForeground(Color.RED); + this.p24Label.setPreferredSize(new Dimension(120, 30)); + this.p24Field=new JTextField(bean.getP24()); + this.p24Field.setPreferredSize(new Dimension(150, 30)); + this.p25Label = new JLabel(rb.getString("bgbh40_display.TITLE")); + //this.p25Label.setForeground(Color.RED); + this.p25Label.setPreferredSize(new Dimension(80, 30)); + this.p25Field=new JTextField(bean.getP25()); + this.p25Field.setPreferredSize(new Dimension(150,30)); + this.p26Label = new JLabel(rb.getString("bghjgscsj40_display.TITLE")); + //this.p26Label.setForeground(Color.RED); + this.p26Label.setPreferredSize(new Dimension(150, 30)); + this.p26DateButton=new DateButton(dateFormat); + this.p26DateButton.setPreferredSize(new Dimension(150, 30)); + this.p26DateButton.setText(bean.getP26()); + panel8.add(this.p24Label); + panel8.add(this.p24Field); + panel8.add(this.p25Label); + panel8.add(this.p25Field); + panel8.add(this.p26Label); + panel8.add(this.p26DateButton); + + partPanel3 = new JPanel(new PropertyLayout()); + partPanel3 + .setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), rb.getString("bghjgfk40_display.TITLE"))); + partPanel3.add("1.1.left.top", panel8); + partPanel3.setPreferredSize(new Dimension(1000, 70)); + + // УԵһ + JPanel panel9 = new JPanel(new FlowLayout()); + JPanel panel91 =new JPanel(new FlowLayout()); + this.p27Label = new JLabel(rb.getString("jdr40_display.TITLE")); + //this.p27Label.setForeground(Color.RED); + this.p27Label.setPreferredSize(new Dimension(80, 30)); + this.p27ComboBox = new JAutoCompleteComboBox(); + this.p27ComboBox.setPreferredSize(new Dimension(150,30)); + this.p27ComboBox.setSelectedItem(bean.getP27()); + this.p28Label = new JLabel(rb.getString("jdsj40_display.TITLE")); + //this.p28Label.setForeground(Color.RED); + this.p28Label.setPreferredSize(new Dimension(80, 30)); + this.p28DateButton = new DateButton(dateFormat); + this.p28DateButton.setPreferredSize(new Dimension(150,30)); + this.p28DateButton.setText(bean.getP28()); + this.p29Label = new JLabel(rb.getString("jdjg40_display.TITLE")); + //this.p29Label.setForeground(Color.RED); + this.p29Label.setPreferredSize(new Dimension(80, 30)); + this.p29ComboBox = new JAutoCompleteComboBox(); + this.p29ComboBox.setPreferredSize(new Dimension(150,30)); + this.p29ComboBox.setSelectedItem(bean.getP29()); + this.p30Label = new JLabel(rb.getString("thyy40_display.TITLE")); + //this.p30Label.setForeground(Color.RED); + this.p30Label.setPreferredSize(new Dimension(80,30)); + this.p30Field = new JTextArea(bean.getP30()); + JScrollPane scrollPane6 = new JScrollPane(); // jtaӹ + scrollPane6.setPreferredSize(new Dimension(700, 80)); + scrollPane6.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane6.setViewportView(this.p30Field); + panel9.add(this.p27Label); + panel9.add(this.p27ComboBox); + panel9.add(this.p28Label); + panel9.add(this.p28DateButton); + panel9.add(this.p29Label); + panel9.add(this.p29ComboBox); + panel91.add(this.p30Label); + panel91.add(scrollPane6); + + partPanel4 = new JPanel(new PropertyLayout()); + partPanel4.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), + rb.getString("bghjgjd40_display.TITLE"))); + partPanel4.add("1.1.left.top", panel9); + partPanel4.add("2.1.left.top", panel91); + partPanel4.setPreferredSize(new Dimension(1000, 170)); + + JPanel mainPanel1 = new JPanel(new PropertyLayout()); + mainPanel1.setPreferredSize(new Dimension(900, 300)); + mainPanel.add("3.1.left.top", partPanel2); + mainPanel.add("4.1.left.top", partPanel3); + mainPanel.add("5.1.left.top", partPanel4); + + + //***************************** + // +// JPanel pane34=new JPanel(new FlowLayout()); +// File file = TMomMethodUtil.getFile(session, "ίеѡ", "MSExcelX"); +// List p69Values = ExcelUtil07.readExcelByEntrustment(file, "ί"); +// String[] p69Value = new String[0]; +// if (bean.getP69() != null) { +// p69Value = bean.getP69().split(","); +// } +// this.p69Field = new JTextArea(); +// this.p69Field.setText(bean.getP69()); +// this.p69Field.setLineWrap(true);//Զ +// this.p69Button = new Button("ѡĿ"); +// this.p69Button.setPreferredSize(new Dimension(200, 100)); +// +// JScrollPane jslp = new JScrollPane(); // jtaӹ +// jslp.setPreferredSize(new Dimension(700, 100)); +// jslp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// jslp.setViewportView(this.p69Field); +// pane34.add(jslp); +// pane34.add(this.p69Button); + + + //****************************************************** + + + + + //%%%%%%%%%%%%%%%%%%%%%%% + + + JPanel pane20 = new JPanel(new FlowLayout()); + this.p32Lable=new JLabel(rb.getString("khmc40_display.TITLE")); + this.p32Lable.setPreferredSize(new Dimension(60,30)); + this.p32Field=new JTextField(bean.getP32()); + this.p32Field.setPreferredSize(new Dimension(150,30)); + this.p33Lable=new JLabel(rb.getString("xmbssty40_display.TITLE")); + this.p33Lable.setPreferredSize(new Dimension(105,30)); + this.p33ComboBox=new JAutoCompleteComboBox(); + this.p33ComboBox.setPreferredSize(new Dimension(150,30)); + this.p33ComboBox.setSelectedItem(bean.getP33()); + this.p34Lable=new JLabel(rb.getString("xmmc40_display.TITLE")); + this.p34Lable.setPreferredSize(new Dimension(60,30)); + this.p34Field=new JTextField(bean.getP34()); + this.p34Field.setPreferredSize(new Dimension(150,30)); + this.p35Lable=new JLabel(rb.getString("xmjl40_display.TITLE")); + //this.p35Lable.setForeground(Color.RED); + this.p35Lable.setPreferredSize(new Dimension(75,30)); + this.p35Field=new JTextField(bean.getP35()); + this.p35Field.setPreferredSize(new Dimension(150,30)); + pane20.add(this.p32Lable); + pane20.add(this.p32Field); + pane20.add(this.p33Lable); + pane20.add(this.p33ComboBox); + pane20.add(this.p34Lable); + pane20.add(this.p34Field); + pane20.add(this.p35Lable); + pane20.add(this.p35Field); + + JPanel pane21= new JPanel(new FlowLayout()); + this.p36Lable=new JLabel(rb.getString("xmdj40_display.TITLE")); + this.p36Lable.setPreferredSize(new Dimension(60,30)); + this.p36ComboBox=new JAutoCompleteComboBox(); + this.p36ComboBox.setPreferredSize(new Dimension(150,30)); + this.p36ComboBox.setSelectedItem(bean.getP36()); + this.p37Lable=new JLabel(rb.getString("sjbsstd40_display.TITLE")); + this.p37Lable.setPreferredSize(new Dimension(105,30)); + this.p37ComboBox=new JAutoCompleteComboBox(); + this.p37ComboBox.setPreferredSize(new Dimension(150,30)); + this.p37ComboBox.setSelectedItem(bean.getP37()); + this.p38Lable=new JLabel(rb.getString("xmbh40_display.TITLE")); + this.p38Lable.setPreferredSize(new Dimension(60,30)); + this.p38Field=new JTextField(bean.getP38()); + this.p38Field.setPreferredSize(new Dimension(150,30)); + this.p39Lable=new JLabel(rb.getString("sjfzr40_display.TITLE")); + this.p39Lable.setPreferredSize(new Dimension(75,30)); + this.p39Field=new JTextField(bean.getP39()); + this.p39Field.setPreferredSize(new Dimension(150,30)); + pane21.add(this.p36Lable); + pane21.add(this.p36ComboBox); + pane21.add(this.p37Lable); + pane21.add(this.p37ComboBox); + pane21.add(this.p38Lable); + pane21.add(this.p38Field); + pane21.add(this.p39Lable); + pane21.add(this.p39Field); + + JPanel pane22=new JPanel(new FlowLayout()); + this.p40Lable=new JLabel(rb.getString("xmlx40_display.TITLE")); + this.p40Lable.setPreferredSize(new Dimension(60,30)); + this.p40ComboBox=new JAutoCompleteComboBox(); + this.p40ComboBox.setPreferredSize(new Dimension(150,30)); + this.p40ComboBox.setSelectedItem(bean.getP40()); + this.p41Lable=new JLabel(rb.getString("qwwcsj40_display.TITLE")); + //this.p41Lable.setForeground(Color.RED); + this.p41Lable.setPreferredSize(new Dimension(105,30)); + this.p41DateButton=new DateButton(dateFormat); + this.p41DateButton.setPreferredSize(new Dimension(150,30)); + this.p41DateButton.setText(bean.getP41()); + pane22.add(this.p40Lable); + pane22.add(this.p40ComboBox); + pane22.add(this.p41Lable); + pane22.add(this.p41DateButton); + + + partPanel5=new JPanel(new PropertyLayout()); + partPanel5.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), + "1.Ϣ Basic Information")); + partPanel5.add("1.1.left.top", pane20); + partPanel5.add("2.1.left.top", pane21); + partPanel5.add("3.1.left.top", pane22); + partPanel5.setPreferredSize(new Dimension(1000,170)); + + JPanel pane33=new JPanel(new FlowLayout()); + this.p68Lable=new JLabel(rb.getString("sybw40_display.TITLE")); + this.p68Lable.setPreferredSize(new Dimension(80,30)); + //this.p68Lable.setForeground(Color.RED); + this.p68ComboBox=new JAutoCompleteComboBox(); + this.p68ComboBox.setPreferredSize(new Dimension(250,30)); + this.p68ComboBox.setSelectedItem(bean.getP68()); + + pane33.add(this.p68Lable); + pane33.add(this.p68ComboBox); + + this.p68ComboBox.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + if(e.getStateChange() == ItemEvent.SELECTED){ + String str=e.getItem().toString(); + item=str; + //item=str.substring(0, str.indexOf(" ")); + dataList1.clear(); + getData1(); + setJTable1(); + dataList2.clear(); + getData2(); + setJTable2(); + + } + } + + }); + + partPanel11=new JPanel(new PropertyLayout()); + partPanel11.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), + rb.getString("srzl40_display.TITLE"))); + partPanel11.add("1.1.left.top",pane33); + + + //%%%%%%%%%%%%%%%%%%%%%%% + + + + + mainTable = getNewjTable(null, null, header, 1); + mainTable.setRowHeight(40); + zlsrLable = new JLabel(rb.getString("bxqrbgxxx40_display.TITLE")); + zlsrLable.setPreferredSize(new Dimension(120, 30)); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setPreferredSize(new Dimension(800, 300)); + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(mainTable); + JPanel pane35=new JPanel(new FlowLayout()); + pane35.add(zlsrLable); + pane35.add(jslp1); + partPanel11.add("2.1.left.top",pane35); + //getData1(); + for(int i=0;i rowList = dataList22.get(i); + if(rowList.get(2).equals("L10m")&&rowList.get(3).equals("1")) { + return isMust1(this.p71ComboBox); + } + if(rowList.get(2).equals("L10mr")&&rowList.get(3).equals("1")) { + return isMust1(this.p71ComboBox); + } + } +// + + return true; + } + + private boolean isMust(JPanel partPanel) { + for (int i = 0; i < partPanel.getComponentCount(); i++) { + if (partPanel.getComponent(i) instanceof JTextField) { + JTextField textField = (JTextField) partPanel.getComponent(i); + if (textField.getText() == null || textField.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof JAutoCompleteComboBox) { + JAutoCompleteComboBox completeComboBox = (JAutoCompleteComboBox) partPanel.getComponent(i); + if (completeComboBox.getText() == null || completeComboBox.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) partPanel.getComponent(i); + if (multiComboBox.editor.getText() == null || multiComboBox.editor.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof JPanel) { + JPanel chidPanel = (JPanel) partPanel.getComponent(i); + return isMust(chidPanel); + } + + } + + return true; + } + + private boolean isMust1(MultiComboBox multiComboBox) { + + // multiComboBox = (MultiComboBox) Panel.getComponent(0); + if (multiComboBox.editor.getText() == null || multiComboBox.editor.getText().isEmpty()) { + return false; + } + return true; + } + + + /*** + * ѡ + */ + public void addSelectItem() { + // ȡѡļ + File file = TMomMethodUtil.getFile(session, "", "MSExcelX"); + if (file == null) { + return; + } + // ȡļȡӦѡ + try { + List p2Values = ExcelUtil07.readExcelByEntrustment(file, "ĿŶ"); + for (String string : p2Values) { + p2ComboBox.addItem(string); + } + this.p2ComboBox.setSelectedItem(bean.getP2()); + + List p5Values = ExcelUtil07.readExcelByEntrustment(file, "Ŀȼ"); + for (String string : p5Values) { + p5ComboBox.addItem(string); + } + this.p5ComboBox.setSelectedItem(bean.getP5()); + + List p6Values = ExcelUtil07.readExcelByEntrustment(file, "ƲŶ"); + for (String string : p6Values) { + p6ComboBox.addItem(string); + } + this.p6ComboBox.setSelectedItem(bean.getP6()); + + List p9Values = ExcelUtil07.readExcelByEntrustment(file, "Ŀ"); + for (String string : p9Values) { + p9ComboBox.addItem(string); + } + this.p9ComboBox.setSelectedItem(bean.getP9()); + + List p15Values = ExcelUtil07.readExcelByEntrustment(file, "нŶ"); + for (String string : p15Values) { + p15ComboBox.addItem(string); + } + this.p15ComboBox.setSelectedItem(bean.getP15()); + + List p16Values = ExcelUtil07.readExcelByEntrustment(file, "н"); + for (String string : p16Values) { + p16ComboBox.addItem(string); + } + this.p16ComboBox.setSelectedItem(bean.getP16()); + + List p17Values = ExcelUtil07.readExcelByEntrustment(file, "ĿĴ"); + for (String string : p17Values) { + p17ComboBox.addItem(string); + } + this.p17ComboBox.setSelectedItem(bean.getP17()); + + List p18Values = ExcelUtil07.readExcelByEntrustment(file, "Э"); + for (String string : p18Values) { + p18ComboBox.addItem(string); + } + this.p18ComboBox.setSelectedItem(bean.getP18()); + + List p21Values = ExcelUtil07.readExcelByEntrustment(file, ""); + for (String string : p21Values) { + p21ComboBox.addItem(string); + } + this.p21ComboBox.setSelectedItem(bean.getP21()); + + List p27Values = ExcelUtil07.readExcelByEntrustment(file, "У"); + for (String string : p27Values) { + p27ComboBox.addItem(string); + } + this.p27ComboBox.setSelectedItem(bean.getP27()); + + List p29Values = ExcelUtil07.readExcelByEntrustment(file, "УԽ"); + for (String string : p29Values) { + p29ComboBox.addItem(string); + } + this.p29ComboBox.setSelectedItem(bean.getP29()); + + + List p33Values = ExcelUtil07.readExcelByEntrustment(file, "ĿŶ"); + for (String string : p33Values) { + p33ComboBox.addItem(string); + } + this.p33ComboBox.setSelectedItem(bean.getP33()); + + List p36Values = ExcelUtil07.readExcelByEntrustment(file, "Ŀȼ"); + for (String string : p36Values) { + p36ComboBox.addItem(string); + } + this.p36ComboBox.setSelectedItem(bean.getP36()); + + List p37Values = ExcelUtil07.readExcelByEntrustment(file, "ƲŶ"); + for (String string : p37Values) { + p37ComboBox.addItem(string); + } + this.p37ComboBox.setSelectedItem(bean.getP37()); + + List p40Values = ExcelUtil07.readExcelByEntrustment(file, "Ŀ"); + for (String string : p40Values) { + p40ComboBox.addItem(string); + } + this.p40ComboBox.setSelectedItem(bean.getP40()); + + List p42Values = ExcelUtil07.readExcelByEntrustment(file, "Ԥ"); + for (String string : p42Values) { + p42ComboBox.addItem(string); + } + this.p42ComboBox.setSelectedItem(bean.getP42()); + + List p44Values = ExcelUtil07.readExcelByEntrustment(file, "Ԥ"); + for (String string : p44Values) { + p44ComboBox.addItem(string); + } + this.p44ComboBox.setSelectedItem(bean.getP44()); + + List p46Values = ExcelUtil07.readExcelByEntrustment(file, "нŶ"); + for (String string : p46Values) { + p46ComboBox.addItem(string); + } + this.p46ComboBox.setSelectedItem(bean.getP46()); + + List p48Values = ExcelUtil07.readExcelByEntrustment(file, "н"); + for (String string : p48Values) { + p48ComboBox.addItem(string); + } + this.p48ComboBox.setSelectedItem(bean.getP48()); + + List p50Values = ExcelUtil07.readExcelByEntrustment(file, "Э"); + for (String string : p50Values) { + p50ComboBox.addItem(string); + } + this.p50ComboBox.setSelectedItem(bean.getP50()); + + List p53Values = ExcelUtil07.readExcelByEntrustment(file, ""); + for (String string : p53Values) { + p53ComboBox.addItem(string); + } + this.p53ComboBox.setSelectedItem(bean.getP53()); + + List p56Values = ExcelUtil07.readExcelByEntrustment(file, "ģ"); + for (String string : p56Values) { + p56ComboBox.addItem(string); + } + this.p56ComboBox.setSelectedItem(bean.getP56()); + + List p58Values = ExcelUtil07.readExcelByEntrustment(file, ""); + for (String string : p58Values) { + p58ComboBox.addItem(string); + } + this.p58ComboBox.setSelectedItem(bean.getP58()); + + List p64Values = ExcelUtil07.readExcelByEntrustment(file, "У"); + for (String string : p64Values) { + p64ComboBox.addItem(string); + } + this.p64ComboBox.setSelectedItem(bean.getP64()); + + List p66Values = ExcelUtil07.readExcelByEntrustment(file, "УԽ"); + for (String string : p66Values) { + p66ComboBox.addItem(string); + } + this.p66ComboBox.setSelectedItem(bean.getP66()); + + List p68Values = ExcelUtil07.readExcelByEntrustment(file, "ʹòλ"); + for (String string : p68Values) { + p68ComboBox.addItem(string); + } + this.p68ComboBox.setSelectedItem(bean.getP68()); + +// List p71Values = ExcelUtil07.readExcelByEntrustment(file, "ɹѡϢ"); +// for (String string : p71Values) { +// p71ComboBox.addItem(string); +// } +// this.p71ComboBox.setSelectedItem(bean.getP71()); +// + + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + // Ӽ + public void createActionEvent() { + + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + //this.p69Button.addActionListener(this); + } + + public void getData() { + // ȡд + this.bean.setP1(this.p1Field.getText()); + this.bean.setP2(this.p2ComboBox.getSelectedItem() == null ? "" : this.p2ComboBox.getSelectedItem().toString()); + this.bean.setP3(this.p3Field.getText()); + this.bean.setP4(this.p4Field.getText()); + this.bean.setP5(this.p5ComboBox.getSelectedItem() == null ? "" : this.p5ComboBox.getSelectedItem().toString()); + this.bean.setP6(this.p6ComboBox.getSelectedItem() == null ? "" : this.p6ComboBox.getSelectedItem().toString()); + this.bean.setP7(this.p7Field.getText()); + this.bean.setP8(this.p8Field.getText()); + this.bean.setP9(this.p9ComboBox.getSelectedItem() == null ? "" : this.p9ComboBox.getSelectedItem().toString()); + this.bean.setP10(this.p10DateButton.getText()); + this.bean.setP11(this.p11Field.getText()); + this.bean.setP12(this.p12DateButton.getText()); + this.bean.setP13(this.p13Field.getText()); + this.bean.setP14(this.p14Field.getText()); + this.bean.setP15(this.p15ComboBox.getText()); + this.bean.setP16(this.p16ComboBox.getSelectedItem() == null ? "" : this.p16ComboBox.getSelectedItem().toString()); + this.bean.setP17(this.p17ComboBox.getSelectedItem() == null ? "" : this.p17ComboBox.getSelectedItem().toString()); + this.bean.setP18(this.p18ComboBox.getSelectedItem() == null ? "" : this.p18ComboBox.getSelectedItem().toString()); + this.bean.setP19(this.p19DateButton.getText()); + this.bean.setP20(this.p20Field.getText()); + this.bean.setP21(this.p21ComboBox.getSelectedItem() == null ? "" : this.p21ComboBox.getSelectedItem().toString()); + this.bean.setP22(this.p22Field.getText()); + this.bean.setP23(this.p23DateButton.getText()); + this.bean.setP24(this.p24Field.getText()); + this.bean.setP25(this.p25Field.getText()); + this.bean.setP26(this.p26DateButton.getText()); + this.bean.setP27(this.p27ComboBox.getSelectedItem() == null ? "" : this.p27ComboBox.getSelectedItem().toString()); + this.bean.setP28(this.p28DateButton.getText()); + this.bean.setP29(this.p29ComboBox.getSelectedItem() == null ? "" : this.p29ComboBox.getSelectedItem().toString()); + this.bean.setP30(this.p30Field.getText()); + this.bean.setP31(this.p31DateButton.getText()); + this.bean.setP32(this.p32Field.getText()); + this.bean.setP33(this.p33ComboBox.getSelectedItem() == null ? "" : this.p33ComboBox.getSelectedItem().toString()); + this.bean.setP34(this.p34Field.getText()); + this.bean.setP35(this.p35Field.getText()); + this.bean.setP36(this.p36ComboBox.getSelectedItem() == null ? "" : this.p36ComboBox.getSelectedItem().toString()); + this.bean.setP37(this.p37ComboBox.getSelectedItem() == null ? "" : this.p37ComboBox.getSelectedItem().toString()); + this.bean.setP38(this.p38Field.getText()); + this.bean.setP39(this.p39Field.getText()); + this.bean.setP40(this.p40ComboBox.getSelectedItem() == null ? "" : this.p40ComboBox.getSelectedItem().toString()); + this.bean.setP41(this.p41DateButton.getText()); + this.bean.setP42(this.p42ComboBox.getSelectedItem() == null ? "" : this.p42ComboBox.getSelectedItem().toString()); + this.bean.setP43(this.p43DateButton.getText()); + this.bean.setP44(this.p44ComboBox.getSelectedItem() == null ? "" : this.p44ComboBox.getSelectedItem().toString()); + this.bean.setP45(this.p45Field.getText()); + this.bean.setP46(this.p46ComboBox.getSelectedItem() == null ? "" : this.p46ComboBox.getSelectedItem().toString()); + this.bean.setP47(this.p47DateButton.getText()); + this.bean.setP48(this.p48ComboBox.getSelectedItem() == null ? "" : this.p48ComboBox.getSelectedItem().toString()); + this.bean.setP49(this.p49Field.getText()); + this.bean.setP50(this.p50ComboBox.getSelectedItem() == null ? "" : this.p50ComboBox.getSelectedItem().toString()); + this.bean.setP51(this.p51DateButton.getText()); + this.bean.setP52(this.p52Field.getText()); + this.bean.setP53(this.p53ComboBox.getSelectedItem() == null ? "" : this.p53ComboBox.getSelectedItem().toString()); + this.bean.setP54(this.p54Field.getText()); + this.bean.setP55(this.p55DateButton.getText()); + this.bean.setP56(this.p56ComboBox.getSelectedItem() == null ? "" : this.p56ComboBox.getSelectedItem().toString()); + this.bean.setP57(this.p57DateButton.getText()); + this.bean.setP58(this.p58ComboBox.getSelectedItem() == null ? "" : this.p58ComboBox.getSelectedItem().toString()); + this.bean.setP59(this.p59DateButton.getText()); + this.bean.setP60(this.p60Field.getText()); + this.bean.setP61(this.p61Field.getText()); + this.bean.setP62(this.p62Field.getText()); + this.bean.setP63(this.p63DateButton.getText()); + this.bean.setP64(this.p64ComboBox.getSelectedItem() == null ? "" : this.p64ComboBox.getSelectedItem().toString()); + this.bean.setP65(this.p65DateButton.getText()); + this.bean.setP66(this.p66ComboBox.getSelectedItem() == null ? "" : this.p66ComboBox.getSelectedItem().toString()); + this.bean.setP67(this.p67Field.getText()); + this.bean.setP68(this.p68ComboBox.getSelectedItem() == null ? "" : this.p68ComboBox.getSelectedItem().toString()); + this.bean.setP71(this.p71ComboBox.editor.getText()); + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + if (mainTable2.isEditing()) { //жǷڱ༭ + int row = mainTable2.getEditingColumn();//һ + int col = mainTable2.getEditingColumn(); //һ + TableCellEditor editor = mainTable2.getCellEditor(row, col); + editor.stopCellEditing(); + } + if (mainTable.isEditing()) { //жǷڱ༭ + int row = mainTable.getEditingColumn();//һ + int col = mainTable.getEditingColumn(); //һ + TableCellEditor editor = mainTable.getCellEditor(row, col); + editor.stopCellEditing(); + } + // жϱǷд + getJTable1(); + getJTable2(); + if (!isMust()) { + + this.p71Lable.setForeground(Color.RED); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("btxbnwk40_display.TITLE"), "", MessageBox.ERROR); + return; + } + this.p71Lable.setForeground(Color.black); + + TMom040EntrustmentFormOperation operation = new TMom040EntrustmentFormOperation(this.bean, this.isHave,this.comp,this.dataList11,this.dataList22); + try { + getData(); + + operation.executeOperation(); + if (!isHave) { + isHave = true; + } + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + // MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else if (source.equals(this.celButton)) { + try { + this.itemRevision.lock(); + this.itemRevision.setStringProperty("object_desc", ""); + this.itemRevision.save(); + this.itemRevision.refresh(); + this.itemRevision.unlock(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + this.dispose(); + //source.equals(this.p69Button) + } +// else if (true) { +// // ʾίѡ +// if (entrustingContentDialog == null) { +// if (this.p69Field.getText() == null) { +// entrustingContentDialog = new EntrustingContentDialog(new ArrayList()); +// } else { +// entrustingContentDialog = new EntrustingContentDialog( +// Arrays.asList(this.p69Field.getText().split(","))); +// } +// } else { +// entrustingContentDialog.valueList = Arrays.asList(this.p69Field.getText().split(",")); +// +// entrustingContentDialog.setJTable(); +// } +// } + + } + + /** + * ί + * + * @author Administrator + * + */ +// private class EntrustingContentDialog { +// private String[] header = new String[] { "һ", "","","" }; +// private int index = -1; +// private List> dataList = new ArrayList>(); +// // ؼ +// private JPanel titlePanel;// +// private JLabel titleLabel; +// private CTable mainTable; +// private JTextPane selectCellValuePane; +// +// private CTMap map; +// +// +// private Button okButton; +// +// public List valueList; +// +// +// +// private Map combineMap = new HashMap();// źϲԪ +// private Object itemDataTable; +// +// // ǩؼ +// // private JTabbedPane tabbedPane; +// +// public EntrustingContentDialog(List valueList) { +// // TODO Auto-generated constructor stub +// super(); +// // getData(); +// this.valueList = valueList; +// getData(); +// //getCombineMap(); +// init(); +// setJTable(); +// //comBine(); +// } +// +// +// +// private void init() { +// getData(); +// mainTable = getNewjTable(null, null, header, dataList.size()); +// mainTable.setRowHeight(40); +// JScrollPane jslp = new JScrollPane(); // jtaӹ +// jslp.setPreferredSize(new Dimension(700, 300)); +// jslp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// jslp.setViewportView(mainTable); +// JPanel pane35=new JPanel(new FlowLayout()); +// pane35.add(jslp); +// partPanel11.add("3.1.left.top",pane35); +// setJTable(); +// } +// + + + /** + * ȡExcelе + */ + private void getData1() { + // TODO Auto-generated method stub + File file = TMomMethodUtil.getFile(session, "", "MSExcelX"); + if (file == null) { + return; + } + try { + List p2Values = ExcelUtil07.readExcelByEntrustment(file, item); + ///dataList = p2Values; + + if(mainTable==null) { + return; + }else { + for (int i = mainTable.getRowCount() - 1; i >= 0; i--) { + this.map.removeRow(i); + } + for (int i = 1; i < p2Values.size()+5; i++) { + List rowList = new ArrayList(); + if(i p2Values = ExcelUtil07.readExcelByEntrustment(file, item); + ///dataList = p2Values; + + if(mainTable2==null) { + return; + }else { + for (int i = mainTable2.getRowCount() - 1; i >= 0; i--) { + this.map2.removeRow(i); + } + for (int i = 1; i < p2Values.size()+5; i++) { + List rowList = new ArrayList(); + if(i rowList = dataList1.get(i); + + for (int j = 0; j < header.length; j++) { + String wer=rowList.get(j+2); + mainTable.setValueAt(rowList.get(j+2), i, j); + } +// if (valueList.contains(mainTable.getValueAt(i, 0)) +// || valueList.contains(" " + mainTable.getValueAt(i, 0) ) +// || valueList.contains("\n " + mainTable.getValueAt(i, 0) ) +// || valueList.contains("\n" + mainTable.getValueAt(i, 0) )) { +// mainTable.setValueAt("1", i, 3); +// } else { +// mainTable.setValueAt("0", i, 3); +// } + } + } +// +// //##############################ȡ + public void getJTable1() {//header2.length + + List> dataListvalue = new ArrayList>(); + for (int i = -1; i < dataList1.size(); i++) { + List rowList = new ArrayList() ; + if(i==-1) { + rowList.add(null); + rowList.add(null); + rowList.add("test"); + rowList.add("test"); + rowList.add("test"); + }else { + rowList.add(null); + rowList.add(null); + for (int j = 0; j < header.length; j++) { + rowList.add((String) mainTable.getValueAt( i, j)); + } + rowList.add("1"); + } + dataListvalue.add(rowList); + } + dataList11=dataListvalue; + + + +// List> dataListvalue = new ArrayList>(); +// for (int i = 0; i < dataList1.size(); i++) { +// List rowList = new ArrayList() ; +// rowList.add(null); +// rowList.add(null); +// for (int j = 0; j < header.length; j++) { +// rowList.add((String) mainTable.getValueAt( i, j)); +// } +// rowList.add("1"); +// dataListvalue.add(rowList); +// } +// dataList11=dataListvalue; + + } + + + + +// +// +// + public void getJTable2() {//header2.length + List> dataListvalue = new ArrayList>(); + for (int i = 0; i < dataList2.size(); i++) { + List rowList = new ArrayList(); + rowList.add(null); + rowList.add(null); + for (int j = 0; j < header2.length; j++) { + //String we=(String) mainTable2.getValueAt( i, j); + rowList.add((String) mainTable2.getValueAt( i, j)); + } + rowList.add("2"); + dataListvalue.add(rowList); + } + dataList22=dataListvalue; + } +// +// +// //################################ + public void setJTable2() {//header2.length + + + + for (int i = 0; i < dataList2.size(); i++) { + List rowList = dataList2.get(i); + for (int j = 0; j < header2.length; j++) { + mainTable2.setValueAt(rowList.get(j+2), i, j); + } +// if (valueList.contains(mainTable.getValueAt(i, 0)) +// || valueList.contains(" " + mainTable.getValueAt(i, 0) ) +// || valueList.contains("\n " + mainTable.getValueAt(i, 0) ) +// || valueList.contains("\n" + mainTable.getValueAt(i, 0) )) { +// mainTable.setValueAt("1", i, 3); +// } else { +// mainTable.setValueAt("0", i, 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()); +// } +// } +// } + +// public void getCombineMap() { +// try { +// if (dataList != null && dataList.size() > 0) { +// for (int i = 0; i < dataList.size(); i++) { +// if (dataList.get(i).get(3) != null && !dataList.get(i).get(3).equals("")) { +// String sombine = dataList.get(i).get(3).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]); +// } +// } 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]); +// } +// } else { +// cloumn = new int[] { Integer.parseInt(cells[1]) }; +// } +// this.combineMap.put(row, cloumn); +// } +// } +// } +// } +// } +// } catch (Exception e) { +// MessageBox.post(e.toString(), "", MessageBox.ERROR); +// e.printStackTrace(); +// } +// } + + // Jtableͨ÷ + public CTable getNewjTable(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + map = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(true); + partsTable = new CTable(map); + // ʾȾ + 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; + } + + public CTable getNewjTable2(CTable partsTable, DefaultTableModel dtm, Object[] titleNames, int rows) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + map2 = new CTMap(rows, titleNames.length); + map2.setColumnIdentifiers(titleNames); + map2.setEditable(true); + partsTable = new CTable(map2); + // ʾȾ + 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; + } +//} + +// private static void print() { +// try { +// File file = new File("C:/Users/Administrator/Desktop/ίеѡ.xlsx"); +// PDDocument document = PDDocument.load(file); +// // سɴӡļ +// PDFPrintable printable = new PDFPrintable(document); +// PrinterJob job = PrinterJob.getPrinterJob(); +// job.setPrintable(printable); +// job.print(); +// } catch (InvalidPasswordException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (PrinterException e) { +// e.printStackTrace(); +// } +// } + + /* ӡָļ */ + +// private void printFileAction() { +// // Excel +// getData(); +// // ȡģ +// File file = TMomMethodUtil.getFile(session, "ίеģ", "MSExcelX"); +// String outFilePath = System.getenv("TEMP") + "\\ίе.xlsx"; +// //ʽί +// if(!bean.getP33().isEmpty()) +// { +// if(bean.getP33().indexOf(",\n") > 0) +// { +// String[] values = bean.getP33().split(",\n"); +// int j = 1; +// StringBuffer valueStringBuffer = new StringBuffer(); +// for (int i = 0; i < values.length; i++) { +// if(bean.getP2().indexOf("") >= 0 && (values[i].indexOf("Ʒ") >= 0 || values[i].indexOf("") >= 0)) +// { +// valueStringBuffer.append(j+""+values[i].split("-")[2] +"\n"); +// j++; +// } +// if(bean.getP2().indexOf("Ϸ") >= 0 && values[i].indexOf("") >= 0) +// { +// valueStringBuffer.append(j+""+values[i].split("-")[2] +"\n"); +// j++; +// } +// } +// bean.setP33(valueStringBuffer.toString()); +// } +// else +// { +// if(bean.getP2().indexOf("") >= 0 && (bean.getP33().indexOf("Ʒ") >= 0 || bean.getP33().indexOf("") >= 0)) +// { +// bean.setP33("1"+bean.getP33().split("-")[2] +"\n"); +// } +// if(bean.getP2().indexOf("Ϸ") >= 0 && bean.getP33().indexOf("") >= 0) +// { +// bean.setP33("1"+bean.getP33().split("-")[2] +"\n"); +// } +// } +// } +// try { +// ExcelUtil07.writeEntrustmentFormToExcel(bean, file, outFilePath); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// File outputFile = new File(outFilePath); +// +// //ӡExcelļ +// Workbook workbook = new Workbook(); +// workbook.loadFromFile(outputFile.getAbsolutePath()); +// +// // PrinterJob +// PrinterJob printerJob = PrinterJob.getPrinterJob(); +// +// //ָӡҳΪĬϴСͷ +// PageFormat pageFormat = printerJob.defaultPage(); +// +// //شӡѡ +// Paper paper = pageFormat.getPaper(); +// paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); +// pageFormat.setPaper(paper); +// if(printerJob.printDialog()) +// { +// printerJob.setCopies(1); +// printerJob.setPrintable(workbook, pageFormat); +// +// //ִдӡ +// try { +// printerJob.print(); +// } catch (PrinterException e) { +// e.printStackTrace(); +// } +// } +// + +// // ӡԼ +// PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); +// // ôӡʽΪδȷļͣѡ AUTOSENSE +// DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE; +// +// // еĿôӡ +// PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, pras); +// +// // λĬϵĴӡ +// PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService(); +// +// // ʾӡԻ +// PrintService service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, flavor, pras); +// +// if (service != null) { +// try { +// DocPrintJob job = service.createPrintJob();// ӡҵ +// FileInputStream fis = new FileInputStream(outputFile);// ӡļ +// DocAttributeSet das = new HashDocAttributeSet(); +// Doc doc = new SimpleDoc(fis, flavor, das);// ӡļʽ +// job.print(doc, pras);// ļĴӡ +// } catch (Exception e) { +// e.printStackTrace(); +// +// } +// } + } + + diff --git a/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormHandler.java b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormHandler.java new file mode 100644 index 0000000..bdd2c6f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormHandler.java @@ -0,0 +1,135 @@ +package com.connor.renben.process.plm.tmom040; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Locale; +import java.util.Properties; +import java.util.ResourceBundle; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom040EntrustmentFormHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + //汾 + String revisionID="";//ȡѡж + String[] Datas=new String[73]; + String[] strs=null; + TCComponent[] items=null; + boolean lag=true; + //ȡѡж + InterfaceAIFComponent comp = app.getTargetComponent(); + //жѡжǷίеİ汾JSFXWTDRevision + if(comp.getType().indexOf("WTDRevision") > 0) + { + +//鿴汾Ƿ,̳+++++++++++++++++++++ + //ȡ汾 + try { + revisionID = comp.getProperty("item_revision_id"); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + //жϰ汾ǷѾдݣд + ResultSet rsselect = null; + SqlUtilT.getTCConnection(); + String sqlselect = String.format("select * from RB3_ENTRUSTMENTFORM WHERE PUID = \'%s\' AND P72 =\'%s\'",comp.getUid(),revisionID); + try { + //ͨѡеİ汾ȡȫ汾 + items = (((TCComponent) comp).getReferenceListProperty("revision_list")); + rsselect=SqlUtilT.read(sqlselect); + if(rsselect.next())lag=false;//ѾдݣѯĽΪǿգlagfalseִļ̳в + } catch (SQLException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //жǷΪV0汾 + if(!revisionID.equals("V0")&&lag) { + //ȡV0汾ݸ°汾 + ResultSet rs = null; + InputStream input = null; + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + try { + pro.load(input); + String sql = String.format(pro.getProperty("RB3_ENTRUSTMENTFORMSELECTA"),items[0].getUid(),"V0"); + rs = SqlUtilT.read(sql); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + while (rs.next()) { + Datas[0]=comp.getUid();Datas[1]=rs.getString("P1");Datas[2]=rs.getString("P2");Datas[3]=rs.getString("P3"); + Datas[4]=rs.getString("P4");Datas[5]=rs.getString("P5");Datas[6]=rs.getString("P6");Datas[7]=rs.getString("P7"); + Datas[8]=rs.getString("P8");Datas[9]=rs.getString("P9");Datas[10]=rs.getString("P10");Datas[11]=rs.getString("P11"); + Datas[12]=rs.getString("P12");Datas[13]=rs.getString("P13");Datas[14]=rs.getString("P14");Datas[15]=rs.getString("P15"); + Datas[16]=rs.getString("P16");Datas[17]=rs.getString("P17");Datas[18]=rs.getString("P18");Datas[19]=rs.getString("P19"); + Datas[20]=rs.getString("P20");Datas[21]=rs.getString("P21");Datas[22]=rs.getString("P22");Datas[23]=rs.getString("P23"); + Datas[24]=rs.getString("P24");Datas[25]=rs.getString("P25");Datas[26]=rs.getString("P26");Datas[27]=rs.getString("P27"); + Datas[28]=rs.getString("P28");Datas[29]=rs.getString("P29");Datas[30]=rs.getString("P30");Datas[31]=rs.getString("P31"); + Datas[32]=rs.getString("P32");Datas[33]=rs.getString("P33");Datas[34]=rs.getString("P34");Datas[35]=rs.getString("P35"); + Datas[36]=rs.getString("P36");Datas[37]=rs.getString("P37");Datas[38]=rs.getString("P38");Datas[39]=rs.getString("P39"); + Datas[40]=rs.getString("P40");Datas[41]=rs.getString("P41");Datas[42]=rs.getString("P42");Datas[43]=rs.getString("P43"); + Datas[44]=rs.getString("P44");Datas[45]=rs.getString("P45");Datas[46]=rs.getString("P46");Datas[47]=rs.getString("P47"); + Datas[48]=rs.getString("P48");Datas[49]=rs.getString("P49");Datas[50]=rs.getString("P50");Datas[51]=rs.getString("P51"); + Datas[52]=rs.getString("P52");Datas[53]=rs.getString("P53");Datas[54]=rs.getString("P54");Datas[55]=rs.getString("P55"); + Datas[56]=rs.getString("P56");Datas[57]=rs.getString("P57");Datas[58]=rs.getString("P58");Datas[59]=rs.getString("P59"); + Datas[60]=rs.getString("P60");Datas[61]=rs.getString("P61");Datas[62]=rs.getString("P62");Datas[63]=rs.getString("P63"); + Datas[64]=rs.getString("P64");Datas[65]=rs.getString("P65");Datas[66]=rs.getString("P66");Datas[67]=rs.getString("P67"); + Datas[68]=rs.getString("P68");Datas[69]=rs.getString("P69");Datas[70]=rs.getString("P70");Datas[71]=rs.getString("P71"); + Datas[72]=revisionID; + } + String insertSQL = pro.getProperty("RB3_ENTRUSTMENTFORMINSERTA"); + SqlUtilT.update(Datas,insertSQL); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +//++++++++++++++++++++++++++++++ + TMom040EntrustmentFormCommand command = new TMom040EntrustmentFormCommand(app, + session,comp,items[0].getUid()); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("sb40_display.TITLE"), "", MessageBox.ERROR); + } + + }else + { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("bb40_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormOperation.java b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormOperation.java new file mode 100644 index 0000000..a964d21 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom040/TMom040EntrustmentFormOperation.java @@ -0,0 +1,170 @@ +package com.connor.renben.process.plm.tmom040; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.util.MessageBox; + +public class TMom040EntrustmentFormOperation extends AbstractAIFOperation { + + private EntrustmentFormBean bean; + private boolean isHave; + private InterfaceAIFComponent comp; + private List> dataList1 = new ArrayList>(); + private List> dataList2 = new ArrayList>(); + private String revisionID = "";//¼汾ID + //private List plmeidList; + public TMom040EntrustmentFormOperation(EntrustmentFormBean bean, boolean isHave,InterfaceAIFComponent comp,List> dataList1,List> dataList2) { + // TODO Auto-generated constructor stub + this.bean = bean; + this.isHave = isHave; + this.dataList1=dataList1; + this.dataList2=dataList2; + this.comp=comp; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // ȡݿ + revisionID=comp.getProperty("item_revision_id"); + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + SqlUtilT.getTCConnection(); + String deleteSQL2 = String.format(pro.getProperty("RB3_ENTRUSTMENTDELETE"),"1",comp.getUid() ); + SqlUtilT.delete(deleteSQL2); + String deleteSQL3 = String.format(pro.getProperty("RB3_ENTRUSTMENTDELETE"),"2",comp.getUid() ); + SqlUtilT.delete(deleteSQL3); + String deleteSQL4 = String.format(pro.getProperty("RB3_ENTRUSTMENTDELETE"),"test",comp.getUid() ); + SqlUtilT.delete(deleteSQL4); + if (isHave) { + // + String updateSQL = String.format(pro.getProperty("RB3_ENTRUSTMENTFORMUPDATEA"), bean.getPuid(),revisionID); + SqlUtilT.update(new String[] { bean.getP1(), bean.getP2(), bean.getP3(), bean.getP4(), bean.getP5(), + bean.getP6(), bean.getP7(), bean.getP8(), bean.getP9(), bean.getP10(), bean.getP11(), + bean.getP12(), bean.getP13(), bean.getP14(), bean.getP15(), bean.getP16(), bean.getP17(), + bean.getP18(), bean.getP19(), bean.getP20(), bean.getP21(), bean.getP22(), bean.getP23(), + bean.getP24(), bean.getP25(), bean.getP26(), bean.getP27(), bean.getP28(), bean.getP29(), + bean.getP30(), bean.getP31(), bean.getP32(), bean.getP33(), bean.getP34(), bean.getP35(), + bean.getP36(), bean.getP37(), bean.getP38(), bean.getP39(), bean.getP40(), bean.getP41(), + bean.getP42(), bean.getP43(), bean.getP44(), bean.getP45(), bean.getP46(), bean.getP47(), + bean.getP48(), bean.getP49(), bean.getP50(), bean.getP51(), bean.getP52(), bean.getP53(), + bean.getP54(), bean.getP55(), bean.getP56(), bean.getP57(), bean.getP58(), bean.getP59(), + bean.getP60(), bean.getP61(), bean.getP62(), bean.getP63(), bean.getP64(), bean.getP65(), + bean.getP66(), bean.getP67(), bean.getP68(), bean.getP69(), bean.getP70(), bean.getP71() + }, updateSQL); + + //*********************** + + for (int i = 0; i < dataList1.size(); i++) { + List rowList = dataList1.get(i); + // + if ( rowList.get(0) != null && !rowList.get(0).equals("")) {//&& plmeidList.contains(rowList.get(0)) + // ȡݿ + String updateSQL2 = String.format(pro.getProperty("RB3_ENTRUSTMENTUPDATEa"), rowList.get(0)); + //String insertSQL2 = pro.getProperty("RB3_ENTRUSTMENTINSERT"); + SqlUtilT.update(new String[] {rowList.get(2),rowList.get(3) }, + updateSQL2); + } else { + + String insertSQL2 = pro.getProperty("RB3_ENTRUSTMENTINSERT"); + + SqlUtilT.write2(new String[] { UUID.randomUUID().toString().replace("-", ""), comp.getUid(), rowList.get(2), rowList.get(3), + rowList.get(4) }, insertSQL2); + + } + + } + + //################################ + + for (int i = 0; i < dataList2.size(); i++) { + List rowList = dataList2.get(i); + //rowList.get(0) != null && !rowList.get(0).equals("") + if (rowList.get(0) != null && !rowList.get(0).equals("") ) {//&& plmeidList.contains(rowList.get(0)) + // ȡݿ + String updateSQL3 = String.format(pro.getProperty("RB3_ENTRUSTMENTUPDATE"), rowList.get(0)); + //String insertSQL3= pro.getProperty("RB3_ENTRUSTMENTINSERT"); + SqlUtilT.update(new String[] {rowList.get(2),rowList.get(3) }, + updateSQL3); + } else { + String insertSQL3 = pro.getProperty("RB3_ENTRUSTMENTINSERT"); + SqlUtilT.write2(new String[] { UUID.randomUUID().toString().replace("-", ""), comp.getUid(), rowList.get(2), rowList.get(3), + rowList.get(4) }, insertSQL3); + } + } + //***************************** + } else { + // + String insertSQL = pro.getProperty("RB3_ENTRUSTMENTFORMINSERTA"); + SqlUtilT.update(new String[] { bean.getPuid(), bean.getP1(), bean.getP2(), bean.getP3(), bean.getP4(), + bean.getP5(), bean.getP6(), bean.getP7(), bean.getP8(), bean.getP9(), bean.getP10(), + bean.getP11(), bean.getP12(), bean.getP13(), bean.getP14(), bean.getP15(), bean.getP16(), + bean.getP17(), bean.getP18(), bean.getP19(), bean.getP20(), bean.getP21(), bean.getP22(), + bean.getP23(), bean.getP24(), bean.getP25(), bean.getP26(), bean.getP27(), bean.getP28(), + bean.getP29(), bean.getP30(), bean.getP31(), bean.getP32(), bean.getP33(), bean.getP34(), + bean.getP35(), bean.getP36(), bean.getP37(), bean.getP38(), bean.getP39(), bean.getP40(), + bean.getP41(), bean.getP42(), bean.getP43(), bean.getP44(), bean.getP45(), bean.getP46(), + bean.getP47(), bean.getP48(), bean.getP49(), bean.getP50(), bean.getP51(), bean.getP52(), + bean.getP53(), bean.getP54(), bean.getP55(), bean.getP56(), bean.getP57(), bean.getP58(), + bean.getP59(), bean.getP60(), bean.getP61(), bean.getP62(), bean.getP63(), bean.getP64(), + bean.getP65(), bean.getP66(), bean.getP67(), bean.getP68(), bean.getP69(), bean.getP70(), + bean.getP71(), revisionID }, insertSQL); + //**************** + for (int i = 0; i < dataList1.size(); i++) { + List rowList = dataList1.get(i); + String insertSQL2 = pro.getProperty("RB3_ENTRUSTMENTINSERT"); + + SqlUtilT.write2(new String[] { UUID.randomUUID().toString().replace("-", ""), comp.getUid(), rowList.get(2), rowList.get(3), + rowList.get(4) }, insertSQL2); + + + } + + for (int i = 0; i < dataList2.size(); i++) { + List rowList = dataList2.get(i); + String insertSQL3 = pro.getProperty("RB3_ENTRUSTMENTINSERT"); + SqlUtilT.write2(new String[] { UUID.randomUUID().toString().replace("-", ""), comp.getUid(), rowList.get(2), rowList.get(3), + rowList.get(4) }, insertSQL3); + + + } + + + //******************* + + } + SqlUtilT.connection.commit(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom041/TMom041EntrustmentFormCommand.java b/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormCommand.java new file mode 100644 index 0000000..1c0fbca --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormCommand.java @@ -0,0 +1,274 @@ +package com.connor.renben.process.plm.tmom041; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TMom041EntrustmentFormCommand extends AbstractAIFCommand { + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp;// ѡеίе汾 + // жݿǷѴ + private boolean isHave = false; + private boolean isHaveProcess = false; + private EntrustmentFormBean bean = new EntrustmentFormBean(); + private List privilegeList = new ArrayList(); + private List> dataList2 = new ArrayList>(); + private List> dataList4 = new ArrayList>(); + + public TMom041EntrustmentFormCommand(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + } + + public boolean getPrivilege() { + try { + // ȡѡõȨ,ѡCust_TestEntrustmentForm_Privilege + String[] privileges = TMomMethodUtil.getPreferenceValues("Cust_TestEntrustmentForm_Privilege"); + TCComponentUser sessionUser = session.getUser(); + String userName = ((TCComponentItemRevision) this.comp).getReferenceProperty("owning_user") + .getStringProperty("user_id"); + + Map privilegeMap = new HashMap(); + + for (int i = 0; i < privileges.length; i++) { + String[] privilegeNode = privileges[i].split("-"); + if (privilegeNode[1].indexOf(",") > 0) { + privilegeMap.put(privilegeNode[0], privilegeNode[1].split(",")); + } else { + privilegeMap.put(privilegeNode[0], new String[] { privilegeNode[1] }); + } + + } + ((TCComponentItemRevision) this.comp).refresh(); + TCComponent[] items = ((TCComponentItemRevision) this.comp).getRelatedComponents("process_stage_list"); + if (items.length > 0) { + isHaveProcess = true; + for (int i = 0; i < items.length; i++) { + items[i].refresh(); + // ȡǰڽڵ + TCComponent[] taskItems = items[i].getRelatedComponents("fnd0StartedTasks"); + + for (int j = 0; j < taskItems.length; j++) { + // ȡǰڽڵ + String name = taskItems[j].getStringProperty("current_name"); + String type = taskItems[j].getStringProperty("task_type"); + // ȡ + TCComponent[] users = taskItems[j].getReferenceListProperty("valid_signoffs"); + + if (users.length > 0) { + for (TCComponent tcComponent : users) { + System.out.println("UID" + tcComponent.getUid()); + TCComponent user = tcComponent.getReferenceProperty("fnd0Performer"); + String userId = user.getStringProperty("user_id"); + System.out.println("ˣ" + userId); + if (sessionUser.getUserId().equals(userId)) { + String[] nodePrivilege = privilegeMap.get(name); + for (int k = 0; k < nodePrivilege.length; k++) { + privilegeList.add(nodePrivilege[k]); + } + break; + } + } + } + if(type.equals("EPMDoTask")) + { + //ȡִ + TCComponent user = taskItems[j].getReferenceProperty("fnd0Performer"); + String userId = user.getStringProperty("user_id"); + System.out.println("ˣ" + userId); + if (sessionUser.getUserId().equals(userId)) { + String[] nodePrivilege = privilegeMap.get(name); + for (int k = 0; k < nodePrivilege.length; k++) { + privilegeList.add(nodePrivilege[k]); + System.out.println("================="+nodePrivilege[k]); + } + break; + } + } + } + } + } else { + // жǷǰ汾 + if (sessionUser.getUserId().equals(userName)) { + privilegeList.add(""); + privilegeList.add(""); + privilegeList.add(""); + privilegeList.add("װ"); + privilegeList.add("װɹ"); + privilegeList.add("װͼ"); + privilegeList.add("ʵʩ"); + privilegeList.add("Ʒ"); + privilegeList.add("鱨"); + } + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return false; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + + // ѡжPUIDȡ + ResultSet rs = null; + ResultSet rs2 = null; + + InputStream input = null; + try { + bean.setPuid(comp.getUid()); + bean.setItemId(comp.getProperty("item_id")); + // ȡݿ + SqlUtilT.getTCConnection(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_ENTRUSTMENTFORMSELECT"), comp.getUid()); + String sql2 = String.format(pro.getProperty("RB3_TESTFORMSELECT"), comp.getUid()); + + rs = SqlUtilT.read(sql); + rs2 = SqlUtilT.read(sql2); + + + while(rs2.next()) { + List rowList = new ArrayList(); + rowList.add(rs2.getString("PLMID")); + rowList.add(rs2.getString("PUID")); + rowList.add(rs2.getString("P1")); + rowList.add(rs2.getString("P2")); + rowList.add(rs2.getString("p3")); + rowList.add(rs2.getString("p4")); + rowList.add(rs2.getString("p5")); + rowList.add(rs2.getString("PLMID")); + dataList2.add(rowList); + } + while (rs.next()) { + isHave = true; + bean.setP1(rs.getString("P1")); + bean.setP2(rs.getString("P2")); + bean.setP3(rs.getString("P3")); + bean.setP4(rs.getString("P4")); + bean.setP5(rs.getString("P5")); + bean.setP6(rs.getString("P6")); + bean.setP7(rs.getString("P7")); + bean.setP8(rs.getString("P8")); + bean.setP9(rs.getString("P9")); + bean.setP10(rs.getString("P10")); + bean.setP11(rs.getString("P11")); + bean.setP12(rs.getString("P12")); + bean.setP13(rs.getString("P13")); + bean.setP14(rs.getString("P14")); + bean.setP15(rs.getString("P15")); + bean.setP16(rs.getString("P16")); + bean.setP17(rs.getString("P17")); + bean.setP18(rs.getString("P18")); + bean.setP19(rs.getString("P19")); + bean.setP20(rs.getString("P20")); + bean.setP21(rs.getString("P21")); + bean.setP22(rs.getString("P22")); + bean.setP23(rs.getString("P23")); + bean.setP24(rs.getString("P24")); + bean.setP25(rs.getString("P25")); + bean.setP26(rs.getString("P26")); + bean.setP27(rs.getString("P27")); + bean.setP28(rs.getString("P28")); + bean.setP29(rs.getString("P29")); + bean.setP30(rs.getString("P30")); + bean.setP31(rs.getString("P31")); + bean.setP32(rs.getString("P32")); + bean.setP33(rs.getString("P33")); + bean.setP34(rs.getString("P34")); + bean.setP35(rs.getString("P35")); + bean.setP36(rs.getString("P36")); + bean.setP37(rs.getString("P37")); + bean.setP38(rs.getString("P38")); + bean.setP39(rs.getString("P39")); + bean.setP40(rs.getString("P40")); + bean.setP41(rs.getString("P41")); + bean.setP42(rs.getString("P42")); + bean.setP43(rs.getString("P43")); + bean.setP44(rs.getString("P44")); + bean.setP45(rs.getString("P45")); + bean.setP46(rs.getString("P46")); + bean.setP47(rs.getString("P47")); + bean.setP48(rs.getString("P48")); + bean.setP49(rs.getString("P49")); + bean.setP50(rs.getString("P50")); + bean.setP51(rs.getString("P51")); + bean.setP52(rs.getString("P52")); + bean.setP53(rs.getString("P53")); + bean.setP54(rs.getString("P54")); + bean.setP55(rs.getString("P55")); + bean.setP56(rs.getString("P56")); + bean.setP57(rs.getString("P57")); + bean.setP58(rs.getString("P58")); + bean.setP59(rs.getString("P59")); + bean.setP60(rs.getString("P60")); + bean.setP61(rs.getString("P61")); + bean.setP62(rs.getString("P62")); + bean.setP63(rs.getString("P63")); + bean.setP64(rs.getString("P64")); + bean.setP65(rs.getString("P65")); + bean.setP66(rs.getString("P66")); + bean.setP67(rs.getString("P67")); + bean.setP68(rs.getString("P68")); + bean.setP64(rs.getString("P69")); + bean.setP65(rs.getString("P70")); + bean.setP66(rs.getString("P71")); + bean.setP67(rs.getString("P72")); + } + } 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(); + } + getPrivilege(); + new Thread() { + @Override + public void run() { + new TMom041EntrustmentFormDialog(app, session, comp, bean, isHave, privilegeList, isHaveProcess,dataList2); + super.run(); + } + }.start(); + super.executeModal(); + } + +} diff --git a/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormDialog.java b/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormDialog.java new file mode 100644 index 0000000..27a63c8 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormDialog.java @@ -0,0 +1,2023 @@ +package com.connor.renben.process.plm.tmom041; + +import java.awt.BorderLayout; +import java.util.Date; +import java.text.SimpleDateFormat; +import java.awt.Button; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Paper; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +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.print.Doc; +import javax.print.DocFlavor; +import javax.print.DocPrintJob; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.ServiceUI; +import javax.print.SimpleDoc; +import javax.print.attribute.DocAttributeSet; +import javax.print.attribute.HashDocAttributeSet; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFileChooser; +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.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTextPane; +import javax.swing.JViewport; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; + +//import org.apache.avalon.framework.component.Component; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.bean.TreeBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.tmom004.TMom004SetControlPlanDialog; +import com.connor.renben.process.plm.tmom004.TableCellTextAreaRenderer2; +import com.connor.renben.process.plm.tmom027.TMom027EntrustmentFormDialog; +import com.connor.renben.process.plm.util.Adapter; +import com.connor.renben.process.plm.util.CTMap; +import com.connor.renben.process.plm.util.CTable; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.JAutoCompleteComboBox; +import com.connor.renben.process.plm.util.MultiComboBox; +import com.connor.renben.process.plm.util.TMomMethodUtil; +import com.connor.renben.process.plm.util.TableCellTextAreaRenderer; +import com.connor.renben.process.plm.util.TreeComboBox; +import com.spire.xls.Workbook; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.commands.reserve.ReserveOperation; +import com.teamcenter.rac.commands.userpreferences.IEOptionsPanel; +import com.teamcenter.rac.common.implicitco.ImplicitCheckOutOperation; +import com.teamcenter.rac.common.viewedit.ViewEditHelper; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +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.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCReservationService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.scrollpage.ScrollPagePane; +import com.teamcenter.services.rac.core.ReservationService; + +public class TMom041EntrustmentFormDialog extends JFrame implements ActionListener { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp;// ѡеίе汾 + private TCComponentItemRevision itemRevision;// ѡеίе汾 + private EntrustmentFormBean bean; + private boolean isHave; + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private List privilegeList;// ڵȨ + private boolean isHaveProcess; + private List> dataList2 = new ArrayList>(); + private List> dataListall = new ArrayList>(); + private List deleteRows; + private List> dataValueList; + public List TypeList =new ArrayList();//ȡţԶ + + //ȡlov + private List> lovlist = new ArrayList>(); + + + private static JPopupMenu leftMenu; + private JMenuItem addNodeItem; + private JMenuItem remNodeItem; + private JMenuItem updateNodItem; + //жϵԪǷý + private boolean isFocusOwner = false; + // ؼ + + // + private String nonode; + private String typenode; + private String timenode; + private String numnode; + private String spenode; + + + private JLabel titleLabel;// + // ѡ + private JTabbedPane tabbedPane; + // ؼ + private JLabel p1Label;// ίе + private JTextField p1Field; + private JLabel p2Label;// 鱳 + private JAutoCompleteComboBox p2ComboBox; + private JLabel p3Label;// ίеλ + private JTextField p3Field; + private JLabel p4Label;// ί + private JTextField p4Field; + private JLabel p5Label;// ίϵʽֻ + private JTextField p5Field; + private JLabel p6Label;// ίϵʽ䣩 + private JTextField p6Field;; + private JLabel p7Label;// ί + private DateButton p7DateButton; + private JLabel p8Label;// ƻʱ + private DateButton p8DateButton; +// private JLabel p8Label;// ί++++ѡ +// private MultiComboBox p8ComboBox; + private JLabel p9Label;// ʱ + private DateButton p9DateButton; + private JLabel p10Label;// ͻ + private JTextField p10Field; + private JLabel p11Label;// Ŀ + private JTextField p11Field; + private JLabel p12Label;// ͻȼ + private JAutoCompleteComboBox p12ComboBox; + private JLabel p13Label;// Ŀ + private JTextField p13Field; + private JLabel p14Label;// Ӧ + private JAutoCompleteComboBox p14ComboBox; + private JLabel p15Label;// Ŀȼ + private JAutoCompleteComboBox p15ComboBox; + private JLabel p16Label;// Ʒ + private JTextField p16Field; + private JLabel p17Label;// Ϻ + private JTextField p17Field; + private JLabel p18Label;// + private JAutoCompleteComboBox p18ComboBox; + private JLabel p19Label;// λ + private JAutoCompleteComboBox p19ComboBox; + private JLabel p20Label;// Ʒ + private JAutoCompleteComboBox p20ComboBox; + private JLabel p21Label;// Ʒ + private JTextField p21Field; + private Button p22Button;// ί + private JLabel p23Label;// + private JTextField p23Field; + private JLabel p24Label;// + private DateButton p24DateButton; + private JLabel p25Label;// ׼״̬ + private JAutoCompleteComboBox p25ComboBox; + private JLabel p26Label;// ׼ + private DateButton p26DateButton; + private JLabel p27Label;// ˻ԭ + private JTextArea p27Field; + private JLabel p28Label;// + private JTextField p28Field; + private JLabel p29Label;// + private DateButton p29DateButton; + private JLabel p30Label;// + private JAutoCompleteComboBox p30ComboBox; + private JLabel p31Label;// ԭ + private JTextArea p31Field; + private JLabel p32Label;// Ŷ + private JTextField p32Field; + private JLabel p33Label;// װŶ + private JTextField p33Field; + private JLabel p34Label;// ׼״̬ + private JAutoCompleteComboBox p34ComboBox; + private JLabel p35Label;// ׼ + private DateButton p35DateButton; + private JLabel p36Label;// ˻ԭ + private JTextArea p36Field; + + //++++++++++++++++++++++++++++++++++++++++++++++++++++ + + private JLabel yyLabel = new JLabel("ԭ:"); + private JCheckBox checkBox09; + + private String str = ""; + private JPanel panel10 = new JPanel(new FlowLayout()); + // + private JPanel partPanel0; + private JPanel partPanel1; + private JPanel partPanel2; + private JPanel partPanel3; + private JPanel partPanel4; + private JPanel partPanel5; + private JPanel partPanel6;// + private JPanel partPanel7; + private JPanel partPanel8; + private JPanel partPanel9; + private JPanel partPanel10; + private JPanel partPanel11; + private JPanel partPanel12; + private JPanel partPanel13; + + + // + private CTable mainTable; + private String[] header = new String[]{"","","ʱh","Ʒ","Ҫ","PLMID"}; + //ڵ + private CTable mainTable4; + private String[] header4 = new String[]{"","","ƻװ","װͼֽļ","ʵʹװ"}; + private CTable mainTable5; + private String[] header5 = new String[]{"","","ӹλ","ƻװ","ʵʹװ"}; + private CTable mainTable6; + private String[] header6 = new String[]{"","","װͼ","ƻװͼ","װ¼","װͼ"}; + private CTable mainTable7; + private String[] header7 = new String[]{"","","ʵʵ","ʵʵ","ǰƷ","ǰƷ¼","鿪ʼ","ƻ()"}; + private CTable mainTable8; + private String[] header8 = new String[]{"","","Ʒ","Ʒ¼"}; + private CTable mainTable9; + private String[] header9 = new String[]{"","","鱨","ʵ"}; + // 水ť + private JPanel rootPanel; + private Button okButton; + private Button celButton; + + public TMom041EntrustmentFormDialog(AbstractAIFApplication app, TCSession session, InterfaceAIFComponent comp, + EntrustmentFormBean bean, boolean isHave, List privilegeList, boolean isHaveProcess,List> dataList2 ) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.bean = bean; + this.isHave = isHave; + this.privilegeList = privilegeList; + this.isHaveProcess = isHaveProcess; + this.dataList2=dataList2; + //this.dataList4=dataList4; + try { + this.itemRevision.refresh(); + if (this.itemRevision.getStringProperty("object_desc").compareTo("Ѵ") == 0) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("zzbj40_display.TITLE"), "", MessageBox.ERROR); + return; + } else { + init(); + this.itemRevision.lock(); + this.itemRevision.setStringProperty("object_desc", "Ѵ"); + this.itemRevision.save(); + this.itemRevision.refresh(); + this.itemRevision.unlock(); + } + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /*** + * ʼ + * + * @throws IOException + * @throws FileNotFoundException + */ + private void init() throws FileNotFoundException, Exception { + + // ȡʻ + 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("sywtd41_display.TITLE")); + this.setPreferredSize(new Dimension(1100, 830)); + // this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + // this.setAlwaysOnTop(true); // ö + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + try { + itemRevision.lock(); + itemRevision.setStringProperty("object_desc", ""); + itemRevision.save(); + itemRevision.refresh(); + itemRevision.unlock(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); + // ʼⲿֿؼ + JPanel titlePanel = new JPanel(new PropertyLayout()); + this.titleLabel = new JLabel(rb.getString("sywtd41_display.TITLE"), JLabel.CENTER); + this.titleLabel.setFont(new Font("", 1, 18)); + this.titleLabel.setPreferredSize(new Dimension(950, 20)); + // TCComponentItemRevision itemRevision = (TCComponentItemRevision) this.comp; + JLabel itemLabel = new JLabel(rb.getString("wtdbh41_display.TITLE") + this.comp.getProperty("item_id"), + JLabel.RIGHT); + itemLabel.setPreferredSize(new Dimension(950, 20)); + titlePanel.add("1.1.left.top", itemLabel); + titlePanel.add("2.1.left.top", titleLabel); + + //ίϢ + JPanel panel1 = new JPanel(new FlowLayout()); + this.p2Label = new JLabel("鱳"); + //this.p2Label.setToolTipText("鱳");//ȥʾϢ + // this.p2Label.setForeground(Color.red); + this.p2Label.setPreferredSize(new Dimension(100, 30)); + this.p2ComboBox = new JAutoCompleteComboBox(); + this.p2ComboBox.setPreferredSize(new Dimension(200, 30)); + this.p2ComboBox.setSelectedItem(bean.getP2()); + panel1.add(this.p2Label); + panel1.add(this.p2ComboBox); + + JPanel panel2 = new JPanel(new FlowLayout()); + this.p3Label = new JLabel("ίеλ"); + // this.p3Label.setForeground(Color.red); + this.p3Label.setPreferredSize(new Dimension(60,30)); + this.p3Field = new JTextField(bean.getP3()); + this.p3Field.setPreferredSize(new Dimension(180, 30)); + this.p4Label = new JLabel("ί"); + // this.p4Label.setForeground(Color.red); + this.p4Label.setPreferredSize(new Dimension(50,30)); + this.p4Field = new JTextField(bean.getP4()); + this.p4Field.setPreferredSize(new Dimension(120, 30)); + panel1.add(this.p3Label); + panel1.add(this.p3Field); + panel1.add(this.p4Label); + panel1.add(this.p4Field); + + + JPanel panel3 = new JPanel(new FlowLayout()); + this.p5Label = new JLabel("ίϵʽ(ֻ)"); + //this.p5Label.setToolTipText("ίϵʽֻ"); + // this.p5Label.setForeground(Color.red); + this.p5Label.setPreferredSize(new Dimension(150,30)); + this.p5Field = new JTextField(bean.getP5()); + this.p5Field.setPreferredSize(new Dimension(150, 30)); + this.p6Label = new JLabel("ίϵʽ()"); + this.p6Label.setPreferredSize(new Dimension(180,30)); + this.p6Field = new JTextField(bean.getP6()); + this.p6Field.setPreferredSize(new Dimension(240, 30)); + panel3.add(this.p5Label); + panel3.add(this.p5Field); + panel3.add(this.p6Label); + panel3.add(this.p6Field); + + + JPanel panel4=new JPanel(new FlowLayout()); + this.p7Label = new JLabel("ί"); + this.p7Label.setPreferredSize(new Dimension(60,30)); + this.p7DateButton = new DateButton(dateFormat); + this.p7DateButton.setPreferredSize(new Dimension(150, 30)); + this.p7DateButton.setText(bean.getP7()); + + this.p8Label = new JLabel("ƻʱ"); + this.p8Label.setPreferredSize(new Dimension(90,30)); + this.p8DateButton = new DateButton(dateFormat); + this.p8DateButton.setPreferredSize(new Dimension(150, 30)); + this.p8DateButton.setText(bean.getP8()); + + this.p9Label = new JLabel("ʱ"); + this.p9Label.setPreferredSize(new Dimension(120,30)); + this.p9DateButton = new DateButton(dateFormat); + this.p9DateButton.setPreferredSize(new Dimension(140, 30)); + this.p9DateButton.setText(bean.getP9()); + + panel4.add(this.p7Label); + panel4.add(this.p7DateButton); + panel4.add(this.p8Label); + panel4.add(this.p8DateButton); + panel4.add(this.p9Label); + panel4.add(this.p9DateButton); + // ################################################### + //д +// JPanel panel5 = new JPanel(new FlowLayout()); +// this.p9Label = new JLabel(rb.getString("sybj41_display.TITLE")); +// this.p9Field = new JTextArea(bean.getP9()); +// JScrollPane scrollPane1 = new JScrollPane(); // jtaӹ +// scrollPane1.setPreferredSize(new Dimension(350, 80)); +// scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); +// scrollPane1.setViewportView(this.p9Field); +// panel5.add(this.p10Label); +// panel5.add(scrollPane1); +//################################################## + // JPanel panel5 = new JPanel(new FlowLayout()); + +// panel5.add(this.p9Label); +// panel5.add(this.p9DateButton); + + partPanel0 = new JPanel(new PropertyLayout()); + partPanel0.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "ίϢ")); + partPanel0.add("1.1.left.top", panel1); + partPanel0.add("2.1.left.top", panel3); + partPanel0.add("3.1.left.top", panel4); + //partPanel0.add("4.1.left.top", panel5); + partPanel0.setPreferredSize(new Dimension(920, 170)); + + //ĿϢ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + JPanel panel6 = new JPanel(new FlowLayout());//һ + JPanel panel7 = new JPanel(new FlowLayout());//ڶ + this.p10Label = new JLabel("ͻ"); + this.p10Label.setPreferredSize(new Dimension(60,30)); + this.p10Field = new JTextField(bean.getP10()); + this.p10Field.setPreferredSize(new Dimension(175, 30)); + this.p11Label = new JLabel("Ŀ"); + this.p11Label.setPreferredSize(new Dimension(60,30)); + this.p11Field = new JTextField(bean.getP11()); + this.p11Field.setPreferredSize(new Dimension(175, 30)); + this.p12Label = new JLabel("ͻȼ"); + this.p12Label.setPreferredSize(new Dimension(60,30)); + this.p12ComboBox=new JAutoCompleteComboBox(); + this.p12ComboBox.setPreferredSize(new Dimension(175,30)); + this.p12ComboBox.setSelectedItem(bean.getP12()); + this.p13Label = new JLabel("Ŀ"); + this.p13Label.setPreferredSize(new Dimension(60,30)); + this.p13Field = new JTextField(bean.getP13()); + this.p13Field.setPreferredSize(new Dimension(175, 30)); + this.p14Label = new JLabel("Ӧ"); + this.p14Label.setPreferredSize(new Dimension(60,30)); + this.p14ComboBox=new JAutoCompleteComboBox(); + this.p14ComboBox.setPreferredSize(new Dimension(180,30)); + this.p14ComboBox.setSelectedItem(bean.getP14()); + this.p15Label = new JLabel("Ŀȼ"); + this.p15Label.setPreferredSize(new Dimension(60,30)); + this.p15ComboBox=new JAutoCompleteComboBox(); + this.p15ComboBox.setPreferredSize(new Dimension(180,30)); + this.p15ComboBox.setSelectedItem(bean.getP15()); + panel6.add(this.p10Label); + panel6.add(this.p10Field); + panel6.add(this.p12Label); + panel6.add(this.p12ComboBox); + panel6.add(this.p14Label); + panel6.add(this.p14ComboBox); + panel7.add(this.p11Label); + panel7.add(this.p11Field); + panel7.add(this.p13Label); + panel7.add(this.p13Field); + panel7.add(this.p15Label); + panel7.add(this.p15ComboBox); + + partPanel1 = new JPanel(new PropertyLayout()); + partPanel1.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "ĿϢ")); + partPanel1.add("1.1.left.top", panel6); + partPanel1.add("2.1.left.top", panel7); + //partPanel1.add("3.1.left.top", panel8); + partPanel1.setPreferredSize(new Dimension(920,120)); + + + //ƷϢ++++++++++++ + JPanel panel9 = new JPanel(new FlowLayout()); + JPanel panel10 = new JPanel(new FlowLayout()); + this.p16Label = new JLabel("Ʒ"); + this.p16Label.setPreferredSize(new Dimension(60,30)); + this.p16Field = new JTextField(bean.getP16()); + this.p16Field.setPreferredSize(new Dimension(175, 30)); + this.p17Label = new JLabel("Ϻ"); + this.p17Label.setPreferredSize(new Dimension(60,30)); + this.p17Field = new JTextField(bean.getP17()); + this.p17Field.setPreferredSize(new Dimension(175, 30)); + this.p18Label = new JLabel(""); + this.p18Label.setPreferredSize(new Dimension(60,30)); + this.p18ComboBox=new JAutoCompleteComboBox(); + this.p18ComboBox.setPreferredSize(new Dimension(175,30)); + this.p18ComboBox.setSelectedItem(bean.getP18()); + this.p19Label = new JLabel("λ"); + this.p19Label.setPreferredSize(new Dimension(60,30)); + this.p19ComboBox=new JAutoCompleteComboBox(); + this.p19ComboBox.setPreferredSize(new Dimension(180,30)); + this.p19ComboBox.setSelectedItem(bean.getP19()); + this.p20Label = new JLabel("Ʒ"); + this.p20Label.setPreferredSize(new Dimension(60,30)); + this.p20ComboBox=new JAutoCompleteComboBox(); + this.p20ComboBox.setPreferredSize(new Dimension(175,30)); + this.p20ComboBox.setSelectedItem(bean.getP20()); + this.p21Label = new JLabel("Ʒ"); + this.p21Label.setPreferredSize(new Dimension(60,30)); + this.p21Field = new JTextField(bean.getP21()); + this.p21Field.setPreferredSize(new Dimension(180, 30)); + panel9.add(this.p16Label); + panel9.add(this.p16Field); + panel9.add(this.p20Label); + panel9.add(this.p20ComboBox); + panel9.add(this.p21Label); + panel9.add(this.p21Field); + panel10.add(this.p17Label); + panel10.add(this.p17Field); + panel10.add(this.p18Label); + panel10.add(this.p18ComboBox); + panel10.add(this.p19Label); + panel10.add(this.p19ComboBox); + + partPanel2 = new JPanel(new PropertyLayout()); + partPanel2.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "ƷϢ")); + partPanel2.add("1.1.left.top", panel9); + partPanel2.add("2.1.left.top", panel10); + //partPanel2.add("3.1.left.top", panel11); + partPanel2.setPreferredSize(new Dimension(920,120)); +//ϸ+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ϸ + if(dataList2.size()==0) {this.mainTable = getNewjTable(null, null, header,1);} + else{this.mainTable = getNewjTable(null, null, header,dataList2.size());} + Adapter adapter = new Adapter(mainTable); + JScrollPane scrollPane1 = new JScrollPane(mainTable); + scrollPane1.setPreferredSize(new Dimension(900,300)); + scrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + + //scrollPane1.getVerticalScrollBar().setUnitIncrement(2); + + this.mainTable.setRowHeight(40); + setJTable2(); + // + 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(mouseevent.getButton() == MouseEvent.BUTTON3) + { + //TypeList.clear(); + if(mainTable.getSelectedColumn()>-1)leftMenu.show(mainTable, mouseevent.getX(), mouseevent.getY()); + + } + mainTable.HiddenCell(5); + } + }); + + 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); +// List t = dataList2.get(0); +// for(int i=0;i1) ((CTMap)mainTable4.getModel()).setColumn(mainTable4.getSelectedColumn()); + + } + } + }); + partPanel7 = new JPanel(new PropertyLayout()); + partPanel7.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "װ")); + partPanel7.add("1.1.left.top",panel22); + + + //ڵ5װɹ+++++++++ + mainTable5 = getNewjTable4(null, null, header5, 0); + mainTable5.setRowHeight(40); + //selectNodeData(dataListall); + createtable(TypeList,header5,mainTable5); + setJTable(dataListall,mainTable5,5,7,TypeList); + JScrollPane jslp5 = new JScrollPane(); // jtaӹ + jslp5.setPreferredSize(new Dimension(900, 300)); + jslp5.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp5.setViewportView(mainTable5); + JPanel panel23=new JPanel(new FlowLayout()); + panel23.add(jslp5); + mainTable5.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap)mainTable5.getModel()).setRow(mainTable5.getSelectedRow()); + if(mainTable5.getSelectedColumn()>1)((CTMap)mainTable5.getModel()).setColumn(mainTable5.getSelectedColumn()); + } + } + }); + partPanel8 = new JPanel(new PropertyLayout()); + partPanel8.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "װɹ")); + partPanel8.add("1.1.left.top",panel23); + + //ڵ6װͼ+++++++++ + mainTable6 = getNewjTable4(null, null, header6, 0); + mainTable6.setRowHeight(40); + //selectNodeData(dataListall); + createtable(TypeList,header6,mainTable6); + setJTable(dataListall,mainTable6,8,11,TypeList); + JScrollPane jslp6 = new JScrollPane(); // jtaӹ + jslp6.setPreferredSize(new Dimension(900, 300)); + jslp6.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp6.setViewportView(mainTable6); + JPanel panel24=new JPanel(new FlowLayout()); + panel24.add(jslp6); + mainTable6.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap)mainTable6.getModel()).setRow(mainTable6.getSelectedRow()); + if(mainTable6.getSelectedColumn()>1)((CTMap)mainTable6.getModel()).setColumn(mainTable6.getSelectedColumn()); + } + } + }); + partPanel9 = new JPanel(new PropertyLayout()); + partPanel9.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "װͼ")); + partPanel9.add("1.1.left.top",panel24); + //ڵ7ʵʩ+++++++++ + mainTable7 = getNewjTable4(null, null, header7, 0); + mainTable7.setRowHeight(40); + createtable(TypeList,header7,mainTable7); + setJTable(dataListall,mainTable7,12,17,TypeList); + JScrollPane jslp7 = new JScrollPane(); // jtaӹ + jslp7.setPreferredSize(new Dimension(900, 300)); + jslp7.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp7.setViewportView(mainTable7); + JPanel panel25=new JPanel(new FlowLayout()); + panel25.add(jslp7); + mainTable7.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap)mainTable7.getModel()).setRow(mainTable7.getSelectedRow()); + if(mainTable7.getSelectedColumn()>1)((CTMap)mainTable7.getModel()).setColumn(mainTable7.getSelectedColumn()); + } + } + }); + partPanel10 = new JPanel(new PropertyLayout()); + partPanel10.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "ʵʩ")); + partPanel10.add("1.1.left.top",panel25); + //ڵ8Ʒ+++++++++ + mainTable8 = getNewjTable4(null, null, header8, 0); + mainTable8.setRowHeight(40); + selectNodeData(dataListall); + createtable(TypeList,header8,mainTable8); + setJTable(dataListall,mainTable8,18,19,TypeList); + JScrollPane jslp8 = new JScrollPane(); // jtaӹ + jslp8.setPreferredSize(new Dimension(900, 300)); + jslp8.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp8.setViewportView(mainTable8); + JPanel panel26=new JPanel(new FlowLayout()); + panel26.add(jslp8); + mainTable8.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap)mainTable8.getModel()).setRow(mainTable8.getSelectedRow()); + if(mainTable8.getSelectedColumn()>1)((CTMap)mainTable8.getModel()).setColumn(mainTable8.getSelectedColumn()); + } + } + }); + partPanel11 = new JPanel(new PropertyLayout()); + partPanel11.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "Ʒ")); + partPanel11.add("1.1.left.top",panel26); + //ڵ9鱨+++++++++ + mainTable9 = getNewjTable4(null, null, header9, 0); + mainTable9.setRowHeight(40); + createtable(TypeList,header9,mainTable9); + setJTable(dataListall,mainTable9,20,21,TypeList); + JScrollPane jslp9 = new JScrollPane(); // jtaӹ + jslp9.setPreferredSize(new Dimension(900, 300)); + jslp9.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp9.setViewportView(mainTable9); + JPanel panel27=new JPanel(new FlowLayout()); + panel27.add(jslp9); + mainTable9.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() == 1) { + ((CTMap)mainTable9.getModel()).setRow(mainTable9.getSelectedRow()); + if(mainTable9.getSelectedColumn()>1)((CTMap)mainTable9.getModel()).setColumn(mainTable9.getSelectedColumn()); + } + } + }); + partPanel12 = new JPanel(new PropertyLayout()); + partPanel12.setBorder( + new TitledBorder(BorderFactory.createLineBorder(Color.black), "鱨")); + partPanel12.add("1.1.left.top",panel27); +//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + JPanel mainPanel1 = new JPanel(new PropertyLayout()); + //mainPanel1.setPreferredSize(new Dimension(900, 600)); + mainPanel1.add("1.1.left.top", partPanel0); + mainPanel1.add("2.1.left.top", partPanel1); + mainPanel1.add("3.1.left.top", partPanel2); + mainPanel1.add("4.1.left.top", partPanel3); + mainPanel1.add("5.1.left.top", partPanel4); + mainPanel1.add("6.1.left.top", partPanel5); + mainPanel1.add("7.1.left.top", partPanel6); + mainPanel1.add("8.1.left.top", partPanel7); + mainPanel1.add("9.1.left.top", partPanel8); + mainPanel1.add("10.1.left.top", partPanel9); + mainPanel1.add("11.1.left.top", partPanel10); + mainPanel1.add("12.1.left.top", partPanel11); + mainPanel1.add("13.1.left.top", partPanel12); +// mainPanel1.add("14.1.left.top", partPanel13); + + tabbedPane = new JTabbedPane(); + tabbedPane.addTab(rb.getString("sywtd241_display.TITLE"), mainPanel1); + ScrollPagePane scrollPagePane = new ScrollPagePane(); + scrollPagePane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + rootPanel = new JPanel(new FlowLayout()); + this.okButton = new Button(rb.getString("bc_display.TITLE")); + okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new Button(rb.getString("qx_display.TITLE")); + celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(celButton); + + //scrollPagePane.setPreferredSize(new Dimension(600,1000 )); + JPanel mainPanel3 = new JPanel(new BorderLayout()); + mainPanel3.add(tabbedPane, BorderLayout.CENTER); + // ÿؼȨ + setPrivilege(); + // + addSelectItem(); + // + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(titlePanel, BorderLayout.NORTH); + ScrollPagePane scrollPane = new ScrollPagePane(mainPanel3); + scrollPane.getVerticalScrollBar().setUnitIncrement(50); + this.add(scrollPane, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + //ܴС + this.setPreferredSize(new Dimension(1000,800)); + this.pack(); + this.show(); + } + +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + /*** + * Ȩ + */ + + public void setPrivilege() { + setPanelEnabled(this.partPanel0, false); + setPanelEnabled(this.partPanel1, false); + setPanelEnabled(this.partPanel2, false); + setPanelEnabled(this.partPanel3, false); + setPanelEnabled(this.partPanel4, false); + setPanelEnabled(this.partPanel5, false); + setPanelEnabled(this.partPanel6, false); + setPanelEnabled(this.partPanel7, false); + setPanelEnabled(this.partPanel8, false); + setPanelEnabled(this.partPanel9, false); + setPanelEnabled(this.partPanel10, false); + setPanelEnabled(this.partPanel11, false); + setPanelEnabled(this.partPanel12, false); + // жǷ񷢲 + boolean isRelease; + try { + isRelease = this.comp.getProperty("release_status_list") != ""; + if (isRelease) { + return; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + for (int i = 0; i < this.privilegeList.size(); i++) { + System.out.println("+++++++++++++++++++" + this.privilegeList.get(i)); + switch (this.privilegeList.get(i)) { + case "": + // System.out.println("Ȩ"); + setPanelEnabled(this.partPanel0, true); + setPanelEnabled(this.partPanel1, true); + setPanelEnabled(this.partPanel2, true); + setPanelEnabled(this.partPanel3, true); + setPanelEnabled(this.partPanel4, true); + break; + case "": + setPanelEnabled(this.partPanel5, true); + break; + case "": + setPanelEnabled(this.partPanel6, true); + break; + case "װ": + setPanelEnabled(this.partPanel7, true); + break; + case "װɹ": + setPanelEnabled(this.partPanel8, true); + break; + case "װͼ": + setPanelEnabled(this.partPanel9, true); + break; + case "ʵʩ": + setPanelEnabled(this.partPanel10, true); + break; + case "Ʒ": + setPanelEnabled(this.partPanel11, true); + break; + case "鱨": + setPanelEnabled(this.partPanel12, true); + break; + default: + break; + } + } + if (!isHaveProcess) { + setPanelEnabled(this.partPanel0, true); + setPanelEnabled(this.partPanel1, true); + setPanelEnabled(this.partPanel2, true); + setPanelEnabled(this.partPanel3, true); + setPanelEnabled(this.partPanel4, true); + setPanelEnabled(this.partPanel5, true); + setPanelEnabled(this.partPanel6, true); + setPanelEnabled(this.partPanel7, true); + setPanelEnabled(this.partPanel8, true); + setPanelEnabled(this.partPanel9, true); + setPanelEnabled(this.partPanel10, true); + setPanelEnabled(this.partPanel11, true); + setPanelEnabled(this.partPanel12, true); + } + } + + 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); + } + } + } + //} + +//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ + + public void JadgeType(String filename, String path, String type1, String type2) { + String as1[] = { path };// ļ· + String as2[] = { type1 }; + String as3[] = { type2 }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = null; + try { + tccomponentDatasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + TCComponentDataset tccomponentDataset = null; + try { + tccomponentDataset = tccomponentDatasetType.create(filename, type1, type2); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + tccomponentDataset.setFiles(as1, as3, as4, as2); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + try { + itemRevision.add("TC_Attaches", tccomponentDataset); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("sccg41_display.TITLE"),"", MessageBox.INFORMATION); + // MessageBox.post(df.format(new Date()), "", MessageBox.ERROR); + // System.out.println(df.format(new Date()));// new Date()Ϊȡǰϵͳʱ + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + // $$$$$$$$$$$ + + public void addSelectItem() { + //Locale defaultLocale = Locale.getDefault(); + //ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + String[] p1Values = { "з", "Ŀ", "ȼƻ"}; + for (String string : p1Values) { + p2ComboBox.addItem(string); + } + this.p2ComboBox.setSelectedItem(bean.getP2()); + + String[] p3Values = { "սԿͻ", "ͻ", "ͨͻ"}; + for (String string : p3Values) { + p12ComboBox.addItem(string); + } + this.p12ComboBox.setSelectedItem(bean.getP12()); + + //String[] p4Values = { ""}; + String[] p4Values = findLovValueByKey(session,"RB3_YYLY"); + for (String string : p4Values) { + p14ComboBox.addItem(string); + } + this.p14ComboBox.setSelectedItem(bean.getP14()); + + String[] p5Values = { "AAA", "AA", "A","B","C"}; + for (String string : p5Values) { + p15ComboBox.addItem(string); + } + this.p15ComboBox.setSelectedItem(bean.getP15()); + + // + String[] p6Values = findLovValueByKey(session,"RB3_ZCLX"); + for (String string : p6Values) { + p18ComboBox.addItem(string); + } + this.p18ComboBox.setSelectedItem(bean.getP18()); + + //λ + //String[] p7Values = { ""}; + String[] p7Values = findLovValueByKey(session,"RB3_SCGC1"); + for (String string : p7Values) { + p19ComboBox.addItem(string); + } + this.p19ComboBox.setSelectedItem(bean.getP19()); + + //Ʒ + String[] p8Values = { "²Ʒ", "ͲƷ", "ϲƷ"}; + for (String string : p8Values) { + p20ComboBox.addItem(string); + } + this.p20ComboBox.setSelectedItem(bean.getP20()); + + //׼״̬ + String[] p9Values = { "׼","˻"}; + for (String string : p9Values) { + p25ComboBox.addItem(string); + } + this.p25ComboBox.setSelectedItem(bean.getP25()); + + // + String[] p10Values = { "У","ڲԴ֣ί","鲻"}; + for (String string : p10Values) { + p30ComboBox.addItem(string); + } + this.p30ComboBox.setSelectedItem(bean.getP30()); + + //׼״̬ + String[] p11Values = { "׼","˻"}; + for (String string : p11Values) { + p34ComboBox.addItem(string); + } + this.p34ComboBox.setSelectedItem(bean.getP34()); + + // У The test is feasible,and arrange immediately + // 鲻 The test is not feasible + // Դ֣ί The resources are not enough, suggest to subcontract the test + // Other suggestions +// String[] p2Values = { rb.getString("sykxljap41_display.TITLE"), rb.getString("sybkx41_display.TITLE"), +// rb.getString("zybcfjywwsy41_display.TITLE"), rb.getString("qijy241_display.TITLE") }; +// for (String string : p2Values) { +// p20ComboBox.addItem(string); +// } +// this.p20ComboBox.setSelectedItem(bean.getP29()); + } + + // жϱ + public boolean isMust() { +// if (!isMust(partPanel0)) { +// return isMust(partPanel0); +// } +// if (!isMust(partPanel1)) { +// return isMust(partPanel1); +// } +// if (!isMust(partPanel2)) { +// return isMust(partPanel2); +// } + return true; + } + + private boolean isMust(JPanel partPanel) { + for (int i = 0; i < partPanel.getComponentCount(); i++) { + if (partPanel.getComponent(i) instanceof JTextField) { + JTextField textField = (JTextField) partPanel.getComponent(i); + if (textField.getText() == null || textField.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof JAutoCompleteComboBox) { + JAutoCompleteComboBox completeComboBox = (JAutoCompleteComboBox) partPanel.getComponent(i); + if (completeComboBox.getText() == null || completeComboBox.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof MultiComboBox) { + MultiComboBox multiComboBox = (MultiComboBox) partPanel.getComponent(i); + if (multiComboBox.editor.getText() == null || multiComboBox.editor.getText().isEmpty()) { + return false; + } + } else if (partPanel.getComponent(i) instanceof JPanel) { + JPanel chidPanel = (JPanel) partPanel.getComponent(i); + return isMust(chidPanel); + } + + } + + return true; + } + + // Ӽ + public void createActionEvent() { + + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.addNodeItem.addActionListener(this); + this.updateNodItem.addActionListener(this); + this.remNodeItem.addActionListener(this); + + } + + public void getData() { + // ȡд + // this.bean.setP1(this.p1Field.getText()); + this.bean.setP2(this.p2ComboBox.getSelectedItem() == null ? "" : this.p2ComboBox.getSelectedItem().toString()); + this.bean.setP3(this.p3Field.getText()); + this.bean.setP4(this.p4Field.getText()); + this.bean.setP5(this.p5Field.getText()); + this.bean.setP6(this.p6Field.getText()); + this.bean.setP7(this.p7DateButton.getText()); + this.bean.setP8(this.p8DateButton.getText()); + this.bean.setP9(this.p9DateButton.getText()); + this.bean.setP10(this.p10Field.getText()); + this.bean.setP11(this.p11Field.getText()); + this.bean.setP12(this.p12ComboBox.getSelectedItem() == null ? "" : this.p12ComboBox.getSelectedItem().toString()); + this.bean.setP13(this.p13Field.getText()); + this.bean.setP14(this.p14ComboBox.getSelectedItem() == null ? "" : this.p14ComboBox.getSelectedItem().toString()); + this.bean.setP15(this.p15ComboBox.getSelectedItem() == null ? "" : this.p15ComboBox.getSelectedItem().toString()); + this.bean.setP16(this.p16Field.getText()); + this.bean.setP17(this.p17Field.getText()); + this.bean.setP18(this.p18ComboBox.getSelectedItem() == null ? "" : this.p18ComboBox.getSelectedItem().toString()); + this.bean.setP19(this.p19ComboBox.getSelectedItem() == null ? "" : this.p19ComboBox.getSelectedItem().toString()); + this.bean.setP20(this.p20ComboBox.getSelectedItem() == null ? "" : this.p20ComboBox.getSelectedItem().toString()); + this.bean.setP21(this.p21Field.getText()); + //this.bean.setP22(this.p22Button); + this.bean.setP23(this.p23Field.getText()); + this.bean.setP24(this.p24DateButton.getText()); + this.bean.setP25(this.p25ComboBox.getSelectedItem() == null ? "" : this.p25ComboBox.getSelectedItem().toString()); + this.bean.setP26(this.p26DateButton.getText()); + this.bean.setP27(this.p27Field.getText()); + this.bean.setP28(this.p28Field.getText()); + this.bean.setP29(this.p29DateButton.getText()); + this.bean.setP30(this.p30ComboBox.getSelectedItem() == null ? "" : this.p30ComboBox.getSelectedItem().toString()); + this.bean.setP31(this.p31Field.getText()); + this.bean.setP32(this.p32Field.getText()); + this.bean.setP33(this.p33Field.getText()); + this.bean.setP34(this.p34ComboBox.getSelectedItem() == null ? "" : this.p34ComboBox.getSelectedItem().toString()); + this.bean.setP35(this.p35DateButton.getText()); + this.bean.setP36(this.p36Field.getText()); + } + + // 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(false); + partsTable = new CTable(map); + partsTable.setRowHeight(50); + //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; + } + + + +public CTable getNewjTable4(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 = new CTMap(rows, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(true); + partsTable = new CTable(map); + // ʾȾ + 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.getColumnModel() + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + + + @Override + public void actionPerformed(ActionEvent e) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + //ƿʱȡ + movemouse(mainTable4); + movemouse(mainTable5); + movemouse(mainTable6); + movemouse(mainTable7); + movemouse(mainTable8); + movemouse(mainTable9); + + // жϱǷд + if (!isMust()) { + MessageBox.post(rb.getString("btxxbnwk41_display.TITLE"), "", MessageBox.ERROR); + return; + } + TMom041EntrustmentFormOperation operation = new TMom041EntrustmentFormOperation(this.bean, this.isHave,this.comp,deleteRows,dataValueList); + try { + getData(); + getJTable(); + operation.executeOperation(); + if (!isHave) { + isHave = true; + } + this.rootPanel.setBackground(Color.GREEN); + new Thread() { + @Override + public void run() { + try { + + this.sleep(1000); + rootPanel.setBackground(Color.WHITE); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + }.start(); + // MessageBox.post("ɹ", "ɹ", MessageBox.INFORMATION); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + else if (source.equals(this.celButton)) {// + try { + this.itemRevision.lock(); + this.itemRevision.setStringProperty("object_desc", ""); + this.itemRevision.save(); + this.itemRevision.refresh(); + this.itemRevision.unlock(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + this.dispose(); + } + else if (source.equals(this.addNodeItem)) {//ӽڵ + final JFrame frame = new JFrame(); + frame.setLocationRelativeTo(this); + frame.setSize(new Dimension(500, 400)); + // + List> dataListnum = new ArrayList>(); + selectNodeData(dataListnum); + final int i=dataListnum.size()+1;//¼ʵ + // + JLabel typelabel = new JLabel(""); + final JTextField typefield = new JTextField(20); + //ʱ + JLabel timelabel = new JLabel("ʱ"); + final JTextField timefield = new JTextField(20); + //Ʒ + JLabel numlabel = new JLabel("Ʒ"); + final JTextField numfield = new JTextField(20); + //Ҫ + JLabel spelabel = new JLabel("Ҫ"); + final JTextField spefield = new JTextField(20); + + JButton okButton = new JButton("ȷ"); + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + List list =new ArrayList(); + nonode=String.valueOf(i); + typenode = typefield.getText(); + timenode = timefield.getText(); + numnode= numfield.getText(); + spenode= spefield.getText(); + list.add(nonode); + list.add(typenode); + list.add(timenode); + list.add(numnode); + list.add(spenode); + String insterSql = ""; + insterSql = "insert into RB3_TESTFORM values(?,?,?,?,?,?,?)"; + UUID uid = UUID.randomUUID(); + SqlUtilT.getTCConnection(); + SqlUtilT.write( + new String[] { uid.toString().replace("-", ""), + comp.getUid(), nonode, typenode, timenode,numnode,spenode}, + insterSql); + InsertNodeData(list); + refreshmainTable(); + mainTable.HiddenCell(5); + + frame.dispose(); + }}); + 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", nolabel); +// jPanel.add("1.2.left.top", nofield); + jPanel.add("1.1.left.top", typelabel); + jPanel.add("1.2.left.top", typefield); + jPanel.add("2.1.left.top", timelabel); + jPanel.add("2.2.left.top", timefield); + jPanel.add("3.1.left.top", numlabel); + jPanel.add("3.2.left.top", numfield); + jPanel.add("4.1.left.top", spelabel); + jPanel.add("4.2.left.top", spefield); + 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.mainTable; + final JFrame frame = new JFrame(); + frame.setLocationRelativeTo(this); + frame.setSize(new Dimension(500, 400)); + // + final int j=table.getSelectedRow()+1; + // + JLabel typelabel = new JLabel(""); + final JTextField typefield = new JTextField(20); + typefield.setText(table.getValueAt(table.getSelectedRow(),1 ) == null ? "" : table.getValueAt(table.getSelectedRow(),1 ).toString()); + //ʱ + JLabel timelabel = new JLabel("ʱ"); + final JTextField timefield = new JTextField(20); + timefield.setText(table.getValueAt(table.getSelectedRow(),2 ) == null ? "" : table.getValueAt(table.getSelectedRow(),2 ).toString()); + //Ʒ + JLabel numlabel = new JLabel("Ʒ"); + final JTextField numfield = new JTextField(20); + numfield.setText(table.getValueAt(table.getSelectedRow(),3 ) == null ? "" : table.getValueAt(table.getSelectedRow(),3 ).toString()); + //Ҫ + JLabel spelabel = new JLabel("Ҫ"); + final JTextField spefield = new JTextField(20); + spefield.setText(table.getValueAt(table.getSelectedRow(),4 ) == null ? "" : table.getValueAt(table.getSelectedRow(),4 ).toString()); + JButton okButton = new JButton("ȷ"); + okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent arg0) { + // TODO Auto-generated method stub + List list =new ArrayList(); + nonode = String.valueOf(j); + typenode = typefield.getText() == null ? "" : typefield.getText(); + timenode = timefield.getText() == null ? "" : timefield.getText(); + numnode = numfield.getText() == null ? "" : numfield.getText(); + spenode = spefield.getText() == null ? "" : spefield.getText(); + list.add(nonode); + list.add(typenode); + list.add(timenode); + list.add(numnode); + list.add(spenode); + try { + String updateSql = ""; + int row=mainTable.getSelectedRow(); + updateSql = String + .format(updateSql = "update RB3_TESTFORM set P2 = ?,P3 = ?,P4 = ?,P5 = ? where PLMID = \'%s\'", + mainTable.getValueAt(mainTable.getSelectedRow(), 5).toString()); + SqlUtilT.getTCConnection(); + SqlUtilT.write(new String[] { typenode,timenode,numnode,spenode },updateSql); +// refreshmainTable(); +// mainTable.HiddenCell(5); + //ɾȡѡе + String tag=mainTable.getValueAt(row, 0).toString(); + deleteNodeData(tag); + //ٲ + InsertNodeData(list); + //dataListall.clear(); + refreshmainTable(); + mainTable.HiddenCell(5); + frame.dispose(); + } 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", typelabel); + jPanel.add("1.2.left.top", typefield); + jPanel.add("2.1.left.top", timelabel); + jPanel.add("2.2.left.top", timefield); + jPanel.add("3.1.left.top", numlabel); + jPanel.add("3.2.left.top", numfield); + jPanel.add("4.1.left.top", spelabel); + jPanel.add("4.2.left.top", spefield); + 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.remNodeItem)) { + String deleteNodeSql = String + .format("delete from RB3_TESTFORM where PLMID = \'%s\'", + mainTable.getValueAt(mainTable.getSelectedRow(), 5).toString()); + //ȡѡе + String tag=mainTable.getValueAt(mainTable.getSelectedRow(), 0).toString(); + deleteNodeData(tag); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteNodeSql); + //±ڵ + updataMainTableNum(mainTable.getSelectedRow(),mainTable.getRowCount()); + + refreshmainTable(); + SqlUtilT.freeAll(); + mainTable.HiddenCell(5); + + } + } + + //ʼ + public void setJTable2() { + this.TypeList.clear(); + //if(dataList2.size()==0)mainTable.setValueAt(null, i, j); + for (int i =0 ; i < dataList2.size(); i++) { + List rowList = dataList2.get(i); + for (int j = 0; j < header.length; j++) { + mainTable.setValueAt(rowList.get(j+2), i, j); + } + this.TypeList.add(rowList.get(2)); + } + mainTable.HiddenCell(5); + } +//ڵ+++++++++++++++++++++++++++ + public void createtable(List List,String[] head,CTable main) { + CTMap map = new CTMap(List.size(),head.length); + map.setColumnIdentifiers(head); + //map.setEditable(true); + main.setModel(map); + int d=main.getColumnModel().getColumn(2).getPreferredWidth(); + main.getColumnModel().getColumn(0).setPreferredWidth(20); + main.getColumnModel().getColumn(1).setPreferredWidth(20); + } +// public void createmaintable(int List,String[] head,CTable main) { +// CTMap map = new CTMap(List,head.length); +// map.setColumnIdentifiers(head); +// //map.setEditable(true); +// main.setModel(map); +// //main.getColumnModel().getColumn(2).setPreferredWidth(200); +// } +//ݵڵ+++++++++++++++++ + public void setJTable(List> data,CTable main,int start,int over,List Type) { + for (int i =0 ; i < Type.size(); i++) { + List rowList = data.get(i); + main.setValueAt(rowList.get(0), i,0); + main.setValueAt(rowList.get(1), i,1); + for (int j = start; j noty){ + UUID uid = UUID.randomUUID(); + SqlUtilT.getTCConnection(); + String insterSql="insert into RB3_TESTDATA values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + SqlUtilT.write( + new String[] { uid.toString().replace("-", ""), + comp.getUid(), noty.get(1), noty.get(0),null,null,null,null, null,null,null,null,null, null,null,null,null,null, null,null,null,null,null,null}, + insterSql); + } + +//ڵݿɾ + public void deleteNodeData(String tag){ + + String deleteNodeSql = String + .format("delete from RB3_TESTDATA where PUID = \'%s\' AND P1= \'%s\'", + comp.getUid(),tag); + SqlUtilT.getTCConnection(); + SqlUtilT.delete(deleteNodeSql); + } + +//ȡڵ + public void selectNodeData(List> dataList){ + ResultSet rs = null; + SqlUtilT.getTCConnection(); + String sql = String.format("select * from RB3_TESTDATA WHERE PUID = \'%s\' order by P1", comp.getUid()); + try { + rs = SqlUtilT.read(sql); + while(rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("P1")); + rowList.add(rs.getString("TYPE")); + rowList.add(rs.getString("P2")); + rowList.add(rs.getString("p3")); + rowList.add(rs.getString("p4")); + rowList.add(rs.getString("p5")); + rowList.add(rs.getString("P6")); + rowList.add(rs.getString("P7")); + rowList.add(rs.getString("p8")); + rowList.add(rs.getString("p9")); + rowList.add(rs.getString("p10")); + rowList.add(rs.getString("P11")); + rowList.add(rs.getString("P12")); + rowList.add(rs.getString("p13")); + rowList.add(rs.getString("p14")); + rowList.add(rs.getString("p15")); + rowList.add(rs.getString("P16")); + rowList.add(rs.getString("P17")); + rowList.add(rs.getString("p18")); + rowList.add(rs.getString("p19")); + rowList.add(rs.getString("p20")); + rowList.add(rs.getString("p21")); + dataList.add(rowList); + } + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + //ˢ± + private void refreshmainTable() { + dataListall.clear(); + selectNodeData(dataListall); + ResultSet rs = null; + InputStream input = null; + List t=new ArrayList(); + TypeList.clear(); + try { + SqlUtilT.getTCConnection(); + // ȡSQL + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format(pro.getProperty("RB3_TESTFORMSELECT"), comp.getUid()); + rs = SqlUtilT.read(sql); + List bneanList = new ArrayList(); + while (rs.next()) { + TreeBean bean = new TreeBean(); + bean.setP1(rs.getString("P1")); + bean.setP2(rs.getString("P2")); + bean.setP3(rs.getString("P3")); + bean.setP4(rs.getString("P4")); + bean.setP5(rs.getString("P5")); + bean.setPlmeid(rs.getString("PLMID")); + TypeList.add(bean.getP1()); + + bneanList.add(bean); + } + if (bneanList.size() > 0) { + CTMap map = new CTMap(bneanList.size(),header.length); + map.setColumnIdentifiers(header); + mainTable.setModel(map); + for (int i = 0; i < bneanList.size(); i++) { + mainTable.setValueAt(bneanList.get(i).getP1(), i, 0); + mainTable.setValueAt(bneanList.get(i).getP2(), i, 1); + mainTable.setValueAt(bneanList.get(i).getP3(), i, 2); + mainTable.setValueAt(bneanList.get(i).getP4(), i, 3); + mainTable.setValueAt(bneanList.get(i).getP5(), i, 4); + mainTable.setValueAt(bneanList.get(i).getPlmeid(), i, 5); + //TypeList.add(bneanList.get(i).getP2()); + } + }else {//ȫɾʱ + mainTable.setValueAt(null, 0, 0); + mainTable.setValueAt(null, 0, 1); + mainTable.setValueAt(null, 0, 2); + mainTable.setValueAt(null, 0, 3); + mainTable.setValueAt(null, 0, 4); + mainTable.setValueAt(null, 0, 5); + + } + //+++++++ˢ¸ڵ + createtable(TypeList,header4,mainTable4); + setJTable(dataListall,mainTable4,2,4,TypeList); + createtable(TypeList,header5,mainTable5); + setJTable(dataListall,mainTable5,5,7,TypeList); + createtable(TypeList,header6,mainTable6); + setJTable(dataListall,mainTable6,8,11,TypeList); + createtable(TypeList,header7,mainTable7); + setJTable(dataListall,mainTable7,12,17,TypeList); + createtable(TypeList,header8,mainTable8); + setJTable(dataListall,mainTable8,18,19,TypeList); + createtable(TypeList,header9,mainTable9); + setJTable(dataListall,mainTable9,20,21,TypeList); + //+++++++++++ + mainTable.HiddenCell(5); + } 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 getJTable() { + List DataList=new ArrayList(); + for(int i=0;i> datalov) { +// List lovlist =new ArrayList(); +// try { +// TCComponentListOfValuesType itemType = (TCComponentListOfValuesType) session.getTypeComponent(type); +// TCPropertyDescriptor descriptor = itemType.getPropertyDescriptor(property); +// TCComponentListOfValues lov = descriptor.getLOV(); +// String[] strs = lov.getListOfValues().getStringListOfValues();// ʵֵ +// +// for (String s : strs) { +// String displayVal = lov.getListOfValues().getDisplayableValue(s);// ʵֵӦʾֵ +// lovlist.add(s); +// lovlist.add(displayVal); +// datalov.add(lovlist); +// lovlist.clear(); +// } +// +// } catch (TCException e) { +// e.printStackTrace(); +// } +// } + /** + * LOV KeyȡLOVֵ + * + * @param tcsession + * @param s + * @return + */ + public String[] findLovValueByKey(TCSession tcsession, String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + String resultValue = null; + String[] groupDisplayName=null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession + .getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype + .find(s); + if (atccomponentlistofvalues != null&& atccomponentlistofvalues.length > 0) { + tccomponentlistofvalues = atccomponentlistofvalues[0]; + + ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); + + //groupName = rtlistOfValuesInfo.getStringListOfValues(); + groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); + } + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return groupDisplayName; + } + + +//ıʱ± + public void updataMainTableNum(int start,int over) { + for(int i=start;i 0) + { + + TMom041EntrustmentFormCommand command = new TMom041EntrustmentFormCommand(app, + session,comp); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("дίеʧܣ", "", MessageBox.ERROR); + } + } + else + { + MessageBox.post("ѡίе汾", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormOperation.java b/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormOperation.java new file mode 100644 index 0000000..6bb2e64 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom041/TMom041EntrustmentFormOperation.java @@ -0,0 +1,133 @@ +package com.connor.renben.process.plm.tmom041; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.util.MessageBox; + +public class TMom041EntrustmentFormOperation extends AbstractAIFOperation { + + private EntrustmentFormBean bean; + private boolean isHave; + private List deleteRows; + private List> dataValueList; + private InterfaceAIFComponent comp; + + public TMom041EntrustmentFormOperation(EntrustmentFormBean bean, boolean isHave,InterfaceAIFComponent comp,List deleteRows,List> dataValueList) { + // TODO Auto-generated constructor stub + this.bean = bean; + this.isHave = isHave; + this.deleteRows = deleteRows; + this.dataValueList = dataValueList; + this.comp=comp; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + // ȡݿ + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + SqlUtilT.getTCConnection(); + + // ɾ +// for (int i = 0; i < deleteRows.size(); i++) { +// // ȡݿ +// SqlUtilT.getTCConnection(); +// String deleteSQL = String.format( +// pro.getProperty("RB3_TESTFORMDELETE"), +// deleteRows.get(i));//deleteRows.get(i)ΪPLMID +// SqlUtilT.delete(deleteSQL); +// SqlUtilT.freeAll(); +// } +// //£ +// for (int i = 0; i < dataValueList.size(); i++) { +// SqlUtilT.getTCConnection(); +// List rowList = dataValueList.get(i); +// if (rowList.get(0) != null && !rowList.get(0).equals("")) { +// // ȡݿ +// String updateSQL = String.format( +// pro.getProperty("RB3_TESTFORMUPDATE"), +// rowList.get(0)); +// SqlUtilT.update( +// new String[] { rowList.get(1), rowList.get(2), +// rowList.get(3), rowList.get(4), +// rowList.get(5), +// }, updateSQL); +// } else { +// String insertSQL = pro +// .getProperty("CONTROLPLANLIBRARYINSERT"); +// SqlUtilT.write( +// new String[] { +// UUID.randomUUID().toString().replace("-", ""), comp.getUid(),rowList.get(1), rowList.get(2), +// rowList.get(3), rowList.get(4), +// rowList.get(5)}, +// insertSQL); +// } +// SqlUtilT.freeAll(); +// } + + if (isHave) { + // + String updateSQL = String.format(pro.getProperty("RB3_ENTRUSTMENTFORMUPDATE"), bean.getPuid()); + SqlUtilT.update(new String[] { bean.getP1(), bean.getP2(), bean.getP3(), bean.getP4(), bean.getP5(), + bean.getP6(), bean.getP7(), bean.getP8(), bean.getP9(), bean.getP10(), bean.getP11(), + bean.getP12(), bean.getP13(), bean.getP14(), bean.getP15(), bean.getP16(), bean.getP17(), + bean.getP18(), bean.getP19(), bean.getP20(), bean.getP21(), bean.getP22(), bean.getP23(), + bean.getP24(), bean.getP25(), bean.getP26(), bean.getP27(), bean.getP28(), bean.getP29(), + bean.getP30(), bean.getP31(), bean.getP32(), bean.getP33(), bean.getP34(), bean.getP35(), + bean.getP36(), bean.getP37(), bean.getP38(), bean.getP39(), bean.getP40(), bean.getP41(), + bean.getP42(), bean.getP43(), bean.getP44(), bean.getP45(), bean.getP46(), bean.getP47(), + bean.getP48(), bean.getP49(), bean.getP50(), bean.getP51(), bean.getP52(), bean.getP53(), + bean.getP54(), bean.getP55(), bean.getP56(), bean.getP57(), bean.getP58(), bean.getP59(), + bean.getP60(), bean.getP61(), bean.getP62(), bean.getP63(), bean.getP64(), bean.getP65(), + bean.getP66(), bean.getP67(), bean.getP68(),bean.getP69(), bean.getP70(), bean.getP71(),bean.getP72() }, updateSQL); + + } else { + // + String insertSQL = pro.getProperty("RB3_ENTRUSTMENTFORMINSERT"); + SqlUtilT.update(new String[] { bean.getPuid(), bean.getP1(), bean.getP2(), bean.getP3(), bean.getP4(), + bean.getP5(), bean.getP6(), bean.getP7(), bean.getP8(), bean.getP9(), bean.getP10(), + bean.getP11(), bean.getP12(), bean.getP13(), bean.getP14(), bean.getP15(), bean.getP16(), + bean.getP17(), bean.getP18(), bean.getP19(), bean.getP20(), bean.getP21(), bean.getP22(), + bean.getP23(), bean.getP24(), bean.getP25(), bean.getP26(), bean.getP27(), bean.getP28(), + bean.getP29(), bean.getP30(), bean.getP31(), bean.getP32(), bean.getP33(), bean.getP34(), + bean.getP35(), bean.getP36(), bean.getP37(), bean.getP38(), bean.getP39(), bean.getP40(), + bean.getP41(), bean.getP42(), bean.getP43(), bean.getP44(), bean.getP45(), bean.getP46(), + bean.getP47(), bean.getP48(), bean.getP49(), bean.getP50(), bean.getP51(), bean.getP52(), + bean.getP53(), bean.getP54(), bean.getP55(), bean.getP56(), bean.getP57(), bean.getP58(), + bean.getP59(), bean.getP60(), bean.getP61(), bean.getP62(), bean.getP63(), bean.getP64(), + bean.getP65(), bean.getP66(), bean.getP67(), bean.getP68(),bean.getP69(), bean.getP70(), bean.getP71(), bean.getP72() }, insertSQL); + } + SqlUtilT.connection.commit(); + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + throw e; + } finally { + 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/tmom042/TMom042NewProductListOutputCommand.java b/src/com/connor/renben/process/plm/tmom042/TMom042NewProductListOutputCommand.java new file mode 100644 index 0000000..3c5f93f --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom042/TMom042NewProductListOutputCommand.java @@ -0,0 +1,182 @@ +package com.connor.renben.process.plm.tmom042; + +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 org.apache.xmlbeans.impl.xb.xsdschema.Public; +//import org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSAdminClass; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soaictstubs.propertyData_u; + +public class TMom042NewProductListOutputCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private InterfaceAIFComponent comp; + private TCComponentItemRevision itemRevision; + private TCComponent[] MERevisions;//µĹ汾 + private TCComponent[] listRevisions;//汾µ嵥 + private TCComponent[] equipmentRevisions;//豸汾 + private TCComponent[] instrumentRevisions;//DZ汾 + private TCComponent[] frockRevisions;//װ汾toStringɻȡ + final List> frockList = new ArrayList>();//װ + final List> equipmentList = new ArrayList>();//豸 + final List> instrumentList = new ArrayList>();//DZ + final List frockName=new ArrayList();//װ + final List equipmentName=new ArrayList();//豸 + final List instrumentName=new ArrayList(); + + + public TMom042NewProductListOutputCommand(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp) { + // TODO Auto-generated constructor stub + this.session = session; + this.app = app; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision)this.comp;//ȡѡжİ汾 + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // ȡ + MERevisions=itemRevision.getRelatedComponents("ps_children"); + System.out.println("йΪ"+Arrays.toString(MERevisions)); + + + //ȡ嵥 + for(int i=0;i Property=new ArrayList();//һ汾з + Property.add(procedureName); + for(int n=0;n0) { +// frockRevisions=listRevisions[j].getRelatedComponents("ps_children"); +// for(int k=0;k frockProperty=new ArrayList();//һ汾з +// frockProperty.add(procedureName); +// frockProperty.add(equipmentName); +// for(int l=0;l Property, + ICSPropertyDescription[] PropertyName){ + switch (parentClassificationID) { + case 12://װ + frockList.add(Property); + //ȡԵֵΪбѡ + if(frockName.size()<=0) { + frockName.add(""); + //frockName.add("豸"); + for(int n=0;n> frockList = new ArrayList>(); + private List> equipmentList = new ArrayList>(); + private List> instrumentList = new ArrayList>(); + private List frockName=new ArrayList();//װ + private List equipmentName=new ArrayList();//豸 + private List instrumentName=new ArrayList();//DZ + private List frockSelect=new ArrayList();//ѡĹװ + private List equipmentSelect=new ArrayList();//ѡ豸 + private List instrumentSelect=new ArrayList();//ѡDZ + // + private JPanel rootPanel; + private Button okButton; + private Button celButton; + private Button path; + private JTable mainTable1;//װ + private JTable mainTable2;//豸 + private JTable mainTable3;//DZ + private String pathway = null;//ȡ· + + public JPanel partPanel1; + public TMom042NewProductListOutputDialog(AbstractAIFApplication app, TCSession session, + InterfaceAIFComponent comp, List> frockList, + List> equipmentList,List> instrumentList, + List frockName,List equipmentName,List instrumentName) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.comp = comp; + this.itemRevision = (TCComponentItemRevision) this.comp; + this.frockList=frockList; + this.equipmentList=equipmentList; + this.instrumentList=instrumentList; + this.frockName=frockName; + this.equipmentName=equipmentName; + this.instrumentName=instrumentName; + init(); + } + + + private void init() { + this.setTitle("ѡб"); + this.setPreferredSize(new Dimension(980, 750)); + //װ + mainTable1 = new JTable(frockName.size(),2); + mainTable1.setRowHeight(40); + DefaultTableModel model1 =(DefaultTableModel)this.mainTable1.getModel(); //ȡģ + model1.setColumnIdentifiers(new Object[] {"װ" , "ѡ" }); + JScrollPane jslp1 = new JScrollPane(); // jtaӹ + jslp1.setPreferredSize(new Dimension(800, 300)); + jslp1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp1.setViewportView(mainTable1); + JPanel pane1=new JPanel(new FlowLayout()); + pane1.add(jslp1); + setJTable1(); + TableColumn tcm1 = mainTable1.getColumnModel().getColumn(1); + tcm1.setCellEditor(mainTable1.getDefaultEditor(Boolean.class)); + tcm1.setCellRenderer(mainTable1.getDefaultRenderer(Boolean.class)); + + //豸 + mainTable2 = new JTable(equipmentName.size(),2); + mainTable2.setRowHeight(40); + DefaultTableModel model2 =(DefaultTableModel)this.mainTable2.getModel(); //ȡģ + model2.setColumnIdentifiers(new Object[] {"豸" , "ѡ" }); + JScrollPane jslp2 = new JScrollPane(); // jtaӹ + jslp2.setPreferredSize(new Dimension(800, 300)); + jslp2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp2.setViewportView(mainTable2); + JPanel pane2=new JPanel(new FlowLayout()); + pane2.add(jslp2); + setJTable2(); + TableColumn tcm2 = mainTable2.getColumnModel().getColumn(1); + tcm2.setCellEditor(mainTable2.getDefaultEditor(Boolean.class)); + tcm2.setCellRenderer(mainTable2.getDefaultRenderer(Boolean.class)); + + //DZ + mainTable3 = new JTable(instrumentName.size(),2); + mainTable3.setRowHeight(40); + DefaultTableModel model3 =(DefaultTableModel)this.mainTable3.getModel(); //ȡģ + model3.setColumnIdentifiers(new Object[] {"DZ" , "ѡ" }); + JScrollPane jslp3 = new JScrollPane(); // jtaӹ + jslp3.setPreferredSize(new Dimension(800, 300)); + jslp3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + jslp3.setViewportView(mainTable3); + JPanel pane3=new JPanel(new FlowLayout()); + pane3.add(jslp3); + setJTable3(); + TableColumn tcm3 = mainTable3.getColumnModel().getColumn(1); + tcm3.setCellEditor(mainTable3.getDefaultEditor(Boolean.class)); + tcm3.setCellRenderer(mainTable3.getDefaultRenderer(Boolean.class)); + + partPanel1=new JPanel(new PropertyLayout()); + partPanel1.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), + "")); + partPanel1.add("1.1.left.top",pane1); + partPanel1.add("2.1.left.top",pane2); + partPanel1.add("3.1.left.top",pane3); + + ScrollPagePane scrollPane = new ScrollPagePane(partPanel1); + scrollPane.getVerticalScrollBar().setUnitIncrement(50); + this.add(scrollPane, BorderLayout.CENTER); + + rootPanel = new JPanel(new FlowLayout()); + this.path = new Button("ѡ·"); + path.setPreferredSize(new Dimension(100, 30)); + this.okButton = new Button(""); + okButton.setPreferredSize(new Dimension(100, 30)); + this.celButton = new Button("ȡ"); + celButton.setPreferredSize(new Dimension(100, 30)); + rootPanel.add(path); + rootPanel.add(new JLabel(" ")); + rootPanel.add(okButton); + rootPanel.add(new JLabel(" ")); + rootPanel.add(celButton); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.path.addActionListener(this); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.show(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + + if (source.equals(this.okButton)) { + if(pathway==null) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("dclj42_display.TITLE"),"",MessageBox.ERROR); + return; + } + getFrock(); + getEquipment(); + getInstrument(); + printFrock(); + this.dispose(); + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("dycg42_display.TITLE"), "ɹ", MessageBox.WARNING); + }else if(source.equals(this.celButton)) { + this.dispose(); + }else if(source.equals(this.path)) { + selectPath(); + } + + } + + //ȡװ + public void getFrock() { + for(int i=0;i logList=new ArrayList(); + logList=frockList.get(i); + titleRow1 = sheet1.createRow(i+1); + for(int j=0;j logList=new ArrayList(); + logList=equipmentList.get(i); + titleRow2 = sheet2.createRow(i+1); + for(int j=0;j logList=new ArrayList(); + logList=instrumentList.get(i); + titleRow3 = sheet3.createRow(i+1); + for(int j=0;j1) {MEOP3=MEOP2[i].getRelatedComponents("ps_children"); +// name=MEOP2[i].toString(); +// } +// } +// MessageBox.post(MEOP1[5].toString()+"У"+MEOP2.length+"豸"+name+"У"+MEOP3.length, "", MessageBox.ERROR); + + } + else + { + + MessageBox.post(rb.getString("bb42_display.TITLE"), "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/tmom042/TMom042NewProductListOutputOperation.java b/src/com/connor/renben/process/plm/tmom042/TMom042NewProductListOutputOperation.java new file mode 100644 index 0000000..daeb1a5 --- /dev/null +++ b/src/com/connor/renben/process/plm/tmom042/TMom042NewProductListOutputOperation.java @@ -0,0 +1,13 @@ +package com.connor.renben.process.plm.tmom042; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class TMom042NewProductListOutputOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManageTableBean.java b/src/com/connor/renben/process/plm/updataBOM/BOMManageTableBean.java new file mode 100644 index 0000000..c20583b --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManageTableBean.java @@ -0,0 +1,74 @@ +package com.connor.renben.process.plm.updataBOM; + +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +public class BOMManageTableBean { + + private String parentString; + private String childString; + private TCComponentItemRevision parentRev; + private TCComponentItemRevision childRev; + private TCComponentBOMLine parentLine; + private TCComponentBOMLine childLine; + + public BOMManageTableBean(String parentString, String childString, TCComponentItemRevision parentRev, + TCComponentItemRevision childRev, TCComponentBOMLine parentLine, TCComponentBOMLine childLine) { + super(); + this.parentString = parentString; + this.childString = childString; + this.parentRev = parentRev; + this.childRev = childRev; + this.parentLine = parentLine; + this.childLine = childLine; + } + + public String getParentString() { + return parentString; + } + + public void setParentString(String parentString) { + this.parentString = parentString; + } + + public String getChildString() { + return childString; + } + + public void setChildString(String childString) { + this.childString = childString; + } + + public TCComponentItemRevision getParentRev() { + return parentRev; + } + + public void setParentRev(TCComponentItemRevision parentRev) { + this.parentRev = parentRev; + } + + public TCComponentItemRevision getChildRev() { + return childRev; + } + + public void setChildRev(TCComponentItemRevision childRev) { + this.childRev = childRev; + } + + public TCComponentBOMLine getParentLine() { + return parentLine; + } + + public void setParentLine(TCComponentBOMLine parentLine) { + this.parentLine = parentLine; + } + + public TCComponentBOMLine getChildLine() { + return childLine; + } + + public void setChildLine(TCComponentBOMLine childLine) { + this.childLine = childLine; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManagementAction.java b/src/com/connor/renben/process/plm/updataBOM/BOMManagementAction.java new file mode 100644 index 0000000..503e9cb --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManagementAction.java @@ -0,0 +1,29 @@ +package com.connor.renben.process.plm.updataBOM; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BOMManagementAction extends AbstractAIFAction { + + private AbstractAIFApplication app; + + public BOMManagementAction(AbstractAIFApplication arg0, String arg1) { + super(arg0, arg1); + // TODO Auto-generated constructor stub + this.app = arg0; + } + + @Override + public void run() { + // TODO Auto-generated method stub + new BOMManagementFrame(app); + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManagementFrame.java b/src/com/connor/renben/process/plm/updataBOM/BOMManagementFrame.java new file mode 100644 index 0000000..3eb90b8 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManagementFrame.java @@ -0,0 +1,2196 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JCheckBox; +import javax.swing.BorderFactory; +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.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.JTree; +import javax.swing.RowSorter; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableRowSorter; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeSelectionModel; + +import com.eltima.components.ui.DatePicker; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.db.Db; +import cn.hutool.db.Entity; +import cn.hutool.db.sql.Condition; + + + + + +public class BOMManagementFrame extends JFrame { + private AbstractAIFApplication app; + private TCSession session; + private CardLayout rootSwitch = new CardLayout(); + private String[] colDisplayNames = new String[] { "ѡ", "", "Ӽ", "λ", "", "״̬" }; + private String[] colDisplayNames2 = new String[] { "", "޸û", "ʱ", "" }; + private JPanel root; + private Map tableDataMap = new HashMap(); + private BOMManagementFrame $this; + private List logDataList; + private Map winMap = new HashMap(); + private TCComponentItemRevision targetRev; + private TCComponentItemRevision targetRev2; + private boolean isLogcreated = false; + private int doIndex = 0; + private boolean complate = false; + private List checkItemType = new ArrayList(); + private JButton[] topBtns; + private TCComponentBOMWindowType winType; + private int width = 1200; + private int height = 800; + private int widthOffset = 0; + private int heightOffset = 0; + private JLabel p1TargetLabel; + private JButton p1TargetBtn; + private JLabel p1ReplaceLabel; + private JButton p1ReplaceBtn; + private JLabel p1UnitLabel; + private KeyValComboBox p1UnitCombo; + private JLabel p1NumLabel; + private JTextField p1NumText; + private JCheckBox p1SelectAll; + private JTable p1Table; + private JScrollPane p1jsp; + private JButton p1BottomBtn1; + private JButton p1BottomBtn2; + private JButton p1BottomBtn3; + private JButton p1BottomBtn4; + private JPanel p1Left; + private JScrollPane p1TreePanel; + private JPanel p1Right; + private JLabel p2TargetLabel; + private JButton p2TargetBtn; + private JLabel p2ChangeNumLabel; + private JTextField p2NumText; + private JCheckBox p2SelectAll; + private JTable p2Table; + private JScrollPane p2jsp; + private JButton p2BottomBtn1; + private JButton p2BottomBtn2; + private JButton p2BottomBtn3; + private JButton p2BottomBtn4; + private JPanel p2Left; + private JScrollPane p2TreePanel; + private JPanel p2Right; + private JLabel p3TargetLabel; + private JButton p3TargetBtn; + private JLabel p3AddLabel; + private JButton p3AddBtn; + private JLabel p3UnitLabel; + private KeyValComboBox p3UnitCombo; + private JLabel p3NumLabel; + private JTextField p3NumText; + private JCheckBox p3SelectAll; + private JTable p3Table; + private JScrollPane p3jsp; + private JButton p3BottomBtn1; + private JButton p3BottomBtn2; + private JButton p3BottomBtn3; + private JButton p3BottomBtn4; + private JPanel p3Left; + private JScrollPane p3TreePanel; + private JPanel p3Right; + private JLabel p4TargetLabel; + private JButton p4TargetBtn; + private JCheckBox p4SelectAll; + private JTable p4Table; + private JScrollPane p4jsp; + private JButton p4BottomBtn1; + private JButton p4BottomBtn2; + private JButton p4BottomBtn3; + private JButton p4BottomBtn4; + private JPanel p4Left; + private JScrollPane p4TreePanel; + private JPanel p4Right; + private JLabel p5UserLabel; + private JTextField p5UserText; + private JLabel p5TimeLabel; + private DatePicker p5TimeStartText; + private JLabel toLabel; + private DatePicker p5TimeEndText; + private JLabel p5ContentLabel; + private JTextArea p5ContentText; + private JScrollPane p5Contentjsp; + private JButton p5Search; + private JComboBox p5Download; + private JTable p5Table; + private JScrollPane p5jsp; + private Map uiSize = new HashMap<>(); + private JPanel p1; + private JPanel p2; + private JPanel p3; + private JPanel p4; + private JPanel p5; + private Set addedBOMLine = new HashSet<>(); + + private List TopRev = new ArrayList(); + + + public BOMManagementFrame(AbstractAIFApplication app) { + super(); + this.app = app; + this.session = (TCSession) app.getSession(); + $this = this; + String[] prefArray = JDMethodUtil.getPrefStrArray("connor_bom_check_type", session); + if (prefArray != null) { + checkItemType = Arrays.asList(prefArray); + } + TCTypeService service = session.getTypeService(); + try { + this.winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + init(); + } + + private void init() { + this.setTitle("BOM"); + this.setSize(new Dimension(1200, 800)); + this.setLayout(new BorderLayout()); + this.setResizable(true); + //this.setAlwaysOnTop(true); + this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + this.setLocationRelativeTo(null); + this.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + // TODO Auto-generated method stub + super.componentResized(e); + Component comp = e.getComponent(); + $this.widthOffset = comp.getWidth() - $this.width; + $this.heightOffset = comp.getHeight() - $this.height; + if ($this.widthOffset != 0 || $this.heightOffset != 0) { + System.out.println("width===>" + comp.getWidth()); + System.out.println("height===>" + comp.getHeight()); + $this.width = comp.getWidth(); + $this.height = comp.getHeight(); + $this.resize(); + } + } + }); + this.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + $this.setAlwaysOnTop(true); + } + }); + + Container container = this.getContentPane(); + container.setLayout(new BorderLayout()); + container.setSize(new Dimension(1200, 800)); + + TCTypeService typeService = session.getTypeService(); + Vector unitVector = new Vector(); + try { + TCComponent[] uomArray = typeService.getTypeComponent("UnitOfMeasure").extent(); + unitVector.add(new CheckBoxPo(" ", " ")); + for (TCComponent comp : uomArray) { + unitVector.add(new CheckBoxPo(comp.toString(), comp)); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // ͷ + JPanel topBtnPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); + topBtns = new JButton[5]; + topBtns[0] = new JButton("滻"); + topBtns[1] = new JButton(""); + topBtns[2] = new JButton(""); + topBtns[3] = new JButton("ɾ"); + topBtns[4] = new JButton("־"); +// topBtns[5] = new JButton("԰ť"); + topBtns[0].setSelected(true); + for (JButton btn : topBtns) { + topBtnPanel.add(btn); + btn.addActionListener(panelSwitch()); + } + container.add(topBtnPanel, BorderLayout.NORTH); + + // root + root = new JPanel(rootSwitch); + + // 滻 + p1 = new JPanel(); + p1.setLayout(null); + + // 滻 + p1Left = new JPanel(); + p1Left.setLayout(null); + p1Left.setBounds(0, 0, 800, 800); + p1Left.setBorder(BorderFactory.createEtchedBorder()); + + p1TargetLabel = new JLabel("Ŀϱ"); + p1TargetLabel.setBounds(20, 20, 100, 25); + p1TargetBtn = new JButton(); + p1TargetBtn.setBounds(130, 20, 400, 25); + p1ReplaceLabel = new JLabel("滻ϱ"); + p1ReplaceLabel.setBounds(20, 60, 100, 25); + p1ReplaceBtn = new JButton(); + p1ReplaceBtn.setBounds(130, 60, 400, 25); + p1UnitLabel = new JLabel("λ"); + p1UnitLabel.setBounds(560, 60, 50, 25); + p1UnitCombo = new KeyValComboBox(unitVector); + p1UnitCombo.setBounds(610, 60, 50, 25); + p1NumLabel = new JLabel(""); + p1NumLabel.setBounds(680, 60, 50, 25); + p1NumText = new JTextField(); + p1NumText.setBounds(730, 60, 50, 25); + p1SelectAll = new JCheckBox("ȫѡ"); + p1SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p1model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p1Table = new JTable(p1model); + p1Table.getColumnModel().getColumn(0).setMinWidth(60); + p1Table.getColumnModel().getColumn(0).setMaxWidth(60); + p1Table.getColumnModel().getColumn(1).setMinWidth(200); + p1Table.getColumnModel().getColumn(2).setMinWidth(200); + p1Table.getColumnModel().getColumn(3).setMinWidth(100); + p1Table.getColumnModel().getColumn(4).setMinWidth(100); + p1Table.getColumnModel().getColumn(5).setMinWidth(100); + p1Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p1Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p1Table.setRowHeight(25); + p1Table.setAutoscrolls(true); + p1Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p1Table.getTableHeader().setReorderingAllowed(false); + p1Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p1sorter = new TableRowSorter(p1model); + p1Table.setRowSorter(p1sorter); + p1jsp = new JScrollPane(p1Table); + p1jsp.setBounds(20, 130, 760, 500); + + p1BottomBtn1 = new JButton(""); + p1BottomBtn1.setBounds(80, 650, 100, 25); + p1BottomBtn2 = new JButton("滻"); + p1BottomBtn2.setBounds(260, 650, 100, 25); + p1BottomBtn3 = new JButton(""); + p1BottomBtn3.setBounds(440, 650, 100, 25); + p1BottomBtn4 = new JButton("ȡ"); + p1BottomBtn4.setBounds(620, 650, 100, 25); + + p1Left.add(p1TargetLabel); + p1Left.add(p1TargetBtn); + p1Left.add(p1ReplaceLabel); + p1Left.add(p1ReplaceBtn); + p1Left.add(p1UnitLabel); + p1Left.add(p1UnitCombo); + p1Left.add(p1NumLabel); + p1Left.add(p1NumText); + p1Left.add(p1SelectAll); + p1Left.add(p1jsp); + p1Left.add(p1BottomBtn1); + p1Left.add(p1BottomBtn2); + p1Left.add(p1BottomBtn3); + p1Left.add(p1BottomBtn4); + + // 滻ұ + p1Right = new JPanel(); + p1Right.setLayout(null); + p1Right.setBounds(800, 0, 400, 800); + p1Right.setBorder(BorderFactory.createEtchedBorder()); + + p1TreePanel = new JScrollPane(); + p1TreePanel.setBounds(20, 130, 360, 500); + p1Right.add(p1TreePanel); + + // ¼ + p1SelectAll.addItemListener(selectAll(p1Table)); + p1Table.addMouseListener(showTree(p1Right)); + p1BottomBtn4.addActionListener(cancel()); + p1BottomBtn1.addActionListener(batchRevise(p1Table, p1SelectAll)); + p1BottomBtn2.addActionListener(batchReplace()); + p1BottomBtn3.addActionListener(startWorkFlow(p1Table)); + p1TargetBtn.addActionListener(clickSearch(p1Table, p1SelectAll)); + p1ReplaceBtn.addActionListener(clickSearch(null, null)); + + p1.add(p1Left); + p1.add(p1Right); + + // + p2 = new JPanel(); + p2.setLayout(null); + + // + p2Left = new JPanel(); + p2Left.setLayout(null); + p2Left.setBounds(0, 0, 800, 800); + p2Left.setBorder(BorderFactory.createEtchedBorder()); + + p2TargetLabel = new JLabel("Ŀϱ"); + p2TargetLabel.setBounds(20, 20, 100, 25); + p2TargetBtn = new JButton(); + p2TargetBtn.setBounds(130, 20, 400, 25); + p2ChangeNumLabel = new JLabel(""); + p2ChangeNumLabel.setBounds(20, 60, 100, 25); + p2NumText = new JTextField(); + p2NumText.setBounds(130, 60, 50, 25); + + p2SelectAll = new JCheckBox("ȫѡ"); + p2SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p2model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p2Table = new JTable(p2model); + p2Table.getColumnModel().getColumn(0).setMinWidth(60); + p2Table.getColumnModel().getColumn(0).setMaxWidth(60); + p2Table.getColumnModel().getColumn(1).setMinWidth(200); + p2Table.getColumnModel().getColumn(2).setMinWidth(200); + p2Table.getColumnModel().getColumn(3).setMinWidth(100); + p2Table.getColumnModel().getColumn(4).setMinWidth(100); + p2Table.getColumnModel().getColumn(5).setMinWidth(100); + p2Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p2Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p2Table.setRowHeight(25); + p2Table.setAutoscrolls(true); + p2Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p2Table.getTableHeader().setReorderingAllowed(false); + p2Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p2sorter = new TableRowSorter(p2model); + p2Table.setRowSorter(p2sorter); + p2jsp = new JScrollPane(p2Table); + p2jsp.setBounds(20, 130, 760, 500); + + p2BottomBtn1 = new JButton(""); + p2BottomBtn1.setBounds(80, 650, 100, 25); + p2BottomBtn2 = new JButton(""); + p2BottomBtn2.setBounds(260, 650, 100, 25); + p2BottomBtn3 = new JButton(""); + p2BottomBtn3.setBounds(440, 650, 100, 25); + p2BottomBtn4 = new JButton("ȡ"); + p2BottomBtn4.setBounds(620, 650, 100, 25); + + p2Left.add(p2TargetLabel); + p2Left.add(p2TargetBtn); + p2Left.add(p2ChangeNumLabel); + p2Left.add(p2NumText); + p2Left.add(p2SelectAll); + p2Left.add(p2jsp); + p2Left.add(p2BottomBtn1); + p2Left.add(p2BottomBtn2); + p2Left.add(p2BottomBtn3); + p2Left.add(p2BottomBtn4); + + // ұ + p2Right = new JPanel(); + p2Right.setLayout(null); + p2Right.setBounds(800, 0, 400, 800); + p2Right.setBorder(BorderFactory.createEtchedBorder()); + + p2TreePanel = new JScrollPane(); + p2TreePanel.setBounds(20, 130, 360, 500); + p2Right.add(p2TreePanel); + + // ¼ + p2SelectAll.addItemListener(selectAll(p2Table)); + p2Table.addMouseListener(showTree(p2Right)); + p2BottomBtn4.addActionListener(cancel()); + p2BottomBtn1.addActionListener(batchRevise(p2Table, p2SelectAll)); + p2BottomBtn2.addActionListener(batchModify()); + p2BottomBtn3.addActionListener(startWorkFlow(p2Table)); + p2TargetBtn.addActionListener(clickSearch(p2Table, p2SelectAll)); + + p2.add(p2Left); + p2.add(p2Right); + + // + p3 = new JPanel(); + p3.setLayout(null); + + // + p3Left = new JPanel(); + p3Left.setLayout(null); + p3Left.setBounds(0, 0, 800, 800); + p3Left.setBorder(BorderFactory.createEtchedBorder()); + + p3TargetLabel = new JLabel("οϱ"); + p3TargetLabel.setBounds(20, 20, 100, 25); + p3TargetBtn = new JButton(); + p3TargetBtn.setBounds(130, 20, 400, 25); + p3AddLabel = new JLabel("ϱ"); + p3AddLabel.setBounds(20, 60, 100, 25); + p3AddBtn = new JButton(); + p3AddBtn.setBounds(130, 60, 400, 25); + p3UnitLabel = new JLabel("λ"); + p3UnitLabel.setBounds(560, 60, 50, 25); + p3UnitCombo = new KeyValComboBox(unitVector); + p3UnitCombo.setBounds(610, 60, 50, 25); + p3NumLabel = new JLabel(""); + p3NumLabel.setBounds(680, 60, 50, 25); + p3NumText = new JTextField(); + p3NumText.setBounds(730, 60, 50, 25); + + p3SelectAll = new JCheckBox("ȫѡ"); + p3SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p3model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p3Table = new JTable(p3model); + p3Table.getColumnModel().getColumn(0).setMinWidth(60); + p3Table.getColumnModel().getColumn(0).setMaxWidth(60); + p3Table.getColumnModel().getColumn(1).setMinWidth(200); + p3Table.getColumnModel().getColumn(2).setMinWidth(200); + p3Table.getColumnModel().getColumn(3).setMinWidth(100); + p3Table.getColumnModel().getColumn(4).setMinWidth(100); + p3Table.getColumnModel().getColumn(5).setMinWidth(100); + p3Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p3Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p3Table.setRowHeight(25); + p3Table.setAutoscrolls(true); + p3Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p3Table.getTableHeader().setReorderingAllowed(false); + p3Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p3sorter = new TableRowSorter(p3model); + p3Table.setRowSorter(p3sorter); + p3jsp = new JScrollPane(p3Table); + p3jsp.setBounds(20, 130, 760, 500); + + p3BottomBtn1 = new JButton(""); + p3BottomBtn1.setBounds(80, 650, 100, 25); + p3BottomBtn2 = new JButton(""); + p3BottomBtn2.setBounds(260, 650, 100, 25); + p3BottomBtn3 = new JButton(""); + p3BottomBtn3.setBounds(440, 650, 100, 25); + p3BottomBtn4 = new JButton("ȡ"); + p3BottomBtn4.setBounds(620, 650, 100, 25); + + p3Left.add(p3TargetLabel); + p3Left.add(p3TargetBtn); + p3Left.add(p3AddLabel); + p3Left.add(p3AddBtn); + p3Left.add(p3UnitLabel); + p3Left.add(p3UnitCombo); + p3Left.add(p3NumLabel); + p3Left.add(p3NumText); + p3Left.add(p3SelectAll); + p3Left.add(p3jsp); + p3Left.add(p3BottomBtn1); + p3Left.add(p3BottomBtn2); + p3Left.add(p3BottomBtn3); + p3Left.add(p3BottomBtn4); + + // ұ + p3Right = new JPanel(); + p3Right.setLayout(null); + p3Right.setBounds(800, 0, 400, 800); + p3Right.setBorder(BorderFactory.createEtchedBorder()); + + p3TreePanel = new JScrollPane(); + p3TreePanel.setBounds(20, 130, 360, 500); + p3Right.add(p3TreePanel); + + // ¼ + p3SelectAll.addItemListener(selectAll(p3Table)); + p3Table.addMouseListener(showTree(p3Right)); + p3BottomBtn4.addActionListener(cancel()); + p3BottomBtn1.addActionListener(batchRevise(p3Table, p3SelectAll)); + p3BottomBtn2.addActionListener(batchAdd()); + p3BottomBtn3.addActionListener(startWorkFlow(p3Table)); + p3TargetBtn.addActionListener(clickSearch(p3Table, p3SelectAll)); + p3AddBtn.addActionListener(clickSearch(null, null)); + + p3.add(p3Left); + p3.add(p3Right); + + // ɾ + p4 = new JPanel(); + p4.setLayout(null); + + // ɾ + p4Left = new JPanel(); + p4Left.setLayout(null); + p4Left.setBounds(0, 0, 800, 800); + p4Left.setBorder(BorderFactory.createEtchedBorder()); + + p4TargetLabel = new JLabel("Ŀϱ"); + p4TargetLabel.setBounds(20, 20, 100, 25); + p4TargetBtn = new JButton(); + p4TargetBtn.setBounds(130, 20, 400, 25); + + p4SelectAll = new JCheckBox("ȫѡ"); + p4SelectAll.setBounds(20, 100, 100, 25); + DefaultTableModel p4model = new DefaultTableModel(colDisplayNames, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + if (paramInt2 == 0) { + return true; + } + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p4Table = new JTable(p4model); + p4Table.getColumnModel().getColumn(0).setMinWidth(60); + p4Table.getColumnModel().getColumn(0).setMaxWidth(60); + p4Table.getColumnModel().getColumn(1).setMinWidth(200); + p4Table.getColumnModel().getColumn(2).setMinWidth(200); + p4Table.getColumnModel().getColumn(3).setMinWidth(100); + p4Table.getColumnModel().getColumn(4).setMinWidth(100); + p4Table.getColumnModel().getColumn(5).setMinWidth(100); + p4Table.getColumnModel().getColumn(0).setCellRenderer(new MyCellRenderer()); + p4Table.getColumnModel().getColumn(0).setCellEditor(new MyCellEditor4(new JTextField())); + p4Table.setRowHeight(25); + p4Table.setAutoscrolls(true); + p4Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p4Table.getTableHeader().setReorderingAllowed(false); + p4Table.putClientProperty("terminateEditOnFocusLost", true); + RowSorter p4sorter = new TableRowSorter(p4model); + p4Table.setRowSorter(p4sorter); + p4jsp = new JScrollPane(p4Table); + p4jsp.setBounds(20, 130, 760, 500); + + p4BottomBtn1 = new JButton(""); + p4BottomBtn1.setBounds(80, 650, 100, 25); + p4BottomBtn2 = new JButton("ɾ"); + p4BottomBtn2.setBounds(260, 650, 100, 25); + p4BottomBtn3 = new JButton(""); + p4BottomBtn3.setBounds(440, 650, 100, 25); + p4BottomBtn4 = new JButton("ȡ"); + p4BottomBtn4.setBounds(620, 650, 100, 25); + + p4Left.add(p4TargetLabel); + p4Left.add(p4TargetBtn); + p4Left.add(p4SelectAll); + p4Left.add(p4jsp); + p4Left.add(p4BottomBtn1); + p4Left.add(p4BottomBtn2); + p4Left.add(p4BottomBtn3); + p4Left.add(p4BottomBtn4); + + // ұ + p4Right = new JPanel(); + p4Right.setLayout(null); + p4Right.setBounds(800, 0, 400, 800); + p4Right.setBorder(BorderFactory.createEtchedBorder()); + + p4TreePanel = new JScrollPane(); + p4TreePanel.setBounds(20, 130, 360, 500); + p4Right.add(p4TreePanel); + + // ¼ + p4SelectAll.addItemListener(selectAll(p4Table)); + p4Table.addMouseListener(showTree(p4Right)); + p4BottomBtn4.addActionListener(cancel()); + p4BottomBtn1.addActionListener(batchRevise(p4Table, p4SelectAll)); + p4BottomBtn2.addActionListener(batchRemove()); + p4BottomBtn3.addActionListener(startWorkFlow(p4Table)); + p4TargetBtn.addActionListener(clickSearch(p4Table, p4SelectAll)); + + p4.add(p4Left); + p4.add(p4Right); + + // ־ + p5 = new JPanel(); + p5.setLayout(null); + + p5UserLabel = new JLabel("޸û"); + p5UserLabel.setBounds(20, 40, 70, 25); + p5UserText = new JTextField(); + p5UserText.setBounds(100, 40, 150, 25); + p5TimeLabel = new JLabel("޸ʱ"); + p5TimeLabel.setBounds(300, 40, 70, 25); + p5TimeStartText = DatePickerUtil.getDatePicker(null); + p5TimeStartText.setBounds(380, 40, 100, 25); + toLabel = new JLabel(""); + toLabel.setBounds(490, 40, 20, 25); + p5TimeEndText = DatePickerUtil.getDatePicker(null); + p5TimeEndText.setBounds(520, 40, 100, 25); + p5ContentLabel = new JLabel("޸"); + p5ContentLabel.setBounds(670, 40, 70, 25); + p5ContentText = new JTextArea(); + p5ContentText.setLineWrap(true); + p5ContentText.setWrapStyleWord(true); + p5Contentjsp = new JScrollPane(p5ContentText); + p5Contentjsp.setBounds(750, 20, 200, 80); + p5Search = new JButton(""); + p5Search.setBounds(1000, 40, 60, 25); + p5Download = new JComboBox(); + p5Download.addItem("־"); + p5Download.addItem("Ϊtxt"); + p5Download.addItem("Ϊexcel"); + p5Download.setSelectedItem("־"); + p5Download.setBounds(1080, 40, 100, 25); + + DefaultTableModel p5model = new DefaultTableModel(colDisplayNames2, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + + @Override + public Class getColumnClass(int paramInt) { + // TODO Auto-generated method stub + if (paramInt == 0) { + return Integer.class; + } + return super.getColumnClass(paramInt); + } + }; + p5Table = new JTable(p5model); + p5Table.getColumnModel().getColumn(0).setMinWidth(60); + p5Table.getColumnModel().getColumn(0).setMaxWidth(60); + p5Table.getColumnModel().getColumn(1).setMinWidth(200); + p5Table.getColumnModel().getColumn(2).setMinWidth(200); + p5Table.getColumnModel().getColumn(3).setMinWidth(700); + p5Table.setRowHeight(25); + p5Table.setAutoscrolls(true); + p5Table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + p5Table.getTableHeader().setReorderingAllowed(false); + RowSorter p5sorter = new TableRowSorter(p5model); + p5Table.setRowSorter(p5sorter); + p5jsp = new JScrollPane(p5Table); + p5jsp.setBounds(20, 130, 1160, 580); + + // ¼ + p5Search.addActionListener(searchLog()); + p5Download.addItemListener(downloadLog(p5Table)); + p5UserText.addKeyListener(logSearchEnter()); + p5TimeStartText.addKeyListener(logSearchEnter()); + p5TimeEndText.addKeyListener(logSearchEnter()); + + p5.add(p5UserLabel); + p5.add(p5UserText); + p5.add(p5TimeLabel); + p5.add(p5TimeStartText); + p5.add(toLabel); + p5.add(p5TimeEndText); + p5.add(p5ContentLabel); + p5.add(p5Contentjsp); + p5.add(p5Search); + p5.add(p5Download); + p5.add(p5jsp); + + root.add("batchReplace", p1); + root.add("batchModify", p2); + root.add("batchAdd", p3); + root.add("batchRemove", p4); + root.add("updateLog", p5); + + rootSwitch.show(root, "batchReplace"); + container.add(root, BorderLayout.CENTER); + this.setVisible(true); + } + + private ActionListener panelSwitch() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String text = ((JButton) e.getSource()).getText(); + for (int i = 0; i < topBtns.length; i++) { + topBtns[i].setSelected(topBtns[i].getText().equals(text)); + } + switch (text) { + case "滻": + clearTable(p1Table, p1SelectAll); + p1Right.removeAll(); + JScrollPane panel1 = new JScrollPane(); + panel1.setBounds(p1TreePanel.getX(), p1TreePanel.getY(), p1TreePanel.getWidth(), + p1TreePanel.getHeight()); + p1TreePanel = panel1; + p1Right.add(panel1); + p1Right.revalidate(); + p1Right.repaint(); + rootSwitch.show(root, "batchReplace"); + break; + case "": + clearTable(p2Table, p2SelectAll); + p2Right.removeAll(); + JScrollPane panel2 = new JScrollPane(); + panel2.setBounds(p2TreePanel.getX(), p2TreePanel.getY(), p2TreePanel.getWidth(), + p2TreePanel.getHeight()); + p2TreePanel = panel2; + p2Right.add(panel2); + p2Right.revalidate(); + p2Right.repaint(); + rootSwitch.show(root, "batchModify"); + break; + case "": + clearTable(p3Table, p3SelectAll); + p3Right.removeAll(); + JScrollPane panel3 = new JScrollPane(); + panel3.setBounds(p3TreePanel.getX(), p3TreePanel.getY(), p3TreePanel.getWidth(), + p3TreePanel.getHeight()); + p3TreePanel = panel3; + p3Right.add(panel3); + p3Right.revalidate(); + p3Right.repaint(); + rootSwitch.show(root, "batchAdd"); + break; + case "ɾ": + clearTable(p4Table, p4SelectAll); + p4Right.removeAll(); + JScrollPane panel4 = new JScrollPane(); + panel4.setBounds(p4TreePanel.getX(), p4TreePanel.getY(), p4TreePanel.getWidth(), + p4TreePanel.getHeight()); + p4TreePanel = panel4; + p4Right.add(panel4); + p4Right.revalidate(); + p4Right.repaint(); + rootSwitch.show(root, "batchRemove"); + break; + case "־": + createLogDataSourceTable(); + clearTable(p5Table, null); + rootSwitch.show(root, "updateLog"); + break; + default: +// createLogDataSourceTable(); + } + } + }; + } + + private void showWhereUesd(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + // TODO Auto-generated method stub + clearTable(table, selectAll); + if (table == null || targetRev == null) { + return; + } + long startTime = System.currentTimeMillis(); + List tableDataList = new ArrayList(); + try { + String revString = targetRev.getProperty("object_string"); + TCComponent[] usedComps = targetRev.whereUsed((short) 0); + System.out.println("װ======>" + usedComps.length); + + tableDataMap.clear(); +// Map usedMap = usedFilter(usedComps); +// for (Entry entry : usedMap.entrySet()) { + for (TCComponentItemRevision parentRev : usedFilter(usedComps)) { +// TCComponentItemRevision parentRev = entry.getValue(); + String parentString = parentRev.getProperty("object_string"); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.put(parentString, win); + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (revString.equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + Object[] rowData = new Object[] { new JCheckBox(), parentString, revString, unit, num, status }; + rowPrint(rowData); + tableDataList.add(rowData); + tableDataMap.put(parentString, + new BOMManageTableBean(parentString, revString, parentRev, targetRev, topLine, child)); + // TODO bomһchildܻ쳣ֻӰһ + break; + } + } + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + if (tableDataList == null || tableDataList.size() == 0) { + JOptionPane.showMessageDialog($this, "ҵӦ󣬵öûκװװöľ°汾ȷϱǷȷ", "ʾ", + JOptionPane.WARNING_MESSAGE); + return; + } + + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("װʾɣʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + + //++++ + //private MouseAdapter showTree(JPanel panelRight) { + //++++ + private MouseAdapter showTree(final JPanel panelRight) { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + JTable table = (JTable) e.getSource(); + String parentString = table.getValueAt(table.getSelectedRow(), 1).toString(); + System.out.println("select row=====>" + table.getSelectedRow()); + System.out.println("parentName=====>" + parentString); + CustomLovBean lovBean = null; + try { + lovBean = new CustomLovBean(tableDataMap.get(parentString).getChildString()); + CustomLovBean subBean = new CustomLovBean(parentString); + lovBean.addSub(subBean); + getTreeData(tableDataMap.get(parentString).getParentRev(), subBean); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + panelRight.removeAll(); + JTree tree = createTree(lovBean); + JScrollPane treePanel = new JScrollPane(tree); + treePanel.setBounds(20, 130, 360, 500); + panelRight.add(treePanel); + panelRight.revalidate(); + panelRight.repaint(); + } + } + }; + } + + private void getTreeData(TCComponent rev, CustomLovBean lov) throws TCException { + TCComponent[] comps = rev.whereUsed((short) 0); + if (comps == null || comps.length == 0) { + return; + } + for (TCComponent comp : comps) { + CustomLovBean sub = new CustomLovBean(comp.getProperty("object_string")); + System.out.println(sub.displayName); + lov.addSub(sub); + getTreeData(comp, sub); + } + } + + private void getTopBom(TCComponent rev) throws TCException { + TCComponent[] comps = rev.whereUsed((short) 0); + if (comps == null || comps.length == 0) { + if(!TopRev.contains((TCComponentItemRevision)rev)) { + TopRev.add((TCComponentItemRevision)rev); + } + return; + }else { + for (TCComponent comp : comps) { + getTopBom(comp); + } + } + } + + private void clearTable(JTable table, JCheckBox selectAll) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + table.revalidate(); + table.repaint(); + if (selectAll != null) { + selectAll.setSelected(false); + } + tableDataMap.clear(); + addedBOMLine.clear(); + try { + closeWin(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private JTree createTree(CustomLovBean lovData) { + if (lovData == null || "".equals(lovData.displayName)) { + return new JTree(); + } + DefaultMutableTreeNode root = new DefaultMutableTreeNode(lovData.displayName); + DefaultMutableTreeNode parent = root; + DefaultTreeModel treeModel = new DefaultTreeModel(root); + + initTree(lovData, parent, treeModel); + + JTree tree = new JTree(treeModel); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + cellRenderer.setTextNonSelectionColor(Color.black); + cellRenderer.setTextSelectionColor(Color.blue); + return tree; + } + + private void initTree(CustomLovBean lovData, DefaultMutableTreeNode parent, DefaultTreeModel treeModel) { + if (!lovData.hasChild()) { + return; + } + List subList = lovData.getSub(); + for (CustomLovBean sub : subList) { + DefaultMutableTreeNode temp = new DefaultMutableTreeNode(sub.displayName); + treeModel.insertNodeInto(temp, parent, parent.getChildCount()); + initTree(sub, temp, treeModel); + } + } + //++++ + //private ItemListener selectAll(JTable table) { + //++++ + private ItemListener selectAll(final JTable table) { + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent e) { + // TODO Auto-generated method stub + boolean select = ((JCheckBox) e.getSource()).isSelected(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox checkBox = (JCheckBox) table.getValueAt(i, 0); + checkBox.setSelected(select); + table.revalidate(); + table.repaint(); + } + } + }; + } + + private ActionListener cancel() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + $this.dispose(); + } + }; + } + + private ActionListener batchRevise(final JTable table,final JCheckBox selectAll) {//++++final + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkAccess(selectedRowList).isRes()) { + return; + } + List msgData = new ArrayList(); + for (int i = 0; i < selectedRowList.size(); i++) { + try { + TCComponentItemRevision newRev = selectedRowList.get(i).getParentRev().saveAs(null); + String parentString = newRev.getProperty("object_string"); + selectedRowList.get(i).setParentRev(newRev); + selectedRowList.get(i).setParentString(parentString); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + newRev.getProperty("object_string"), "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); +// JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + msgData.add(new String[] { msgData.size() + 1 + "", selectedRowList.get(i).getParentString(), + "", "ʧܣ" + e1.getMessage() }); + } + } + +// showWhereUesd(table, selectAll); + updateSelectedRow(table, selectedRowList); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "汾(ǰ)", "汾()", "" }, + msgData).panel; + JOptionPane.showMessageDialog($this, jsp, "", JOptionPane.PLAIN_MESSAGE); + } + }; + } + + private List usedFilter(TCComponent[] comps) throws TCException { +// Map sameParentUsedMap = new HashMap(); + List list = new ArrayList<>(); + for (TCComponent comp : comps) { + if (comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision) comp; +// String itemId; +// if (sameParentUsedMap.containsKey(itemId = comp.getProperty("item_id"))) { +// if (sameParentUsedMap.get(itemId).getProperty("item_revision_id") +// .compareTo(comp.getProperty("item_revision_id")) < 0) { +// sameParentUsedMap.put(itemId, rev); +// } +// } else { + if (rev.getItem().getLatestItemRevision().getUid().equals(rev.getUid())) { + list.add(rev); + } +// sameParentUsedMap.put(itemId, rev); +// } + } + } + return list; + } + + private void createLogDataSourceTable() { + if (isLogcreated) { + return; + } + String sql1 = "CREATE TABLE JD2_BOMManageLog ( id NUMBER ( 38, 0 ) primary key, modify_user VARCHAR2 ( 200 ), modify_time DATE, modify_content VARCHAR2 ( 500 ))"; + String sql2 = "CREATE sequence JD2_BOMManageLog_seq minvalue 1 maxvalue 99999999 INCREMENT BY 1 START WITH 1"; + String sql3 = "CREATE OR REPLACE TRIGGER JD2_BOMManageLog_tri before INSERT ON JD2_BOMManageLog FOR each ROW BEGIN SELECT JD2_BOMManageLog_seq.nextval INTO : new.id FROM dual; END;"; + try { + List temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_tables", + new Condition("table_name", "JD2_BOMMANAGELOG")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql1); + System.out.println("JD2_BOMMANAGELOG create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("user_sequences", + new Condition("sequence_name", "JD2_BOMMANAGELOG_SEQ")); + if (temp == null || temp.size() == 0) { + Db.use(DBUtil.getDataSource(session)).execute(sql2); + System.out.println("JD2_BOMMANAGELOG_SEQ create success"); + } + temp = null; + temp = Db.use(DBUtil.getDataSource(session)).findBy("all_triggers", + new Condition("trigger_name", "JD2_BOMMANAGELOG_TRI")); + if (temp == null || temp.size() == 0) { + DBConnectionUtil.dbConn(session).createStatement().execute(sql3); + System.out.println("JD2_BOMManageLog_tri create success"); + } + isLogcreated = true; + System.out.println("init log success"); + } catch (Exception e) { + // TODO Auto-generated catch block + JOptionPane.showMessageDialog($this, "ݿʧܣѡrb_db_settings", "", JOptionPane.ERROR_MESSAGE); + e.printStackTrace(); + } + } + + private ActionListener searchLog() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String username = p5UserText.getText().trim(); + String content = p5ContentText.getText(); + if (username == null || "".equals(username)) { + return; + } + + String sql = "select * from JD2_BOMMANAGELOG where "; + if (!"*".equals(username)) { + sql += "modify_user like '%" + username + "%' and"; + } + sql += " modify_time between to_date('" + p5TimeStartText.getText() + + " 00:00:00','yyyy-MM-dd hh24:mi:ss') and to_date('" + p5TimeEndText.getText() + + " 23:59:59','yyyy-MM-dd hh24:mi:ss')"; + if (content != null && !"".equals(content)) { + sql += " and modify_content like '%" + content + "%'"; + } + sql += "order by MODIFY_TIME asc"; + System.out.println(sql); + try { + logDataList = Db.use(DBUtil.getDataSource(session)).query(sql); + System.out.println("log size=====>" + logDataList.size()); + DefaultTableModel model = (DefaultTableModel) p5Table.getModel(); + for (Entity entity : logDataList) { + Object[] objArr = new Object[] { entity.get("ID"), entity.get("MODIFY_USER"), + entity.get("MODIFY_TIME"), entity.get("MODIFY_CONTENT") }; + model.addRow(objArr); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + p5Table.revalidate(); + p5Table.repaint(); + } + }; + } + + private ItemListener downloadLog(final JTable table) {//++++final + return new ItemListener() { + + @Override + public void itemStateChanged(ItemEvent paramItemEvent) { + // TODO Auto-generated method stub + if (paramItemEvent.getStateChange() == ItemEvent.DESELECTED) { + return; + } + String selectItem = ((JComboBox) paramItemEvent.getSource()).getSelectedItem().toString(); + System.out.println(selectItem); + if (!selectItem.contains("txt") && !selectItem.contains("excel")) { + return; + } + if (table.getRowCount() > 0) { + JFileChooser chooser = new JFileChooser(); + chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + chooser.setMultiSelectionEnabled(false); + chooser.setCurrentDirectory(FileSystemView.getFileSystemView().getHomeDirectory()); + chooser.showOpenDialog($this); + File folder = chooser.getSelectedFile(); + if (folder == null) { + p5Download.setSelectedItem("־"); + return; + } + String fileName = ""; + if (selectItem.contains("txt")) { + FileWriter fileWriter = null; + fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".txt"; + try { + fileWriter = new FileWriter(folder.getPath() + File.separator + fileName);// ıļ + String temp; + System.out.println(logDataList.size()); + for (Entity entity : logDataList) { + fileWriter.write((temp = entity.get("ID").toString()) + + StringCreateUtil.createBlank(10 - temp.length()) + + (temp = entity.get("MODIFY_USER").toString()) + + StringCreateUtil.createBlank(20 - temp.length()) + + (temp = entity.get("MODIFY_TIME").toString()) + + StringCreateUtil.createBlank(30 - temp.length()) + + entity.get("MODIFY_CONTENT").toString() + "\r\n"); + } + fileWriter.flush(); + fileWriter.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return; + } + } else { + fileName = "BOM־-" + new SimpleDateFormat("yyyyMMddHHmm").format(new Date()) + ".xlsx"; + String[] header = new String[] { "", "޸û", "ʱ", "" }; + List data = new ArrayList<>(); + System.out.println(logDataList.size()); + for (Entity entity : logDataList) { + data.add(new String[] { entity.get("ID").toString(), entity.get("MODIFY_USER").toString(), + entity.get("MODIFY_TIME").toString(), entity.get("MODIFY_CONTENT").toString() }); + } + SimpleExcelUtil.exportExcel(folder.getPath() + File.separator + fileName, header, data); + + } + + JOptionPane.showMessageDialog($this, "־ɹ\r\n·" + folder + File.separator + fileName, "ʾ", + JOptionPane.WARNING_MESSAGE); + p5Download.setSelectedItem("־"); + } + } + }; + + } + + private ActionListener batchReplace() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p1NumText.getText().trim(); + String text = p1UnitCombo.getSelectedText().trim(); + Object value = p1UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p1Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + L1: for (int i = 0; i < selectedRowList.size(); i++) { + try { + doIndex++; + BOMManageTableBean bean = selectedRowList.get(i); + System.out.println(value.toString()); + if (!addedBOMLine.add(bean.getParentRev().getUid() + targetRev2.getUid())) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), value.toString(), + numStr, "ʧܣ滻һΣ滻" }); + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), targetRev2.getProperty("object_string"), + value.toString(), numStr, "ʧܣѴͬӼ" }); + continue L1; + } + } + String seq = selectedRowList.get(i).getChildLine().getProperty("bl_sequence_no"); + bean.getParentLine().remove("", bean.getChildLine()); + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity", "bl_sequence_no" }, + new String[] { numStr, seq }); + msgData.add( + new String[] { msgData.size() + 1 + "", bean.getParentString(), bean.getChildString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + selectedRowList.get(i).setChildString(targetRev2.getProperty("object_string")); + selectedRowList.get(i).setChildRev(targetRev2); + selectedRowList.get(i).setChildLine(childLine); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("滻ִϣʱ" + (endTime - startTime) + "ms"); + doLog("滻", msgData); + JScrollPane jsp = DialogUtil + .createTableMsg(new String[] { "", "", "ԭӼ", "滻Ӽ", "λ", "", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "滻 ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow2(p1Table, selectedRowList); + } + }; + } + + private ActionListener batchModify() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p2NumText.getText(); + List selectedRowList = getselectedRow(p2Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + for (BOMManageTableBean bean : selectedRowList) { + String oldNumStr = ""; + try { + doIndex++; + oldNumStr = bean.getChildLine().getProperty("bl_quantity"); + bean.getChildLine().setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), oldNumStr, numStr, "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("޸", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "ԭ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "Ľ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); + updateSelectedRow(p2Table, selectedRowList); + } + }; + } + + private ActionListener batchAdd() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String numStr = p3NumText.getText().trim(); + String text = p3UnitCombo.getSelectedText().trim(); + Object value = p3UnitCombo.getSelectedValue(); + System.out.println(numStr); + if ("".equals(numStr) || "".equals(text) || targetRev2 == null) { + JOptionPane.showMessageDialog($this, "δдϢд", "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } + List selectedRowList = getselectedRow(p3Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + L1: for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + System.out.println(value.toString()); + if (!addedBOMLine.add(bean.getParentRev().getUid() + targetRev2.getUid())) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, + "ʧܣӹһΣظ" }); + continue L1; + } + AIFComponentContext[] aifs = bean.getParentLine().getChildren(); + for (AIFComponentContext aif : aifs) { + String objStr = ((TCComponentBOMLine) aif.getComponent()).getItemRevision() + .getProperty("object_string"); + if (objStr.equals(targetRev2.getProperty("object_string"))) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, + "ʧܣѴͬӼ" }); + continue L1; + } + } + TCComponentBOMLine childLine = bean.getParentLine().add(targetRev2.getItem(), targetRev2, null, + false, ""); + childLine.setReferenceProperty("bl_uom", (TCComponent) value); + childLine.setProperties(new String[] { "bl_quantity" }, new String[] { numStr }); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + targetRev2.getProperty("object_string"), value.toString(), numStr, "ɹ" }); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ִϣʱ" + (endTime - startTime) + "ms"); + doLog("", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "Ӽ", "λ", "", "" }, + msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, " ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// showWhereUesd(p3Table, p3SelectAll); + } + }; + } + + private ActionListener batchRemove() { + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + List selectedRowList = getselectedRow(p4Table); + if (selectedRowList.size() == 0) { + return; + } + if (!checkTargetAndSelect(targetRev, selectedRowList)) { + return; + } + long startTime = System.currentTimeMillis(); + updateTitleShowProgress(selectedRowList); + List msgData = new ArrayList(); + for (BOMManageTableBean bean : selectedRowList) { + try { + doIndex++; + if (bean.getChildLine() == null) { + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "bomLineڣѾɹɾ" }); + } else { + bean.getParentLine().remove("", bean.getChildLine()); + msgData.add(new String[] { msgData.size() + 1 + "", bean.getParentString(), + bean.getChildString(), "ɹ" }); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + complate = true; + return; + } + } + try { + saveWin(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + JOptionPane.showMessageDialog($this, e1.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return; + } finally { + complate = true; + } + long endTime = System.currentTimeMillis(); + System.out.println("ɾִϣʱ" + (endTime - startTime) + "ms"); + doLog("ɾ", msgData); + JScrollPane jsp = DialogUtil.createTableMsg(new String[] { "", "", "ɾӼ", "" }, msgData).panel; + JOptionPane + .showMessageDialog( + $this, jsp, "ɾ ɹ(" + getResultNum(msgData, true) + ") ʧ(" + + getResultNum(msgData, false) + ") ʱ" + (endTime - startTime) + "ms", + JOptionPane.PLAIN_MESSAGE); +// removeSelectRow(p4Table); + updateSelectedRow3(p4Table, selectedRowList); + } + }; + } + + private List getselectedRow(JTable table) { + List selectedList = new ArrayList(); + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + System.out.println("select=====>" + table.getValueAt(i, 1)); + selectedList.add(tableDataMap.get(table.getValueAt(i, 1))); + } + } + return selectedList; + } + + private void updateSelectedRow(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + try { + TCComponentItemRevision parentRev = newRowData.get(index).getParentRev(); + String parentString = newRowData.get(index).getParentString(); + TCComponentBOMWindow win = winType.create(null); + TCComponentBOMLine topLine = win.setWindowTopLine(parentRev.getItem(), parentRev, null, null); + winMap.get(table.getValueAt(i, 1).toString()).close(); + winMap.remove(table.getValueAt(i, 1)); + winMap.put(parentString, win); + tableDataMap.remove(table.getValueAt(i, 1).toString()); + TCComponent[] statusArray = parentRev.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + AIFComponentContext[] aifs = topLine.getChildren(); + for (AIFComponentContext aif : aifs) { + TCComponentBOMLine child = (TCComponentBOMLine) aif.getComponent(); + if (newRowData.get(index).getChildString() + .equals(child.getItemRevision().getProperty("object_string"))) { + + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + + JCheckBox selected = new JCheckBox(); + selected.setSelected(true); + Object[] rowData = new Object[] { selected, parentString, + newRowData.get(index).getChildString(), unit, num, status }; + rowPrint(rowData); + for (int ii = 0; ii < rowData.length; ii++) { + table.setValueAt(rowData[ii], i, ii); + } + tableDataMap.put(parentString, new BOMManageTableBean(parentString, + newRowData.get(index).getChildString(), parentRev, targetRev, topLine, child)); + break; + } + } + index++; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow2(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + try { + TCComponentBOMLine child = bean.getChildLine(); + String unit = child.getProperty("bl_uom"); + String num = child.getProperty("bl_quantity"); + table.setValueAt(bean.getChildString(), i, 2); + table.setValueAt(unit, index, 3); + table.setValueAt(num, index, 4); + tableDataMap.get(bean.getParentString()).setChildRev(bean.getChildRev()); + tableDataMap.get(bean.getParentString()).setChildString(bean.getChildString()); + tableDataMap.get(bean.getParentString()).setChildLine(child); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void updateSelectedRow3(JTable table, List newRowData) { + int index = 0; + for (int i = 0; i < table.getRowCount(); i++) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + BOMManageTableBean bean = newRowData.get(index); + table.setValueAt("", i, 2); + table.setValueAt("", index, 3); + table.setValueAt("", index, 4); + tableDataMap.get(bean.getParentString()).setChildLine(null); + index++; + } + } + table.revalidate(); + table.repaint(); + } + + private void removeSelectRow(JTable table) { + DefaultTableModel model = (DefaultTableModel) table.getModel(); + int i = 0; + while (i < table.getRowCount()) { + JCheckBox select = (JCheckBox) table.getValueAt(i, 0); + if (select.isSelected()) { + model.removeRow(i); + continue; + } + i++; + } + table.revalidate(); + table.repaint(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + new Thread(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + try { + closeWin(); + System.out.println("closed"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }).start(); + + super.dispose(); + } + + private void saveWin() throws TCException { + for (Entry entry : winMap.entrySet()) { + if (entry.getValue() != null) { + entry.getValue().save(); + } + + } + } + + private void closeWin() throws TCException { + saveWin(); + + for (Entry entry : winMap.entrySet()) { + entry.getValue().close(); + } + winMap.clear(); + } + + private void doLog(String operation, List msgData) { + createLogDataSourceTable(); + String content = ""; + if ("滻".equals(operation)) { + content = "%sӼ%s滻Ϊ%s;%s;%s"; + } else if ("޸".equals(operation)) { + content = "%sӼ%s%sΪ%s"; + } else if ("".equals(operation)) { + content = "%sӼ%s;%s;%s"; + } else if ("ɾ".equals(operation)) { + content = "%sɾӼ%s"; + } + String username = ""; + try { + username = session.getUser().getUserName() + "(" + session.getUser().getUserId() + ")"; + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + String datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + + List sqls = new ArrayList(); + int num = StrUtil.count(content, "%s"); + for (String[] arr : msgData) { + String temp; + String[] row = new String[num]; + for (int i = 0; i < num; i++) { + row[i] = arr[i + 1]; + } + temp = String.format(content, row); + String sql = "insert into JD2_BOMMANAGELOG (MODIFY_USER,MODIFY_TIME,MODIFY_CONTENT) VALUES ('" + username + + "',to_date('" + datetime + "','yyyy-MM-dd hh24:mi:ss'),'" + temp + "')"; + sqls.add(sql); + } + + try { + Db.use(DBUtil.getDataSource(session)).executeBatch(sqls.toArray(new String[sqls.size()])); + } catch (SQLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private ActionListener clickSearch(final JTable table,final JCheckBox selectAll) {//++++final + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + final JDialog content = DialogUtil.createSearchAndSelectRevDialog($this, table, selectAll,//++++final + (JButton) e.getSource()); + } + }; + } + + public void okCallback(JTable revTable, JTable table, JCheckBox selectAll, JButton field) { + // TODO Auto-generated method stub + int rowIndex = revTable.getSelectedRow(); + if (rowIndex < 0) { + return; + } + String text = revTable.getValueAt(rowIndex, 0).toString(); + System.out.println(text); + field.setText(text); + if ("".equals(text)) { + return; + } + if (table != null) { + targetRev = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + showWhereUesd(table, selectAll); + } else { + targetRev2 = (TCComponentItemRevision) revTable.getValueAt(rowIndex, 5); + } + } + + private KeyAdapter logSearchEnter() { + return new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + // TODO Auto-generated method stub + super.keyTyped(e); + if (e.getKeyChar() == KeyEvent.VK_ENTER) { + p5Search.doClick(); + } + } + }; + } + + private void updateTitleShowProgress(final List list) {//++++final + new Thread(new Runnable() { + + @Override + public void run() { + int num = 1; + String temp; + doIndex = 0; + while (!complate) { + $this.setTitle("ڴ" + (temp = StringCreateUtil.createPoint(num % 3)) + + StringCreateUtil.createBlank(5 - temp.length()) + list.get(doIndex).getParentString() + + " " + (doIndex + 1) + "/" + list.size()); + try { + Thread.sleep(200); + } catch (InterruptedException e) { + e.printStackTrace(); + } + num++; + } + $this.setTitle("BOM"); + doIndex = -1; + complate = false; + } + }).start(); + } + + private boolean checkReleaseStatus(TCComponentItemRevision rev) { + try { + System.out.println("item type======>" + rev.getItem().getType()); + if (checkItemType.contains(rev.getItem().getType())) { + return true; + } + TCComponent form = rev.getRelatedComponents("IMAN_master_form_rev")[0]; + TCComponent[] statusArray = form.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + if (!"".equals(status)||!" ".equals(status)||status!=null) { + return false; + } + return true; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return true; + } + + private ResultData checkAccess(List data) { + for (BOMManageTableBean bean : data) { + boolean isAccess = true; + try { + isAccess = session.getTCAccessControlService().checkPrivilege(bean.getParentLine(), "WRITE"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (!isAccess) { + try { + return new ResultData(false, "ǰûûж" + bean.getParentLine().getProperty("object_string") + "дȨ", + bean.getParentLine()); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return new ResultData(true, "", null); + } + + private boolean checkTargetAndSelect(TCComponentItemRevision rev, List data) { + if (!checkReleaseStatus(rev)) { + JOptionPane.showMessageDialog($this, "Ŀδߴڶ״̬޷BOM", "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + ResultData res = checkAccess(data); + if (!res.isRes()) { + JOptionPane.showMessageDialog($this, res.getMessage(), "ʾ", JOptionPane.WARNING_MESSAGE); + return false; + } + return true; + } + //̷̣ + private ActionListener startWorkFlow(final JTable table) {//++++final + return new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + final List select = getselectedRow(table); + List parentRev = new ArrayList<>(); + + //+++++ȡbom + if(select.size()==0||select==null){//ȫûѡͷж + try { + getTopBom(targetRev); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + }else {//ѡ˾ͷѡbom͹ѡĶbom + for (BOMManageTableBean bean : select) { + parentRev.add(bean.getParentRev()); + try { + getTopBom(bean.getParentRev()); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + + } + for(TCComponentItemRevision Rev:TopRev) { + parentRev.add(Rev); + } + TopRev.clear(); + //TopRev.clear(); + //++++ + $this.setExtendedState(JFrame.ICONIFIED); + NewProcessCommand command = new NewProcessCommand(AIFUtility.getActiveDesktop(), app, + parentRev.toArray(new TCComponentItemRevision[parentRev.size()])); + } + }; + } + + private void rowPrint(Object[] arr) { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (Object obj : arr) { + if (obj instanceof JCheckBox) { + sb.append(((JCheckBox) obj).isSelected()); + } else { + sb.append(obj.toString()); + } + sb.append(","); + } + if (sb.length() > 1) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append("]"); + System.out.println(sb.toString()); + } + + private void resize() { + double left = 2 * this.widthOffset / 3.0; + double right = this.widthOffset - left; + + int bottom1 = p1BottomBtn2.getX() - p1BottomBtn1.getX() - p1BottomBtn1.getWidth(); + int bottom2 = p1BottomBtn3.getX() - p1BottomBtn2.getX() - p1BottomBtn2.getWidth(); + int botttom3 = p1BottomBtn4.getX() - p1BottomBtn3.getX() - p1BottomBtn3.getWidth(); + + // p1 + int p1x1 = p1TargetBtn.getX() - p1TargetLabel.getX() - p1TargetLabel.getWidth(); + int p1x2 = p1ReplaceBtn.getX() - p1ReplaceLabel.getX() - p1ReplaceLabel.getWidth(); + int p1x3 = p1UnitLabel.getX() - p1ReplaceBtn.getX() - p1ReplaceBtn.getWidth(); + int p1x4 = p1NumLabel.getX() - p1UnitCombo.getX() - p1UnitCombo.getWidth(); + p1TargetLabel.setBounds(p1TargetLabel.getX() + getOffset(left, 20, 800), 20, + p1TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p1TargetBtn.setBounds(p1TargetLabel.getX() + p1TargetLabel.getWidth() + p1x1 + getOffset(left, 10, 800), 20, + p1TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p1ReplaceLabel.setBounds(p1ReplaceLabel.getX() + getOffset(left, 20, 800), 60, + p1ReplaceLabel.getWidth() + getOffset(left, 100, 800), 25); + p1ReplaceBtn.setBounds(p1ReplaceLabel.getX() + p1ReplaceLabel.getWidth() + p1x2 + getOffset(left, 10, 800), 60, + p1ReplaceBtn.getWidth() + getOffset(left, 400, 800), 25); + p1UnitLabel.setBounds(p1ReplaceBtn.getX() + p1ReplaceBtn.getWidth() + p1x3 + getOffset(left, 30, 800), 60, + p1UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p1UnitCombo.setBounds(p1UnitLabel.getX() + p1UnitLabel.getWidth(), 60, + p1UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p1NumLabel.setBounds(p1UnitCombo.getX() + p1UnitCombo.getWidth() + p1x4 + getOffset(left, 20, 800), 60, + p1NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p1NumText.setBounds(p1NumLabel.getX() + p1NumLabel.getWidth(), 60, + p1NumText.getWidth() + getOffset(left, 50, 800), 25); + p1SelectAll.setBounds(p1SelectAll.getX() + getOffset(left, 20, 800), 100, + p1SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p1jsp.setBounds(p1jsp.getX() + getOffset(left, 20, 800), p1jsp.getY(), + p1jsp.getWidth() + getOffset(left, 760, 800), p1jsp.getHeight() + this.heightOffset); + p1BottomBtn1.setBounds(p1BottomBtn1.getX() + getOffset(left, 80, 800), p1BottomBtn1.getY() + this.heightOffset, + p1BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn2.setBounds(p1BottomBtn1.getX() + p1BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p1BottomBtn2.getY() + this.heightOffset, p1BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn3.setBounds(p1BottomBtn2.getX() + p1BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p1BottomBtn3.getY() + this.heightOffset, p1BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p1BottomBtn4.setBounds(p1BottomBtn3.getX() + p1BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p1BottomBtn4.getY() + this.heightOffset, p1BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p1Left.setBounds(0, 0, p1Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p1Left.getHeight() + this.heightOffset); + p1TreePanel.setBounds(p1TreePanel.getX() + getOffset(right, 20, 400), 130, + p1TreePanel.getWidth() + getOffset(right, 360, 400), p1TreePanel.getHeight() + this.heightOffset); + p1Right.setBounds(p1Left.getX() + p1Left.getWidth(), 0, + p1Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p1Right.getHeight() + this.heightOffset); + p1.revalidate(); + p1.repaint(); + + // p2 + int p2x1 = p2TargetBtn.getX() - p2TargetLabel.getX() - p2TargetLabel.getWidth(); + int p2x2 = p2NumText.getX() - p2ChangeNumLabel.getX() - p2ChangeNumLabel.getWidth(); + p2TargetLabel.setBounds(p2TargetLabel.getX() + getOffset(left, 20, 800), 20, + p2TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p2TargetBtn.setBounds(p2TargetLabel.getX() + p2TargetLabel.getWidth() + p2x1 + getOffset(left, 10, 800), 20, + p2TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p2ChangeNumLabel.setBounds(p2ChangeNumLabel.getX() + getOffset(left, 20, 800), 60, + p2ChangeNumLabel.getWidth() + getOffset(left, 100, 800), 25); + p2NumText.setBounds(p2ChangeNumLabel.getX() + p2ChangeNumLabel.getWidth() + p2x2 + getOffset(left, 10, 800), 60, + p2NumText.getWidth() + getOffset(left, 50, 800), 25); + p2SelectAll.setBounds(p2SelectAll.getX() + getOffset(left, 20, 800), 100, + p2SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p2jsp.setBounds(p2jsp.getX() + getOffset(left, 20, 800), p2jsp.getY(), + p2jsp.getWidth() + getOffset(left, 760, 800), p2jsp.getHeight() + this.heightOffset); + p2BottomBtn1.setBounds(p2BottomBtn1.getX() + getOffset(left, 80, 800), p2BottomBtn1.getY() + this.heightOffset, + p2BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn2.setBounds(p2BottomBtn1.getX() + p2BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p2BottomBtn2.getY() + this.heightOffset, p2BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn3.setBounds(p2BottomBtn2.getX() + p2BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p2BottomBtn3.getY() + this.heightOffset, p2BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p2BottomBtn4.setBounds(p2BottomBtn3.getX() + p2BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p2BottomBtn4.getY() + this.heightOffset, p2BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p2Left.setBounds(0, 0, p2Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p2Left.getHeight() + this.heightOffset); + p2TreePanel.setBounds(p2TreePanel.getX() + getOffset(right, 20, 400), 130, + p2TreePanel.getWidth() + getOffset(right, 360, 400), p2TreePanel.getHeight() + this.heightOffset); + p2Right.setBounds(p2Left.getX() + p2Left.getWidth(), 0, + p2Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p2Right.getHeight() + this.heightOffset); + p2.revalidate(); + p2.repaint(); + + // p3 + int p3x1 = p3TargetBtn.getX() - p3TargetLabel.getX() - p3TargetLabel.getWidth(); + int p3x2 = p3AddBtn.getX() - p3AddLabel.getX() - p3AddLabel.getWidth(); + int p3x3 = p3UnitLabel.getX() - p3AddBtn.getX() - p3AddBtn.getWidth(); + int p3x4 = p3NumLabel.getX() - p3UnitCombo.getX() - p3UnitCombo.getWidth(); + p3TargetLabel.setBounds(p3TargetLabel.getX() + getOffset(left, 20, 800), 20, + p3TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p3TargetBtn.setBounds(p3TargetLabel.getX() + p3TargetLabel.getWidth() + p3x1 + getOffset(left, 10, 800), 20, + p3TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p3AddLabel.setBounds(p3AddLabel.getX() + getOffset(left, 20, 800), 60, + p3AddLabel.getWidth() + getOffset(left, 100, 800), 25); + p3AddBtn.setBounds(p3AddLabel.getX() + p3AddLabel.getWidth() + p3x2 + getOffset(left, 10, 800), 60, + p3AddBtn.getWidth() + getOffset(left, 400, 800), 25); + p3UnitLabel.setBounds(p3AddBtn.getX() + p3AddBtn.getWidth() + p3x3 + getOffset(left, 30, 800), 60, + p3UnitLabel.getWidth() + getOffset(left, 50, 800), 25); + p3UnitCombo.setBounds(p3UnitLabel.getX() + p3UnitLabel.getWidth(), 60, + p3UnitCombo.getWidth() + getOffset(left, 50, 800), 25); + p3NumLabel.setBounds(p3UnitCombo.getX() + p3UnitCombo.getWidth() + p3x4 + getOffset(left, 20, 800), 60, + p3NumLabel.getWidth() + getOffset(left, 50, 800), 25); + p3NumText.setBounds(p3NumLabel.getX() + p3NumLabel.getWidth(), 60, + p3NumText.getWidth() + getOffset(left, 50, 800), 25); + p3SelectAll.setBounds(p3SelectAll.getX() + getOffset(left, 20, 800), 100, + p3SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p3jsp.setBounds(p3jsp.getX() + getOffset(left, 20, 800), p3jsp.getY(), + p3jsp.getWidth() + getOffset(left, 760, 800), p3jsp.getHeight() + this.heightOffset); + p3BottomBtn1.setBounds(p3BottomBtn1.getX() + getOffset(left, 80, 800), p3BottomBtn1.getY() + this.heightOffset, + p3BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn2.setBounds(p3BottomBtn1.getX() + p3BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p3BottomBtn2.getY() + this.heightOffset, p3BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn3.setBounds(p3BottomBtn2.getX() + p3BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p3BottomBtn3.getY() + this.heightOffset, p3BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p3BottomBtn4.setBounds(p3BottomBtn3.getX() + p3BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p3BottomBtn4.getY() + this.heightOffset, p3BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p3Left.setBounds(0, 0, p3Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p3Left.getHeight() + this.heightOffset); + p3TreePanel.setBounds(p3TreePanel.getX() + getOffset(right, 20, 400), 130, + p3TreePanel.getWidth() + getOffset(right, 360, 400), p3TreePanel.getHeight() + this.heightOffset); + p3Right.setBounds(p3Left.getX() + p3Left.getWidth(), 0, + p3Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p3Right.getHeight() + this.heightOffset); + p3.revalidate(); + p3.repaint(); + + // p4 + int p4x1 = p4TargetBtn.getX() - p4TargetLabel.getX() - p4TargetLabel.getWidth(); + p4TargetLabel.setBounds(p4TargetLabel.getX() + getOffset(left, 20, 800), 20, + p4TargetLabel.getWidth() + getOffset(left, 100, 800), 25); + p4TargetBtn.setBounds(p4TargetLabel.getX() + p4TargetLabel.getWidth() + p4x1 + getOffset(left, 10, 800), 20, + p4TargetBtn.getWidth() + getOffset(left, 400, 800), 25); + p4SelectAll.setBounds(p4SelectAll.getX() + getOffset(left, 20, 800), 100, + p4SelectAll.getWidth() + getOffset(left, 100, 800), 25); + p4jsp.setBounds(p4jsp.getX() + getOffset(left, 20, 800), p4jsp.getY(), + p4jsp.getWidth() + getOffset(left, 760, 800), p4jsp.getHeight() + this.heightOffset); + p4BottomBtn1.setBounds(p4BottomBtn1.getX() + getOffset(left, 80, 800), p4BottomBtn1.getY() + this.heightOffset, + p4BottomBtn1.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn2.setBounds(p4BottomBtn1.getX() + p4BottomBtn1.getWidth() + bottom1 + getOffset(left, 80, 800), + p4BottomBtn2.getY() + this.heightOffset, p4BottomBtn2.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn3.setBounds(p4BottomBtn2.getX() + p4BottomBtn2.getWidth() + bottom2 + getOffset(left, 80, 800), + p4BottomBtn3.getY() + this.heightOffset, p4BottomBtn3.getWidth() + getOffset(left, 100, 800), 25); + p4BottomBtn4.setBounds(p4BottomBtn3.getX() + p4BottomBtn3.getWidth() + botttom3 + getOffset(left, 80, 800), + p4BottomBtn4.getY() + this.heightOffset, p4BottomBtn4.getWidth() + getOffset(left, 100, 800), 25); + p4Left.setBounds(0, 0, p4Left.getWidth() + getOffset(this.widthOffset, 800, 1200), + p4Left.getHeight() + this.heightOffset); + p4TreePanel.setBounds(p4TreePanel.getX() + getOffset(right, 20, 400), 130, + p4TreePanel.getWidth() + getOffset(right, 360, 400), p4TreePanel.getHeight() + this.heightOffset); + p4Right.setBounds(p4Left.getX() + p4Left.getWidth(), 0, + p4Right.getWidth() + getOffset(this.widthOffset, 400, 1200), p4Right.getHeight() + this.heightOffset); + p4.revalidate(); + p4.repaint(); + + // p5 + int p5x1 = p5UserText.getX() - p5UserLabel.getX() - p5UserLabel.getWidth(); + int p5x2 = p5TimeLabel.getX() - p5UserText.getX() - p5UserText.getWidth(); + int p5x3 = p5TimeStartText.getX() - p5TimeLabel.getX() - p5TimeLabel.getWidth(); + int p5x4 = toLabel.getX() - p5TimeStartText.getX() - p5TimeStartText.getWidth(); + int p5x5 = p5TimeEndText.getX() - toLabel.getX() - toLabel.getWidth(); + int p5x6 = p5ContentLabel.getX() - p5TimeEndText.getX() - p5TimeEndText.getWidth(); + int p5x7 = p5Contentjsp.getX() - p5ContentLabel.getX() - p5ContentLabel.getWidth(); + int p5x8 = p5Search.getX() - p5Contentjsp.getX() - p5Contentjsp.getWidth(); + int p5x9 = p5Download.getX() - p5Search.getX() - p5Search.getWidth(); + p5UserLabel.setBounds(p5UserLabel.getX(), 40, p5UserLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), + 25); + p5UserText.setBounds(p5UserLabel.getX() + p5UserLabel.getWidth() + p5x1 + getOffset(this.widthOffset, 10, 1200), + 40, p5UserText.getWidth() + getOffset(this.widthOffset, 150, 1200), 25); + p5TimeLabel.setBounds(p5UserText.getX() + p5UserText.getWidth() + p5x2 + getOffset(this.widthOffset, 50, 1200), + 40, p5TimeLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5TimeStartText.setBounds( + p5TimeLabel.getX() + p5TimeLabel.getWidth() + p5x3 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeStartText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + toLabel.setBounds( + p5TimeStartText.getX() + p5TimeStartText.getWidth() + p5x4 + getOffset(this.widthOffset, 10, 1200), 40, + toLabel.getWidth() + getOffset(this.widthOffset, 20, 1200), 25); + p5TimeEndText.setBounds(toLabel.getX() + toLabel.getWidth() + p5x5 + getOffset(this.widthOffset, 10, 1200), 40, + p5TimeEndText.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5ContentLabel.setBounds( + p5TimeEndText.getX() + p5TimeEndText.getWidth() + p5x6 + getOffset(this.widthOffset, 50, 1200), 40, + p5ContentLabel.getWidth() + getOffset(this.widthOffset, 70, 1200), 25); + p5Contentjsp.setBounds( + p5ContentLabel.getX() + p5ContentLabel.getWidth() + p5x7 + getOffset(this.widthOffset, 10, 1200), 20, + p5Contentjsp.getWidth() + getOffset(this.widthOffset, 200, 1200), 80); + p5Search.setBounds(p5Contentjsp.getX() + p5Contentjsp.getWidth() + p5x8 + getOffset(this.widthOffset, 50, 1200), + 40, p5Search.getWidth() + getOffset(this.widthOffset, 60, 1200), 25); + p5Download.setBounds(p5Search.getX() + p5Search.getWidth() + p5x9 + getOffset(this.widthOffset, 20, 1200), 40, + p5Download.getWidth() + getOffset(this.widthOffset, 100, 1200), 25); + p5jsp.setBounds(p5jsp.getX() + getOffset(this.widthOffset, 20, 1200), p5jsp.getY(), + p5jsp.getWidth() + getOffset(this.widthOffset, 1160, 1200), p5jsp.getHeight() + this.heightOffset); + p5.revalidate(); + p5.repaint(); + } + + private int getOffset(double num1, int num2, int num3) { + return (int) (num1 * num2 / num3); + } + + private int getResultNum(List msgData, boolean success) { + int num = 0; + String str = success ? "ɹ" : "ʧ"; + for (String[] row : msgData) { + if (row[row.length - 1].contains(str)) { + num++; + } + } + return num; + } + +} + + diff --git a/src/com/connor/renben/process/plm/updataBOM/BOMManagementHandler.java b/src/com/connor/renben/process/plm/updataBOM/BOMManagementHandler.java new file mode 100644 index 0000000..bd516e3 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/BOMManagementHandler.java @@ -0,0 +1,24 @@ +package com.connor.renben.process.plm.updataBOM; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class BOMManagementHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + BOMManagementAction action = new BOMManagementAction(app, ""); + new Thread(action).start(); + return null; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/CheckBoxPo.java b/src/com/connor/renben/process/plm/updataBOM/CheckBoxPo.java new file mode 100644 index 0000000..333fa29 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/CheckBoxPo.java @@ -0,0 +1,14 @@ +package com.connor.renben.process.plm.updataBOM; + +public class CheckBoxPo { + public Object value = null; + public String text = null; + + public CheckBoxPo() { + } + + public CheckBoxPo(String text, Object value) { + this.value = value; + this.text = text; + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/updataBOM/CustomLovBean.java b/src/com/connor/renben/process/plm/updataBOM/CustomLovBean.java new file mode 100644 index 0000000..3b736ac --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/CustomLovBean.java @@ -0,0 +1,37 @@ +package com.connor.renben.process.plm.updataBOM; +import java.util.ArrayList; +import java.util.List; + +public class CustomLovBean { + private List sub = new ArrayList(); + public String displayName = ""; + + public CustomLovBean(String displayName) { + super(); + this.displayName = displayName; + } + + public CustomLovBean(String displayName, String[] subArray) { + super(); + this.displayName = displayName; + translateArrayToSub(subArray); + } + + public void translateArrayToSub(String[] subArray) { + for (int i = 0; i < subArray.length; i++) { + sub.add(new CustomLovBean(subArray[i])); + } + } + + public List getSub() { + return sub; + } + + public boolean hasChild() { + return sub.size() != 0; + } + + public void addSub(CustomLovBean clb) { + sub.add(clb); + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/DBConnectionUtil.java b/src/com/connor/renben/process/plm/updataBOM/DBConnectionUtil.java new file mode 100644 index 0000000..a7bc9ff --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DBConnectionUtil.java @@ -0,0 +1,50 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; +import java.util.HashMap; +import java.util.Map; + +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DBConnectionUtil { + + public static Connection dbConn(TCSession session) { + Connection c = null; + try { + Class.forName("oracle.jdbc.driver.OracleDriver"); + // ҪǵûгɹĻǻclassnotfoundException.ԼDz,classpathЩ + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + try { + String[] dbSettings = JDMethodUtil.getPrefStrArray("rb_db_settings", session); + if (dbSettings.length != 3) { + MessageBox.post("rb_db_settingsݿô", "", MessageBox.ERROR); + throw new Exception("rb_db_settingsݿô"); + } else { + Map settingMap = new HashMap(); + for (String s : dbSettings) { + settingMap.put(s.substring(0, s.indexOf(":")), s.substring(s.indexOf(":") + 1, s.length())); + } + System.out.println(settingMap.get("url") + settingMap.get("user") + settingMap.get("pass")); + c = DriverManager.getConnection(settingMap.get("url"), settingMap.get("user"), settingMap.get("pass")); + } +// c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:TC", name, pass); + // ݵķ, 򵥵,һҳ TCݿʵƣصļtest.sqlпִ鿴 + // "jdbc:oracle:thin:@:˿:ϵͳʵ", username, password, + // ,ҪԼ֪ڼԲ֪. + // ˿һĬ1521, ҪǸı˾ͿԼļļlistener.ora + // ϵͳʵһĬorcl, ҪDzǵĻ select name from v$database; + // username,password,ǵ½ݿû. + + } catch (SQLException e) { + e.printStackTrace(); + } catch (Exception e1) { + e1.printStackTrace(); + } + return c; + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/DBUtil.java b/src/com/connor/renben/process/plm/updataBOM/DBUtil.java new file mode 100644 index 0000000..fabcb93 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DBUtil.java @@ -0,0 +1,38 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.util.HashMap; +import java.util.Map; + +import javax.sql.DataSource; +import javax.swing.JOptionPane; + +import com.teamcenter.rac.kernel.TCSession; + +import cn.hutool.db.ds.simple.SimpleDataSource; + +public class DBUtil { + + public static DataSource getDataSource(TCSession session) { + + Map settingMap = getDbSetting(session); + String str = settingMap.get("url") + settingMap.get("user") + settingMap.get("pass"); + DataSource dataSource = new SimpleDataSource(settingMap.get("url"), settingMap.get("user"), + settingMap.get("pass")); + return dataSource; + } + + private static Map getDbSetting(TCSession session) { + Map settingMap = null; + String[] dbSettings = JDMethodUtil.getPrefStrArray("rb_db_settings", session); + if (dbSettings.length != 3) { + JOptionPane.showMessageDialog(null, "rb_db_settingsݿô", "", JOptionPane.ERROR); + } else { + settingMap = new HashMap(); + for (String s : dbSettings) { + settingMap.put(s.substring(0, s.indexOf(":")), s.substring(s.indexOf(":") + 1, s.length())); + } + } + return settingMap; + } + +} diff --git a/src/com/connor/renben/process/plm/updataBOM/DatePickerUtil.java b/src/com/connor/renben/process/plm/updataBOM/DatePickerUtil.java new file mode 100644 index 0000000..8c672c3 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DatePickerUtil.java @@ -0,0 +1,81 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Date; +import java.util.Locale; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +import com.eltima.components.ui.DatePicker; + +public class DatePickerUtil { + public static void main(String[] args) { + + final JFrame f = new JFrame("LoL");//++++final + f.setSize(400, 300); + f.setLocation(200, 200); + f.setLayout(null); + + final DatePicker datepick; + datepick = getDatePicker("yyyy-MM-dd hh:mm"); + + f.add(datepick); + + JButton b = new JButton("ȡʱ"); + b.setBounds(137, 183, 100, 30); + f.add(b); + + b.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(f, "ȡؼеڣ" + datepick.getText()); + System.out.println(datepick.getValue()); + } + }); + + f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + f.setVisible(true); + } + + public static DatePicker getDatePicker(String format) { + final DatePicker datepick; + // ʽ ¼ʱѡUI + String DefaultFormat = "yyyy-MM-dd"; + // ǰʱ + Date date = new Date(); + // + Font font = new Font("Times New Roman", Font.BOLD, 14); + + Dimension dimension = new Dimension(180, 24); + +// int[] hilightDays = { 1, 3, 5, 7 }; + +// int[] disabledDays = { 4, 6, 5, 9 }; + + datepick = new DatePicker(date, format == null ? DefaultFormat : format, font, dimension); + + datepick.setLocation(137, 83); + datepick.setBounds(137, 83, 180, 24); + // һ·Ҫʾ +// datepick.setHightlightdays(hilightDays, Color.red); + // һ·вҪӣʻɫʾ +// datepick.setDisableddays(disabledDays); + // ù + datepick.setLocale(Locale.CHINA); + // ʱɼ + if (format != null) { + datepick.setTimePanleVisible(true); + } else { + datepick.setTimePanleVisible(false); + } + return datepick; + } +} + diff --git a/src/com/connor/renben/process/plm/updataBOM/DialogUtil.java b/src/com/connor/renben/process/plm/updataBOM/DialogUtil.java new file mode 100644 index 0000000..ef8e2e8 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/DialogUtil.java @@ -0,0 +1,289 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Dialog.ModalityType; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import com.connor.renben.process.plm.updataBOM.BOMManagementFrame; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class DialogUtil { + + public static TableMsg createTableMsg(String[] header, List msgContent) { + DefaultTableModel msgModel = new DefaultTableModel(header, 0) { + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + // TODO Auto-generated method stub + return false; + } + }; + JTable msgTable = new JTable(msgModel); + for (int columnIndex = 0; columnIndex < msgTable.getColumnCount(); columnIndex++) { + // msgTable.getColumnModel().getColumn(columnIndex).setMinWidth(100); + msgTable.getColumnModel().getColumn(columnIndex).setPreferredWidth(200); + } + msgTable.setRowHeight(25); + msgTable.setShowGrid(false); + msgTable.setAutoscrolls(true); + msgTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + msgTable.getTableHeader().setReorderingAllowed(false); +// msgTable.getTableHeader().setVisible(false); + + for (String[] row : msgContent) { + msgModel.addRow(row); + } + + msgTable.invalidate(); + msgTable.repaint(); + JScrollPane msgPanel = new JScrollPane(msgTable); + msgPanel.setPreferredSize(new Dimension(header.length * 200, 400)); + msgPanel.setBorder(BorderFactory.createEmptyBorder()); + return new TableMsg(msgPanel, msgTable); + } + + public static JDialog createSearchAndSelectRevDialog(final BOMManagementFrame frame, final JTable paramTable,//++++final + final JCheckBox selectAll,final JButton field) {//++++final + final JDialog dialog = new JDialog();//++++final + dialog.setTitle("汾"); + dialog.setSize(520, 400); + dialog.setResizable(true); + dialog.setAutoRequestFocus(true); + dialog.setAlwaysOnTop(true); + dialog.setLocationRelativeTo(frame); + dialog.setModalityType(ModalityType.APPLICATION_MODAL); + + final JPanel content = new JPanel();//++++final + content.setLayout(null); + content.setPreferredSize(new Dimension(520, 400)); + JLabel targetLabel = new JLabel("Ŀ"); + targetLabel.setBounds(10, 10, 50, 25); + final JTextField targetText = new JTextField();//++++final + targetText.setText("ҪID"); + targetText.setForeground(Color.GRAY); + if (!"".equals(field.getText())) { + targetText.setText(field.getText().substring(0, field.getText().indexOf("/"))); + targetText.setForeground(Color.BLACK); + } + targetText.setBounds(20, 50, 300, 25); + final JButton searchBtn = new JButton("");//++++final + searchBtn.setBounds(380, 50, 100, 25); + + String[] colDisplayNames = new String[] { "", "", "״̬", "", "ID", "" }; + final DefaultTableModel model = new DefaultTableModel(colDisplayNames, 0) {//++++final + @Override + public boolean isCellEditable(int paramInt1, int paramInt2) { + return false; + } + }; + final JTable table = new JTable(model);//++++final + table.getColumnModel().getColumn(0).setMinWidth(100); + table.getColumnModel().getColumn(1).setMinWidth(100); + table.getColumnModel().getColumn(2).setMinWidth(100); + table.getColumnModel().getColumn(3).setMinWidth(100); + table.getColumnModel().getColumn(4).setMinWidth(60); + table.getColumnModel().getColumn(4).setPreferredWidth(60); + TableColumnModel tcm = table.getColumnModel(); + TableColumn tc = tcm.getColumn(5); + tc.setWidth(0); + tc.setPreferredWidth(0); + tc.setMaxWidth(0); + tc.setMinWidth(0); + table.getTableHeader().getColumnModel().getColumn(5).setMaxWidth(0); + table.getTableHeader().getColumnModel().getColumn(5).setMinWidth(0); + table.setRowHeight(25); + table.setAutoscrolls(true); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table.getTableHeader().setReorderingAllowed(false); + JScrollPane jsp = new JScrollPane(table); + jsp.setBounds(20, 100, 460, 200); + + JButton okBtn = new JButton("ȷ"); + okBtn.setBounds(140, 320, 100, 25); + JButton cancelBtn = new JButton("ȡ"); + cancelBtn.setBounds(260, 320, 100, 25); + + targetText.addFocusListener(new FocusListener() { + + @Override + public void focusLost(FocusEvent e) { + // TODO Auto-generated method stub + if ("".equals(targetText.getText())) { + targetText.setText("ҪID"); + targetText.setForeground(Color.GRAY); + } + } + + @Override + public void focusGained(FocusEvent e) { + // TODO Auto-generated method stub + if ("ҪID".equals(targetText.getText())) { + targetText.setText(""); + targetText.setForeground(Color.BLACK); + } + } + }); + + targetText.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent paramKeyEvent) { + // TODO Auto-generated method stub + super.keyTyped(paramKeyEvent); + if (paramKeyEvent.getKeyChar() == KeyEvent.VK_ENTER) { + searchBtn.doClick(); + } + } + }); + + searchBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int cnt = model.getRowCount(); + for (int i = 0; i < cnt; i++) { + model.removeRow(0); + } + table.revalidate(); + table.repaint(); + String text = targetText.getText(); + System.out.println(text); + if ("ҪID".equals(text)) { + return; + } + long startTime = System.currentTimeMillis(); + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + TCComponentItem[] items = getTarget(content, text, session); + if (items == null) { + return; + } + List tableDataList = new ArrayList(); + for (TCComponentItem item : items) { + try { + item.refresh(); + TCComponent[] comps = item.getRelatedComponents("revision_list"); + for (TCComponent comp : comps) { + String objetcString = comp.getProperty("object_string"); + TCComponent[] forms = comp.getRelatedComponents("IMAN_master_form_rev"); + String desc = ""; + if (forms.length > 0) { + desc = forms[0].getProperty("jd2_wlms"); + } + TCComponent[] statusArray = comp.getRelatedComponents("release_status_list"); + String status = ""; + if (statusArray != null && statusArray.length > 0) { + status = statusArray[statusArray.length - 1].getProperty("object_name"); + } + String owningUser = comp.getProperty("owning_user"); + String groupId = comp.getProperty("owning_group"); + tableDataList.add(new Object[] { objetcString, desc, status, owningUser, groupId, comp }); + } + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + for (Object[] rowData : tableDataList) { + model.addRow(rowData); + } + table.revalidate(); + table.repaint(); + System.out.println("ʾʱ" + (System.currentTimeMillis() - startTime) + "ms"); + } + }); + + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub + frame.okCallback(table, paramTable, selectAll, field); +// dialog.setVisible(false); + dialog.dispose(); + } + }); + + cancelBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent paramActionEvent) { + // TODO Auto-generated method stub +// dialog.setVisible(false); + dialog.dispose(); + } + }); + + content.add(targetLabel); + content.add(targetText); + content.add(searchBtn); + content.add(jsp); + content.add(okBtn); + content.add(cancelBtn); + + dialog.add(content); + dialog.setVisible(true); + + return dialog; + } + + private static TCComponentItem[] getTarget(Component parent, String itemId, TCSession session) { + TCComponent[] comps = null; + try { + comps = session.search("Item ID", new String[] { " ID" }, new String[] { itemId }); +// TCComponentItemType type = new TCComponentItemType(); +// comps = type.findItems(itemId); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return null; + } + if (comps == null || comps.length == 0) { + JOptionPane.showMessageDialog(parent, "Чϱ룬ȷϱǷȷ", "ʾ", JOptionPane.WARNING_MESSAGE); + return null; + } + TCComponentItem[] items = new TCComponentItem[comps.length]; + for (int i = 0; i < comps.length; i++) { + items[i] = (TCComponentItem) comps[i]; + } + return items; + } + + public static class TableMsg { + public JScrollPane panel; + public JTable table; + + public TableMsg(JScrollPane panel, JTable table) { + super(); + this.panel = panel; + this.table = table; + } + + } +} + diff --git a/src/com/connor/renben/process/plm/updataBOM/JDMethodUtil.java b/src/com/connor/renben/process/plm/updataBOM/JDMethodUtil.java new file mode 100644 index 0000000..62ab005 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/JDMethodUtil.java @@ -0,0 +1,48 @@ +package com.connor.renben.process.plm.updataBOM; + +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class JDMethodUtil { + + public static TCPreferenceService service; + public static TCUserService userservice; + + /** + * + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /** + * + * + * @param prefName + * @return + */ + public static String[] getPrefStrArray(String prefName, TCSession session) { + if (service == null) { + service = session.getPreferenceService(); + } + String[] strs = service.getStringArray(TCPreferenceService.TC_preference_site, prefName); + service.getStringValues(prefName); + service.getStringValue(prefName); + if (strs == null) { + strs = new String[] { "" }; + } + return strs; + } +} + diff --git a/src/com/connor/renben/process/plm/updataBOM/KeyValComboBox.java b/src/com/connor/renben/process/plm/updataBOM/KeyValComboBox.java new file mode 100644 index 0000000..6536d34 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/KeyValComboBox.java @@ -0,0 +1,96 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Component; +import java.util.Vector; + +import javax.swing.DefaultComboBoxModel; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JComboBox; +import javax.swing.JList; + + + +public class KeyValComboBox extends JComboBox { + + public KeyValComboBox(Vector values) { + super(values); + rendererData(); // Ⱦ + } + + public void rendererData() { + DefaultListCellRenderer render = new DefaultListCellRenderer() { + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, + boolean cellHasFocus) { + super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + if (value instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) value; + this.setText(po.text); + } + return this; + } + }; + this.setRenderer(render); + } + + // ޸Comboxе + public void updateData(Vector values) { + setModel(new DefaultComboBoxModel(values)); + rendererData(); + } + + @Override + public void setSelectedItem(Object anObject) { // ѡtext봫IJͬ + if (anObject != null) { + if (anObject instanceof CheckBoxPo) { + super.setSelectedItem(anObject); + } + if (anObject instanceof String) { + for (int index = 0; index < getItemCount(); index++) { + CheckBoxPo po = (CheckBoxPo) getItemAt(index); + if (po.text.equals(anObject.toString())) { + super.setSelectedIndex(index); + } + } + } + } else { + super.setSelectedItem(anObject); + } + } + + public void setSelectedValue(Object anObject) { // ѡvalue봫IJͬ + if (anObject != null) { + if (anObject instanceof CheckBoxPo) { + super.setSelectedItem(anObject); + } + if (anObject instanceof String) { + for (int index = 0; index < getItemCount(); index++) { + CheckBoxPo po = (CheckBoxPo) getItemAt(index); + if (po.value.equals(anObject.toString())) { + super.setSelectedIndex(index); + } + } + } + } else { + super.setSelectedItem(anObject); + } + } + + // ѡļֵ + public Object getSelectedValue() { + if (getSelectedItem() instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) getSelectedItem(); + return po.value; + } + return (getSelectedItem() != null) ? getSelectedItem().toString() : null; + } + + // ѡʾı + public String getSelectedText() { + if (getSelectedItem() instanceof CheckBoxPo) { + CheckBoxPo po = (CheckBoxPo) getSelectedItem(); + return po.text; + } + return (getSelectedItem() != null) ? getSelectedItem().toString() : null; + } +} diff --git a/src/com/connor/renben/process/plm/updataBOM/MyCellEditor4.java b/src/com/connor/renben/process/plm/updataBOM/MyCellEditor4.java new file mode 100644 index 0000000..242eb0d --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/MyCellEditor4.java @@ -0,0 +1,39 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Component; + +import javax.swing.DefaultCellEditor; +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.JTextField; + +public class MyCellEditor4 extends DefaultCellEditor { + private int type = -1; + private JCheckBox check; + + public MyCellEditor4(JTextField arg0) { + super(arg0); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof JCheckBox) { + System.out.println("123456789abcdefg"); + check = (JCheckBox) value; + type = 1; + return check; + } + type = 0; + return super.getTableCellEditorComponent(table, value, isSelected, row, column); + } + + @Override + public Object getCellEditorValue() { + if (type == 1) { + return check; + } + return super.getCellEditorValue(); + } + +} + diff --git a/src/com/connor/renben/process/plm/updataBOM/MyCellRenderer.java b/src/com/connor/renben/process/plm/updataBOM/MyCellRenderer.java new file mode 100644 index 0000000..e874ed0 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/MyCellRenderer.java @@ -0,0 +1,20 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.awt.Component; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; + +public class MyCellRenderer extends DefaultTableCellRenderer { + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, + int row, int column) { + // TODO Auto-generated method stub + if (value instanceof JCheckBox) { + return (JCheckBox) value; + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } +} + diff --git a/src/com/connor/renben/process/plm/updataBOM/ResultData.java b/src/com/connor/renben/process/plm/updataBOM/ResultData.java new file mode 100644 index 0000000..d32ebab --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/ResultData.java @@ -0,0 +1,41 @@ +package com.connor.renben.process.plm.updataBOM; + + +public class ResultData { + private boolean res; + private String Message; + private Object data; + + public ResultData(boolean res, String message, Object data) { + super(); + this.res = res; + Message = message; + this.data = data; + } + + public boolean isRes() { + return res; + } + + public void setRes(boolean res) { + this.res = res; + } + + public String getMessage() { + return Message; + } + + public void setMessage(String message) { + Message = message; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } + +} + diff --git a/src/com/connor/renben/process/plm/updataBOM/SimpleExcelUtil.java b/src/com/connor/renben/process/plm/updataBOM/SimpleExcelUtil.java new file mode 100644 index 0000000..c2c59a6 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/SimpleExcelUtil.java @@ -0,0 +1,69 @@ +package com.connor.renben.process.plm.updataBOM; + +import java.io.File; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +import com.aspose.cells.Cells; +import com.aspose.cells.License; +import com.aspose.cells.Workbook; +import com.aspose.cells.WorksheetCollection; + +public class SimpleExcelUtil { + public static void exportExcel(String path, String[] header, List data) { + if (path == null || data == null) { + return; + } + try { + File file = new File(path); + file.createNewFile(); + + getLicense(); + + Workbook excel = new Workbook(path); + WorksheetCollection wc = excel.getWorksheets(); + Cells cells = wc.get(0).getCells(); + int rowIndex = 0; + if (header != null) { + for (int columnIndex = 0; columnIndex < header.length; columnIndex++) { + cells.get(rowIndex, columnIndex).setValue(header[columnIndex]); + } + rowIndex++; + } + for (String[] arr : data) { + for (int columnIndex = 0; columnIndex < arr.length; columnIndex++) { + cells.get(rowIndex, columnIndex).setValue(arr[columnIndex]); + } + rowIndex++; + } + excel.save(path); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static boolean getLicense() throws Exception { + boolean result = false; + try { + InputStream is = com.aspose.cells.Cell.class.getResourceAsStream("/com/aspose/cells/resources/license.xml"); + License aposeLic = new License(); + aposeLic.setLicense(is); + result = true; + is.close(); + } catch (Exception e) { + e.printStackTrace(System.out); + throw e; + } + return result; + } + + public static void main(String[] args) { + List test = new ArrayList(); + test.add(new String[] { "zzz", "xxx" }); + SimpleExcelUtil.exportExcel(System.getenv("temp") + File.separator + "xxxxxxxxxxxxxxxxxxxx.xlsx", + new String[] { "1", "2" }, test); + System.out.println(System.getenv("temp")); + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/updataBOM/StringCreateUtil.java b/src/com/connor/renben/process/plm/updataBOM/StringCreateUtil.java new file mode 100644 index 0000000..904f783 --- /dev/null +++ b/src/com/connor/renben/process/plm/updataBOM/StringCreateUtil.java @@ -0,0 +1,21 @@ +package com.connor.renben.process.plm.updataBOM; + +public class StringCreateUtil { + public static String createBlank(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append(" "); + num--; + } + return sb.toString(); + } + + public static String createPoint(int num) { + StringBuilder sb = new StringBuilder(); + while (num > 0) { + sb.append("."); + num--; + } + return sb.toString(); + } +} diff --git a/src/com/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/CTMap.java b/src/com/connor/renben/process/plm/util/CTMap.java new file mode 100644 index 0000000..d65a2b9 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTMap.java @@ -0,0 +1,323 @@ +package com.connor.renben.process.plm.util; + +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.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +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; + } + + @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 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; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + if (arg0 == row && arg1 == column) { + 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); + } + } + + // if (processRowList.contains(row)) { + // for (int i = 0; i < processRowList.size(); i++) { + // 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+1) + // { + // processRowList.set(i, processRowList.get(i)+1); + // } + // } + // } + // else + // { + // for (int i = 0; i < processRowList.size(); i++) { + // if(processRowList.get(i) != null && processRowList.get(i) == + // row-1) + // { + // index = i+1; + // processRowList.add(i+1, row); + // } + // 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/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..bb74ec0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTable.java @@ -0,0 +1,233 @@ +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.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("4")||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..7ab5747 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CTreeNode.java @@ -0,0 +1,22 @@ +package com.connor.renben.process.plm.util; + +import javax.swing.tree.DefaultMutableTreeNode; + +import com.connor.renben.process.plm.bean.TreeBean; + +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-USUnicodeַĻ */ + 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"; + /** ijַ **/ + 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..024787d --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CheckBoxCellEditor.java @@ -0,0 +1,117 @@ +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.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 CTMap tableModel; + + public CheckBoxCellEditor(final CTable table) { + super(); + this.tableModel = (CTMap) 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..4c028f4 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CollectControlPlan.java @@ -0,0 +1,192 @@ +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.renben.process.plm.sql.util.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(); + }finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + } + } + +} 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..a45c8e0 --- /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.renben.process.plm.sql.util.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..1944c81 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/CreateNewBOHandler.java @@ -0,0 +1,194 @@ +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); + // 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(); + dialog = null; + m_boModel = null; + UIUtilities.setCurrentModalShell(shell); + System.out.println("ر"); + } + + private final Shell m_shell; + private final boolean m_revisionFlag; + 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..92652a1 --- /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..d73d5a0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelUtil.java @@ -0,0 +1,1191 @@ +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.usermodel.CellValue; +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[] areaR2 = AreaReference.generateContiguous(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; + 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 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(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(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(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(HSSFCellStyle.BORDER_THIN); + style.setBorderTop(HSSFCellStyle.BORDER_THIN); + style.setBorderRight(HSSFCellStyle.BORDER_THIN); + style.setBorderLeft(HSSFCellStyle.BORDER_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(HSSFCell.CELL_TYPE_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(HSSFCellStyle.BORDER_THIN); + style.setBorderTop(HSSFCellStyle.BORDER_THIN); + style.setBorderRight(HSSFCellStyle.BORDER_THIN); + style.setBorderLeft(HSSFCellStyle.BORDER_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(HSSFCell.CELL_TYPE_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(HSSFCellStyle.BORDER_THIN); + style.setBorderTop(HSSFCellStyle.BORDER_THIN); + style.setBorderRight(HSSFCellStyle.BORDER_THIN); + style.setBorderLeft(HSSFCellStyle.BORDER_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(HSSFCell.CELL_TYPE_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(HSSFCell.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(); + 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(3); + // ͼƬ + 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(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(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; + } + + // ͼƬ;isProportionfalseǽͼƬǶ뵽ȫԪtrueǽԭͼ + // sheetexcelpicturePathͼƬ·RowsͼƬУ1ʼcolunmsͼƬУ1ʼ + // RowHeightCMƵиߣColumnWidthCMƵп + public static void InsertTitlePicture2(File file, String outFilePath, String picturePath, int[] rows, int[] columns, + boolean isProportion, double rowHeightCM, double columnWidthCM, int ii, int jj) throws IOException { + + Workbook wb = new Workbook(); + try (FileInputStream fis = new FileInputStream(file)) { + wb.loadFromHtml(fis); + } + + Worksheet sheet = wb.getWorksheets().get(0); + + // ͼƬʼλ + int startRow = rows[0] - 1; // Excel д1ʼJava0ʼ + int startColumn = columns[0] - 1; // ͬ + + // ͼƬǵке + int rowCount = rows.length; + int columnCount = columns.length; + + // ȡͼƬ + try (FileInputStream input = new FileInputStream(picturePath)) { + BufferedImage sourceImg = ImageIO.read(input); + + // ȡͼƬԭʼߴ + int imgWidth = sourceImg.getWidth(); + int imgHeight = sourceImg.getHeight(); + + // ͼƬExcelеĿȺ͸߶ + double excelWidth = columnCount * columnWidthCM * 28.3465; // 28.3465: 1cm to points + double excelHeight = rowCount * rowHeightCM * 28.3465; + + // ͼƬ + if (isProportion) { + double ratio = (double) imgWidth / imgHeight; + + // ͼƬȴڸ߶ȣ򰴿 + if (ratio > (excelWidth / excelHeight)) { + double scaledWidth = excelWidth; + double scaledHeight = scaledWidth / ratio; + sheet.getPictures().add(ii, jj, sourceImg, (int) scaledWidth, (int) scaledHeight); + } else { // 򰴸߶ + double scaledHeight = excelHeight; + double scaledWidth = scaledHeight * ratio; + sheet.getPictures().add(ii, jj, sourceImg, (int) scaledWidth, (int) scaledHeight); + } + } else { // ͼƬ + sheet.getPictures().add(ii, jj, sourceImg, (int) excelWidth, (int) excelHeight); + } + } + + // ļ + wb.saveToFile(outFilePath); + + // Դ + new File(picturePath).delete(); + } + + 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; i < colunms.length; i++) { + ColumnWidth = ColumnWidth + sheet.getColumnWidthPixels(colunms[i]); + // ColumnWidthCM=ColumnWidthCM+sheet.getColumnWidth(colunms[i]);//ColumnWidthCMȡexcelпƣ + } + for (int i = 0; i < Rows.length; i++) { + RowHeight = RowHeight + sheet.getRowHeightPixels(Rows[i]); + // RowHeightCM=RowHeightCM+sheet.getRowHeight(Rows[i]);;//RowHeightCMȡexcelиߣƣ + } +// //ȡипתΪ +// RowHeightCM=RowHeightCM*(0.031);//*0.031=3.25/105иߣףgetRowHeightõexcelʾĵλ +// ColumnWidthCM=ColumnWidthCM*(0.22862);//*0.211=5.46/25.9пףgetColumnWidthõexcelʾĵλ + + // ȡͼƬ + FileInputStream input = new FileInputStream(picturePath); + BufferedImage sourceImg = ImageIO.read(input); + ExcelPicture pic1 = sheet.getPictures().add(ii, jj, sourceImg); + // ȡͼƬر + double W = sourceImg.getWidth(); + double H = sourceImg.getHeight(); +// //ͼֱʱ +// double WH=W/H; + // и + double w1 = ColumnWidthCM / ColumnWidth; + double h1 = RowHeightCM / RowHeight; + double CW = W / ColumnWidth; + double RH = H / RowHeight; + + if (isProportion) { + // + double h = 0.0; + double w = 0.0; + if (CW * h1 / w1 > RH) { + 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 HSSFCell.CELL_TYPE_STRING: + strCell = cell.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_NUMERIC: + strCell = "" + cell.getNumericCellValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + break; + case HSSFCell.CELL_TYPE_BOOLEAN: + strCell = String.valueOf(cell.getBooleanCellValue()); + break; + case HSSFCell.CELL_TYPE_BLANK: + strCell = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + strCell = String.valueOf(cell.getErrorCellValue()); + break; + case HSSFCell.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 ""; + } + 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..e84b81c --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ExcelUtil07.java @@ -0,0 +1,8020 @@ +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.formula.FormulaParseException; +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 org.jacorb.idl.runtime.int_token; + +import com.connor.renben.process.plm.bean.CXBean; +import com.connor.renben.process.plm.bean.EntrustmentFormBean; +import com.connor.renben.process.plm.bean.JobProcessFormBean; +import com.connor.renben.process.plm.bean.TMomControlPlanBean; +import com.connor.renben.process.plm.bean.TMomControlPlanSimpleBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +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"; + + /** + * ȡ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>(); + 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(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(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(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(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(); + } + } + + /** + * str1str2 + * + * @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,row3.getCell(5).getStringCellValue()+controlPlanBean.getKeyPhone()); + setCellValue(row3,10,row3.getCell(10).getStringCellValue()+controlPlanBean.getCreateDateStr()); + setCellValue(row3,13,row3.getCell(13).getStringCellValue()+controlPlanBean.getUpdateDateStr()); + XSSFRow row4 = sheet.getRow(3); + setCellValue(row4,0,row4.getCell(0).getStringCellValue()+controlPlanBean.getPartNumber()); + setCellValue(row4,5,row4.getCell(5).getStringCellValue()+controlPlanBean.getCoreTeam()); + setCellValue(row4,10,row4.getCell(10).getStringCellValue()+controlPlanBean.getCustromEngineeringApprovalDateStr()); + XSSFRow row5 = sheet.getRow(4); + setCellValue(row5,0,row5.getCell(0).getStringCellValue()+controlPlanBean.getPartNameDesc()); + setCellValue(row5,5,row5.getCell(5).getStringCellValue()+controlPlanBean.getSupplierApprovalDateStr()); + setCellValue(row5,10,row5.getCell(10).getStringCellValue()+controlPlanBean.getCustromQuantyApprovalDateStr()); + XSSFRow row6 = sheet.getRow(5); + setCellValue(row6,0,row6.getCell(0).getStringCellValue()+controlPlanBean.getSupplier()); + setCellValue(row6,3,row6.getCell(3).getStringCellValue()+controlPlanBean.getSupplierCode()); + setCellValue(row6,5,row6.getCell(5).getStringCellValue()+controlPlanBean.getOtherApprovalDateStr()); + setCellValue(row6,10,row6.getCell(10).getStringCellValue()+controlPlanBean.getOtherApprovalIfDateStr()); + + } else { + return -1; + } + if (simpleBeanList == null) { + return -1; + } + String selectSQL = String.format("SELECT ORI,SPE FROM RB3_SPETABLE"); + Map getStrings = new HashMap(); + SqlUtilT.getTCConnection(); + try (ResultSet rs = SqlUtilT.read(selectSQL)) { + while (rs.next()) { + System.out.println(rs.getString("ORI")); + System.out.println(rs.getString("SPE")); + getStrings.put(rs.getString("ORI"), rs.getString("SPE")); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + 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); + SqlUtilT.getTCConnection(); + + System.out.print(selectSQL); + System.out.println("޸Ĵ"); + String ss=simpleBeanList.get(i).getSpecialClass(); + if(ss!=null) { + System.out.println("滻ַ"+ss); + } + + if(simpleBeanList.get(i).getSpecialClass()!=null) { + if(getStrings.containsKey(simpleBeanList.get(i).getSpecialClass())) { + System.out.println("滻ַ"+getStrings.get(simpleBeanList.get(i).getSpecialClass())); + ss = getStrings.get(simpleBeanList.get(i).getSpecialClass()); + } + } + if(ss!=null) { + System.out.println(ss); + } + + cell7.setCellValue(ss); + + //+++ + + 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_New(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,11);//Dzλ + } + + 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()); + setCellValue(titleRow, 10, controlPlanBean.getWjbh()); + setCellValue(titleRow, 16, controlPlanBean.getBz()); + titleRow = sheet.getRow(1); + setCellValue(titleRow, 10, controlPlanBean.getBbh()); + setCellValue(titleRow, 16, controlPlanBean.getSh()); + titleRow = sheet.getRow(2); + setCellValue(titleRow, 10, controlPlanBean.getLjdh()); + setCellValue(titleRow, 16, controlPlanBean.getPz()); + titleRow = sheet.getRow(3); + setCellValue(titleRow, 3, controlPlanBean.getCxqy()); + setCellValue(titleRow, 6, controlPlanBean.getSbxh()); + setCellValue(titleRow, 10, controlPlanBean.getSbmc()); + setCellValue(titleRow, 16, controlPlanBean.getFbrq()); + titleRow = sheet.getRow(4); + setCellValue(titleRow, 10, titleRow.getCell(10).getStringCellValue()+controlPlanBean.getBgx()); + setCellValue(titleRow, 14, titleRow.getCell(14).getStringCellValue()+controlPlanBean.getXdgx()); + //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) {//i0ʼ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, 7 }); + combine(sheet, new int[] { i + startRow }, new int[] { 8, 9 }); + } + + 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(8); + cell4.setCellValue(toolingDetailList.get(4)); + } + startRow = 19; + if (toolingDetailData.size() > 11) { + // ֺϲԪ + 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 }); +// combine(sheet, rows, new int[] { 10, 11, 12, 13, 14, 15, 16 }); + startRow = 19 + toolingDetailData.size() - 11; + } + + int rows = 10; + if (machiningParameterData.size() > 20) { + if(machiningParameterData.size() % 2 == 1) { + rows = machiningParameterData.size() / 2 + 1; + }else { + rows = machiningParameterData.size() / 2; + } + for (int i = 10; i < rows; 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 < 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, 8, 9 }); + combine(sheet, new int[] { i + startRow }, new int[] { 11, 12 }); + combine(sheet, new int[] { i + startRow }, new int[] { 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(10); + cell1.setCellValue(machiningParameterList.get(1)); + XSSFCell cell2 = row.getCell(11); + cell2.setCellValue(machiningParameterList.get(2)); + XSSFCell cell3 = row.getCell(13); + cell3.setCellValue(machiningParameterList.get(3)); + XSSFCell cell4 = row.getCell(14); + 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 > 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[] { 3, 4 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 6, 7, 8 }); + combine(sheet, new int[] { i + startRow }, new int[] { 11, 12 }); + combine(sheet, new int[] { i + startRow }, new int[] { 14, 15,16 }); + + } + + 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(7); + cell4.setCellValue(controlRequirementList.get(4)); + XSSFCell cell5 = row.getCell(9); + cell5.setCellValue(controlRequirementList.get(5)); + XSSFCell cell6 = row.getCell(10); + cell6.setCellValue(controlRequirementList.get(6)); + XSSFCell cell7 = row.getCell(11); + cell7.setCellValue(controlRequirementList.get(7)); + XSSFCell cell8 = row.getCell(13); + cell8.setCellValue(controlRequirementList.get(8)); + XSSFCell cell9 = row.getCell(14); + cell9.setCellValue(controlRequirementList.get(9)); + XSSFCell cel10 = row.getCell(6); + cel10.setCellValue(controlRequirementList.get(11)); + XSSFCell cel11 = row.getCell(8); + cel11.setCellValue(controlRequirementList.get(12)); + } + + 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 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);//Dzλ + } + + 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()); + titleRow = sheet.getRow(4); + setCellValue(titleRow, 10, controlPlanBean.getBgx()); + //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) {//i0ʼ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 writeJobProcessFormVerticalToExcel_Copy(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[] {11,12,13,14,15,16,17,18},true,3.1,9.52,5,3);//Dzλ + } + + 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, 2, controlPlanBean.getGsmc()); + setCellValue(titleRow, 13, controlPlanBean.getWjbh()); + setCellValue(titleRow, 17, controlPlanBean.getBbh()); + setCellValue(titleRow, 21, controlPlanBean.getBz()); + titleRow = sheet.getRow(1); + setCellValue(titleRow, 13, controlPlanBean.getLjdh()); + setCellValue(titleRow, 17, controlPlanBean.getCxqy()); + setCellValue(titleRow, 21, controlPlanBean.getSh()); + titleRow = sheet.getRow(2); + setCellValue(titleRow, 13, controlPlanBean.getSbxh()); + setCellValue(titleRow, 17, controlPlanBean.getSbmc()); + setCellValue(titleRow, 21, controlPlanBean.getPz()); + titleRow = sheet.getRow(3); + setCellValue(titleRow, 13, controlPlanBean.getBgx()); + setCellValue(titleRow, 17, controlPlanBean.getXdgx()); + setCellValue(titleRow, 21, controlPlanBean.getFbrq()); + + 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) {//i0ʼ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 < 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[] { 18, 19 }); + combine(sheet, new int[] { i + startRow }, new int[] { 20, 21 }); + combine(sheet, new int[] { i + startRow }, new int[] { 22, 23 }); + } + + List toolingDetailList = toolingDetailData.get(i); + // XSSFRow row = sheet.getRow(i + startRow); + XSSFCell cell1 = row.getCell(17); + cell1.setCellValue(toolingDetailList.get(1)); + XSSFCell cell2 = row.getCell(18); + cell2.setCellValue(toolingDetailList.get(2)); + XSSFCell cell3 = row.getCell(20); + cell3.setCellValue(toolingDetailList.get(3)); + XSSFCell cell4 = row.getCell(22); + cell4.setCellValue(toolingDetailList.get(4)); + } + startRow = 20; + if (toolingDetailData.size() > 10) { + // ֺϲԪ + unMerge(sheet, "A5"); + unMerge(sheet, "C5"); + unMerge(sheet, "Q5"); + // ϲԪ + 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 }); + combine(sheet, rows, new int[] { 16 }); + combine(sheet, rows, new int[] { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }); + startRow = 20 + toolingDetailData.size() - 10; + } +// if (controlRequirementData.size() > 11) { +// // ֺϲԪ +// unMerge(sheet, "A"+(startRow - 3)); +// unMerge(sheet, "Q"+(startRow - 3)); +// // ϲԪ +// int[] rows = new int[3 + controlRequirementData.size()]; +// int[] rows2 = new int[3 + machiningParameterData.size()]; +// rows[0] = startRow - 3; +// rows[1] = startRow - 2; +// rows[2] = startRow - 1; +// rows2[0] = startRow - 3; +// rows2[1] = startRow - 2; +// rows2[2] = startRow - 1; +// for (int i = 0; i < controlRequirementData.size(); i++) { +// rows[i + 3] = i + startRow; +// } +// for (int i = 0; i < machiningParameterData.size(); i++) { +// rows2[i + 3] = i + startRow; +// } +// +// combine(sheet, rows, new int[] { 0, 1 }); +// combine(sheet, rows2, new int[] { 16 }); +// } + +// startRow = 20; +// int rows = 10; +// if (controlRequirementData.size() > 11) { +// rows = controlRequirementData.size() - 1; +// } +// if (machiningParameterData.size() > rows) { +// rows = machiningParameterData.size(); +// } + 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 < 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[] { 13, 14, 15 }); + combine(sheet, new int[] { i + startRow }, new int[] { 18, 19 }); + combine(sheet, new int[] { i + startRow }, new int[] { 20, 21 }); + combine(sheet, new int[] { i + startRow }, new int[] { 22, 23 }); + + + } + List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + 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(22); + cell4.setCellValue(machiningParameterList.get(4)); + } + + + for (int i = 0; i < controlRequirementData.size(); i++) { + + XSSFRow row = null; + Boolean isCreat = false; + if(i == machiningParameterData.size() +1) { + row = createRow(sheet, i + startRow); + isCreat = true; + } + else if (i == controlRequirementData.size() - 1) { + if(controlRequirementData.size()-machiningParameterData.size() >= 2) { + row = createRow(sheet, i + startRow); + isCreat = true; + }else { + row = sheet.getRow(i + startRow); + isCreat = false; + } + } else if (i > machiningParameterData.size()+1) { + 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[] { 0, 1 }); + combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15 }); + combine(sheet, new int[] { i + startRow }, new int[] { 18, 19 }); + combine(sheet, new int[] { i + startRow }, new int[] { 20, 21 }); + combine(sheet, new int[] { i + startRow }, new int[] { 22, 23 }); + } + + 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(4); + cell2.setCellValue(controlRequirementList.get(2)); + XSSFCell cell3 = row.getCell(5); + cell3.setCellValue(controlRequirementList.get(3)); + XSSFCell cell4 = row.getCell(7); + cell4.setCellValue(controlRequirementList.get(4)); + XSSFCell cell5 = row.getCell(9); + cell5.setCellValue(controlRequirementList.get(5)); + XSSFCell cell6 = row.getCell(10); + cell6.setCellValue(controlRequirementList.get(6)); + XSSFCell cell7 = row.getCell(11); + 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)); + XSSFCell cel11 = row.getCell(6); + cel11.setCellValue(controlRequirementList.get(11)); + XSSFCell cel12 = row.getCell(8); + cel12.setCellValue(controlRequirementList.get(12)); + XSSFCell cel13 = row.getCell(3); + cel13.setCellValue(controlRequirementList.get(13)); + } + if (controlRequirementData.size() > machiningParameterData.size() && controlRequirementData.size() > 11) { + // ֺϲԪ + unMerge(sheet, "A"+(startRow - 3)); + unMerge(sheet, "Q"+(startRow - 3)); + // ϲԪ + int[] rows = new int[3 + controlRequirementData.size()]; + int[] rows2 = new int[2 + controlRequirementData.size()]; + rows[0] = startRow - 3; + rows[1] = startRow - 2; + rows[2] = startRow - 1; + rows2[0] = startRow - 3; + rows2[1] = startRow - 2; + rows2[2] = startRow - 1; + for (int i = 0; i < controlRequirementData.size(); i++) { + rows[i + 3] = i + startRow; + if(i != controlRequirementData.size()-1) { + rows2[i + 3] = i + startRow; + } + } + + combine(sheet, rows, new int[] { 0, 1 }); + combine(sheet, rows2, new int[] { 16 }); + } + + if (machiningParameterData.size() >= controlRequirementData.size() && machiningParameterData.size() > 10) { + // ֺϲԪ + unMerge(sheet, "A"+(startRow - 3)); + unMerge(sheet, "Q"+(startRow - 3)); + // ϲԪ + int[] rows = new int[3 + machiningParameterData.size()]; + int[] rows2 = new int[4 + machiningParameterData.size()]; + rows[0] = startRow - 3; + rows[1] = startRow - 2; + rows[2] = startRow - 1; + rows2[0] = startRow - 3; + rows2[1] = startRow - 2; + rows2[2] = startRow - 1; + for (int i = 0; i < machiningParameterData.size(); i++) { + rows[i + 3] = i + startRow; + rows2[i + 3] = i + startRow; + } + + rows2[4 + machiningParameterData.size() - 1] = machiningParameterData.size() + startRow; + combine(sheet, rows2, new int[] { 0, 1 }); + combine(sheet, rows, new int[] { 16 }); + } + +//// } +// +//// 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(14); +//// cell1.setCellValue(machiningParameterList.get(1)); +//// XSSFCell cell2 = row.getCell(15); +//// cell2.setCellValue(machiningParameterList.get(2)); +//// XSSFCell cell3 = row.getCell(16); +//// cell3.setCellValue(machiningParameterList.get(3)); +//// XSSFCell cell4 = row.getCell(17); +//// 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(19); +//// cell1.setCellValue(machiningParameterList.get(1)); +//// XSSFCell cell2 = row.getCell(20); +//// cell2.setCellValue(machiningParameterList.get(2)); +//// XSSFCell cell3 = row.getCell(22); +//// cell3.setCellValue(machiningParameterList.get(3)); +//// XSSFCell cell4 = row.getCell(23); +//// 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(14); +//// cell1.setCellValue(machiningParameterList.get(1)); +//// XSSFCell cell2 = row.getCell(15); +//// cell2.setCellValue(machiningParameterList.get(2)); +//// XSSFCell cell3 = row.getCell(16); +//// cell3.setCellValue(machiningParameterList.get(3)); +//// XSSFCell cell4 = row.getCell(17); +//// cell4.setCellValue(machiningParameterList.get(4)); +//// } +//// } +// // startRow = 18; +// // ϲԪ +// if (rows > 10) { +// // ֺϲԪ +// unMerge(sheet, "A5"); +// // ֺϲԪ +// unMerge(sheet, "M1"); +// // ֺϲԪ +// unMerge(sheet, "N5"); +// // ϲԪ +// int[] rowIndexs = new int[2 + rows - 1]; +// rowIndexs[0] = 4; +// rowIndexs[1] = 5; +// for (int i = 0; i < rows - 1; i++) { +// rowIndexs[i + 2] = i + 6; +// } +// // ϲԪ +// 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] = 4; +// for (int i = 0; i < rows; i++) { +// rowIndexs3[i + 1] = i + 5; +// } +// +// combine(sheet, rowIndexs, new int[] { 0, 1 }); +// combine(sheet, rowIndexs2, new int[] { 12}); +// combine(sheet, rowIndexs3, new int[] { 13 }); +// startRow = 19 + rows - 10; +// } +// +// +// +////machiningParameterData +// int rows = 10; +// if (toolingDetailData.size() > 10) { +// rows = toolingDetailData.size() + 1; +// } +// 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) {//i0ʼ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 < 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, 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 < machiningParameterData.size(); i++) { +// if(i==9) { +// System.out.println(); +// } +// List machiningParameterList = machiningParameterData.get(i); +// XSSFRow row = sheet.getRow(i + 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(22); +// 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(10); +//// cell1.setCellValue(machiningParameterList.get(1)); +//// XSSFCell cell2 = row.getCell(11); +//// cell2.setCellValue(machiningParameterList.get(2)); +//// XSSFCell cell3 = row.getCell(13); +//// cell3.setCellValue(machiningParameterList.get(3)); +//// XSSFCell cell4 = row.getCell(14); +//// 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 - 3)); +// // ϲԪ +// int[] rowInders = new int[1 + rows]; +// rowInders[0] = startRow - 3; +// rowInders[0] = startRow - 2; +// 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 = 20 + toolingDetailData.size() - 10; +// } else { +// startRow = 20; +// } +// if (rows > 10) { +// startRow = startRow + rows - 10; +// } +// System.out.println("startRow:"+startRow); +// 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[] { 11, 12 }); +// combine(sheet, new int[] { i + startRow }, new int[] { 14, 15, 16 }); +// } +// +// 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(4); +// cell2.setCellValue(controlRequirementList.get(2)); +// XSSFCell cell3 = row.getCell(5); +// cell3.setCellValue(controlRequirementList.get(3)); +// XSSFCell cell4 = row.getCell(7); +// cell4.setCellValue(controlRequirementList.get(4)); +// XSSFCell cell5 = row.getCell(9); +// cell5.setCellValue(controlRequirementList.get(5)); +// XSSFCell cell6 = row.getCell(10); +// cell6.setCellValue(controlRequirementList.get(6)); +// XSSFCell cell7 = row.getCell(11); +// 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)); +// XSSFCell cel11 = row.getCell(6); +// cel11.setCellValue(controlRequirementList.get(11)); +// XSSFCell cel12 = row.getCell(8); +// cel12.setCellValue(controlRequirementList.get(12)); +// XSSFCell cel13 = row.getCell(3); +// cel13.setCellValue(controlRequirementList.get(13)); +// } +// +// 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,5.67,9.52,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(18); + cell1.setCellValue(machiningParameterList.get(1)); + XSSFCell cell2 = row.getCell(19); + cell2.setCellValue(machiningParameterList.get(2)); + XSSFCell cell3 = row.getCell(21); + cell3.setCellValue(machiningParameterList.get(3)); + XSSFCell cell4 = row.getCell(22); + 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 writeJobProcessFormAcrossToExcel_New(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()/2-10>i) { + if(controlPlanBean.getMachiningParameterData().size()%2 == 1) { + + i=controlPlanBean.getMachiningParameterData().size()/2-9; + }else { + i=controlPlanBean.getMachiningParameterData().size()/2-10; + } + } + ExcelUtil.InsertTitlePicture(file,outFilePath,outFilePathp,new int[] {18,19,20,21,22,23,24,25,26,27,28,29}, + new int[] {18,19,20,21,22,23,24},true,5.67,9.52,18+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 = 6; + if (controlPlanBean != null) { + // ӵϢexcel + XSSFRow titleRow = sheet.getRow(0); + setCellValue(titleRow, 2, controlPlanBean.getGsmc()); + setCellValue(titleRow, 14, controlPlanBean.getWjbh()); + setCellValue(titleRow, 18, controlPlanBean.getBbh()); + setCellValue(titleRow, 22, controlPlanBean.getBz()); + titleRow = sheet.getRow(1); + setCellValue(titleRow, 14, controlPlanBean.getLjdh()); + setCellValue(titleRow, 18, controlPlanBean.getCxqy()); + setCellValue(titleRow, 22, controlPlanBean.getSh()); + titleRow = sheet.getRow(2); + setCellValue(titleRow, 14, controlPlanBean.getSbxh()); + setCellValue(titleRow, 18, controlPlanBean.getSbmc()); + setCellValue(titleRow, 22, controlPlanBean.getPz()); + titleRow = sheet.getRow(3); + setCellValue(titleRow, 14, controlPlanBean.getBgx()); + setCellValue(titleRow, 18, controlPlanBean.getXdgx()); + setCellValue(titleRow, 22, controlPlanBean.getFbrq()); + + + 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 = 2; j < 25; 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[] { 5, 6, 7 }); + combine(sheet, new int[] { i + startRow }, new int[] { 8, 9, 10, 11 }); + combine(sheet, new int[] { i + startRow }, new int[] { 17, 18 }); + combine(sheet, new int[] { i + startRow }, new int[] { 20, 21 }); + combine(sheet, new int[] { i + startRow }, new int[] { 23, 24 }); + } + + 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(8); + cell4.setCellValue(toolingDetailList.get(4)); + } + startRow = 5; +// 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) { + if(machiningParameterData.size() % 2 == 1) { + rows = machiningParameterData.size() / 2 + 1; + }else { + rows = machiningParameterData.size() / 2; + } + for (int i = 10; i < rows; 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 < 25; 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, 7 }); + combine(sheet, new int[] { i + startRow }, new int[] { 8, 9, 10, 11 }); + combine(sheet, new int[] { i + startRow }, new int[] { 17, 18 }); + combine(sheet, new int[] { i + startRow }, new int[] { 20, 21 }); + combine(sheet, new int[] { i + startRow }, new int[] { 23, 24 }); + } + } + } + + 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(14); + cell1.setCellValue(machiningParameterList.get(1)); + XSSFCell cell2 = row.getCell(15); + cell2.setCellValue(machiningParameterList.get(2)); + XSSFCell cell3 = row.getCell(16); + cell3.setCellValue(machiningParameterList.get(3)); + XSSFCell cell4 = row.getCell(17); + 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(19); + cell1.setCellValue(machiningParameterList.get(1)); + XSSFCell cell2 = row.getCell(20); + cell2.setCellValue(machiningParameterList.get(2)); + XSSFCell cell3 = row.getCell(22); + cell3.setCellValue(machiningParameterList.get(3)); + XSSFCell cell4 = row.getCell(23); + 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(14); + cell1.setCellValue(machiningParameterList.get(1)); + XSSFCell cell2 = row.getCell(15); + cell2.setCellValue(machiningParameterList.get(2)); + XSSFCell cell3 = row.getCell(16); + cell3.setCellValue(machiningParameterList.get(3)); + XSSFCell cell4 = row.getCell(17); + cell4.setCellValue(machiningParameterList.get(4)); + } + } + // startRow = 18; + // ϲԪ + if (rows > 10) { + // ֺϲԪ + unMerge(sheet, "A5"); + // ֺϲԪ + unMerge(sheet, "M1"); + // ֺϲԪ + unMerge(sheet, "N5"); + // ϲԪ + int[] rowIndexs = new int[2 + rows - 1]; + rowIndexs[0] = 4; + rowIndexs[1] = 5; + for (int i = 0; i < rows - 1; i++) { + rowIndexs[i + 2] = i + 6; + } + // ϲԪ + 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] = 4; + for (int i = 0; i < rows; i++) { + rowIndexs3[i + 1] = i + 5; + } + + combine(sheet, rowIndexs, new int[] { 0, 1 }); + combine(sheet, rowIndexs2, new int[] { 12}); + combine(sheet, rowIndexs3, new int[] { 13 }); + startRow = 19 + rows - 10; + } + else + { + startRow = 19; + } + System.out.println("startRow:"+startRow); + 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 > 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 < 25; 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[] { 11, 12}); + combine(sheet, new int[] { i + startRow }, new int[] { 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(7); + cell4.setCellValue(controlRequirementList.get(4)); + XSSFCell cell5 = row.getCell(9); + cell5.setCellValue(controlRequirementList.get(5)); + XSSFCell cell6 = row.getCell(10); + cell6.setCellValue(controlRequirementList.get(6)); + XSSFCell cell7 = row.getCell(11); + cell7.setCellValue(controlRequirementList.get(7)); + XSSFCell cell8 = row.getCell(13); + cell8.setCellValue(controlRequirementList.get(8)); + XSSFCell cell9 = row.getCell(14); + cell9.setCellValue(controlRequirementList.get(9)); +// XSSFCell cell10 = row.getCell(15); +// cell10.setCellValue(controlRequirementList.get(10)); + XSSFCell cell11 = row.getCell(6); + cell11.setCellValue(controlRequirementList.get(11)); + XSSFCell cell12 = row.getCell(8); + cell12.setCellValue(controlRequirementList.get(12)); + } + + //++++++ + // ϲԪ + if (controlRequirementData.size() > 10) { + // ֺϲԪ + unMerge(sheet, "A" + (startRow - 2)); + // ϲԪ + int[] rowIndexs = new int[3 + controlRequirementData.size()]; + rowIndexs[0] = startRow - 3; + rowIndexs[1] = startRow - 2; + rowIndexs[2] = startRow - 1; + for (int i = 0; i < controlRequirementData.size(); i++) { + rowIndexs[i + 3] = i + startRow; + } + + combine(sheet, rowIndexs, new int[] { 0, 1 }); + + combine(sheet, rowIndexs, new int[] { 17, 18, 19, 20, 21, 22, 23, 24 }); + } + + } 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.getSbxh()); + titleRow = sheet.getRow(3); + setCellValue(titleRow, 9, controlPlanBean.getSbmc()); + //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 writeAssembleProcessFormToExcel_New(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 = 6; + if (controlPlanBean != null) { + // ӵϢexcel + XSSFRow titleRow = sheet.getRow(0); + setCellValue(titleRow, 2, controlPlanBean.getGsmc()); + setCellValue(titleRow, 11, controlPlanBean.getWjbh()); + setCellValue(titleRow, 17, controlPlanBean.getBz()); + titleRow = sheet.getRow(1); + setCellValue(titleRow, 11, controlPlanBean.getBbh()); + setCellValue(titleRow, 17, controlPlanBean.getSh()); + titleRow = sheet.getRow(2); + setCellValue(titleRow, 11, controlPlanBean.getLjdh()); + setCellValue(titleRow, 17, controlPlanBean.getPz()); + titleRow = sheet.getRow(3); + setCellValue(titleRow, 2, controlPlanBean.getCxqy()); + setCellValue(titleRow, 6, controlPlanBean.getSbxh()); + setCellValue(titleRow, 11, controlPlanBean.getSbmc()); + setCellValue(titleRow, 17, controlPlanBean.getFbrq()); + //setCellValue(titleRow, 13, " ¹"+controlPlanBean.getXdgx()); + + List> toolingDetailData = controlPlanBean.getToolingDetailData();//0 1 10 13 16 + List> machiningParameterData = controlPlanBean.getMachiningParameterData();//1 2 5 6 7ޣ 8 9 12 13 14 16 + 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 = 10; j < 19; 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[] { 11, 12 }); + combine(sheet, new int[] { i + startRow }, new int[] { 13, 14 }); + combine(sheet, new int[] { i + startRow }, new int[] { 15, 16 }); + combine(sheet, new int[] { i + startRow }, new int[] { 17, 18 }); + } + + List toolingDetailList = toolingDetailData.get(i); +// XSSFRow row = sheet.getRow(i + startRow); + XSSFCell cell1 = row.getCell(10); + cell1.setCellValue(toolingDetailList.get(1)); + XSSFCell cell2 = row.getCell(11); + cell2.setCellValue(toolingDetailList.get(2)); + XSSFCell cell3 = row.getCell(13); + cell3.setCellValue(toolingDetailList.get(3)); + XSSFCell cell4 = row.getCell(15); + cell4.setCellValue(toolingDetailList.get(4)); + XSSFCell cell5 = row.getCell(17); + cell5.setCellValue(toolingDetailList.get(5)); + } + startRow = 18; + 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 ,8 , 9}); + startRow = 18 + 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 > 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 < 19; 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[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); + combine(sheet, new int[] { i + startRow }, new int[] { 10, 11, 12 }); + combine(sheet, new int[] { i + startRow }, new int[] { 13, 14, 15 }); + combine(sheet, new int[] { i + startRow }, new int[] { 16, 17, 18 }); + } + + List machiningParameterList = machiningParameterData.get(i); + XSSFCell cell1 = row.getCell(0); + cell1.setCellValue(machiningParameterList.get(1)); + XSSFCell cell2 = row.getCell(1); + cell2.setCellValue(machiningParameterList.get(2)); + XSSFCell cell3 = row.getCell(10); + cell3.setCellValue(machiningParameterList.get(3)); + XSSFCell cell4 = row.getCell(13); + cell4.setCellValue(machiningParameterList.get(4)); + XSSFCell cell5 = row.getCell(16); + cell5.setCellValue(machiningParameterList.get(5)); + } + startRow = 31; + if (toolingDetailData.size() > 10) { + startRow = 31 + toolingDetailData.size() - 10; + } + if (machiningParameterData.size() > 9) { + startRow = startRow + machiningParameterData.size() - 9; + } + for (int i = 0; i < controlRequirementData.size(); i++) { + if(i==9) { + System.out.println(); + } + 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 = 1; j < 19; 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[] { 2, 3, 4}); + combine(sheet, new int[] { i + startRow }, new int[] { 9, 10, 11 }); + combine(sheet, new int[] { i + startRow }, new int[] { 14, 15 }); + combine(sheet, new int[] { i + startRow }, new int[] { 16, 17, 18 }); + } + + List controlRequirementList = controlRequirementData.get(i); + XSSFCell cell1 = row.getCell(1); + cell1.setCellValue(controlRequirementList.get(1)); + XSSFCell cell2 = row.getCell(2); + cell2.setCellValue(controlRequirementList.get(2)); + XSSFCell cell3 = row.getCell(5); + cell3.setCellValue(controlRequirementList.get(3)); + XSSFCell cell4 = row.getCell(7); + cell4.setCellValue(controlRequirementList.get(4)); + XSSFCell cell5 = row.getCell(9); + cell5.setCellValue(controlRequirementList.get(5)); + XSSFCell cell6 = row.getCell(12); + cell6.setCellValue(controlRequirementList.get(6)); + XSSFCell cell7 = row.getCell(13); + cell7.setCellValue(controlRequirementList.get(7)); + XSSFCell cell8 = row.getCell(14); + cell8.setCellValue(controlRequirementList.get(8)); + XSSFCell cell9 = row.getCell(16); + cell9.setCellValue(controlRequirementList.get(9)); + XSSFCell cell10 = row.getCell(6); + cell10.setCellValue(controlRequirementList.get(10)); + XSSFCell cell11 = row.getCell(8); + cell11.setCellValue(controlRequirementList.get(11)); + } + + if (controlRequirementData.size() > 10) { + // ֺϲԪ + 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}); + } + + } 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; + } + + /** + * ҵҪ½һPOIrow + * + * @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..aba28dd --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiComboBox.java @@ -0,0 +1,218 @@ +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; + + +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..f73bcc4 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/MultiComboBox2.java @@ -0,0 +1,259 @@ +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; + + +/** + * ѡ + * + */ +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..bbf3fa7 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ParseXMLUtil.java @@ -0,0 +1,146 @@ +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.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +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) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + MessageBox.post(rb.getString("sjjutil_display.TITLE"), "WARNING", + MessageBox.WARNING); + return null; + } else { + File fmsFile = file[0].getFmsFile(); + return fmsFile; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } else { + MessageBox.post("δҵѡ["+pernaem+"]ѡô", "", + MessageBox.ERROR); + return null; + } + return null; + } + +// /** +// * +// * @param args +// */ +// public static void main(String[] args) { +// // TODO Auto-generated method stub +// File file = new File("C:\\Users\\wangc\\Desktop\\\\˱Ʒƴӷʽ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/ProcessBarDialog.java b/src/com/connor/renben/process/plm/util/ProcessBarDialog.java new file mode 100644 index 0000000..484ce47 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ProcessBarDialog.java @@ -0,0 +1,60 @@ +package com.connor.renben.process.plm.util; + + +import javax.swing.Box; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; + +import java.awt.Dimension; +import java.util.TimerTask; +import java.util.Timer; +import javax.swing.*; + +public class ProcessBarDialog extends JFrame { + + private JProgressBar progressBar = new JProgressBar(); + + private Box box = Box.createVerticalBox(); + + private Box box2 = Box.createHorizontalBox(); + private String name; + + public ProcessBarDialog(String name) { + this.name = name; + } + + public void open() { + this.setTitle("..."); + + setBounds(200, 200, 300, 100); + + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + setLocationRelativeTo(null); + progressBar.setIndeterminate(true);// ýʽΪȷĽʽ(ع)falseΪȷĽʽ(ͷβʾ) + + progressBar.setStringPainted(true);// ýʾʾϢ + + progressBar.setString(name);// ʾϢ + progressBar.setPreferredSize(new Dimension(300, 100)); + + box2.add(progressBar); + box.add(box2); + add(box); + setVisible(true); + // Timer timer = new Timer(); + // TimerTask timerTask = new TimerTask(){ + // @Override + // public void run() { + // System.out.println("ԓУ"); + // dispose(); + // } + // }; + // timer.schedule(timerTask,5000);//5000Ϊ5 + } + + public void close() { + dispose(); + } + +} diff --git a/src/com/connor/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..205b29a --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SaveControlPlan.java @@ -0,0 +1,772 @@ +package com.connor.renben.process.plm.util; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +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 insertData2() { +// Connection tcConnection = null; +// PreparedStatement insertStmt = null; +// PreparedStatement updateStmt = null; +// PreparedStatement updateStmt2 = null; +// ResultSet rs = null; +// InputStream input = null; +// +// try { +// // 1. ʼݿӺ +// tcConnection = SqlUtilT.getTCConnection(); +// tcConnection.setAutoCommit(false); +// +// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// +// // 2. ׼SQL +// String insertSQL = pro.getProperty("INSERTSQL"); +// String selectSQL = String.format(pro.getProperty("BOMCHECKSAVESELECT"), item.getUid(), "飨%", +// comp.getUid()); +// String updateSQL = pro.getProperty("BOMCHECKSAVEUPDATE"); +// String updateSQL2 = pro.getProperty("BOMCHECKSAVEUPDATE2"); +// +// // 3. ȡҵ +// properties = TMomMethodUtil.getBomPropertys(session, item); +// List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); +// String itemUid = item.getUid(); +// +// // 4. ȡƼƻŻѯ +// List kzjhList = getControlPlans(item); +// +// // 5. ޿Ƽƻֱ +// if (kzjhList.isEmpty()) { +// processWithoutControlPlans(tcConnection, pro, itemUid, meopNameList); +// } else { +// processWithControlPlans(tcConnection, pro, kzjhList, itemUid, meopNameList); +// } +// +// tcConnection.commit(); +// } catch (Exception e) { +// try { +// if (tcConnection != null) +// tcConnection.rollback(); +// } catch (SQLException ex) { +// ex.printStackTrace(); +// } +// e.printStackTrace(); +// } finally { +// closeResources(rs, insertStmt, updateStmt, updateStmt2, tcConnection, input); +// SqlUtilT.freeAll(); +// } +// } +// +// private List getControlPlans(TCComponentItem item) throws Exception { +// return Arrays.stream(item.getRelatedComponents("IMAN_reference")) +// .filter(c -> c.getType().toUpperCase().contains("KZJH")).map(c -> (TCComponentItem) c) +// .collect(Collectors.toList()); +// } +// +// private void processWithoutControlPlans(Connection conn, Properties pro, String itemUid, List meopNameList) +// throws SQLException { +// // 1. ѯ +// try (PreparedStatement selectStmt = conn.prepareStatement( +// String.format(pro.getProperty("BOMCHECKSAVESELECT"), itemUid, "飨%", comp.getUid()))) { +// +// ResultSet rs = selectStmt.executeQuery(); +// while (rs.next()) { +// List row = new ArrayList<>(); +// row.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// row.add(rs.getString("RB3_GYBH")); +// row.add(rs.getString("RB3_GCMC")); +// row.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(row); +// } +// } +// +// // 2. ݲѯ +// if (dataList.isEmpty()) { +// batchInsertForNonControlPlan(conn, pro, itemUid, meopNameList); +// } else { +// batchUpdateForNonControlPlan(conn, pro, itemUid); +// } +// } +// +// private void batchInsertForNonControlPlan(Connection conn, Properties pro, String itemUid, +// List meopNameList) throws SQLException { +// String insertSQL = pro.getProperty("INSERTSQL"); +// +// try (PreparedStatement stmt = conn.prepareStatement(insertSQL)) { +// for (int j = 0; j < properties.size(); j++) { +// // +// UUID kzjhUid = UUID.randomUUID(); +// String processName = formatProcessName(properties.get(j).get(2).toString()); +// String inspectionType = getInspectionType(properties.get(j).get(2).toString()); +// +// setInsertParameters(stmt, kzjhUid, itemUid, j, processName, inspectionType, "RB3_YJKZJH"); +// stmt.addBatch(); +// +// // Ѳ +// if (meopNameList.contains(properties.get(j).get(2).toString())) { +// UUID patrolUid = UUID.randomUUID(); +// String patrolName = formatPatrolName(properties.get(j).get(2).toString()); +// setInsertParameters(stmt, patrolUid, itemUid, j, patrolName, "Ѳ\nPatrol inspection", +// "RB3_YJKZJH"); +// stmt.addBatch(); +// } +// +// if (j % 100 == 0) +// stmt.executeBatch(); +// } +// stmt.executeBatch(); +// } +// } +// +// private void batchUpdateForNonControlPlan(Connection conn, Properties pro, String itemUid) throws SQLException { +// String updateSQL = String.format(pro.getProperty("BOMCHECKSAVEUPDATE"), itemUid, "?", "飨%"); +// String updateSQL2 = String.format(pro.getProperty("BOMCHECKSAVEUPDATE2"), itemUid, "?", "飨%"); +// +// try (PreparedStatement updateStmt = conn.prepareStatement(updateSQL); +// PreparedStatement updateStmt2 = conn.prepareStatement(updateSQL2)) { +// +// for (List dataRow : dataList) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataRow.get(0).equals(properties.get(j).get(0))) { +// // +// updateStmt.setString(1, properties.get(j).get(1).toString()); +// updateStmt.setString(2, formatProcessName(properties.get(j).get(2).toString())); +// updateStmt.setString(3, properties.get(j).get(3).toString()); +// updateStmt.setString(4, dataRow.get(0).toString()); +// updateStmt.addBatch(); +// +// // Ѳ +// updateStmt2.setString(1, properties.get(j).get(1).toString()); +// updateStmt2.setString(2, formatPatrolName(properties.get(j).get(2).toString())); +// updateStmt2.setString(3, ""); +// updateStmt2.setString(4, dataRow.get(0).toString()); +// updateStmt2.addBatch(); +// } +// } +// } +// updateStmt.executeBatch(); +// updateStmt2.executeBatch(); +// } +// } +// +// private void processWithControlPlans(Connection conn, Properties pro, List kzjhList, +// String itemUid, List meopNameList) throws SQLException { +// for (TCComponentItem kzjh : kzjhList) { +// String kzjhType = kzjh.getType().toUpperCase(); +// +// // ѯ +// try (PreparedStatement selectStmt = conn.prepareStatement( +// String.format(pro.getProperty("BOMCHECKSAVESELECT"), itemUid, "飨%", comp.getUid()))) { +// +// ResultSet rs = selectStmt.executeQuery(); +// dataList.clear(); +// while (rs.next()) { +// List row = new ArrayList<>(); +// row.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// row.add(rs.getString("RB3_GYBH")); +// row.add(rs.getString("RB3_GCMC")); +// row.add(rs.getString("RB3_JQSB") == null ? "" : rs.getString("RB3_JQSB")); +// dataList.add(row); +// } +// } +// +// if (dataList.isEmpty()) { +// batchInsertForControlPlan(conn, pro, itemUid, kzjhType); +// } else { +// batchUpdateForControlPlan(conn, pro, itemUid, kzjhType, meopNameList); +// } +// } +// } +// +// private void batchInsertForControlPlan(Connection conn, Properties pro, String itemUid, String kzjhType) +// throws SQLException { +// String insertSQL = pro.getProperty("INSERTSQL"); +// +// try (PreparedStatement stmt = conn.prepareStatement(insertSQL)) { +// for (int j = 0; j < properties.size(); j++) { +// UUID kzjhUid = UUID.randomUUID(); +// String processName = formatProcessName(properties.get(j).get(2).toString()); +// +// setInsertParameters(stmt, kzjhUid, itemUid, j, processName, "", kzjhType); +// stmt.addBatch(); +// +// if (j % 100 == 0) +// stmt.executeBatch(); +// } +// stmt.executeBatch(); +// } +// } +// +// private void batchUpdateForControlPlan(Connection conn, Properties pro, String itemUid, String kzjhType, +// List meopNameList) throws SQLException { +// String updateSQL = String.format(pro.getProperty("BOMCHECKSAVEUPDATE"), itemUid, "?", "飨%"); +// String updateSQL2 = String.format(pro.getProperty("BOMCHECKSAVEUPDATE2"), itemUid, "?", "飨%"); +// String insertSQL = pro.getProperty("INSERTSQL"); +// +// try (PreparedStatement updateStmt = conn.prepareStatement(updateSQL); +// PreparedStatement updateStmt2 = conn.prepareStatement(updateSQL2); +// PreparedStatement insertStmt = conn.prepareStatement(insertSQL)) { +// +// // 1. +// for (List dataRow : dataList) { +// for (int j = 0; j < properties.size(); j++) { +// if (dataRow.get(0).equals(properties.get(j).get(0))) { +// // +// updateStmt.setString(1, properties.get(j).get(1).toString()); +// updateStmt.setString(2, formatProcessName(properties.get(j).get(2).toString())); +// updateStmt.setString(3, +// dataRow.get(3).toString().isEmpty() ? properties.get(j).get(3).toString() +// : dataRow.get(3).toString()); +// updateStmt.setString(4, dataRow.get(0).toString()); +// updateStmt.addBatch(); +// +// // Ѳ +// updateStmt2.setString(1, properties.get(j).get(1).toString()); +// updateStmt2.setString(2, formatPatrolName(properties.get(j).get(2).toString())); +// updateStmt2.setString(3, ""); +// updateStmt2.setString(4, dataRow.get(0).toString()); +// updateStmt2.addBatch(); +// } +// } +// } +// updateStmt.executeBatch(); +// updateStmt2.executeBatch(); +// +// // 2. +// Set existingMeopIds = dataList.stream().map(row -> row.get(0).toString()) +// .collect(Collectors.toSet()); +// +// for (int i = 0; i < properties.size(); i++) { +// if (!existingMeopIds.contains(properties.get(i).get(0).toString())) { +// UUID kzjhUid = UUID.randomUUID(); +// String processName = formatProcessName(properties.get(i).get(2).toString()); +// String inspectionType = getInspectionType(properties.get(i).get(2).toString()); +// +// setInsertParameters(insertStmt, kzjhUid, itemUid, i, processName, inspectionType, kzjhType); +// insertStmt.addBatch(); +// +// if (meopNameList.contains(properties.get(i).get(2).toString())) { +// UUID patrolUid = UUID.randomUUID(); +// String patrolName = formatPatrolName(properties.get(i).get(2).toString()); +// setInsertParameters(insertStmt, patrolUid, itemUid, i, patrolName, "Ѳ\nPatrol inspection", +// kzjhType); +// insertStmt.addBatch(); +// } +// } +// } +// insertStmt.executeBatch(); +// +// // 3. ɾ +// Set currentMeopIds = properties.stream().map(prop -> prop.get(0).toString()) +// .collect(Collectors.toSet()); +// +// List toDelete = dataList.stream().map(row -> row.get(0).toString()) +// .filter(id -> !currentMeopIds.contains(id)).collect(Collectors.toList()); +// +// if (!toDelete.isEmpty()) { +// String deleteSQL = String.format(pro.getProperty("DELETE"), "?", itemUid); +// try (PreparedStatement deleteStmt = conn.prepareStatement(deleteSQL)) { +// for (String id : toDelete) { +// deleteStmt.setString(1, id); +// deleteStmt.addBatch(); +// } +// deleteStmt.executeBatch(); +// } +// } +// } +// } +// +// // +// private String formatProcessName(String originalName) { +// if (originalName.contains("/") && originalName.split("/").length == 2) { +// return originalName.replace("/", "\n"); +// } +// return originalName; +// } +// +// private String formatPatrolName(String originalName) { +// if (originalName.contains("/") && originalName.split("/").length == 2) { +// return "飨" + originalName.split("/")[0] + "\n" + "inspect(" + originalName.split("/")[1] + ")"; +// } +// return "飨" + originalName + ""; +// } +// +// private String getInspectionType(String processName) { +// return processName.contains("") ? "Ѳ\nPatrol inspection" : ""; +// } +// +// private void setInsertParameters(PreparedStatement stmt, UUID uid, String itemUid, int propIndex, +// String processName, String inspectionType, String kzjhType) throws SQLException { +// stmt.setString(1, uid.toString().replace("-", "")); +// stmt.setString(2, itemUid); +// stmt.setString(3, properties.get(propIndex).get(0).toString()); +// stmt.setString(4, properties.get(propIndex).get(1).toString()); +// stmt.setString(5, processName); +// stmt.setString(6, properties.get(propIndex).get(3).toString()); +// stmt.setString(7, inspectionType); +// stmt.setString(8, "1"); // ǹ̶ֵ +// stmt.setString(9, ""); +// stmt.setString(10, ""); +// stmt.setString(11, ""); +// stmt.setString(12, ""); +// stmt.setString(13, ""); +// stmt.setString(14, ""); +// stmt.setString(15, ""); +// stmt.setString(16, ""); +// stmt.setString(17, ""); +// stmt.setString(18, ""); +// stmt.setString(19, ""); +// stmt.setString(20, ""); +// stmt.setString(21, ""); +// stmt.setString(22, ""); +// stmt.setString(23, ""); +// stmt.setString(24, ""); +// stmt.setString(25, ""); +// stmt.setString(26, ""); +// stmt.setString(27, ""); +// stmt.setString(28, ""); +// stmt.setString(29, kzjhType); +// stmt.setString(30, "1"); // ǹ̶ֵ +// stmt.setString(31, "0"); // ǹ̶ֵ +// stmt.setString(32, ""); // ֵ +// stmt.setString(33, "0"); // ǹ̶ֵ +// stmt.setString(34, comp.getUid()); +// stmt.setString(35, properties.get(propIndex).get(4).toString()); +// } +// +// private void closeResources(AutoCloseable... resources) { +// for (AutoCloseable res : resources) { +// if (res != null) { +// try { +// res.close(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// } +// } + + 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); + System.out.println("11"); + // properties.clear(); + List meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); + System.out.println("22"); + 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()); + System.out.println("sql:"+sql); + 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(); + // ݲ뵽Ƽƻ + SqlUtilT.getTCConnection(); + String insertSQL = pro.getProperty("INSERTSQL"); + + 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)))) { + 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); + } + } + } + // ӹ + // ѯݿе + 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"); + 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); + System.out.println("====>" + sql); + while (rs.next()) { + List rowList = new ArrayList(); + rowList.add(rs.getString("RB3_MEOPID") == null ? "" : 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(); + // ݲ뵽Ƽƻ + 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); + } + } + } + // ӹ + // ѯݿе + 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"); + 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..4b341e9 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/SavePermissions.java @@ -0,0 +1,444 @@ +package com.connor.renben.process.plm.util; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +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() { +// ResultSet rs = null; +// ResultSet result = null; +// ResultSet resultSet = null; +// InputStream input = null; +// PreparedStatement pstmtInsert = null; +// PreparedStatement pstmtUpdate = null; +// PreparedStatement pstmtDelete = null; +// PreparedStatement pstmtControlPlan = null; +// PreparedStatement pstmtPFMEA = null; +// +// try { +// // ȡȨ +// properties = TMomMethodUtil.getPermissionsBomPropertys(session, item); +// String itemUid = item.getUid(); +// +// // ȡƼƻPFMEA +// TCComponent[] referenceTarget = item.getRelatedComponents("IMAN_reference"); +// List referenceTargetList = new ArrayList<>(); +// for (TCComponent component : referenceTarget) { +// String type = component.getType().toUpperCase(); +// TCComponent[] revisions = component.getReferenceListProperty("revision_list"); +// +// if (type.contains("KZJH")) { // Ƽƻ +// for (TCComponent revision : revisions) { +// if (revision.getProperty("release_status_list") == null || revision.getProperty("release_status_list").equals("")) { +// controlUids.add(revision.getUid()); +// } +// } +// } else if (type.contains("PFMEA")) { // PFMEA +// for (TCComponent revision : revisions) { +// if (revision.getProperty("release_status_list") == null || revision.getProperty("release_status_list").equals("")) { +// PFMEAUids.add(revision.getUid()); +// } +// } +// } +// } +// +// // ȡݿ +// SqlUtilT.getTCConnection(); +// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// +// // ѯݿе +// String sql = String.format(pro.getProperty("BOMCHECKSAVESELECTPERMISSIONS"), itemUid, "飨%"); +// rs = SqlUtilT.read(sql); +// List> dataList = new ArrayList<>(); +// while (rs.next()) { +// List rowList = new ArrayList<>(); +// rowList.add(rs.getString("RB3_MEOPID") == null ? "" : rs.getString("RB3_MEOPID")); +// 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) { +// pstmtInsert = SqlUtilT.connection.prepareStatement(pro.getProperty("INSERTPERMISSIONS")); +// for (List property : properties) { +// pstmtInsert.setString(1, UUID.randomUUID().toString().replace("-", "")); +// pstmtInsert.setString(2, itemUid); +// pstmtInsert.setString(3, property.get(0).toString()); +// pstmtInsert.setString(4, property.get(1).toString()); +// pstmtInsert.setString(5, property.get(2).toString().contains("/") ? property.get(2).toString().split("/")[0] : property.get(2).toString()); +// pstmtInsert.setString(6, ""); +// pstmtInsert.setString(7, ""); +// pstmtInsert.setString(8, ""); +// pstmtInsert.setString(9, ""); +// pstmtInsert.setString(10, property.get(3).toString()); +// pstmtInsert.addBatch(); +// } +// pstmtInsert.executeBatch(); +// } else { +// // ޸ıӦĹ +// pstmtUpdate = SqlUtilT.connection.prepareStatement(pro.getProperty("UPDATEPERMISSIONS")); +// for (List dataRow : dataList) { +// for (List property : properties) { +// if (dataRow.get(0).equals(property.get(0)) && +// (!dataRow.get(1).equals(property.get(1)) || +// !dataRow.get(2).equals(property.get(2)) || +// !dataRow.get(3).equals(property.get(3)))) { +// pstmtUpdate.setString(1, property.get(1).toString()); +// pstmtUpdate.setString(2, property.get(2).toString().contains("/") ? property.get(2).toString().split("/")[0] : property.get(2).toString()); +// pstmtUpdate.setString(3, property.get(3).toString()); +// pstmtUpdate.setString(4, itemUid); +// pstmtUpdate.setString(5, dataRow.get(0).toString()); +// pstmtUpdate.addBatch(); +// } +// } +// } +// pstmtUpdate.executeBatch(); +// +// // ӹ +// result = SqlUtilT.read(sql); +// List indexList = new ArrayList<>(); +// while (result.next()) { +// indexList.add(result.getString("RB3_MEOPID")); +// } +// for (List property : properties) { +// if (!indexList.contains(property.get(0))) { +// pstmtInsert.setString(1, UUID.randomUUID().toString().replace("-", "")); +// pstmtInsert.setString(2, itemUid); +// pstmtInsert.setString(3, property.get(0).toString()); +// pstmtInsert.setString(4, property.get(1).toString()); +// pstmtInsert.setString(5, property.get(2).toString().contains("/") ? property.get(2).toString().split("/")[0] : property.get(2).toString()); +// pstmtInsert.setString(6, ""); +// pstmtInsert.setString(7, ""); +// pstmtInsert.setString(8, ""); +// pstmtInsert.setString(9, ""); +// pstmtInsert.setString(10, property.get(3).toString()); +// pstmtInsert.addBatch(); +// } +// } +// pstmtInsert.executeBatch(); +// +// // ɾӦĹ +// StringBuffer sb = new StringBuffer("("); +// for (List property : properties) { +// sb.append("\'").append(property.get(0)).append("\',"); +// } +// String selectSql = String.format(pro.getProperty("BOMCHECKSAVESELECTPERMISSIONS2"), itemUid, sb.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) { +// pstmtDelete = SqlUtilT.connection.prepareStatement(pro.getProperty("DELETEPERMISSIONS")); +// for (String deleteId : deleteList) { +// pstmtDelete.setString(1, deleteId); +// pstmtDelete.setString(2, itemUid); +// pstmtDelete.addBatch(); +// } +// pstmtDelete.executeBatch(); +// } +// } +// +// // ޸ĿƼƻPFMEAݵı +// if (controlUids != null && controlUids.size() > 0) { +// pstmtControlPlan = SqlUtilT.connection.prepareStatement("UPDATE RB3_CONTROLPLAN SET NO=? WHERE RB3_MEOPID = ? AND RB3_GCMC = ? AND REVISIONUID = ?"); +// for (String controlUid : controlUids) { +// for (List property : properties) { +// pstmtControlPlan.setString(1, property.get(1).toString()); +// pstmtControlPlan.setString(2, property.get(0).toString()); +// pstmtControlPlan.setString(3, property.get(2).toString()); +// pstmtControlPlan.setString(4, controlUid); +// pstmtControlPlan.addBatch(); +// } +// } +// pstmtControlPlan.executeBatch(); +// } +// +// if (PFMEAUids != null && PFMEAUids.size() > 0) { +// pstmtPFMEA = SqlUtilT.connection.prepareStatement("UPDATE RB3_PFMEA SET NO=? WHERE RB3_MEOPID = ? AND REVISIONID = ?"); +// for (String PFMEAUid : PFMEAUids) { +// for (List property : properties) { +// pstmtPFMEA.setString(1, property.get(1).toString()); +// pstmtPFMEA.setString(2, property.get(0).toString()); +// pstmtPFMEA.setString(3, PFMEAUid); +// pstmtPFMEA.addBatch(); +// } +// } +// pstmtPFMEA.executeBatch(); +// } +// +// // ύ +// SqlUtilT.connection.commit(); +// } catch (Exception e) { +// // ع +// try { +// if (SqlUtilT.connection != null && !SqlUtilT.connection.isClosed()) { +// SqlUtilT.connection.rollback(); +// } +// } catch (SQLException ex) { +// ex.printStackTrace(); +// } +// e.printStackTrace(); +// } finally { +// // ͷԴ +// SqlUtilT.free(rs); +// SqlUtilT.free(result); +// SqlUtilT.free(resultSet); +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// SqlUtilT.free(pstmtInsert); +// SqlUtilT.free(pstmtUpdate); +// SqlUtilT.free(pstmtDelete); +// SqlUtilT.free(pstmtControlPlan); +// SqlUtilT.free(pstmtPFMEA); +// SqlUtilT.freeAll(); +// } +// 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..ad60ffd --- /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/ServiceUtil.java b/src/com/connor/renben/process/plm/util/ServiceUtil.java new file mode 100644 index 0000000..15e625d --- /dev/null +++ b/src/com/connor/renben/process/plm/util/ServiceUtil.java @@ -0,0 +1,111 @@ +package com.connor.renben.process.plm.util; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ServiceUtil { + public static TCSession session; +// public static String address = "http://127.0.0.1:13025/api/saveAsObj"; + public static String address = ""; + public static String port; + + /** + * ʼѡ + */ + static { + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + address = session.getPreferenceService().getStringValue("RB3_ProcessServiceAgentAddress"); + if (address == null || address.isEmpty()) { + MessageBox.post("RB3_ProcessServiceAgentAddressERROR!", "error", MessageBox.ERROR); + throw new IllegalStateException("Failed to get valid address from preferences."); + } + } +// + /** + * + * @param args + */ + public static void sendRequest(String... args) { + JSONObject jsonReq = new JSONObject(); + JSONArray argArray = new JSONArray(); + for (String arg : args) { + argArray.add(arg); + } + jsonReq.put("args", argArray); + + // POST + String response; + try { + response = sendPostRequest(address, jsonReq.toJSONString()); + if (response != null) { + System.out.println("Response: " + response); + } else { + System.out.println("Failed to get response"); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * ִpost + * @param urlString + * @param jsonInputString + * @return + * @throws IOException + */ + private static String sendPostRequest(String urlString, String jsonInputString) throws IOException { + URL apiUrl = new URL(urlString); + HttpURLConnection connection = (HttpURLConnection) apiUrl.openConnection(); + + connection.setRequestMethod("POST"); + connection.setRequestProperty("Content-Type", "application/json; utf-8"); + connection.setDoOutput(true); + + try (OutputStream outputStream = connection.getOutputStream()) { + byte[] input = jsonInputString.getBytes("utf-8"); + outputStream.write(input, 0, input.length); + } + + int statusCode = connection.getResponseCode(); + if (statusCode == 200) { + try (InputStream inputStream = connection.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8"); + BufferedReader reader = new BufferedReader(inputStreamReader)) { + StringBuilder response = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + response.append(line); + } + return response.toString(); + } + } else { + + // Ӧ + try (InputStream errorStream = connection.getErrorStream(); + InputStreamReader errorStreamReader = new InputStreamReader(errorStream, "UTF-8"); + BufferedReader errorReader = new BufferedReader(errorStreamReader)) { + StringBuilder errorResponse = new StringBuilder(); + String errorLine; + while ((errorLine = errorReader.readLine()) != null) { + errorResponse.append(errorLine); + } + System.err.println("Error Response: " + errorResponse.toString()); + MessageBox.post(errorResponse.toString(), "error", MessageBox.ERROR); + throw new IllegalStateException(errorResponse.toString()); + } + } + } +} 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..0ee141c --- /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/TCUtils.java b/src/com/connor/renben/process/plm/util/TCUtils.java new file mode 100644 index 0000000..2eecf33 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TCUtils.java @@ -0,0 +1,76 @@ +package com.connor.renben.process.plm.util; + + +import java.io.BufferedWriter; +import java.io.FileWriter; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +/** + * @ClassName: TCUtils + * @Description: TODO(һ仰) + * @author admin + * @date 2024108 + * + */ +public class TCUtils { + + private static final String LOG_FILE_PATH = System.getenv("TEMP") + "\\ByPassLog.txt"; + + /** + * + * @Title: setLogByPass + * @Description: TODO(һ仰) + * @param @param session ǰỰsession + * @param @param name + * @param @throws TCException + * @return void + * @throws + */ + public static void openLogByPass(TCSession session, String name) throws TCException { + //ȡǰû + String userName = session.getUser().getUserName(); + + // ȡǰʱ + Date now = new Date(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String timestamp = formatter.format(now); + + // ־ + String logContent = timestamp + " " + "û" + userName + "ʹ" + name + "" + "·" + "\n"; + + // ׷־ļ + try (BufferedWriter writer = new BufferedWriter(new FileWriter(LOG_FILE_PATH, true))) { + writer.write(logContent); + } catch (IOException e) { + e.printStackTrace(); + System.err.println("д־ļʱ: " + e.getMessage()); + } + } + + public static void closeLogByPass(TCSession session, String name) throws TCException { + //ȡǰû + String userName = session.getUser().getUserName(); + + // ȡǰʱ + Date now = new Date(); + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String timestamp = formatter.format(now); + + // ־ + String logContent = timestamp + " " + "û" + userName + "ʹ" + name + "" + "ر·" + "\n"; + + // ׷־ļ + try (BufferedWriter writer = new BufferedWriter(new FileWriter(LOG_FILE_PATH, true))) { + writer.write(logContent); + } catch (IOException e) { + e.printStackTrace(); + System.err.println("д־ļʱ: " + e.getMessage()); + } + } +} + 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..4e496c0 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TMomFinalUtil.java @@ -0,0 +1,107 @@ +package com.connor.renben.process.plm.util; + +public class TMomFinalUtil { + // ---------------ALL---------------------------------------------- + public static final String PROCESS_MODEL_FILE = "PROCESS_MODEL_FILE";// ģļ + public static final String PROCESS_MODEL_FILE_NEW = "PROCESS_MODEL_FILE_NEW";// ģļ£ + // ---------------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;// ӢIJɿƼƻ + 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..c8d1492 --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TMomMethodUtil.java @@ -0,0 +1,1900 @@ +package com.connor.renben.process.plm.util; + +import java.io.File; +import java.io.IOException; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JOptionPane; + +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.connor.renben.process.plm.sql.util.SqlUtilT; +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.BOMEvent.BOMLineLiteLWBChildAddedEvent; +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.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +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) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // 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)) + { + if(modelFiles[i].split("-")[1].split(";").length == 2) { + // ڱ + String frameTitle = rb.getString("tmommethod01"); + // 尴ťѡ + Object[] options = {rb.getString("tmommethod02"), rb.getString("tmommethod03")}; + // ʾѡԻ򲢻ȡûѡĽ + int choice = JOptionPane.showOptionDialog( + null, // null ʾûи + rb.getString("tmommethod04"), // ԻϢ + frameTitle, // Ի + JOptionPane.YES_NO_OPTION, // ѡ + JOptionPane.QUESTION_MESSAGE, // Ϣ + null, // ͼ꣬null ʾʹĬͼ + options, // ťѡ + rb.getString("tmommethod02") // Ĭѡ + ); + + // ûѡд + if (choice == JOptionPane.YES_OPTION) { + puid = modelFiles[i].split("-")[1].split(";")[0]; + } else if (choice == JOptionPane.NO_OPTION) { + puid = modelFiles[i].split("-")[1].split(";")[1]; + } else { + JOptionPane.showMessageDialog(null, rb.getString("tmommethod05"), "ʾ", JOptionPane.WARNING_MESSAGE); + return null; + } + }else { + puid = modelFiles[i].split("-")[1]; + } + + } + } + System.out.println("puid:"+puid); + 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 session session + * @param fileName ļ + * @param Filetype ļ + * @return + */ + public static File getFile_New(TCSession session,String fileName,String Filetype) { + Locale defaultLocale = Locale.getDefault(); + ResourceBundle rb = ResourceBundle.getBundle("com.connor.renben.process.plm.message.Message", defaultLocale); + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues(TMomFinalUtil.PROCESS_MODEL_FILE_NEW); + 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)) + { + if(modelFiles[i].split("-")[1].split(";").length == 2) { + // ڱ + String frameTitle = rb.getString("tmommethod01"); + // 尴ťѡ + Object[] options = {rb.getString("tmommethod02"), rb.getString("tmommethod03")}; + // ʾѡԻ򲢻ȡûѡĽ + int choice = JOptionPane.showOptionDialog( + null, // null ʾûи + rb.getString("tmommethod04"), // ԻϢ + frameTitle, // Ի + JOptionPane.YES_NO_OPTION, // ѡ + JOptionPane.QUESTION_MESSAGE, // Ϣ + null, // ͼ꣬null ʾʹĬͼ + options, // ťѡ + rb.getString("tmommethod02") // Ĭѡ + ); + + // ûѡд + if (choice == JOptionPane.YES_OPTION) { + puid = modelFiles[i].split("-")[1].split(";")[0]; + } else if (choice == JOptionPane.NO_OPTION) { + puid = modelFiles[i].split("-")[1].split(";")[1]; + } else { + JOptionPane.showMessageDialog(null, rb.getString("tmommethod05"), "ʾ", JOptionPane.WARNING_MESSAGE); + return null; + } + }else { + puid = modelFiles[i].split("-")[1]; + } + + } + } + System.out.println("puid:"+puid); + 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; + } + + /** + * ȡѡȡ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) { + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("MEOP")); + + + return tccomponentitemtype.getNewID(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return ""; + } + /** + * ͨSOAITEM + * + * @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(); + try { + item.refresh(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + //ȡBOM + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topBomLine = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); +// topBomLine.refresh(); +// //ȡµĿƼƻ +// 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]); +// } +// } +// topBomLine.refresh(); + getBomPropertys3(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++) { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + if(subline.getItem().getType().equals("MEProcess")) + { + continue; + } + + + List propertie = new ArrayList(); + propertie + .add(subline.getStringProperty("bl_indented_title") + .split("/")[0]); + propertie.add(subline.getStringProperty("bl_sequence_no")); + String stringProperty = subline.getStringProperty("bl_item_object_name"); + String objectName = stringProperty == null ? "" + : stringProperty; + 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++) { + + System.out.println("ȣ"+subline.getChildren().length); + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) subline.getChildren()[j] + .getComponent(); + System.out.println(""+subChildrenline); + System.out.println("2"+subChildrenline.getItem()); + equipmentNameList.add(subChildrenline.getItem().getStringProperty("item_id")); + } + } + 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 + * + */ + +// ȫֻԻȡ + private static List meopLines = new ArrayList<>(); + private static List equipmentSubLines = new ArrayList<>(); + + public static void getBomPropertys3(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) { + try { + meprocessBomLine.refresh(); + AIFComponentContext[] aif = meprocessBomLine.getChildren(); + if (aif == null || aif.length == 0) return; + + // һ׶ΣռҪĶ + System.out.println("ռҪĶ"); + + collectObjectsRecursively(aif, isPFEMA); + + System.out.println("ռҪĶ"); + + // ڶ׶Σȡ + System.out.println("ȡ"); + processBatchProperties(isPFEMA); + System.out.println("ȡ"); + + + } catch (Exception e) { + e.printStackTrace(); + } finally { + // ջ + meopLines.clear(); + equipmentSubLines.clear(); + } + } + + // ݹռMEOPڵӽڵ + private static void collectObjectsRecursively(AIFComponentContext[] contexts, boolean isPFEMA) throws Exception { + for (AIFComponentContext context : contexts) { + if (context == null) continue; + + TCComponentBOMLine subline = (TCComponentBOMLine) context.getComponent(); + if (subline == null) continue; + + TCComponentItem item = subline.getItem(); + if (item == null) continue; + + String itemType = item.getType(); + if ("MEProcess".equals(itemType)) { + collectObjectsRecursively(subline.getChildren(), isPFEMA); + } else if ("MEOP".equals(itemType)) { + meopLines.add(subline); + if (!isPFEMA) collectEquipmentSubLines(subline); + } + } + } + + // ռ豸ӽڵ + private static void collectEquipmentSubLines(TCComponentBOMLine meopLine) throws Exception { + AIFComponentContext[] children = meopLine.getChildren(); + if (children == null) return; + + for (AIFComponentContext child : children) { + TCComponentBOMLine subline = (TCComponentBOMLine) child.getComponent(); + if (subline != null && !"<<޷ȡ>>".equals(subline.toString())) { + equipmentSubLines.add(subline); + } + } + } + + // + private static void processBatchProperties(boolean isPFEMA) throws Exception { + // 1. ȡMEOPԣŻ + System.out.println("ȡ"); + List meopProps = Arrays.asList("bl_indented_title", "RB3_GXH", "bl_item_object_name", "bl_sequence_no"); + + TCProperty[][] meopProperties = TCComponentType.getTCPropertiesSet(meopLines, meopProps.toArray(new String[0])); + System.out.println("Իȡ"); + // 2. MEOP + for (int i = 0; i < meopLines.size(); i++) { + System.out.println("MEOP"+i); + TCComponentBOMLine meopLine = meopLines.get(i); + List propertie = new ArrayList<>(); + + // + String indentedTitle = meopProperties[i][0].getStringValue(); + propertie.add(indentedTitle != null && !indentedTitle.isEmpty() ? indentedTitle.split("/")[0] : ""); + + // + propertie.add(meopProperties[i][1].getStringValue()); // RB3_GXH + propertie.add(meopProperties[i][2].getStringValue()); // bl_item_object_name + System.out.println("ȡ豸ԴϢ"); + // 豸ԴϢԭԭʼ߼ + if (!isPFEMA) { + List equipmentNames = new ArrayList<>(); + AIFComponentContext[] children = meopLine.getChildren(); + if (children != null && children.length > 0) { + List revs = new ArrayList(); + for (AIFComponentContext child : children) { + TCComponentBOMLine subline = (TCComponentBOMLine) child.getComponent(); + if (subline == null || "<<޷ȡ>>".equals(subline.toString())) { + continue; + } + + // ԭʼ߼ +// revs.add(subline.getItemRevision()); + String classID = null; + try { + classID = subline.getItemRevision().getClassificationClass(); + } catch (Exception e) { + // ܵ쳣 + } + + if (classID != null && classID.length() > 2 && "15".equals(classID.substring(0, 2))) { + String equipmentName = subline.getItem().getStringProperty("object_name"); + if (equipmentName != null) { + equipmentNames.add(equipmentName); + } + } + } +// TCProperty[][] meopProperties1 = TCComponentType.getTCPropertiesSet(revs, new String[] {"item_id","object_name","ics_subclass_name"}); +// +// for(int j = 0;j 2 && +// "15".equals(meopProperties1[j][0].getStringValue().substring(0, 2))) { +// String equipmentName = meopProperties1[j][1].getStringValue(); +// if (equipmentName != null) { +// equipmentNames.add(equipmentName); +// } +// } +// } + } + propertie.add(equipmentNames.isEmpty() ? "" : String.join(", ", equipmentNames)); + } else { + propertie.add(""); + } + System.out.println("22豸ԴϢ"); + propertie.add(meopProperties[i][3].getStringValue()); // bl_sequence_no + bomPropertyList.add(propertie); + } + } + public static void getBomPropertys2(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) { + try { + // ˢBOMȷ + meprocessBomLine.refresh(); + + // ȡӽڵ + AIFComponentContext[] aif = meprocessBomLine.getChildren(); + if (aif == null || aif.length == 0) { + return; // ûӽڵ㣬ֱ˳ + } + + // ռҪȡ + List propertyNames = Arrays.asList( + "bl_indented_title", "RB3_GXH", "bl_item_object_name", "bl_sequence_no" + ); + + for (AIFComponentContext context : aif) { + if (context == null) { + continue; // սڵ + } + + TCComponentBOMLine subline = (TCComponentBOMLine) context.getComponent(); + if (subline == null) { + continue; // Чӽڵ + } + + TCComponentItem item = subline.getItem(); + if (item == null) { + continue; // Ч + } + + String itemType = item.getType(); + + // ǹͣݹ鴦 + if ("MEProcess".equals(itemType)) { + getBomPropertys(subline, isPFEMA); + } + // ǹ + else if ("MEOP".equals(itemType)) { + // ȡֵ + String[] properties = subline.getProperties(propertyNames.toArray(new String[0])); + Map propertiesMap = new HashMap<>(); + for (int i = 0;i propertie = new ArrayList<>(); + + // + String indentedTitle = propertiesMap.get("bl_indented_title"); + propertie.add(indentedTitle != null && !indentedTitle.isEmpty() ? indentedTitle.split("/")[0] : ""); + + // ӹ + propertie.add(propertiesMap.get("RB3_GXH")); + + // Ӷ + propertie.add(propertiesMap.get("bl_item_object_name")); + + // PFEMAȡ豸ԴϢ + if (!isPFEMA) { + List equipmentNameList = new ArrayList<>(); + AIFComponentContext[] children = subline.getChildren(); + if (children != null && children.length > 0) { + for (AIFComponentContext childContext : children) { + TCComponentBOMLine subChildrenline = (TCComponentBOMLine) childContext.getComponent(); + if (subChildrenline == null || "<<޷ȡ>>".equals(subChildrenline.toString())) { + continue; // ЧȨ޶ȡĽڵ + } + + // ȡ ID ǷҪ + String classID = subChildrenline.getItemRevision().getClassificationClass(); + if (classID != null && classID.length() > 2 && "15".equals(classID.substring(0, 2))) { + String equipmentName = subChildrenline.getItem().getStringProperty("object_name"); + if (equipmentName != null) { + equipmentNameList.add(equipmentName); + } + } + } + } + + // 豸бתΪַӵб + propertie.add(equipmentNameList.isEmpty() ? "" : String.join(", ", equipmentNameList)); + } else { + propertie.add(""); // PFEMA ģʽ豸Դ + } + + // к + propertie.add(propertiesMap.get("bl_sequence_no")); + + // бӵȫֽ + bomPropertyList.add(propertie); + } + } + } catch (Exception e) { + e.printStackTrace(); // 쳣 + } + } + + public static void getBomPropertys(TCComponentBOMLine meprocessBomLine, boolean isPFEMA) + { + try { + meprocessBomLine.refresh(); + //ȡµ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; + } + public static String setBgxAndXdgx(TCProperty ljbh_prop,TCProperty bgx_prop, TCProperty xdgx_prop, TCComponentItemRevision itemRevision) throws TCException, SQLException { + AIFComponentContext[] aifccs = itemRevision.getItem().whereReferenced(); + TCComponentMEOPRevision meop = null; + TCComponentMEProcessRevision meprocess = null; + for (AIFComponentContext aifcc_MEOP : aifccs) { + if (aifcc_MEOP.getComponent() instanceof TCComponentMEOPRevision) { + meop = (TCComponentMEOPRevision)aifcc_MEOP.getComponent(); + break; + } + } + if(meop != null) + { + TCComponent[] its = meop.getItem().whereUsed(TCComponent.WHERE_USED_ALL); + for (TCComponent tcComponent : its) { + if (tcComponent instanceof TCComponentMEProcessRevision) { + meprocess = (TCComponentMEProcessRevision)tcComponent; + break; + } + } + } + if(meprocess != null) { + TCComponent[] referenceList = meprocess.getItem().getReferenceListProperty("IMAN_reference"); + for(TCComponent reference : referenceList) { + if("RB3_SSCKZJH".equals(reference.getType()) || "RB3_SCKZJH".equals(reference.getType())){ + TCComponentItemRevision sckzjhRev = ((TCComponentItem)reference).getLatestItemRevision(); + TCComponent form = sckzjhRev.getRelatedComponent("IMAN_master_form_rev"); + ljbh_prop.setStringValue(form.getProperty("rb3_ljmcms")); + break; + } + } + + String meprocessUid = meprocess.getItem().getUid(); + String meopId = meop.getItem().getStringProperty("item_id"); + SqlUtilT.getTCConnection(); + String sql = String.format("SELECT rb3_gcmc, rb3_meopid,rb3_gybh FROM (SELECT t.*,ROW_NUMBER() OVER(PARTITION BY rb3_gcmc,rb3_meopid, rb3_gybh ORDER BY rb3_hh) AS rn FROM rb3_controlplan t where processpuid='%s' ORDER BY rb3_hh) WHERE rn = 1", meprocessUid); + + System.out.println("sql:"+sql); + ResultSet rs = null; + try { + rs = SqlUtilT.read(sql); + boolean isNext = false; + while (rs.next()) { + if(isNext) { + xdgx_prop.setStringValue(rs.getString("RB3_GCMC")); + break; + } + if(rs.getString("RB3_MEOPID").equals(meopId)) { + String gcmc = rs.getString("RB3_GCMC"); + bgx_prop.setStringValue(gcmc); + isNext = true; + } + } + }catch (Exception e) { + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + SqlUtilT.freeAll(); + } + + } + return null; + } +} 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..b772a1e --- /dev/null +++ b/src/com/connor/renben/process/plm/util/TableCellCheckboxRenderer.java @@ -0,0 +1,121 @@ +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.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 CTMap tableModel; + private JTableHeader tableHeader; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public TableCellCheckboxRenderer(final CTable table) { + this.tableModel = (CTMap) 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 +// if(value != null) +// { +// String valueStr = (boolean)value ? "true" : "false"; +// //System.out.println(valueStr); +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected((boolean)value); +// } +// else +// { +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ +// this.setHorizontalAlignment(SwingConstants.CENTER);// ͷǩ +// this.setBorderPainted(true); +// this.setSelected(false); +// } +// String valueStr = (String) value; +// JLabel label = new JLabel(valueStr); +// label.setHorizontalAlignment(SwingConstants.CENTER); // ͷǩ + 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ַֿ˳ʹDocumentinsertString + 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.classClass󣩣 + // ŵһCellEditorListenerʵ + listener = (CellEditorListener) listeners[i + 1]; + // changeEventȥ֪ͨ༭Ѿ༭ + // editingStoppedУJTablegetCellEditorValue()ȡصԪֵ + // Ұֵݸ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ַֿ˳ʹDocumentinsertString + 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..2697814 --- /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..e03a119 --- /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/connor/renben/process/plm/worklist/CusRoot.java b/src/com/connor/renben/process/plm/worklist/CusRoot.java new file mode 100644 index 0000000..651b22c --- /dev/null +++ b/src/com/connor/renben/process/plm/worklist/CusRoot.java @@ -0,0 +1,38 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. +// Jad home page: http://www.kpdus.com/jad.html +// Decompiler options: packimports(3) radix(10) lradix(10) +package com.connor.renben.process.plm.worklist; + +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.cm.ui.ICNTreeRoot; + +public class CusRoot extends ICNTreeRoot { + private List elements; + + public CusRoot(Object obj) { + super(obj); + elements = new ArrayList(); + elements.add(obj); + } + + @Override + public Object[] getElements() { + return elements.toArray(new Object[elements.size()]); + } + + public void addElement(Object obj) { + elements.add(obj); + } + +} + +/* + * DECOMPILATION REPORT + * + * Decompiled from: + * C:\TC\Siemens\Teamcenter11\portal\plugins\com.teamcenter.rac.cm_11000.2.0.jar + * Total time: 16 ms Jad reported messages/errors: Exit status: 0 Caught + * exceptions: + */ \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/worklist/MyView.java b/src/com/connor/renben/process/plm/worklist/MyView.java new file mode 100644 index 0000000..2297207 --- /dev/null +++ b/src/com/connor/renben/process/plm/worklist/MyView.java @@ -0,0 +1,572 @@ +package com.connor.renben.process.plm.worklist; + +import java.awt.Composite; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IViewSite; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.ViewSite; + +import com.connor.renben.process.plm.bean.Workflow_InfoBean; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.views.TCComponentView; +import com.teamcenter.rac.util.PlatformHelper; +import com.teamcenter.rac.viewer.provider.node.ComponentNode; + +public class MyView extends TCComponentView implements IViewPart { + + private static final String JDBC_DRIVER = "oracle.jdbc.OracleDriver"; + public static final String ID = MyView.class.getName(); + public static final String FOLDER1_NAME = "Ҫִе"; + public static final String FOLDER2_NAME = "Ҫٵ"; + public static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd"); + private TCSession session; + private String userId; + private TCComponent folder1;// ѷ + private TCComponent folder2;// + private long timeInterval = 900000; + private int maxYear; // õĹ + private int maxMonth; // õĹ· + private int maxDay; // õĹ + private int currentYear; + private int curretnMonth; + private IViewPart myView; + + + @Override + public void dispose() { + // رͼͷԴ + if (myView != null) { + getViewSite().getPage().hideView(myView); + myView.dispose(); + myView = null; + } + super.dispose(); + } + public MyView() throws PartInitException { + super(); + try { + myView = ShowMyViewHandler.showView; + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + private AIFComponentContext contextChange; + + @Override + protected void processSetInput(IWorkbenchPart iWorkbenchPart, List list) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + try { + // õǰ¼ûid + userId = session.getUser().getUserId(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + ComponentNode object; + // Object object4 = list.isEmpty() ? null : list.get(0); + object = new ComponentNode(); + try { + TCComponent[] search = session.search("...", new String[] { "", "Ȩû" }, + new String[] { "ҵĹб", userId }); + + ComponentNode node = new ComponentNode(); + node.setObject(search[0]); + // жҵĹбļǷ + TCComponent workFolder = isFolderExisted("ҵĹбʷ"); + this.setInputObject(iWorkbenchPart, search[0]); + this.updatePartDetails(search[0]); + CusRoot cusRoot = new CusRoot(node); + ComponentNode addNode = addNode(object, workFolder); + cusRoot.addElement(addNode); + this.getTreeViewer().setInput(cusRoot); + this.selectAndExpand(this.contextChange, 1); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Override + protected void makeViewBlank(IWorkbenchPart iWorkbenchPart, List list, boolean bl) { + IWorkbenchPage iWorkbenchPage; + super.makeViewBlank(iWorkbenchPart, list, bl); + if (!this.isDisposed() && (iWorkbenchPage = PlatformHelper.getCurrentPage()) != null) { + iWorkbenchPage.hideView(this); + } + } + + @Override + public void refreshDataInView() { + // TODO Auto-generated method stub + super.refreshDataInView(); + System.out.println("------ˢ"); + } + + @Override + public void refreshTrim() { + // TODO Auto-generated method stub + super.refreshTrim(); + System.out.println("------ˢ2"); + } + + // ˢ + public void refreshs() { + ExecutorService es = Executors.newFixedThreadPool(5); + es.execute(new Runnable() { + @Override + public void run() { + try { + addTask(folder1, 0); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + es.execute(new Runnable() { + @Override + public void run() { + try { + addTask(folder2, 1); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + } + + private ComponentNode addNode(ComponentNode object, TCComponent workFolder) { + getRootFolder(workFolder); + System.out.println("**********************************"); + ExecutorService es = Executors.newFixedThreadPool(5); + es.execute(new Runnable() { + @Override + public void run() { + try { + while (true) { + addTask(folder1, 0); + Thread.sleep(timeInterval); + } + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + es.execute(new Runnable() { + @Override + public void run() { + try { + while (true) { + addTask(folder2, 1); + Thread.sleep(timeInterval); + } + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }); + object.setObject(workFolder); + // cusRoot = new CusRoot(object); + return object; + } + + /** + * @param folder + * @param type + */ + // ޸ĺaddTask + private void addTask(final TCComponent folder, final int type) { + final ExecutorService dataExecutor = Executors.newSingleThreadExecutor(); + dataExecutor.execute(new Runnable() { + @Override + public void run() { + try { + final List componentsToAdd = getWorkFlowComponents(type); + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + try { + Map taskFolderMap = getTaskFolder(folder); + for(TCComponent component : componentsToAdd) { + String jobName; + try { + jobName = component.getProperty("job_name"); + String[] parts = jobName.split("_"); + if(parts.length > 0) { + String prefix = parts[0]; + TCComponent targetFolder = taskFolderMap.get(prefix); + if(targetFolder != null) { + try { + targetFolder.add("contents", component); + } catch(TCException e) { + System.out.println(component + " already exists"); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + refreshViewer(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } catch (Exception e) { + e.printStackTrace(); + } finally { + dataExecutor.shutdown(); + } + } + }); + } + + // ޸ĺgetWorkFlowComponents + private List getWorkFlowComponents(int type) { + List components = new ArrayList(); + try { + TCComponent[] Flowfolder = session.search("RBSearchTaskBox", + new String[] { "ID" }, + new String[] { userId }); + + TCComponent targetFolder = null; + for (TCComponent folder : Flowfolder) { + try { + if(type == 0 && "Ҫִе".equals(folder.getStringProperty("object_string"))) { + targetFolder = folder; + break; + } else if(type == 1 && "Ҫٵ".equals(folder.getStringProperty("object_string"))) { + targetFolder = folder; + break; + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + if(targetFolder != null) { + TCComponent[] tasks = targetFolder.getRelatedComponents("contents"); + for(TCComponent task : tasks) { + components.add(task); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return components; + } + + private TCComponent findFolder(TCComponent[] folders, String name) { + for(TCComponent folder : folders) { + try { + if(folder.getProperty("object_string").equals(name)) { + return folder; + } + } catch (TCException e) { + e.printStackTrace(); + } + } + return null; + } + + private void refreshViewer() { + if(!getTreeViewer().getControl().isDisposed()) { + getTreeViewer().refresh(); + getTreeViewer().expandAll(); + } + } + + /** + * òѯ + * + * @param lastDate + * @return + */ + private String searchDate(Integer[] lastDate) { + int year = lastDate[0]; + int month = lastDate[1]; + return year + "-" + (month < 10 ? "0" + month : month) + "-" + "01"; + } + + /** + * õļ + * + * @param workFolder + * @throws TCException + * @get ѷļ Ѳļ + */ + private void getRootFolder(TCComponent workFolder) { + try { + AIFComponentContext[] children = workFolder.getChildren("contents"); + for (AIFComponentContext aifComponentContext : children) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + String name = folder.getProperty("object_name"); + if (name.equals(FOLDER1_NAME)) { + folder1 = folder; + } else if (name.equals(FOLDER2_NAME)) { + folder2 = folder; + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * taskļʱ + * + * @param taskFolder + * @return + */ + private Integer[] getLastDate(Map> taskFolder) { + System.out.println("taskļʱ䣺===" + maxYear + "" + maxMonth + ""); + return new Integer[] { maxYear, maxMonth }; + } + + /** + * ļм + * + * @return Map> + * + */ + private Map getTaskFolder(TCComponent parent) { + System.out.println(parent == null); + System.out.println("parent :====" + parent); + Map map = new HashMap<>(); + try { + for (AIFComponentContext aifComponentContext : parent.getChildren("contents")) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + map.put(folder.getProperty("object_name"), folder); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return map; + } + + /** + * ļм + * + * @return Map key value ļ + * + */ + private Map getYearFolder(TCComponent parent) { + Map map = new HashMap<>(); + try { + for (AIFComponentContext aifComponentContext : parent.getChildren("contents")) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + Integer year = Integer.valueOf(folder.getProperty("object_name").split("")[0]); + map.put(year, folder); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return map; + } + + /** + * ļм + * + * @return Map key value ļ + * + */ + private Map getMonthFolder(TCComponent parent) { + Map map = new HashMap<>(); + try { + for (AIFComponentContext aifComponentContext : parent.getChildren("contents")) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + map.put(Integer.parseInt(folder.getProperty("object_name").split("")[0]), folder); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return map; + } + + /** + * ж ʷļǷ񴴽 + * + * @param folderName + * @return folder + */ + private TCComponent isFolderExisted(String folderName) { + TCComponent folder = null; + try { + System.out.println("жļǷ...."); + System.out.println(userId); + TCComponent[] search = session.search("...", new String[] { "", "", "Ȩû" }, + new String[] { folderName, "Folder", userId }); + System.out.println("ȣ" + search.length); + // ʷļδ½ļ12 + if (search.length == 0) { + System.out.println("ļ"); + folder = createFolder(folderName, null); + clearhistory((TCComponentFolder) folder); + } else { + folder = search[0]; + clearhistory((TCComponentFolder) folder); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return folder; + } + + /** + * ļ + * + * @param folderName + * @return + */ + private TCComponent createFolder(String folderName, TCComponent parent) { + TCComponent folder = null; + try { + TCComponentFolderType type = (TCComponentFolderType) session.getTypeComponent("Folder"); + folder = type.create(folderName, null, "Folder"); + if (parent != null) { + parent.add("contents", folder); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return folder; + } + + + + // ÿμǰʷļвҪļ + public void clearhistory(TCComponentFolder folder) { + try { + // AIFComponentContext[] children = folder.getChildren("contents"); + TCComponent[] children = folder.getRelatedComponents("contents"); + if (children.length > 0) { + folder.remove("contents", children); + } + // ѷ ļ + TCComponentFolder sponsorFolder = (TCComponentFolder) createFolder(FOLDER1_NAME, folder); + // Ѳ ļ + TCComponentFolder participationFolder = (TCComponentFolder) createFolder(FOLDER2_NAME, folder); + + // ȡ̿ͷΪͣѡRB3_workflow_startName_type + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("RB3_workflow_startName_type"); + for (int i = 0; i < strs.length; i++) { + TCComponentFolder Folder = (TCComponentFolder) createFolder(strs[i], sponsorFolder); + TCComponentFolder Folde2r = (TCComponentFolder) createFolder(strs[i], participationFolder); + } + System.out.println("ʷбʼɹ"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void getTime() { + // õǰʱǰʱ + Calendar cal = Calendar.getInstance(); + currentYear = cal.get(Calendar.YEAR); + curretnMonth = cal.get(Calendar.MONTH) + 1; + int currentDay = cal.get(Calendar.DATE); + + if (curretnMonth < 4) { + this.maxYear = currentYear - 1; + this.maxMonth = curretnMonth + 9; + } else { + this.maxYear = currentYear; + this.maxMonth = curretnMonth - 3; + } + + } + + // ȡ˽ڵûִʱ + private Date getExecutiontime(TCComponent task, String userID) { + Date time = null; + try { + String type = task.getProperty("task_type"); + // Ͽɽڵ˽ڵ + if (type.equals("EPMAcknowledgeTask") || type.equals("EPMReviewTask")) { + TCComponent[] childs = task.getRelatedComponents("child_tasks"); + // ǩСڵ + TCComponent signoff = null; + if (childs.length > 1) { + signoff = childs[1]; + } + // Чǩ + TCComponent[] valid_signoffs = task.getRelatedComponents("valid_signoffs"); + if (valid_signoffs != null && valid_signoffs.length > 1) { + for (TCComponent valid : valid_signoffs) { + String assign = valid.getProperty("fnd0Assignee"); + if (assign.contains(userID)) { + String result = valid.getProperty("decision"); + Date date = valid.getDateProperty("decision_date"); + return date; + } + + } + } + + } + time = task.getDateProperty("last_mod_date"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return time; + } + +} + +//Ƚ ǩʱ +class SortByDate implements Comparator { + public int compare(Object o1, Object o2) { + Workflow_InfoBean s1 = (Workflow_InfoBean) o1; + Workflow_InfoBean s2 = (Workflow_InfoBean) o2; + return s2.getDate().compareTo(s1.getDate()); + } + +} diff --git a/src/com/connor/renben/process/plm/worklist/MyView2.java b/src/com/connor/renben/process/plm/worklist/MyView2.java new file mode 100644 index 0000000..5f80981 --- /dev/null +++ b/src/com/connor/renben/process/plm/worklist/MyView2.java @@ -0,0 +1,385 @@ +package com.connor.renben.process.plm.worklist; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import org.eclipse.swt.events.TreeEvent; +import org.eclipse.swt.events.TreeListener; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; + +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFolderType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.views.TCComponentView; +import com.teamcenter.rac.viewer.provider.node.ComponentNode; + +import sun.reflect.generics.tree.Tree; + +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TreeSelection; + +public class MyView2 extends TCComponentView implements IViewPart { + + private static final String JDBC_DRIVER = "oracle.jdbc.OracleDriver"; + public static final String ID = MyView2.class.getName(); + public static final String FOLDER1_NAME = "Ҫִе"; + public static final String FOLDER2_NAME = "Ҫٵ"; + public Map> taskNameMap = new HashMap<>(); + public Map> taskNameMap2 = new HashMap<>(); + private TCSession session; + private String userId; + private TCComponent folder1; + private TCComponent folder2; + private long timeInterval = 900000; + private IViewPart myView; + + private Map> fold1 = new HashMap<>(); + private Map> fold2 = new HashMap<>(); + private List isTask = new ArrayList<>(); + + @Override + public void dispose() { + if (myView != null) { + getViewSite().getPage().hideView(myView); + myView.dispose(); + myView = null; + } + super.dispose(); + } + + public MyView2() throws PartInitException { + super(); + try { + myView = ShowMyViewHandler.showView; + } catch (Exception e) { + e.printStackTrace(); + } + } + + private AIFComponentContext contextChange; + + @Override + protected void processSetInput(IWorkbenchPart iWorkbenchPart, List list) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + try { + userId = session.getUser().getUserId(); + } catch (TCException e) { + e.printStackTrace(); + } + + ComponentNode object = new ComponentNode(); + try { + TCComponent[] search = session.search("...", new String[] { "", "Ȩû" }, + new String[] { "ҵĹб", userId }); + + ComponentNode node = new ComponentNode(); + node.setObject(search[0]); + TCComponent workFolder = isFolderExisted("ҵĹбʷ"); + this.setInputObject(iWorkbenchPart, search[0]); + this.updatePartDetails(search[0]); + CusRoot cusRoot = new CusRoot(node); + ComponentNode addNode = addNode(object, workFolder); + cusRoot.addElement(addNode); + this.getTreeViewer().setInput(cusRoot); + this.selectAndExpand(this.contextChange, 1); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private ComponentNode addNode(ComponentNode object, TCComponent workFolder) { + getRootFolder(workFolder); + object.setObject(workFolder); + //ݿ ȡ + Connection connection = SqlUtilT.getConnectionTC12(); + + try { + // 滻 SQL еռλ + String sql = SLQSTR.MYWORKLIST.replace("?", "'" + userId.toUpperCase() + "'"); + ResultSet read = SqlUtilT.read(sql); + while(read.next()) { + if(read.getString("WFTEMPLATE_CN") != null) { + String name = read.getString("WFTEMPLATE_CN"); + String uid = read.getString("EPMTASK_PUID"); + String taskType = read.getString("EPMTASK_TYPE"); + if(taskNameMap.containsKey(name)) { + taskNameMap.get(name).add(uid); + }else { + List uids = new ArrayList<>(); + uids.add(uid); + taskNameMap.put(name,uids); + } + + if(!"EPMDoTask".equals(taskType)) { + if(taskNameMap2.containsKey(name)) { + taskNameMap2.get(name).add(uid); + }else { + List uids = new ArrayList<>(); + uids.add(uid); + taskNameMap2.put(name,uids); + } + } + + + } + + } + }catch(Exception e) { + e.printStackTrace(); + }finally { + SqlUtilT.free(connection); + } + + // ȡ TreeViewer ĵײ Tree ؼ + org.eclipse.swt.widgets.Tree tree = getTreeViewer().getTree(); + + // TreeListener չ۵¼ + tree.addTreeListener(new TreeListener() { + @Override + public void treeExpanded(TreeEvent event) { + // ڵ㱻չʱ + handleTreeEvent(event); + } + + @Override + public void treeCollapsed(TreeEvent event) { + // ڵ㱻۵ʱ + handleTreeEvent(event); + } + + private void handleTreeEvent(TreeEvent event) { + // ȡǰѡеĽڵ + Object item = event.item; + if (item instanceof TreeItem) { + TreeItem treeItem = (TreeItem) item; + Object data = treeItem.getData(); // ȡڵ󶨵 + if (data != null) { + String folderName = data.toString(); + System.out.println("Tree event triggered for: " + folderName); + + // selectionChanged Ƶ߼ + if (isTask.contains(folderName)) { + return; + } + if (taskNameMap.containsKey(folderName)) { + List list = taskNameMap.get(folderName); + List list2 = taskNameMap2.get(folderName); + try { + if(list != null && list.size()>0) { + TCComponent[] stringToComponent = session.stringToComponent(list.toArray(new String[0])); + for (Entry> entry : fold1.entrySet()) { + Map value = entry.getValue(); + TCComponentFolder tcComponentFolder = value.get(folderName); + tcComponentFolder.add("contents", stringToComponent); + tcComponentFolder.refresh(); + } + } + if(list2 != null && list2.size()>0) { + TCComponent[] stringToComponent2 = session.stringToComponent(list2.toArray(new String[0])); + for (Entry> entry : fold2.entrySet()) { + Map value = entry.getValue(); + TCComponentFolder tcComponentFolder2 = value.get(folderName); + tcComponentFolder2.add("contents", stringToComponent2); + tcComponentFolder2.refresh(); + } + } + + isTask.add(folderName); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + }); + + // ԭе SelectionChangedListener + getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() { + @Override + public void selectionChanged(SelectionChangedEvent event) { + TreeSelection selection = (TreeSelection) event.getSelection(); + if (selection != null && !selection.isEmpty()) { + Object firstElement = selection.getFirstElement(); + String folderName = firstElement.toString(); + if (isTask.contains(folderName)) { + return; + } + System.out.println(firstElement.toString()); + if (taskNameMap.containsKey(folderName)) { + List list = taskNameMap.get(folderName); + try { + TCComponent[] stringToComponent = session.stringToComponent(list.toArray(new String[0])); + for (Entry> entry : fold1.entrySet()) { + Map value = entry.getValue(); + TCComponentFolder tcComponentFolder = value.get(folderName); + tcComponentFolder.add("contents", stringToComponent); + tcComponentFolder.refresh(); + } + for (Entry> entry : fold2.entrySet()) { + Map value = entry.getValue(); + TCComponentFolder tcComponentFolder2 = value.get(folderName); + tcComponentFolder2.add("contents", stringToComponent); + tcComponentFolder2.refresh(); + } + isTask.add(folderName); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + }); + return object; + } + + private List getWorkFlowComponents(int type) { + List components = new ArrayList(); + try { + TCComponent[] Flowfolder = session.search("RBSearchTaskBox", + new String[] { "ID" }, + new String[] { userId }); + + TCComponent targetFolder = null; + for (TCComponent folder : Flowfolder) { + try { + if(type == 0 && "Ҫִе".equals(folder.getStringProperty("object_string"))) { + targetFolder = folder; + break; + } else if(type == 1 && "Ҫٵ".equals(folder.getStringProperty("object_string"))) { + targetFolder = folder; + break; + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + if(targetFolder != null) { + TCComponent[] tasks = targetFolder.getRelatedComponents("contents"); + for(TCComponent task : tasks) { + components.add(task); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return components; + } + + private void refreshViewer() { + if(!getTreeViewer().getControl().isDisposed()) { + getTreeViewer().refresh(); + getTreeViewer().expandAll(); + } + } + + private void getRootFolder(TCComponent workFolder) { + try { + AIFComponentContext[] children = workFolder.getChildren("contents"); + for (AIFComponentContext aifComponentContext : children) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + String name = folder.getProperty("object_name"); + if (name.equals(FOLDER1_NAME)) { + folder1 = folder; + } else if (name.equals(FOLDER2_NAME)) { + folder2 = folder; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + private Map getTaskFolder(TCComponent parent) { + Map map = new HashMap<>(); + try { + for (AIFComponentContext aifComponentContext : parent.getChildren("contents")) { + TCComponent folder = (TCComponent) aifComponentContext.getComponent(); + map.put(folder.getProperty("object_name"), folder); + } + } catch (TCException e) { + e.printStackTrace(); + } + return map; + } + + private TCComponent isFolderExisted(String folderName) { + TCComponent folder = null; + try { + TCComponent[] search = session.search("...", new String[] { "", "", "Ȩû" }, + new String[] { folderName, "Folder", userId }); + if (search.length == 0) { + folder = createFolder(folderName, null); + clearhistory((TCComponentFolder) folder); + } else { + folder = search[0]; + clearhistory((TCComponentFolder) folder); + } + } catch (Exception e) { + e.printStackTrace(); + } + return folder; + } + + private TCComponent createFolder(String folderName, TCComponent parent) { + TCComponent folder = null; + try { + TCComponentFolderType type = (TCComponentFolderType) session.getTypeComponent("Folder"); + folder = type.create(folderName, null, "Folder"); + if (parent != null) { + parent.add("contents", folder); + } + } catch (TCException e) { + e.printStackTrace(); + } + return folder; + } + + public void clearhistory(TCComponentFolder folder) { + try { + TCComponent[] children = folder.getRelatedComponents("contents"); + if (children.length > 0) { + folder.remove("contents", children); + } + TCComponentFolder sponsorFolder = (TCComponentFolder) createFolder(FOLDER1_NAME, folder); + TCComponentFolder participationFolder = (TCComponentFolder) createFolder(FOLDER2_NAME, folder); + + TCPreferenceService service = session.getPreferenceService(); + String[] strs = service.getStringValues("RB3_workflow_startName_type"); + Map folder1 = new HashMap<>(); + Map folder2 = new HashMap<>(); + for (int i = 0; i < strs.length; i++) { + TCComponentFolder Folder = (TCComponentFolder) createFolder(strs[i], sponsorFolder); + folder1.put(strs[i], Folder); + TCComponentFolder Folde2r = (TCComponentFolder) createFolder(strs[i], participationFolder); + folder2.put(strs[i], Folde2r); + } + fold1.put(sponsorFolder, folder1); + fold2.put(participationFolder, folder2); + + } catch (TCException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/src/com/connor/renben/process/plm/worklist/MyWorkbenchListener.java b/src/com/connor/renben/process/plm/worklist/MyWorkbenchListener.java new file mode 100644 index 0000000..6666224 --- /dev/null +++ b/src/com/connor/renben/process/plm/worklist/MyWorkbenchListener.java @@ -0,0 +1,34 @@ +package com.connor.renben.process.plm.worklist; + +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchListener; +import org.eclipse.ui.IWorkbenchWindow; +public class MyWorkbenchListener implements IWorkbenchListener { + private IViewPart myView; + public MyWorkbenchListener(IViewPart myView) { + this.myView = myView; + } + @Override + public boolean preShutdown(IWorkbench workbench, boolean forced) { + // ڹرTCǰر㴴ͼ + myView.getViewSite().getPage().hideView(myView); + return true; + } + @Override + public void postShutdown(IWorkbench workbench) { + // do nothing + } + public void preStartup() { + // do nothing + } + public void postStartup() { + // do nothing + } + public void workbenchActivated(IWorkbenchWindow window) { + // do nothing + } + public void workbenchDeactivated(IWorkbenchWindow window) { + // do nothing + } +} diff --git a/src/com/connor/renben/process/plm/worklist/SLQSTR.java b/src/com/connor/renben/process/plm/worklist/SLQSTR.java new file mode 100644 index 0000000..d547478 --- /dev/null +++ b/src/com/connor/renben/process/plm/worklist/SLQSTR.java @@ -0,0 +1,5 @@ +package com.connor.renben.process.plm.worklist; + +public class SLQSTR { + public final static String MYWORKLIST = "select j.WFTEMPLATE as WFTEMPLATE_EN,(select DISTINCT PVAL_0 from infodba.VL10N_TEMPLATE_NAME where puid = j.WFTemplateUid and locale = 'zh_CN') as WFTEMPLATE_CN,v.* from infodba.V_CUST_TASKSTOPERFORM v,infodba.v_cust_wfjoblist j where j.JobUid = v.EPMJOB_PUID and upper(V.PUSER_ID)=?"; +} diff --git a/src/com/connor/renben/process/plm/worklist/ShowMyViewHandler.java b/src/com/connor/renben/process/plm/worklist/ShowMyViewHandler.java new file mode 100644 index 0000000..0562471 --- /dev/null +++ b/src/com/connor/renben/process/plm/worklist/ShowMyViewHandler.java @@ -0,0 +1,97 @@ +/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. + +package com.connor.renben.process.plm.worklist; + +import java.awt.Window; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +import org.eclipse.core.commands.*; +import org.eclipse.ui.*; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.internal.Workbench; +import org.eclipse.ui.part.ViewPart; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +//ʾ˵ +public class ShowMyViewHandler extends AbstractHandler +{ + + public static IViewPart showView; + + public ShowMyViewHandler() + { + } + + @Override + public Object execute(ExecutionEvent executionevent) + throws ExecutionException + { + IWorkbenchPart iworkbenchpart = HandlerUtil.getActivePart(executionevent); + IViewPart iviewpart = (IViewPart)iworkbenchpart; + IWorkbenchPage iworkbenchpage = iviewpart.getSite().getPage(); + String s = "com.connor.renben.process.plm.Workspace"; + try + { + showView = iworkbenchpage.showView(s, null, IWorkbenchPage.VIEW_VISIBLE); + System.out.println("ҵ"+s+";"); + Workbench.getInstance().addWorkbenchListener(new IWorkbenchListener() { + @Override + public boolean preShutdown(IWorkbench workbench, boolean forced) { + IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); + page.hideView(showView); + return true; + } + @Override + public void postShutdown(IWorkbench workbench) { + } + }); +// AbstractAIFUIApplication abstractAIFUIApplication = AIFUtility.getCurrentApplication(); +// +// JPanel applicationPanel = abstractAIFUIApplication.getApplicationPanel(); +// System.out.println(applicationPanel); +// Window parent = SwingUtilities.getWindowAncestor(applicationPanel); +// if (parent != null) { +// System.out.println("ʼwindow"); +// parent.addWindowListener(new WindowAdapter() { // WindowListener +// @Override +// public void windowClosing(WindowEvent e) { +// System.out.println("Window is closing."); // Windowر +// try { +// showView.dispose(); +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// super.windowClosing(e); +// } +// }); +// }else { +// System.out.println("ûмwindow"); +// } +// + + } + catch(PartInitException partinitexception) + { + System.out.println("δҵ"+s+";"); + //Logger.getLogger(com/teamcenter/rac/classification/icm/ShowClassificationViewHandler).error(partinitexception.getLocalizedMessage(), partinitexception); + } + return null; + } +} + + +/* + DECOMPILATION REPORT + + Decompiled from: D:\Teamcenter_4Sh\OTW11\rac\plugins\com.teamcenter.rac.classification.icm_11000.2.0.jar + Total time: 1022 ms + Jad reported messages/errors: + Exit status: 0 + Caught exceptions: +*/ \ No newline at end of file diff --git a/src/com/nbtm/customization/project/N01/DBHelper.java b/src/com/nbtm/customization/project/N01/DBHelper.java new file mode 100644 index 0000000..4a0445d --- /dev/null +++ b/src/com/nbtm/customization/project/N01/DBHelper.java @@ -0,0 +1,309 @@ +package com.nbtm.customization.project.N01; + + +import java.io.File; +import java.net.URL; +import java.net.URLClassLoader; +import java.sql.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + + + +public class DBHelper { + Connection _CONN = null; + + //ȡ + private boolean GetConn(String sUser, String sPwd) { + if(_CONN!=null)return true; + + + try + { + File file = new File("file://D:/DBDriver/sqljdbc4.jar"); + URLClassLoader loader = new URLClassLoader(new URL[]{ file.toURI().toURL() }); + + Class clazz = loader.loadClass("com.microsoft.sqlserver.jdbc.SQLServerDriver"); + Driver driver = (Driver) clazz.newInstance(); + + String sDBUrl = "jdbc:sqlserver://192.168.23.2;databaseName=NBTMU9DB"; + + Properties p = new Properties(); + p.put("user", "sa"); + p.put("password", "ad123456!"); + _CONN = driver.connect(sDBUrl, p); + System.out.println("ӳɹ:"+_CONN); + + + + System.out.println("̬سɹ"); + + } catch (Exception ex) + { + + System.out.println("138̬ش:"+ex.getMessage()); + return false; + } + + + + + + + + + try { + String sDriverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + String sDBUrl = "jdbc:sqlserver://192.168.23.2;databaseName=NBTMU9DB"; + + //Class.forName(sDriverName); + //_CONN = DriverManager.getConnection(sDBUrl, sUser, sPwd); + //_CONN = DriverManager.getConnection(sDBUrl, "sa", "ad123456!"); + + } catch (Exception ex) { + + System.out.println("38:"+ex.getMessage()); + return false; + } + return true; + } + + private boolean GetConn() + { + return GetConn("sa","ad123456!"); + } + + //ر + public void CloseConn() + { + try { + _CONN.close(); + _CONN = null; + } catch (Exception ex) { + System.out.println("56:"+ex.getMessage()); + _CONN=null; + } + } + + + // + public boolean TestConn() { + if (!GetConn()) + return false; + + CloseConn(); + return true; + } + + public ResultSet GetResultSet(String sSQL,Object[] objParams) + { + GetConn(); + ResultSet rs=null; + try + { + PreparedStatement ps = _CONN.prepareStatement(sSQL); + if(objParams!=null) + { + for(int i=0;i< objParams.length;i++) + { + ps.setObject(i+1, objParams[i]); + } + } + rs=ps.executeQuery(); + }catch(Exception ex) + { + System.out.println("88:"+ex.getMessage()); + CloseConn(); + } + + return rs; + } + + public Object GetSingle(String sSQL,Object... objParams) + { + GetConn(); + try + { + PreparedStatement ps = _CONN.prepareStatement(sSQL); + if(objParams!=null) + { + for(int i=0;i< objParams.length;i++) + { + ps.setObject(i+1, objParams[i]); + } + } + ResultSet rs=ps.executeQuery(); + if(rs.next()) + return rs.getString(1);//1ʼ + }catch(Exception ex) + { + System.out.println("113:"+ex.getMessage()); + } + finally + { + CloseConn(); + } + return null; + } + + public void Update(String sSQL) + { + GetConn(); + + try + { + + ResultSet rs = null; + + + PreparedStatement ps = _CONN.prepareStatement(sSQL); + + rs = ps.executeQuery(); + + + try{ + if(rs != null){ + rs.close(); + } + + } catch (SQLException e) { + e.printStackTrace(); + } + + + } + catch(Exception ex) + { + System.out.println("150:"+ex.getMessage()); + + } + + + } + + + + public int UpdateData(String sSQL,Object[] objParams) + { + GetConn(); + int iResult=0; + + try + { + PreparedStatement ps = _CONN.prepareStatement(sSQL); + if(objParams!=null) + { + for(int i=0;i< objParams.length;i++) + { + ps.setObject(i+1, objParams[i]); + } + } + iResult = ps.executeUpdate(); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + return -1; + } + + return iResult; + } + + public DataTable GetDBTable(String sSQL) + { + GetConn(); + DataTable dt=null; + try + { + PreparedStatement ps = _CONN.prepareStatement(sSQL); + + ResultSet rs=ps.executeQuery(); + ResultSetMetaData rsmd=rs.getMetaData(); + + List row=new ArrayList(); //м + List col=null; //м + DataRow r=null;// һ + DataColumn c=null;//һ + + String columnName; + Object value; + int iRowCount=0; + while(rs.next())//ʼѭȡÿвһм¼ + { + iRowCount++; + col=new ArrayList();//ʼм + for(int i=1;i<=rsmd.getColumnCount();i++) + { + columnName=rsmd.getColumnName(i); + value=rs.getObject(columnName); + c=new DataColumn(columnName,value);//ʼԪ + col.add(c); //Ϣ뵽м + } + r=new DataRow(col);//ʼԪ + row.add(r);//Ϣ뵽м + } + dt = new DataTable(row); + dt.RowCount=iRowCount; + dt.ColumnCount = rsmd.getColumnCount(); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + + return dt; + } + + + public DataTable GetDataTable(String sSQL,Object... objParams) + { + GetConn(); + DataTable dt=null; + try + { + PreparedStatement ps = _CONN.prepareStatement(sSQL); + if(objParams!=null) + { + for(int i=0;i< objParams.length;i++) + { + ps.setObject(i+1, objParams[i]); + } + } + ResultSet rs=ps.executeQuery(); + ResultSetMetaData rsmd=rs.getMetaData(); + + List row=new ArrayList(); //м + List col=null; //м + DataRow r=null;// һ + DataColumn c=null;//һ + + String columnName; + Object value; + int iRowCount=0; + while(rs.next())//ʼѭȡÿвһм¼ + { + iRowCount++; + col=new ArrayList();//ʼм + for(int i=1;i<=rsmd.getColumnCount();i++) + { + columnName=rsmd.getColumnName(i); + value=rs.getObject(columnName); + c=new DataColumn(columnName,value);//ʼԪ + col.add(c); //Ϣ뵽м + } + r=new DataRow(col);//ʼԪ + row.add(r);//Ϣ뵽м + } + dt = new DataTable(row); + dt.RowCount=iRowCount; + dt.ColumnCount = rsmd.getColumnCount(); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + + return dt; + } + + + +} diff --git a/src/com/nbtm/customization/project/N01/DataColumn.java b/src/com/nbtm/customization/project/N01/DataColumn.java new file mode 100644 index 0000000..e032693 --- /dev/null +++ b/src/com/nbtm/customization/project/N01/DataColumn.java @@ -0,0 +1,33 @@ +package com.nbtm.customization.project.N01; + + +public class DataColumn { + String key; + Object value; + + public DataColumn(String _key,Object _value) + { + key = _key; + value = _value; + } + + public String GetKey() + { + return key; + } + + public Object GetValue() + { + return value; + } + + public void SetKey(String _key) + { + key = _key; + } + + public void SetValue(Object _value) + { + value = _value; + } +} diff --git a/src/com/nbtm/customization/project/N01/DataRow.java b/src/com/nbtm/customization/project/N01/DataRow.java new file mode 100644 index 0000000..b5b6bfd --- /dev/null +++ b/src/com/nbtm/customization/project/N01/DataRow.java @@ -0,0 +1,140 @@ +package com.nbtm.customization.project.N01; + +import java.sql.Date; +import java.sql.Blob; +import java.util.List; + + +public class DataRow { + List col; + public DataRow(List _col) + { + col = _col; + } + + public List GetColumn() + { + return col; + } + + public void SetColumn(List _col) + { + col = _col; + } + + public DataColumn GetColumn(String colName) + { + for(DataColumn c:col) + { + if(c.GetKey().toUpperCase().equals(colName.toUpperCase())) + { + try + { + return c; + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + } + } + + return null; + } + + public int GetColumnInt(String colName) + { + for(DataColumn c:col) + { + if(c.GetKey().toUpperCase().equals(colName.toUpperCase())) + { + try + { + return Integer.parseInt(c.GetValue().toString()); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + } + } + + return 0; + } + + public String GetColumnString(String colName) + { + for(DataColumn c:col) + { + if(c.GetKey().toUpperCase().equals(colName.toUpperCase())) + { + try + { + return c.GetValue().toString(); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + } + } + + return ""; + } + + public Date GetColumnDate(String colName) + { + for(DataColumn c:col) + { + if(c.GetKey().toUpperCase().equals(colName.toUpperCase())) + { + try + { + return Date.valueOf(c.GetValue().toString()); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + } + } + + return null; + } + + public Blob GetColumnBlob(String colName) + { + for(DataColumn c:col) + { + if(c.GetKey().toUpperCase().equals(colName.toUpperCase())) + { + try + { + return (Blob)c.GetValue(); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + } + } + + return null; + } + + public float GetColumnFloat(String colName) + { + for(DataColumn c:col) + { + if(c.GetKey().toUpperCase().equals(colName.toUpperCase())) + { + try + { + return Float.parseFloat(c.GetValue().toString()); + }catch(Exception ex) + { + System.out.println(ex.getMessage()); + } + } + } + + return 0; + } + +} + diff --git a/src/com/nbtm/customization/project/N01/DataTable.java b/src/com/nbtm/customization/project/N01/DataTable.java new file mode 100644 index 0000000..b3b77e8 --- /dev/null +++ b/src/com/nbtm/customization/project/N01/DataTable.java @@ -0,0 +1,34 @@ +package com.nbtm.customization.project.N01; + + +import java.util.List; + + +public class DataTable { + List row; + public DataTable(){} + public DataTable(List _row){} + + public List GetRow() + { + return row; + } + + public void SetRow(List _row) + { + row = _row; + } + + public static void PrintTable(DataTable dt) { + for (DataRow r : dt.GetRow()) { + for (DataColumn c : r.GetColumn()) { + System.out.print(c.GetKey() + ":" + c.GetValue() + " "); + } + System.out.println(""); + } + } + + public static int RowCount=0; + public static int ColumnCount=0; +} + diff --git a/src/com/nbtm/customization/project/N01/NBTMFilesuploadCommand.java b/src/com/nbtm/customization/project/N01/NBTMFilesuploadCommand.java new file mode 100644 index 0000000..9663c19 --- /dev/null +++ b/src/com/nbtm/customization/project/N01/NBTMFilesuploadCommand.java @@ -0,0 +1,124 @@ +package com.nbtm.customization.project.N01; + + + +import com.connor.renben.process.plm.tmom006.TMom006CreateProcessByProcessDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + + + + + +public class NBTMFilesuploadCommand extends AbstractAIFCommand{ + + + private AbstractAIFApplication app; //һǰѡеĶ + private TCSession session; //һǰӻỰ + private String commandId;//һcommandId + private InterfaceAIFComponent comp; + + public NBTMFilesuploadCommand(AbstractAIFApplication app, + TCSession session, String commandId) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.commandId = commandId; + this.comp = app.getTargetComponent(); + } + + + public void executeModal() throws Exception { + // TODO Auto-generated method stub + + + + //ȡǰѡеĶ + + final InterfaceAIFComponent targetComponent = app.getTargetComponent(); + + /* + if (targetComponent instanceof TCComponentItem) { + if (targetComponent.getType().toUpperCase().indexOf("PRODUCT") < 0) { + MessageBox.post("ѡƷ", "", MessageBox.ERROR); + return; + } + } + else + { + MessageBox.post("ѡƷ", "", MessageBox.ERROR); + return; + } + */ + // ǰ + System.out.println(targetComponent.getType()); + + + //ǰǹնʾ˳ + if (!targetComponent.getType().equals("MEProcess")) { + MessageBox.post("ѡն", "", MessageBox.ERROR); + return; + } + + + + //¿·߳ + new Thread() { + @Override + public void run() { + + String Str = "" ; + + if (targetComponent instanceof TCComponentItem) + { + + + TCComponentItem item = (TCComponentItem) targetComponent; //ǰֵitem + try { + Str = item.getProperty("item_id").toString(); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + if(Str == "") + { + // + NBTMFilesuploadDialog lDialog = new NBTMFilesuploadDialog( + app, session, targetComponent); + + } + else + { + session.queueOperation(new NBTMFilesuploadOperation(comp,Str, session)); + + + } + + } + + else + { + return ; //ǰͲҪ + } + + + + } + }.start();//ʼִ߳ + super.executeModal(); + } + +} + + diff --git a/src/com/nbtm/customization/project/N01/NBTMFilesuploadDialog.java b/src/com/nbtm/customization/project/N01/NBTMFilesuploadDialog.java new file mode 100644 index 0000000..9d79bd3 --- /dev/null +++ b/src/com/nbtm/customization/project/N01/NBTMFilesuploadDialog.java @@ -0,0 +1,157 @@ +package com.nbtm.customization.project.N01; + + + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.connor.renben.process.plm.tmom006.TMom006CreateProcessByModuleOperation; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + + + + + +public class NBTMFilesuploadDialog extends AbstractAIFDialog +implements ActionListener { + +private AbstractAIFApplication app; +private TCSession session; +private InterfaceAIFComponent targetComponent; + +// ҳؼ +private JPanel mainPanel; +private JLabel nameLabel; +private JTextField nameField; + +private JPanel rootPanel; +private JButton okButton; +private JButton celButton; + +//handlerִCommand ִʲôhandlerļõ +//CommandлѴ Dialog ʼʾ ϵвOperation +// Dialog Operation Command handler ֮໥ִйϵ +// XMLļеϢ +// +// + +public NBTMFilesuploadDialog(AbstractAIFApplication app, + TCSession session, InterfaceAIFComponent targetComponent) { +// TODO Auto-generated constructor stub +this.app = app; +this.session = session; +this.targetComponent = targetComponent; +init(); + +if (targetComponent instanceof TCComponentItem) { + //ȡǰĶ + + TCComponentItem item = (TCComponentItem) this.targetComponent; //ǰֵitem + + + try { + System.out.println("ǰIDֵ"+item.getProperty("item_id")); + //ǰIDֵ nameField + this.nameField.setText(item.getProperty("item_id")); + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + +} +} + +//ʼ +private void init() { +// TODO Auto-generated method stub +System.out.println("ݵ棡"); +this.setTitle("ݵ뵽IMS"); +this.mainPanel = new JPanel(new PropertyLayout()); +this.nameLabel = new JLabel("ձţ"); +this.nameField = new JTextField(30); +this.mainPanel.add("1.1.left.top", nameLabel); +this.mainPanel.add("1.2.left.top", nameField); +this.rootPanel = new JPanel(new FlowLayout()); +this.okButton = new JButton("ȷ"); +//OKť¼ +this.okButton.addActionListener(this); +this.celButton = new JButton("ȡ"); +this.celButton.addActionListener(this); +this.rootPanel.add(okButton); +this.rootPanel.add(celButton); +this.setLayout(new BorderLayout()); +this.add(mainPanel, BorderLayout.CENTER); +this.add(rootPanel, BorderLayout.SOUTH); +this.pack(); + + + +//ʾ +this.showDialog(); + + +} + +@Override +public void actionPerformed(ActionEvent actionevent) { +// TODO Auto-generated method stub +Object source = actionevent.getSource(); +//ťOKť +if (source.equals(this.okButton)) + { + try + { + System.out.println("In Program "); + //ȡǰỰ sessionĶԻ + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item"); + + + + + //ͨǰĶItemIdֵȥitemType ͲMEProcess + if (!itemType.find(this.nameField.getText()).getType() + .equals("MEProcess")) + { + MessageBox.post("дȷĹItemId", "", MessageBox.ERROR); + return; + } + + + //ִв + NBTMFilesuploadOperation operation = new NBTMFilesuploadOperation( + targetComponent, this.nameField.getText(), session); + this.session.queueOperation(operation); + this.disposeDialog(); + this.dispose(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } +} else if (source.equals(this.celButton)) { + this.disposeDialog(); + this.dispose(); +} +} +} + + diff --git a/src/com/nbtm/customization/project/N01/NBTMFilesuploadHandler.java b/src/com/nbtm/customization/project/N01/NBTMFilesuploadHandler.java new file mode 100644 index 0000000..3fef18f --- /dev/null +++ b/src/com/nbtm/customization/project/N01/NBTMFilesuploadHandler.java @@ -0,0 +1,42 @@ +package com.nbtm.customization.project.N01; + +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; +import com.teamcenter.rac.util.MessageBox; + + + + +public class NBTMFilesuploadHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + //ǰѡж + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + //ǰỰ + TCSession session = (TCSession) app.getSession(); + //commandId ֵ arg0ǵǰĻỰ + String commandId = arg0.getCommand().getId(); + + //System.out.println("handler򣡣"); + MessageBox.post("handler", "OK", MessageBox.INFORMATION); + // + NBTMFilesuploadCommand command = new NBTMFilesuploadCommand( + app, session, commandId); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("ϴʧܣ", "", MessageBox.ERROR); + } + return null; + } + +} diff --git a/src/com/nbtm/customization/project/N01/NBTMFilesuploadOperation.java b/src/com/nbtm/customization/project/N01/NBTMFilesuploadOperation.java new file mode 100644 index 0000000..3e13dd1 --- /dev/null +++ b/src/com/nbtm/customization/project/N01/NBTMFilesuploadOperation.java @@ -0,0 +1,811 @@ +package com.nbtm.customization.project.N01; + + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.TreeMap; +import java.util.UUID; +import java.sql.*; +import java.text.SimpleDateFormat; +import java.util.Date; + +import com.connor.renben.process.plm.bean.PFMEADataBean; +import com.connor.renben.process.plm.bean.ProcessBean; +import com.connor.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.ExcelUtil07; +import com.connor.renben.process.plm.util.TMomFinalUtil; +import com.connor.renben.process.plm.util.TMomMethodUtil; +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.common.Activator; +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.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + + + + + + +//ִв + +public class NBTMFilesuploadOperation extends AbstractAIFOperation { + + private InterfaceAIFComponent targets; + private String selectItems; + private TCSession session; + private Map itemIdMap = new HashMap();// ItemId + private Map noMap = new HashMap();// Ųұ + + public NBTMFilesuploadOperation(InterfaceAIFComponent targets, + String selectItems, TCSession session) { + super(); + this.targets = targets;//ȡѡж ǰΪȡĶϢ + this.selectItems = selectItems;//ѡеItemIDֵ + this.session = session;//ȡsessionϢ ǰsessionΪsession + } + + + + //ʼִв + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + //һ + TreeMap itemlists = new TreeMap(); + //һ + ArrayList childrenItemlists = new ArrayList(); + //һ Ϊǰ + TCComponentItem item = null;//ǰ + + MessageBox.post("", "OK", MessageBox.INFORMATION); + + String LineID = "" ;//к + String ItemCode = "" ;//Ʒͺ + String ItemName = "" ;//Ʒ + String DrawingNo = "" ;//ͼ + String ProcessName = "" ;// + String MBOMCode = "" ;//ƺ + String EquiNames = "" ;//豸 + String StringNames = "" ;//豸 + + System.out.println("ʼץȡ"); + + System.out.println("ǰû:"+this.session.getUserName()); + //ȡѡUploadURLֵ + + TCPreferenceService service = session.getPreferenceService(); + + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "UpLoadURL"); + String url = ""; + + if ((array != null)&&(array.length > 0)) + { + + //MessageBox.post(" = "+array.length,"INFO",MessageBox.INFORMATION); + for (String str : array) { + + //MessageBox.post(" ˶URL = "+str,"INFO",MessageBox.INFORMATION); + + if (str != null && str != "" && str.startsWith("\\")) { + url = str; + + } + else + { + MessageBox.post(" ѡΪ "+str,"INFO",MessageBox.INFORMATION); + } + + + } + } + else + { + MessageBox.post(" ѡΪ ","INFO",MessageBox.INFORMATION); + } + + //MessageBox.post(" ϴURL = "+url,"INFO",MessageBox.INFORMATION); + + + //ȡѡUploadURLֵ + + //Իȡʵ + //ǰѡеĶtargets һ ʵ һϵ Ͱѵǰֵitem + if (this.targets instanceof TCComponentItem) { + item = (TCComponentItem) this.targets; //ǰֵitem + } + //ǰǹնʾ˳ + if (!item.getType().equals("MEProcess")) { + MessageBox.post("ѡն", "", MessageBox.ERROR); + return; + } + //Իȡʵ + + System.out.println("ǰIDֵ"+item.getProperty("item_id")); + + System.out.println("ȡʵϣ"); + + + //////////////////////////////// + //ͨselectItemsԲҵķʽҵ + // һַ + String[] itemID = null; + //ԻȡǰѡеʵitemID + //ȡItemIDϢа|Ե|ָɶֵַitemID + if (selectItems.indexOf(" | ") > -1) { + itemID = selectItems.split(" | "); + + } else { + itemID = new String[] { selectItems }; + } + //ԻȡǰѡеʵitemID //ѡжʵ + + + + + //Իȡʵ + + //ȡѡеĶĶ + //ǰʵкItem ʵ ʵ͸ֵitemType + //Item һ Ǹ е඼ + TCComponentItemType itemType = (TCComponentItemType) this.session + .getTypeComponent("Item");//ȡʵ + + //ǰʵкMEProcess ʵ ʵ͸ֵgyType + TCComponentItemType gyType = (TCComponentItemType) session + .getTypeComponent("MEProcess");//ȡն + //Իȡʵ + + + + //ȡitemID鲻Ϊղ鳤ȴ0 ʼѭ + if (itemID != null && itemID.length > 0) { + for (int i = 0; i < itemID.length; i++) { + + + //һoldTopItem itemIDлȡһItem + TCComponentItem oldTopItem = itemType.find(itemID[i].substring( + 0, itemID[i].length() - 1)); + + //ǰitemID[i]ֵа"/"Ȱ汾ָ"/"ַָitemID[i]ȡһֵַָ + //ȥ汾 + if (itemID[i].indexOf("/") >= 0) + { + oldTopItem = itemType.find(itemID[i].split("/")[0]); + } + else + { + oldTopItem = itemType.find(itemID[i]); + } + + + + //жϵǰĶ ȡoldTopItemͲǹնʾϢ + if (!oldTopItem.getType().equals("MEProcess")) { + MessageBox.post("ѡն", "", MessageBox.ERROR); + return; + } + + + + //ϻȡ˶ʵȷ˻ȡʵǹն + + + + //ȡǰ°汾 + TCComponentItemRevision oldTopItemRevision = oldTopItem + .getLatestItemRevision(); + + //////////////////////////////// + //Բҵķʽҵ + + System.out.println("ҵķʽҵʼ"); + + //ȡն֮ ҲƷ + + System.out.println("ǰͣ"+item.getType()); + + + //TCComponent[] mepComponents = item.getRelatedComponents("IMAN_reference"); //ȡƷݼ + + AIFComponentContext[] mepComponents = item + .whereReferenced(); //ݹշȡƷݼ + + for (int jj = 0; jj < mepComponents.length; jj++) { + + if (mepComponents[jj].getComponent() instanceof TCComponentItem) //жǷʵ + { + //ȡ"PRODUCT" Ͷ //ȡĶֵа"PRODUCT" Ʒͺŵ RB3_Product + if (mepComponents[jj].getComponent().getType().toUpperCase().indexOf("PRODUCT") >= 0) { + //Ʒͺ + ItemCode = mepComponents[jj].getComponent().getProperty("item_id"); + ItemName = mepComponents[jj].getComponent().getProperty("object_name"); + DrawingNo = mepComponents[jj].getComponent().getProperty("rb3_press_drawing"); + MBOMCode = mepComponents[jj].getComponent().getProperty("RB3_powder"); + StringNames = mepComponents[jj].getComponent().getProperty("object_string"); + + } + } + + + } + + + + + System.out.println("Ʒͺ="+ItemCode); + System.out.println("Ʒ="+ItemName); + System.out.println("Ʒͼ="+DrawingNo); + System.out.println("ƺ="+MBOMCode); + System.out.println("ϸϢ="+StringNames); + + System.out.println("ҵķʽҵϣ"); + + + + // ȡ°汾ĹնBOMݼ + TCComponent[] components = item.getLatestItemRevision() + .getRelatedComponents("ps_children"); + + //BOMݼѭ + for (int j = 0; j < components.length; j++) { + //ǰcomponents[j] ǰ汾 + if (components[j] instanceof TCComponentItemRevision) { + //ȡǰĶʵ + TCComponentItem oldMeop = ((TCComponentItemRevision) components[j]).getItem(); + + + + + // + ProcessName = oldMeop.getStringProperty("object_name");//ȡ + + //ȡ豸 //ȡ豸ݼ view豸 ϵ + TCComponent[] EquiComponents = oldMeop.getLatestItemRevision().getRelatedComponents("view"); + + + for (int jj = 0 ; jj< EquiComponents.length;jj++) + { + + //豸 + EquiNames = EquiComponents[jj].getStringProperty("object_name");//ȡ豸 + + } + + + + System.out.println("豸:"+EquiNames); + System.out.println(":"+ProcessName); + + + System.out.println("ID:"+oldMeop.getStringProperty("item_id").toString()); + + + + + // µĹװ + TCComponent[] gzComponents = oldMeop + .getLatestItemRevision().getRelatedComponents( + "RB3_gongzhuang"); + + // µҵָ + TCComponent[] workInstructionComponents = oldMeop + .getLatestItemRevision().getRelatedComponents( + "RB3_zuoyezhidaoshu"); + + for (int k = 0; k < workInstructionComponents.length; k++) + { + if (workInstructionComponents[k] instanceof TCComponentItem) + { + TCComponentItem dataItem = (TCComponentItem) workInstructionComponents[k]; //ȡ + + TCComponentItemRevision dataItemrev = dataItem.getLatestItemRevision();//ȡ°汾 + + TCComponent form = ((TCComponentItemRevision) dataItemrev) //ȡ汾 + .getRelatedComponent("IMAN_master_form_rev"); + + System.out.println("ҵָ汾:"+form.getStringProperty("rb3_revision").toString()); + System.out.println("ҵָID:"+dataItem.getStringProperty("item_id").toString()); + System.out.println("ҵָ:"+dataItem.getStringProperty("object_name").toString()); + + String NewPath= url+ProcessName+"\\1.txt"; + File file = new File(NewPath); + File fileParent = file.getParentFile(); + if(!fileParent.exists()){ + fileParent.mkdirs(); + } + Date dt = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + String Datestr=sdf.format(dt); + NewPath = url+ProcessName+"\\"+Datestr+"\\2.txt"; + //MessageBox.post( NewPath, "Waring", MessageBox.INFORMATION); + file = new File(NewPath); + fileParent = file.getParentFile(); + if(!fileParent.exists()){ + fileParent.mkdirs(); + } + + NewPath = url + ProcessName+"\\"+Datestr+"\\"; + + + //TCComponentDataset datasetComponent = ExcelUtil07.getComponentToDataset(session, dataItemrev, "TC_Attaches"); + TCComponentDataset[] datasetComponent = ExcelUtil07.getComponentToDatasets(session, dataItemrev, "TC_Attaches"); + if ( datasetComponent != null) + { + + //MessageBox.post(String.valueOf(datasetComponent.length), "Waring", MessageBox.INFORMATION); + + for(int q=0; q < datasetComponent.length ; q++) + { + if (datasetComponent[q] != null) + { + try + { + // + String FilesName = ProcessName+"-"+dataItem.getStringProperty("object_name").toString()+"-"+q+"-"+dataItem.getStringProperty("item_id").toString(); + + //String filePath = TMomMethodUtil.downLoadFile(datasetComponent); + //String filePath = TMomMethodUtil.downLoadFiles(datasetComponent,FilesName,url,true); + String filePath = TMomMethodUtil.downLoadFiles(datasetComponent[q],FilesName,NewPath,true); + String fileName = dataItemrev.getProperty("object_string"); + + + + System.out.println("FILE NAME = " + fileName + + " ,FILE PATH = " + filePath); + + + + // + } + catch(Exception ex) + { + System.out.println("352:"+ex.getMessage()); + return ; + + } + + + + } + + } + + + + + } + else + { + MessageBox.post("ݼΪգ", "Waring", MessageBox.INFORMATION); + } + + + } + } + + + + + + + + + + + + + + + + + + + } + } + + } + } + + + + + } + + /** + * Ϊ + * + * @param item + */ + public TCComponentItem saveAsItem(TCComponentItem productItem, + int itemCount, TCComponentItem item) { + TCComponentItem newItem = null; + try { + String itemID = ""; + if (item.getType().equals("MEProcess")) { + itemID = TMomMethodUtil.getRuleItemID(session, + productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GY_CODE); + } else if (item.getType().equals("MEOP")) { + itemID = TMomMethodUtil.getRuleItemID(session, + productItem.getStringProperty("item_id"), null, + TMomFinalUtil.GX_CODE); + itemIdMap.put(item.getStringProperty("item_id"), itemID); + } else { + itemID = item.getTypeComponent().getNewID(); + } + newItem = item.getLatestItemRevision().saveAsItem( + itemID, + item.getLatestItemRevision().getStringProperty( + "item_revision_id")); //ϵĶΪһµĶ + if (item.getType().equals("MEProcess")) { + TCComponent[] target = newItem.getLatestItemRevision() + .getReferenceListProperty("IMAN_METarget"); + if (target.length > 0) { + newItem.getLatestItemRevision().remove("IMAN_METarget", + target); + } + } + TCComponent[] itemDatas = item + .getReferenceListProperty("IMAN_reference"); + TCComponent[] newItemDatas = newItem + .getReferenceListProperty("IMAN_reference"); + if (newItemDatas.length > 0) { + newItem.remove("IMAN_reference", newItemDatas); + } + for (int j = 0; j < itemDatas.length; j++) { + if (itemDatas[j] instanceof TCComponentItem) { + TCComponentItem dataItem = (TCComponentItem) itemDatas[j]; + // TCComponentItemType dataType=(TCComponentItemType) + // session.getTypeComponent(dataItem.getStringProperty("object_type")); + TCComponentItem newDataItem = dataItem + .getLatestItemRevision().saveAsItem( + dataItem.getTypeComponent().getNewID(), + dataItem.getLatestItemRevision() + .getStringProperty( + "item_revision_id")); + newItem.add("IMAN_reference", newDataItem); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return newItem; + } + + /** + * ݿеĿƼƻ + * + * @param oldItem + * ն + * @param newDataItem + * ¹ն + */ + private void copyDataValue(TCComponentItem oldItem, TCComponentItem newItem) { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet rs2 = null; + ResultSet pfmeaRs = null; + InputStream input = null; + try { +// SqlUtilT.getConnectionTC10(); + SqlUtilT.getConnection("jdbc:Oracle:thin:@localhost:1521:TC10", + "tc10", "infodba"); + List processBeans = new ArrayList(); + // ѯϹյĿƼƻ + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String sql = String.format( + "select * from rb3_controlplan where processpuid = \'%s\'", + oldItem.getUid()); + rs = SqlUtilT.read(sql); + while (rs.next()) { + ProcessBean processBean = new ProcessBean(); + processBean.setMeopId(rs.getString("RB3_MEOPID")); + processBean.setGybh(rs.getString("RB3_GYBH")); + processBean.setGcmc(rs.getString("RB3_GCMC")); + processBean.setJqsb(rs.getString("RB3_JQSB")); + processBean.setSmjy(rs.getString("RB3_SMJY")); + processBean.setQptbh(rs.getString("RB3_QPTBH")); + processBean.setCc(rs.getString("RB3_CC")); + processBean.setCp(rs.getString("RB3_CP")); + processBean.setGc(rs.getString("RB3_GC")); + processBean.setTstx(rs.getString("RB3_TSTX")); + processBean.setCpgc(rs.getString("RB3_CPGC")); + processBean.setPgclff(rs.getString("RB3_CLFF")); + processBean.setRl(rs.getString("RB3_RL")); + processBean.setPl(rs.getString("RB3_PL")); + processBean.setSjsj(rs.getString("RB3_SJSJ")); + processBean.setGcsj(rs.getString("RB3_GCSJ")); + processBean.setMjsj(rs.getString("RB3_MJSJ")); + processBean.setFzr(rs.getString("RB3_FZR")); + processBean.setKzff(rs.getString("RB3_KZFF")); + processBean.setCzgf(rs.getString("RB3_CZGF")); + processBean.setFyjh(rs.getString("RB3_FYJH")); + processBean.setHh(String.valueOf(rs.getInt("RB3_HH"))); + processBean.setHbdyg(rs.getString("RB3_HBDYG")); + processBean.setSfwc(String.valueOf(rs.getInt("RB3_SFWC"))); + processBean.setHhc(String.valueOf(rs.getInt("RB3_HHC"))); + processBean.setSpecial(rs.getString("RB3_SPECIAL")); + processBean.setType(rs.getString("TYPE")); + processBeans.add(processBean); + } + noMap = getNomMap(newItem); + // + for (int i = 0; i < processBeans.size(); i++) { + // itemidȡϢ + ProcessBean process = processBeans.get(i); + String insertSQL = pro.getProperty("INSERTSQL"); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString().replace("-", ""), + newItem.getUid(), + itemIdMap.get(process.getMeopId()), + process.getGybh(), process.getGcmc(), + process.getJqsb(), process.getSmjy(), + process.getQptbh(), process.getCc(), + process.getCp(), process.getGc(), + process.getTstx(), process.getCpgc(), + process.getPgclff(), process.getRl(), + process.getPl(), process.getSjsj(), + process.getGcsj(), process.getMjsj(), + process.getFzr(), process.getKzff(), + process.getCzgf(), process.getFyjh(), + process.getHh(), process.getHbdyg(), + process.getSfwc(), process.getHhc(), + process.getSpecial(), process.getType() }, + insertSQL); + } + // Ȩޱ + List> meopList = new ArrayList>(); + String selectSQL = String + .format("select processpuid,rb3_meopid,rb3_gybh,rb3_gcmc from rb3_controlplan where processpuid = \'%s\' and rb3_gcmc not like \'%s\' group by processpuid,rb3_meopid,rb3_gybh,rb3_gcmc", + newItem.getUid(), "%"); + System.out.println(selectSQL); + rs2 = SqlUtilT.read(selectSQL); + while (rs2.next()) { + List list = new ArrayList(); + list.add(rs2.getString("processpuid")); + list.add(rs2.getString("rb3_meopid")); + list.add(rs2.getString("rb3_gybh")); + list.add(rs2.getString("rb3_gcmc")); + meopList.add(list); + } + for (int i = 0; i < meopList.size(); i++) { + String insertSQL = pro.getProperty("INSERTPERMISSIONS"); + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + meopList.get(i).get(0), meopList.get(i).get(1), + meopList.get(i).get(2), meopList.get(i).get(3), "", "", + "", "", }, insertSQL); + } + // ӵPFMEAе + List pfmeaDataBeans = new ArrayList(); + // ѯϹյPFMEA + String pfmeaSql = String.format(pro.getProperty("SETPFMEASELECT"), + oldItem.getUid()); + pfmeaRs = SqlUtilT.read(pfmeaSql); + while (pfmeaRs.next()) { + PFMEADataBean pfmeaDataBean = new PFMEADataBean(); + pfmeaDataBean.setMeopId(pfmeaRs.getString("RB3_MEOPID")); + pfmeaDataBean.setGybh(pfmeaRs.getString("RB3_GYBH")); + pfmeaDataBean.setGcmc(pfmeaRs.getString("RB3_GCMC")); + pfmeaDataBean.setStation(pfmeaRs.getString("RB3_STATION")); + pfmeaDataBean.setRequirement(pfmeaRs + .getString("RB3_REQUIREMENT")); + pfmeaDataBean.setQzsxms(pfmeaRs.getString("RB3_QZSXMS")); + pfmeaDataBean.setQzsxhg(pfmeaRs.getString("RB3_QZSXHG")); + pfmeaDataBean.setYzd(pfmeaRs.getString("RB3_YZD")); + pfmeaDataBean.setJb(pfmeaRs.getString("RB3_JB")); + pfmeaDataBean.setQzsxqy(pfmeaRs.getString("RB3_QZSXQY")); + pfmeaDataBean.setXxgckzyf(pfmeaRs.getString("RB3_XXGCKZYF")); + pfmeaDataBean.setPds(pfmeaRs.getString("RB3_PDS")); + pfmeaDataBean.setXxgckztc(pfmeaRs.getString("RB3_XXGCKZTC")); + pfmeaDataBean.setTcd(pfmeaRs.getString("RB3_TCD")); + pfmeaDataBean.setTm2Rpn(pfmeaRs.getString("RB3_RPN")); + pfmeaDataBean.setJycs(pfmeaRs.getString("RB3_JYCS")); + pfmeaDataBean.setZrr(pfmeaRs.getString("RB3_ZZR")); + pfmeaDataBean.setJhwcrq(pfmeaRs.getString("RB3_JHWCRQ")); + pfmeaDataBean.setCqdcs(pfmeaRs.getString("RB3_CQDCS")); + pfmeaDataBean.setNewSev(pfmeaRs.getString("RB3_NEW_SEV")); + pfmeaDataBean.setNewOcc(pfmeaRs.getString("RB3_NEW_OCC")); + pfmeaDataBean.setNewDel(pfmeaRs.getString("RB3_NEW_DET")); + pfmeaDataBean.setNewRpn(pfmeaRs.getString("RB3_NEW_RPN")); + pfmeaDataBean.setIdealState(pfmeaRs + .getString("RB3_IDEAL_STATE")); + pfmeaDataBean.setHh(String.valueOf(pfmeaRs.getInt("RB3_HH"))); + pfmeaDataBean.setHbdyg(pfmeaRs.getString("RB3_HBDYG")); + pfmeaDataBean.setHhc(String.valueOf(pfmeaRs.getInt("RB3_HHC"))); + pfmeaDataBean.setSpecial(pfmeaRs.getString("RB3_SPECIAL")); + pfmeaDataBean.setType(pfmeaRs.getString("TYPE")); + pfmeaDataBean.setBak(pfmeaRs.getString("BAK")); + pfmeaDataBeans.add(pfmeaDataBean); + } + // + for (int i = 0; i < pfmeaDataBeans.size(); i++) { + PFMEADataBean pfmeaData = pfmeaDataBeans.get(i); + String insertSQL = pro.getProperty("INSERTPFMEA"); + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString().replace("-", ""), + newItem.getUid(), + itemIdMap.get(pfmeaData.getMeopId()), + noMap.get(itemIdMap.get(pfmeaData.getMeopId())), + pfmeaData.getGcmc(), pfmeaData.getStation(), + pfmeaData.getRequirement(), + pfmeaData.getQzsxms(), pfmeaData.getQzsxhg(), + pfmeaData.getYzd(), pfmeaData.getJb(), + pfmeaData.getQzsxqy(), pfmeaData.getXxgckzyf(), + pfmeaData.getPds(), pfmeaData.getXxgckztc(), + pfmeaData.getTcd(), pfmeaData.getTm2Rpn(), + pfmeaData.getJycs(), pfmeaData.getZrr(), + pfmeaData.getJhwcrq(), pfmeaData.getCqdcs(), + pfmeaData.getNewSev(), pfmeaData.getNewOcc(), + pfmeaData.getNewDel(), pfmeaData.getNewRpn(), + pfmeaData.getIdealState(), pfmeaData.getHh(), + pfmeaData.getHbdyg(), pfmeaData.getHhc(), + pfmeaData.getSpecial(), pfmeaData.getType(), + pfmeaData.getBak() ,"","",""}, insertSQL); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + SqlUtilT.free(rs); + } + if (rs2 != null) { + SqlUtilT.free(rs2); + } + if (pfmeaRs != null) { + SqlUtilT.free(rs2); + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + SqlUtilT.freeAll(); + } + } + + private Map getNomMap(TCComponentItem item) { + Map resultMap = new HashMap(); + try { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine subline = ((TCComponentBOMLine) children + .getComponent()); + resultMap.put( + subline.getStringProperty("bl_indented_title") + .split("/")[0], subline + .getStringProperty("bl_sequence_no")); + } + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.toString(), "", MessageBox.ERROR); + e.printStackTrace(); + } + return resultMap; + } + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateMeopBom(TCComponentItem topItem, + TreeMap itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, + topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + Iterator it = itemlists.keySet().iterator(); + while (it.hasNext()) { + TCComponentItem meopItem = itemlists.get(it.next()); + TCComponentItemRevision revision = meopItem.getLatestItemRevision(); + topline.add(meopItem, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + + + /** + * ´BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem topItem, + ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItem, + topItem.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + + + + + + + +} + diff --git a/src/com/proya/savebomcheck/BomCheckSaveCommand.java b/src/com/proya/savebomcheck/BomCheckSaveCommand.java new file mode 100644 index 0000000..b576c0d --- /dev/null +++ b/src/com/proya/savebomcheck/BomCheckSaveCommand.java @@ -0,0 +1,125 @@ +package com.proya.savebomcheck; + +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.renben.process.plm.sql.util.SqlUtilT; +import com.connor.renben.process.plm.util.SaveControlPlan; +import com.connor.renben.process.plm.util.SavePermissions; +import com.connor.renben.process.plm.util.SavePfmea; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +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.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.pse.common.InterfaceBOMEditingApplication; +import com.teamcenter.rac.pse.operations.SaveBOMOperation; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.internal.core._2011_06.ict.Array; + +public class BomCheckSaveCommand extends AbstractAIFCommand { + private List> dataList = new ArrayList>();// е + private TCSession session; + private List meopNameList; + + public BomCheckSaveCommand( + InterfaceBOMEditingApplication interfacebomeditingapplication) { + try { + System.out.println("=========BomCheckSaveCommand========="); + // PLA8SProduct + SaveBOMOperation savebomoperation = new SaveBOMOperation( + interfacebomeditingapplication); + savebomoperation.executeOperation(); +// interfacebomeditingapplication.getSession().queueOperation( +// savebomoperation); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + // ȡ㹤ն + TCComponentBOMLine topBomLine = interfacebomeditingapplication + .getTopBOMLine(); + //String itemUid = topBomLine.getItem().getUid(); + String topType = topBomLine.getItem().getType(); + if ("MEProcess".equals(topType)) { + //+++++++ڽṹӹʱݲƼƻ,PFMEAݿ + //SaveControlPlan controlPlan = new SaveControlPlan(session, topBomLine.getItem()); +// SaveControlPlan controlPlan = new SaveControlPlan(session, topBomLine.getItem(),app.getTargetComponent()); +// controlPlan.insertData(); +// SavePfmea pfmea = new SavePfmea(session, topBomLine.getItem()); +// pfmea.insertData(); + SavePermissions permissions = new SavePermissions(session, topBomLine.getItem()); + permissions.insertData(); + + } + else if("MEOP".equals(topType)) + { + try { + // ȡ + TCComponentBOMLine subline = topBomLine; + //ȡն + TCComponentItem meopItem = subline.getItem(); + //ȡµ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()); + } + } + } + } + } + } + String value = ""; + if(equipmentNameList.size() > 0) + { + value = equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1); + } + // + SqlUtilT.getTCConnection(); + String updateSql = String.format("update RB3_CONTROLPLAN set RB3_JQSB = ? where RB3_MEOPID = \'%s\' and RB3_GCMC not like (\'飨%%\')", meopItem.getStringProperty("item_id")); + SqlUtilT.update(new String[] { value }, updateSql); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/src/com/proya/savebomcheck/CopyOfBomCheckSaveCommand.java b/src/com/proya/savebomcheck/CopyOfBomCheckSaveCommand.java new file mode 100644 index 0000000..dd17f10 --- /dev/null +++ b/src/com/proya/savebomcheck/CopyOfBomCheckSaveCommand.java @@ -0,0 +1,440 @@ +package com.proya.savebomcheck; + +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.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.pse.common.InterfaceBOMEditingApplication; +import com.teamcenter.rac.pse.operations.SaveBOMOperation; + +public class CopyOfBomCheckSaveCommand extends AbstractAIFCommand { + private List> dataList = new ArrayList>();// е + + public CopyOfBomCheckSaveCommand( + InterfaceBOMEditingApplication interfacebomeditingapplication) { + try { + System.out.println("=========BomCheckSaveCommand========="); + // ȡ㹤ն + TCComponentBOMLine topBomLine = interfacebomeditingapplication + .getTopBOMLine(); + String itemUid = topBomLine.getItem().getUid(); + String topType = topBomLine.getItem().getType(); + if ("MEProcess".equals(topType)) { + // StringBuffer buffer=new StringBuffer(); + // ȡ + AIFComponentContext aif[] = topBomLine.getChildren(); + List> properties = new ArrayList>(); + for (int i = 0; i < aif.length; i++) { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + TCComponentICO[] icos = subline.getItem() + .getClassificationObjects(); + 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")); + if (icos.length > 0) { + ICSProperty[] descriptions = icos[0] + .getICSProperties(true); + for (int j = 0; j < descriptions.length; j++) { + if (descriptions[j].getId() == 1004) { + propertie + .add(descriptions[j].getValue() == null ? "" + : descriptions[j].getValue()); + } + } + } else { + propertie.add(""); + } + // propertie.add(); + properties.add(propertie); + } + updateDataValue(itemUid, properties); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // PLA8SProduct + SaveBOMOperation savebomoperation = new SaveBOMOperation( + interfacebomeditingapplication); + interfacebomeditingapplication.getSession().queueOperation( + savebomoperation); + } + + private void updateDataValue(String itemUid, List> properties) { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet result = null; + ResultSet resultSet = null; + InputStream input = null; + try { + 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++) { + UUID sckzjhUid = UUID.randomUUID(); + UUID ssckzjhUid = UUID.randomUUID(); + UUID yjkzjhUid = UUID.randomUUID(); + // ݲ뵽Ƽƻ + String insertSQL = pro.getProperty("INSERTSQL"); + // 뵽Ȩޱ + String insertSQL2 = pro.getProperty("INSERTPERMISSIONS"); + // 뵽PFMEA + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + 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[] { + sckzjhUid.toString().replace("-", ""), + itemUid, properties.get(j).get(0), + properties.get(j).get(1), + properties.get(j).get(2), + properties.get(j).get(3), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_SCKZJH" }, + insertSQL); + // ƼƻѲ + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(j).get(0), + number.toString(), name, + properties.get(j).get(3), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_SCKZJH" }, + insertSQL); + // Ƽƻ + SqlUtilT.write( + new String[] { + ssckzjhUid.toString().replace("-", ""), + itemUid, properties.get(j).get(0), + properties.get(j).get(1), + properties.get(j).get(2), + properties.get(j).get(3), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_SSCKZJH" }, + insertSQL); + // ƼƻѲ + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(j).get(0), + number.toString(), name, + properties.get(j).get(3), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_SSCKZJH" }, + insertSQL); + // Ƽƻ + SqlUtilT.write( + new String[] { + yjkzjhUid.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" }, + insertSQL); + // ƼƻѲ + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(j).get(0), + number.toString(), name, + properties.get(j).get(3), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "RB3_YJKZJH" }, + insertSQL); + // ƼƻȨޱ + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(j).get(0), + properties.get(j).get(1), properties.get(j).get(2), + "", "", "", "" }, insertSQL2); + // 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), + "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", + "" ,"","",""}, insertPFMEA); + } + } 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), "%"); + String updateSQL2 = String.format( + pro.getProperty("UPDATEPERMISSIONS"), + itemUid, dataList.get(i).get(0)); + String updatePFMEA = String.format( + pro.getProperty("UPDATEPFMEA"), 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, + properties.get(j).get(3) }, updateSQL1); + SqlUtilT.update(new String[] { + properties.get(j).get(1), + properties.get(j).get(2) }, updateSQL2); +// // PFMEA +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2) }, updatePFMEA); + //+++ + // PFMEA + SqlUtilT.update(new String[] { + properties.get(j).get(1)+ + properties.get(j).get(2) }, updatePFMEA); + //+++ + } + // 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 sckzjhUid = UUID.randomUUID(); + UUID ssckzjhUid = UUID.randomUUID(); + UUID yjkzjhUid = UUID.randomUUID(); + // ݲ뵽 + String insertSQL = pro.getProperty("INSERTSQL"); + String insertSQL2 = pro + .getProperty("INSERTPERMISSIONS"); + // 뵽PFMEA + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + 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[] { + sckzjhUid.toString().replace("-", ""), itemUid, + properties.get(i).get(0), + properties.get(i).get(1), + properties.get(i).get(2), + properties.get(i).get(3), "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "RB3_SCKZJH" }, insertSQL); + // ƼƻѲ + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(i).get(0), + number.toString(), name, + properties.get(i).get(3), "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "RB3_SCKZJH" }, insertSQL); + // Ƽƻ + SqlUtilT.write(new String[] { + ssckzjhUid.toString().replace("-", ""), + itemUid, properties.get(i).get(0), + properties.get(i).get(1), + properties.get(i).get(2), + properties.get(i).get(3), "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "RB3_SSCKZJH" }, insertSQL); + // ƼƻѲ + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(i).get(0), + number.toString(), name, + properties.get(i).get(3), "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "RB3_SSCKZJH" }, insertSQL); + // Ƽƻ + SqlUtilT.write(new String[] { + yjkzjhUid.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" }, insertSQL); + // ƼƻѲ + SqlUtilT.write( + new String[] { + UUID.randomUUID().toString() + .replace("-", ""), itemUid, + properties.get(i).get(0), + number.toString(), name, + properties.get(i).get(3), "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + "RB3_YJKZJH" }, insertSQL); + // ƼƻȨޱ + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(i).get(0), + properties.get(i).get(1), + properties.get(i).get(2), "", "", "", "" }, + insertSQL2); + // 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), "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "" ,"","",""}, + insertPFMEA); + } + } + // ɾӦĹ + 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); + String deleteSQL2 = String.format( + pro.getProperty("DELETEPERMISSIONS"), + deleteList.get(i), itemUid); + String deletePFMEA = String.format( + pro.getProperty("DELETEPFMEA"), + deleteList.get(i), itemUid); + SqlUtilT.delete(deleteSQL); + SqlUtilT.delete(deleteSQL2); + SqlUtilT.delete(deletePFMEA); + } + } + } + } 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/proya/savebomcheck/Copy_2_of_BomCheckSaveCommand.java b/src/com/proya/savebomcheck/Copy_2_of_BomCheckSaveCommand.java new file mode 100644 index 0000000..d40eb76 --- /dev/null +++ b/src/com/proya/savebomcheck/Copy_2_of_BomCheckSaveCommand.java @@ -0,0 +1,570 @@ +package com.proya.savebomcheck; + +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.renben.process.plm.sql.util.SqlUtilT; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +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.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.pse.common.InterfaceBOMEditingApplication; +import com.teamcenter.rac.pse.operations.SaveBOMOperation; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.internal.core._2011_06.ict.Array; + +public class Copy_2_of_BomCheckSaveCommand extends AbstractAIFCommand { + private List> dataList = new ArrayList>();// е + private TCSession session; + private List meopNameList; + + public Copy_2_of_BomCheckSaveCommand( + InterfaceBOMEditingApplication interfacebomeditingapplication) { + try { + System.out.println("=========BomCheckSaveCommand========="); + // PLA8SProduct + SaveBOMOperation savebomoperation = new SaveBOMOperation( + interfacebomeditingapplication); + savebomoperation.executeOperation(); +// interfacebomeditingapplication.getSession().queueOperation( +// savebomoperation); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + this.session = (TCSession) app.getSession(); + // ȡ㹤ն + TCComponentBOMLine topBomLine = interfacebomeditingapplication + .getTopBOMLine(); + String itemUid = topBomLine.getItem().getUid(); + String topType = topBomLine.getItem().getType(); + if ("MEProcess".equals(topType)) { + // StringBuffer buffer=new StringBuffer(); + //ȡҪĹ + meopNameList = getMeopNames("RB3_CONCEAL_MEOP_NAME"); + //ȡն + topBomLine.refresh(); + TCComponentItem processItem = topBomLine.getItem(); + //ȡµĿƼƻ + TCComponent[] kzjh = processItem.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); + } + updateDataValue(itemUid, properties,itme); + } + else if("MEOP".equals(topType)) + { + try { + // ȡ + TCComponentBOMLine subline = topBomLine; + //ȡն + TCComponentItem meopItem = subline.getItem(); + //ȡµ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()); + } + } + } + } + } + } + String value = ""; + if(equipmentNameList.size() > 0) + { + value = equipmentNameList.toString().substring(1, equipmentNameList.toString().length()-1); + } + // + SqlUtilT.getTCConnection(); + String updateSql = String.format("update RB3_CONTROLPLAN set RB3_JQSB = ? where RB3_MEOPID = \'%s\' and RB3_GCMC not like (\'飨%%\')", meopItem.getStringProperty("item_id")); + SqlUtilT.update(new String[] { value }, updateSql); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + SqlUtilT.freeAll(); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + 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); + } + + private void updateDataValue(String itemUid, List> properties,List kzjh) { + // TODO Auto-generated method stub + ResultSet rs = null; + ResultSet result = null; + ResultSet resultSet = null; + InputStream input = null; + try { + 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++) { + // 뵽Ȩޱ + String insertSQL2 = pro.getProperty("INSERTPERMISSIONS"); + // 뵽PFMEA + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + if(kzjh.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 < kzjh.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), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", kzjh.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), "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", kzjh.get(i).getType().toUpperCase(),"0","","0" }, + insertSQL); + } + } + } + // ƼƻȨޱ + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(j).get(0), + properties.get(j).get(1), properties.get(j).get(2), + "", "", "", "" }, insertSQL2); + // 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), + "", "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", "", + "","","","" }, insertPFMEA); + } + } 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), "飨%"); + String updateSQL2 = String.format( + pro.getProperty("UPDATEPERMISSIONS"), + itemUid, dataList.get(i).get(0)); + String updatePFMEA = String.format( + pro.getProperty("UPDATEPFMEA"), 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); + SqlUtilT.update(new String[] { + properties.get(j).get(1), + properties.get(j).get(2) }, updateSQL2); + // PFMEA +// SqlUtilT.update(new String[] { +// properties.get(j).get(1), +// properties.get(j).get(2) }, updatePFMEA); + //+++ + // PFMEA + SqlUtilT.update(new String[] { + properties.get(j).get(1)+ + properties.get(j).get(2) }, updatePFMEA); + //+++ + } + // 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))) { + String insertSQL2 = pro + .getProperty("INSERTPERMISSIONS"); + // 뵽PFMEA + String insertPFMEA = pro.getProperty("INSERTPFMEA"); + if(kzjh.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 < kzjh.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), "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", kzjh.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, + "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", + kzjh.get(k).getType().toUpperCase(),"0","0","","0" }, insertSQL); + } + } + } + // ƼƻȨޱ + SqlUtilT.write(new String[] { + UUID.randomUUID().toString().replace("-", ""), + itemUid, properties.get(i).get(0), + properties.get(i).get(1), + properties.get(i).get(2), "", "", "", "" }, + insertSQL2); + // 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), "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "","","","" }, + insertPFMEA); + } + } + // ɾӦĹ + 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); + String deleteSQL2 = String.format( + pro.getProperty("DELETEPERMISSIONS"), + deleteList.get(i), itemUid); + String deletePFMEA = String.format( + pro.getProperty("DELETEPFMEA"), + deleteList.get(i), itemUid); + SqlUtilT.delete(deleteSQL); + SqlUtilT.delete(deleteSQL2); + SqlUtilT.delete(deletePFMEA); + } + } + } + } 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/teamcenter/rac/pse/pse_user.properties b/src/com/teamcenter/rac/pse/pse_user.properties new file mode 100644 index 0000000..b93d9a9 --- /dev/null +++ b/src/com/teamcenter/rac/pse/pse_user.properties @@ -0,0 +1,3 @@ + + +saveBOMCommand=com.proya.savebomcheck.BomCheckSaveCommand \ No newline at end of file