first commit

main
ChenZichaoczc 1 month ago
commit a068006111

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/commons-codec-1.15.jar"/>
<classpathentry kind="lib" path="libs/commons-collections4-4.4.jar"/>
<classpathentry kind="lib" path="libs/commons-compress-1.21.jar"/>
<classpathentry kind="lib" path="libs/commons-io-2.11.0.jar"/>
<classpathentry kind="lib" path="libs/commons-math3-3.6.1.jar"/>
<classpathentry kind="lib" path="libs/poi-5.2.1.jar"/>
<classpathentry kind="lib" path="libs/poi-ooxml-5.2.1.jar"/>
<classpathentry kind="lib" path="libs/poi-ooxml-lite-5.2.1.jar"/>
<classpathentry kind="lib" path="libs/swingx-core-1.6.2.jar"/>
<classpathentry kind="lib" path="libs/xml-apis-1.4.01.jar"/>
<classpathentry kind="lib" path="libs/xmlbeans-5.0.3.jar"/>
<classpathentry kind="lib" path="json-20151123.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored

@ -0,0 +1 @@
/bin/

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.connor.ahboxinwei.plm</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,15 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.ui.text.custom_code_templates=

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false

@ -0,0 +1,103 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: boxinwei
Bundle-SymbolicName: com.connor.ahboxinwei.plm;singleton:=true
Bundle-Version: 1.0.0
Bundle-Localization: plugin
Automatic-Module-Name: com.conor.ferrorTech.metal
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.teamcenter.rac.aif,
com.teamcenter.rac.aif.kernel,
com.teamcenter.rac.aifrcp,
com.teamcenter.rac.classification.common.table,
com.teamcenter.rac.classification.icm,
com.teamcenter.rac.kernel,
com.teamcenter.rac.util,
com.teamcenter.services.rac.core,
com.teamcenter.services.rac.core._2006_03,
com.teamcenter.services.rac.core._2008_06,
com.teamcenter.services.rac.core._2013_05,
com.teamcenter.soa.exceptions,
org.apache.commons.lang,
org.eclipse.core.commands,
org.eclipse.core.databinding
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.teamcenter.rac.aifrcp,
com.teamcenter.rac.common,
com.teamcenter.rac.ui.commands,
com.teamcenter.rac.external,
com.teamcenter.rac.kernel,
com.teamcenter.rac.tcapps,
com.teamcenter.rac.util,
TcSoaCadRac,
TcSoaCommon,
TcSoaCoreRac,
TcSoaCoreTypes,
TcSoaCoreLoose,
com.teamcenter.rac.classification.icm,
com.teamcenter.rac.tcapps,
com.teamcenter.rac.workflow.processdesigner;bundle-version="14000.3.0",
TcSoaWorkflowRac;bundle-version="14000.3.0"
Export-Package: .,
com.connor.ferrorTech.metal,
com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate,
com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel,
com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity,
com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate,
com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload,
com.connor.ferrorTech.metal.batchDownload,
com.connor.ferrorTech.metal.bomProcess,
com.connor.ferrorTech.metal.changeManagement.createECO,
com.connor.ferrorTech.metal.changeManagement.createECR,
com.connor.ferrorTech.metal.constant,
com.connor.ferrorTech.metal.createTechnicalDocuments,
com.connor.ferrorTech.metal.createTechnicalDocuments.AinternalDrawing,
com.connor.ferrorTech.metal.createTechnicalDocuments.BprocessControl,
com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing,
com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing,
com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing,
com.connor.ferrorTech.metal.createTechnicalDocuments.FsetupSheet,
com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction,
com.connor.ferrorTech.metal.createTechnicalDocuments.HncFile,
com.connor.ferrorTech.metal.createTechnicalDocuments.IprocessDrawing,
com.connor.ferrorTech.metal.createTechnicalDocuments.JpreMillDrawing,
com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing,
com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList,
com.connor.ferrorTech.metal.createTechnicalDocuments.LstandardInstruction,
com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments,
com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments,
com.connor.ferrorTech.metal.exception,
com.connor.ferrorTech.metal.importMaterial,
com.connor.ferrorTech.metal.material.finishedProducts,
com.connor.ferrorTech.metal.material.material,
com.connor.ferrorTech.metal.material.semiFinishedProducts,
com.connor.ferrorTech.metal.processManagement.classificationCraft,
com.connor.ferrorTech.metal.processManagement.classificationProcesses,
com.connor.ferrorTech.metal.processManagement.createCraft,
com.connor.ferrorTech.metal.processManagement.createProcesses,
com.connor.ferrorTech.metal.processManagement.entity,
com.connor.ferrorTech.metal.quotationManagement.createClientFile,
com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings,
com.connor.ferrorTech.metal.quotationManagement.createQuotationProject,
com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation,
com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate,
com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings,
com.connor.ferrorTech.metal.share,
com.connor.ferrorTech.metal.util
Bundle-Vendor: boxinwei
Bundle-ClassPath: .,
libs/commons-codec-1.15.jar,
libs/commons-collections4-4.4.jar,
libs/commons-compress-1.21.jar,
libs/commons-io-2.11.0.jar,
libs/commons-math3-3.6.1.jar,
libs/poi-5.2.1.jar,
libs/poi-ooxml-5.2.1.jar,
libs/poi-ooxml-lite-5.2.1.jar,
libs/swingx-core-1.6.2.jar,
libs/xml-apis-1.4.01.jar,
libs/xmlbeans-5.0.3.jar,
json-20151123.jar
Bundle-ActivationPolicy: lazy

@ -0,0 +1,21 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
build.properties,\
plugin.xml,\
libs/commons-codec-1.15.jar,\
libs/commons-collections4-4.4.jar,\
libs/commons-compress-1.21.jar,\
libs/commons-io-2.11.0.jar,\
libs/commons-math3-3.6.1.jar,\
libs/poi-5.2.1.jar,\
libs/poi-ooxml-5.2.1.jar,\
libs/poi-ooxml-lite-5.2.1.jar,\
libs/swingx-core-1.6.2.jar,\
libs/xml-apis-1.4.01.jar,\
libs/xmlbeans-5.0.3.jar,\
plugin_zh_CN.properties,\
plugin.properties,\
json-20151123.jar
jars.compile.order = .

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -0,0 +1,62 @@
vf.1=Share File Auto Distribution
vf.2=File Management
vf.3=Import Bill Of Materials
plugin.0=PLM Menu
quo.0=Quote Management
quo.1=Create customer profiles
quo.2=Create quotation projects
quo.3=Create quotation drawings
quo.4=Upload quotation drawings
quo.5=Create technical quotations
quo.6=Create external quotations
npi.0=NPI Project
npi.1=Create NPI project
npi.2=Create NPI No Quotation Project
npi.3=Create customer drawings
npi.4=Upload customer drawings
mar.0=Create Material Master
mar.1=Finished products
mar.2=Semi-finished products
mar.3=Raw Material
gy.0=Process Management
gy.1=Process Routing Library
gy.2=Operation Library
gy.3=Create Routing
gy.4=Create Operation
cg.0=Change Management
cg.1=Create ECR
cg.2=Create ECO
tech.0=Create Engineering document
tech.1=Create Internal Drawing
tech.2=Create Process Control
tech.3=Create Redline Drawing
tech.4=Create RawMaterial Drawing
tech.5=Create Sub-Parts Drawing
tech.6=Create Setup Sheet
tech.7=Create Rework Work Instruction
tech.8=Create CNC file
tech.9=Create Process Drawing
tech.10=Create Pre-Mill Drawing
tech.11=Create Jig & Fixture Drawing
tech.12=Create Tooling List
tech.13=Create Standard Work Instruction
tech.14=Create In-Process Inspection Plan
tech.15=Upload Documents
tech.16=Batch Approval Of Tec-Documents
BOMgy.0=BOM process batch approval
batchDownload.0=Batch Download Files
plugin.1=Design Management
toBom.1=DBOM To EBOM

@ -0,0 +1,296 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="startTest"
name="start hello teamcenter"
point="org.eclipse.ui.startup">
<startup class="com.connor.ferrorTech.metal.share.start"/>
</extension>
<extension point="org.eclipse.ui.commands">
<category name="Double Category" id="com.connor.ferrorTech.metal.commands.category">
</category>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%quo.1" id="com.connor.ferrorTech.metal.quotationManagher.createClientFile">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%quo.2" id="com.connor.ferrorTech.metal.quotationManagher.createQuotationProject">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%quo.3" id="com.connor.ferrorTech.metal.quotationManagher.createQuotationDrawings">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%quo.4" id="com.connor.ferrorTech.metal.quotationManagher.uploadQuotationDrawings">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%quo.5" id="com.connor.ferrorTech.metal.quotationManagher.createTechnicalQuotation">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%quo.6" id="com.connor.ferrorTech.metal.quotationManagher.CreateExternalQuotation">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%npi.1" id="com.connor.ferrorTech.metal.NPIproject.createNPIproject">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%npi.2" id="com.connor.ferrorTech.metal.NPIproject.createNPIprojectByQuotation">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%npi.3" id="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%npi.4" id="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%mar.1" id="com.connor.ferrorTech.metal.material.finishedProducts">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%mar.2" id="com.connor.ferrorTech.metal.material.semiFinishedProducts">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%mar.3" id="com.connor.ferrorTech.metal.material.material">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%gy.1" id="com.connor.ferrorTech.metal.processManagement.callCraft">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%gy.2" id="com.connor.ferrorTech.metal.processManagement.callProcesses">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%gy.3" id="com.connor.ferrorTech.metal.processManagement.createCraft">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%gy.4" id="com.connor.ferrorTech.metal.processManagement.createProcesses">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%cg.1" id="com.connor.ferrorTech.metal.changeManagement.createECR">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%cg.2" id="com.connor.ferrorTech.metal.changeManagement.createECO">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.1" id="com.connor.ferrorTech.metal.createTechnicalDocuments.internalDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.2" id="com.connor.ferrorTech.metal.createTechnicalDocuments.processControl">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.3" id="com.connor.ferrorTech.metal.createTechnicalDocuments.redlineDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.4" id="com.connor.ferrorTech.metal.createTechnicalDocuments.rawMaterialDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.5" id="com.connor.ferrorTech.metal.createTechnicalDocuments.subPartsDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.6" id="com.connor.ferrorTech.metal.createTechnicalDocuments.setupSheet">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.7" id="com.connor.ferrorTech.metal.createTechnicalDocuments.reworkWorkInstruction">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.8" id="com.connor.ferrorTech.metal.createTechnicalDocuments.nCFile">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.9" id="com.connor.ferrorTech.metal.createTechnicalDocuments.processDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.10" id="com.connor.ferrorTech.metal.createTechnicalDocuments.preMillDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.11" id="com.connor.ferrorTech.metal.createTechnicalDocuments.jitFixtureDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.12" id="com.connor.ferrorTech.metal.createTechnicalDocuments.toolingList">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.13" id="com.connor.ferrorTech.metal.createTechnicalDocuments.standardWorkInstruction">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.14" id="com.connor.ferrorTech.metal.createTechnicalDocuments.inspectionPlan">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.15" id="com.connor.ferrorTech.metal.createTechnicalDocuments.uploadDocuments">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.16" id="com.connor.ferrorTech.metal.createTechnicalDocuments.batchApproval">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%BOMgy.0" id="com.connor.ferrorTech.metal.approvalOfBom">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%batchDownload.0" id="com.connor.ferrorTech.metal.downloadFiles">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%vf.3" id="com.connor.ferrorTech.metal.importMaterial">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%toBom.1" id="com.connor.ah.bxw.DBOMtoEBOM">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler class="com.connor.ferrorTech.metal.quotationManagement.createClientFile.CreateClientFileHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createClientFile">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.createQuotationProject.CreateQuotationProjectHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationProject">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings.CreateQuotationDrawingsHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationDrawings">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.uploadQuotationDrawings">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation.CreateTechnicalHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createTechnicalQuotation">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate.CreateExternalQuotationHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.CreateExternalQuotation">
</handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.CreateNPIprojectHandler" commandId="com.connor.ferrorTech.metal.NPIproject.createNPIproject">
</handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.NPIprojectCreateOnQuotation.CreateNPIprojectOnQuotationHandler" commandId="com.connor.ferrorTech.metal.NPIproject.createNPIprojectByQuotation">
</handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate.CreateClientDrawingHandler" commandId="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload.UploadClientDrawingHandler" commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.material.finishedProducts.FinishedProductsCreateHandler" commandId="com.connor.ferrorTech.metal.material.finishedProducts">
</handler>
<handler class="com.connor.ferrorTech.metal.material.semiFinishedProducts.SemiFinishedProductsCreateHandler" commandId="com.connor.ferrorTech.metal.material.semiFinishedProducts">
</handler>
<handler class="com.connor.ferrorTech.metal.material.material.MaterialCreateHandler" commandId="com.connor.ferrorTech.metal.material.material">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.classificationCraft.ClassificationCraftHandler" commandId="com.connor.ferrorTech.metal.processManagement.callCraft">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.classificationProcesses.ClassificationProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.callProcesses">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.createCraft.CreateCraftHandler" commandId="com.connor.ferrorTech.metal.processManagement.createCraft">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.createProcesses.CreateProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.createProcesses">
</handler>
<handler class="com.connor.ferrorTech.metal.changeManagement.createECR.ChangeApplyFormCreateHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createECR">
</handler>
<handler class="com.connor.ferrorTech.metal.changeManagement.createECO.ChangeNoticeFormCreateHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createECO">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.AinternalDrawing.CreateInternalDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.internalDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.BprocessControl.CreateProcessControlHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processControl">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing.CreateRedlineDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.redlineDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing.CreateRawMaterialDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.rawMaterialDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing.CreateSubPartsDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.subPartsDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.FsetupSheet.CreateSetupSheetHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.setupSheet">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction.CreateReworkInstructionHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.reworkWorkInstruction">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.HncFile.CreateNcFileHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.nCFile">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.IprocessDrawing.CreateProcessDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.JpreMillDrawing.CreatePreMillDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.preMillDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing.CreateJitFixtureHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.jitFixtureDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.toolingList">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.LstandardInstruction.CreateStandardInstructionHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.standardWorkInstruction">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.LTinspectionPlan.InspectionPlanHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.inspectionPlan">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments.UploadDocumentsHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.uploadDocuments">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments.ApprovalofDocumentsHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.batchApproval">
</handler>
<handler class="com.connor.ferrorTech.metal.bomProcess.ApprovalOfBomProcessHandler" commandId="com.connor.ferrorTech.metal.approvalOfBom">
</handler>
<handler class="com.connor.ferrorTech.metal.batchDownload.BatchDownloadHandler" commandId="com.connor.ferrorTech.metal.downloadFiles">
</handler>
<handler class="com.connor.ferrorTech.metal.importMaterial.ImportMaterialHandler" commandId="com.connor.ferrorTech.metal.importMaterial">
</handler>
<handler class="com.connor.ferrorTech.metal.materialManage.DbomTransitionToEbomHandler" commandId="com.connor.ah.bxw.DBOMtoEBOM">
</handler>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu label="%plugin.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.plmMenu.metal">
<menu label="%quo.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.quoteManager">
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createClientFile" id="com.connor.ferrorTech.metal.menus.quotation.client" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationProject" id="com.connor.ferrorTech.metal.menus.quotation.project" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationDrawings" id="com.connor.ferrorTech.metal.menus.quotation.drawings" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.uploadQuotationDrawings" id="com.connor.ferrorTech.metal.menus.quotation.upload" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createTechnicalQuotation" id="com.connor.ferrorTech.metal.menus.quotation.technical" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.CreateExternalQuotation" id="com.connor.ferrorTech.metal.menus.quotation.external" mnemonic="S">
</command>
</menu>
<menu label="%npi.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.npiProject">
<command commandId="com.connor.ferrorTech.metal.NPIproject.createNPIproject" id="com.connor.ferrorTech.metal.menus.npiProject.createNpi" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.NPIproject.createNPIprojectByQuotation" id="com.connor.ferrorTech.metal.menus.npiProject.createNpiByQuotation" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing" id="com.connor.ferrorTech.metal.menus.npiProject.createCustomerDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing" id="com.connor.ferrorTech.metal.menus.npiProject.uploadCustomerDrawing" mnemonic="S">
</command>
</menu>
<menu label="%mar.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.createMaterial">
<command commandId="com.connor.ferrorTech.metal.material.finishedProducts" id="com.connor.ferrorTech.metal.menus.npiProject.finishedProducts" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.material.semiFinishedProducts" id="com.connor.ferrorTech.metal.menus.npiProject.semiFinishedProducts" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.material.material" id="com.connor.ferrorTech.metal.menus.npiProject.material" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.importMaterial" id="com.connor.ferrorTech.metal.menus.importMaterial" mnemonic="S">
</command>
</menu>
<menu label="%gy.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.processManagement">
<command commandId="com.connor.ferrorTech.metal.processManagement.callCraft" id="com.connor.ferrorTech.metal.menus.processManagement.callCraft" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.processManagement.callProcesses" id="com.connor.ferrorTech.metal.menus.processManagement.callProcesses" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.processManagement.createCraft" id="com.connor.ferrorTech.metal.menus.processManagement.createCraft" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.processManagement.createProcesses" id="com.connor.ferrorTech.metal.menus.processManagement.createProcesses" mnemonic="S">
</command>
</menu>
<menu label="%cg.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.changeManagement">
<command commandId="com.connor.ferrorTech.metal.changeManagement.createECR" id="com.connor.ferrorTech.metal.menus.metal.changeManagement.createECR" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.changeManagement.createECO" id="com.connor.ferrorTech.metal.menus.metal.changeManagement.createECO" mnemonic="S">
</command>
</menu>
<menu label="%tech.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.createTechnicalDocuments">
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.internalDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.internalDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processControl" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.processControl" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.redlineDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.redlineDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.rawMaterialDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.rawMaterialDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.subPartsDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.subPartsDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.setupSheet" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.setupSheet" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.reworkWorkInstruction" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.reworkWorkInstruction" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.nCFile" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.nCFile" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.processDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.preMillDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.preMillDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.jitFixtureDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.jitFixtureDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.toolingList" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.toolingList" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.standardWorkInstruction" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.standardWorkInstruction" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.inspectionPlan" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.inspectionPlan" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.uploadDocuments" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.uploadDocuments" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.batchApproval" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.batchApproval" mnemonic="S">
</command>
</menu>
<command commandId="com.connor.ferrorTech.metal.approvalOfBom" id="com.connor.ferrorTech.metal.menus.approvalOfBom" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.downloadFiles" id="com.connor.ferrorTech.metal.menus.downloadFiles" mnemonic="S">
</command>
</menu>
<menu label="%plugin.1" mnemonic="M" id="com.connor.menus.plmMenu.bxw">
<command commandId="com.connor.ah.bxw.DBOMtoEBOM" id="com.connor.menus.plmMenu.bxw.DBOMtoEBOM" mnemonic="S">
</command>
</menu>
</menuContribution>
</extension>
</plugin>

@ -0,0 +1,66 @@
vf.1=\u5171\u4eab\u6587\u4ef6\u81ea\u52a8\u5206\u53d1
vf.2=\u6587\u4ef6\u7ba1\u7406
vf.3=Import Bill Of Materials
plugin.0=PLM Menu
quo.0=\u62A5\u4EF7\u7BA1\u7406
quo.1=\u521B\u5EFA\u5BA2\u6237\u6863\u6848
quo.2=\u521B\u5EFA\u62A5\u4EF7\u9879\u76EE
quo.3=\u521B\u5EFA\u62A5\u4EF7\u56FE\u7EB8
quo.4=\u4E0A\u4F20\u62A5\u4EF7\u56FE\u7EB8
quo.5=\u521B\u5EFA\u6280\u672F\u62A5\u4EF7\u5355
quo.6=\u521B\u5EFA\u5BF9\u5916\u62A5\u4EF7\u5355
npi.0=NPI\u9879\u76EE
npi.1=\u521B\u5EFANPI
npi.2=\u9009\u4E2D\u6587\u4EF6\u5939\u521B\u5EFANPI
npi.3=\u521B\u5EFA\u5BA2\u6237\u56FE\u7EB8
npi.4=\u4E0A\u4F20\u5BA2\u6237\u56FE\u7EB8
mar.0=\u521B\u5EFA\u7269\u6599
mar.1=\u4EA7\u6210\u54C1
mar.2=\u534A\u6210\u54C1
mar.3=\u6750\u6599
gy.0=\u5DE5\u827A\u7BA1\u7406
gy.1=Process Routing Library
gy.2=Operation Library
gy.3=Create Routing
gy.4=Create Operation
cg.0=\u53D8\u66F4\u7BA1\u7406
cg.1=Create ECR
cg.2=Create ECO
tech.0=\u521B\u5EFA\u6280\u672F\u6587\u4EF6
tech.1=Create Internal Drawing
tech.2=Create Process Control
tech.3=Create Redline Drawing
tech.4=Create RawMaterial Drawing
tech.5=Create Sub-Parts Drawing
tech.6=Create Setup Sheet
tech.7=Create Rework Work Instruction
tech.8=Create CNC file
tech.9=Create Process Drawing
tech.10=Create Pre-Mill Drawing
tech.11=Create Jig & Fixture Drawing
tech.12=Create Tooling List
tech.13=Create Standard Work Instruction
tech.14=Create In-Process Inspection Plan
tech.15=Upload Documents
tech.16=Batch Approval Of Tec-Documents
BOMgy.0=BOM\u5DE5\u827A\u6279\u91CF\u5BA1\u6279
batchDownload.0=Batch Download Files
plugin.1=\u8BBE\u8BA1\u7BA1\u7406
toBom.1=DBOM\u8F6CEBOM

@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="startTest"
name="start hello teamcenter"
point="org.eclipse.ui.startup">
<startup class="com.connor.ferrorTech.metal.share.start"/>
</extension>
<extension point="org.eclipse.ui.commands">
<category name="Double Category" id="com.connor.ferrorTech.metal.commands.category">
</category>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建客户档案 " id="com.connor.ferrorTech.metal.quotationManagher.createClientFile">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建报价项目" id="com.connor.ferrorTech.metal.quotationManagher.createQuotationProject">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建报价图纸" id="com.connor.ferrorTech.metal.quotationManagher.createQuotationDrawings">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="上传报价图纸" id="com.connor.ferrorTech.metal.quotationManagher.uploadQuotationDrawings">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建技术报价单" id="com.connor.ferrorTech.metal.quotationManagher.createTechnicalQuotation">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建对外报价单" id="com.connor.ferrorTech.metal.quotationManagher.CreateExternalQuotation">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建NPI项目" id="com.connor.ferrorTech.metal.NPIproject.createNPIproject">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建客户图纸" id="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="上传客户图纸" id="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="产成品" id="com.connor.ferrorTech.metal.material.finishedProducts">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="半成品" id="com.connor.ferrorTech.metal.material.semiFinishedProducts">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="材料" id="com.connor.ferrorTech.metal.material.material">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="分类库调用工艺" id="com.connor.ferrorTech.metal.processManagement.callCraft">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="分类库调用工序" id="com.connor.ferrorTech.metal.processManagement.callProcesses">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建工艺" id="com.connor.ferrorTech.metal.processManagement.createCraft">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建工序" id="com.connor.ferrorTech.metal.processManagement.createProcesses">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create ECR" id="com.connor.ferrorTech.metal.changeManagement.createECR">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create ECO" id="com.connor.ferrorTech.metal.changeManagement.createECO">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Internal Drawing" id="com.connor.ferrorTech.metal.createTechnicalDocuments.internalDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Process Control" id="com.connor.ferrorTech.metal.createTechnicalDocuments.processControl">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Redline Drawing" id="com.connor.ferrorTech.metal.createTechnicalDocuments.redlineDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create RawMaterial Drawing" id="com.connor.ferrorTech.metal.createTechnicalDocuments.rawMaterialDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Sub-Parts Drawing" id="com.connor.ferrorTech.metal.createTechnicalDocuments.subPartsDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Setup Sheet" id="com.connor.ferrorTech.metal.createTechnicalDocuments.setupSheet">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Rework Work Instruction" id="com.connor.ferrorTech.metal.createTechnicalDocuments.reworkWorkInstruction">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create NC File" id="com.connor.ferrorTech.metal.createTechnicalDocuments.nCFile">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Process Drawing" id="com.connor.ferrorTech.metal.createTechnicalDocuments.processDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Pre-Mill Drawing" id="com.connor.ferrorTech.metal.createTechnicalDocuments.preMillDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Jit-Fixture Drawing" id="com.connor.ferrorTech.metal.createTechnicalDocuments.jitFixtureDrawing">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Tooling List" id="com.connor.ferrorTech.metal.createTechnicalDocuments.toolingList">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Create Standard Work Instruction" id="com.connor.ferrorTech.metal.createTechnicalDocuments.standardWorkInstruction">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Upload Documents" id="com.connor.ferrorTech.metal.createTechnicalDocuments.uploadDocuments">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Batch Approval Of Tec-Documents" id="com.connor.ferrorTech.metal.createTechnicalDocuments.batchApproval">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="BOM工艺批量审批" id="com.connor.ferrorTech.metal.approvalOfBom">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="Batch Download Files" id="com.connor.ferrorTech.metal.downloadFiles">
</command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%vf.3" id="com.connor.ferrorTech.metal.importMaterial">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler class="com.connor.ferrorTech.metal.quotationManagement.createClientFile.CreateClientFileHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createClientFile">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.createQuotationProject.CreateQuotationProjectHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationProject">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings.CreateQuotationDrawingsHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationDrawings">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.uploadQuotationDrawings">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation.CreateTechnicalHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.createTechnicalQuotation">
</handler>
<handler class="com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate.CreateExternalQuotationHandler" commandId="com.connor.ferrorTech.metal.quotationManagher.CreateExternalQuotation">
</handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.CreateNPIprojectHandler" commandId="com.connor.ferrorTech.metal.NPIproject.createNPIproject">
</handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate.CreateClientDrawingHandler" commandId="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload.UploadClientDrawingHandler" commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.material.finishedProducts.FinishedProductsCreateHandler" commandId="com.connor.ferrorTech.metal.material.finishedProducts">
</handler>
<handler class="com.connor.ferrorTech.metal.material.semiFinishedProducts.SemiFinishedProductsCreateHandler" commandId="com.connor.ferrorTech.metal.material.semiFinishedProducts">
</handler>
<handler class="com.connor.ferrorTech.metal.material.material.MaterialCreateHandler" commandId="com.connor.ferrorTech.metal.material.material">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.classificationCraft.ClassificationCraftHandler" commandId="com.connor.ferrorTech.metal.processManagement.callCraft">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.classificationProcesses.ClassificationProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.callProcesses">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.createCraft.CreateCraftHandler" commandId="com.connor.ferrorTech.metal.processManagement.createCraft">
</handler>
<handler class="com.connor.ferrorTech.metal.processManagement.createProcesses.CreateProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.createProcesses">
</handler>
<handler class="com.connor.ferrorTech.metal.changeManagement.createECR.ChangeApplyFormCreateHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createECR">
</handler>
<handler class="com.connor.ferrorTech.metal.changeManagement.createECO.ChangeNoticeFormCreateHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createECO">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.AinternalDrawing.CreateInternalDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.internalDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.BprocessControl.CreateProcessControlHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processControl">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing.CreateRedlineDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.redlineDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing.CreateRawMaterialDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.rawMaterialDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing.CreateSubPartsDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.subPartsDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.FsetupSheet.CreateSetupSheetHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.setupSheet">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction.CreateReworkInstructionHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.reworkWorkInstruction">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.HncFile.CreateNcFileHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.nCFile">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.IprocessDrawing.CreateProcessDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.JpreMillDrawing.CreatePreMillDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.preMillDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing.CreateJitFixtureHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.jitFixtureDrawing">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.toolingList">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.LstandardInstruction.CreateStandardInstructionHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.standardWorkInstruction">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments.UploadDocumentsHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.uploadDocuments">
</handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments.ApprovalofDocumentsHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.batchApproval">
</handler>
<handler class="com.connor.ferrorTech.metal.bomProcess.ApprovalOfBomProcessHandler" commandId="com.connor.ferrorTech.metal.approvalOfBom">
</handler>
<handler class="com.connor.ferrorTech.metal.batchDownload.BatchDownloadHandler" commandId="com.connor.ferrorTech.metal.downloadFiles">
</handler>
<handler class="com.connor.ferrorTech.metal.importMaterial.ImportMaterialHandler" commandId="com.connor.ferrorTech.metal.importMaterial">
</handler>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu label="大和金属PLM" mnemonic="M" id="com.connor.ferrorTech.metal.menus.plmMenu.metal">
<menu label="报价管理" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.quoteManager">
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createClientFile" id="com.connor.ferrorTech.metal.menus.quotation.client" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationProject" id="com.connor.ferrorTech.metal.menus.quotation.project" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createQuotationDrawings" id="com.connor.ferrorTech.metal.menus.quotation.drawings" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.uploadQuotationDrawings" id="com.connor.ferrorTech.metal.menus.quotation.upload" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.createTechnicalQuotation" id="com.connor.ferrorTech.metal.menus.quotation.technical" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.quotationManagher.CreateExternalQuotation" id="com.connor.ferrorTech.metal.menus.quotation.external" mnemonic="S">
</command>
</menu>
<menu label="NPI项目" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.npiProject">
<command commandId="com.connor.ferrorTech.metal.NPIproject.createNPIproject" id="com.connor.ferrorTech.metal.menus.npiProject.createNpi" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing" id="com.connor.ferrorTech.metal.menus.npiProject.createCustomerDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing" id="com.connor.ferrorTech.metal.menus.npiProject.uploadCustomerDrawing" mnemonic="S">
</command>
</menu>
<menu label="创建物料" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.createMaterial">
<command commandId="com.connor.ferrorTech.metal.material.finishedProducts" id="com.connor.ferrorTech.metal.menus.npiProject.finishedProducts" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.material.semiFinishedProducts" id="com.connor.ferrorTech.metal.menus.npiProject.semiFinishedProducts" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.material.material" id="com.connor.ferrorTech.metal.menus.npiProject.material" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.importMaterial" id="com.connor.ferrorTech.metal.menus.importMaterial" mnemonic="S">
</command>
</menu>
<menu label="工艺管理" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.processManagement">
<command commandId="com.connor.ferrorTech.metal.processManagement.callCraft" id="com.connor.ferrorTech.metal.menus.processManagement.callCraft" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.processManagement.callProcesses" id="com.connor.ferrorTech.metal.menus.processManagement.callProcesses" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.processManagement.createCraft" id="com.connor.ferrorTech.metal.menus.processManagement.createCraft" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.processManagement.createProcesses" id="com.connor.ferrorTech.metal.menus.processManagement.createProcesses" mnemonic="S">
</command>
</menu>
<menu label="变更管理" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.changeManagement">
<command commandId="com.connor.ferrorTech.metal.changeManagement.createECR" id="com.connor.ferrorTech.metal.menus.metal.changeManagement.createECR" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.changeManagement.createECO" id="com.connor.ferrorTech.metal.menus.metal.changeManagement.createECO" mnemonic="S">
</command>
</menu>
<menu label="创建技术文件" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.createTechnicalDocuments">
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.internalDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.internalDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processControl" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.processControl" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.redlineDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.redlineDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.rawMaterialDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.rawMaterialDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.subPartsDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.subPartsDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.setupSheet" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.setupSheet" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.reworkWorkInstruction" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.reworkWorkInstruction" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.nCFile" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.nCFile" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.processDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.processDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.preMillDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.preMillDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.jitFixtureDrawing" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.jitFixtureDrawing" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.toolingList" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.toolingList" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.standardWorkInstruction" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.standardWorkInstruction" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.uploadDocuments" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.uploadDocuments" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.batchApproval" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.batchApproval" mnemonic="S">
</command>
</menu>
<command commandId="com.connor.ferrorTech.metal.approvalOfBom" id="com.connor.ferrorTech.metal.menus.approvalOfBom" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.downloadFiles" id="com.connor.ferrorTech.metal.menus.downloadFiles" mnemonic="S">
</command>
</menu>
</menuContribution>
</extension>
</plugin>

@ -0,0 +1,90 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
import java.awt.Frame;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateNPIprojectAction extends AbstractAIFAction {
private AbstractAIFApplication application;
private JLabel[] inputLabels;
private JComponent[] inputFields;
private String[] columnNames;
private Object[][] data;
public CreateNPIprojectAction(AbstractAIFApplication application, Frame frame, String param) {
super(application, frame, param);
this.application = application;
}
@Override
public void run() {
boolean flag = false;
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
TCComponentFolder targetRev = (TCComponentFolder) selectComponent;
System.out.println("选中对象版本类型为: " + targetRev.getType());
if (targetRev.getType().equals("Folder")) {
flag = true;
} else {
MessageBox.post("Please select the Folder", "Error", MessageBox.ERROR);
return;
}
}
else {
MessageBox.post("Please select Item Revision", "Error", MessageBox.ERROR);
return;
}
if(flag) {
inputLabels = new JLabel[]{
new JLabel("NPI Project Name"), new JLabel("Order date"), new JLabel("Special requirements")};
inputFields = new JComponent[]{
new JTextField(14), createDatePicker(), new JTextField(14)
};
// 表格列标题
columnNames = new String[]{"Serial", "Customer PN", "Product Name", "Rev", "Date of Issuance", "Num", "BOM Deadline", "Drawings Deadline", "Tec BOM Deadline", "Tec Drawings Deadline","Remarks"};
// 表格数据
data = new Object[][]{};
CreateNPIprojectDialog dialog;
dialog = new CreateNPIprojectDialog(this.application,inputLabels,inputFields,null,columnNames,data,false);
new Thread(dialog).start();
}
}
private JXDatePicker createDatePicker() {
// 创建 JXDatePicker
JXDatePicker datePicker = new JXDatePicker();
// 设置日期格式
datePicker.setFormats(new java.text.SimpleDateFormat("yyyy-MM-dd"));
return datePicker;
}
}

@ -0,0 +1,691 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JComboBox;
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.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.jdesktop.swingx.JXDatePicker;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel.ExcelRowData;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel.ReadExcelData;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.DatePickerEditor;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.FormData;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.RowData;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.teamcenter.rac.aif.AbstractAIFApplication;
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.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateNPIprojectDialog extends JFrame implements Runnable {
private final String TABLE_TITLE = "Drawing Task Book Table";
private final String JFRAME_TITLE = "Create NPI Project";
private final String PREFERENCE_EXCEL_GETUID = "VF5CTRWS";
private final String TARGET_REV_XJXXD_GX = "VF5xjxxdgx";
private JFrame frame;
private JTable table;
private JLabel[] inputLalels;
private JComponent[] inputFields;
private Map<String, Map<String, String>> lovMap;
private JButton okButton;
private JButton celButton;
private JButton importButton;
private JButton exportButton;
private JButton addButton;
private JButton deleteButton;
private JButton moveUpButton;
private JButton moveDownButton;
private String[] columnNames;
private Object[][] data;
private boolean isFolder;
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentFolder targetFolder;
public CreateNPIprojectDialog(AbstractAIFApplication application, Object... params) {
this.application = application;
this.inputLalels = (JLabel[]) params[0];
this.inputFields = (JComponent[]) params[1];
this.lovMap = (Map<String, Map<String, String>>) params[2];
this.columnNames = (String[]) params[3];
this.data = (Object[][]) params[4];
this.isFolder = (boolean) params[5];
this.tcSession = (TCSession) application.getSession();
}
@Override
public void run() {
// TODO Auto-generated method stub
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
targetFolder = (TCComponentFolder) selectComponent;
}
initUI();
}
private void initUI() {
try {
frame = new JFrame(JFRAME_TITLE);
frame.setSize(850, 550);
// 初始化所有信息
setPanelProperties();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getTopPanel();
JPanel bottomPanel = getButtomPanel();
// 创建表格和滚动条
JPanel tableScrollPane = createTable();
tableScrollPane.setPreferredSize(new Dimension(700, 200)); // 设置滚动条的大小
frame.getContentPane().add(centerPanel, BorderLayout.NORTH);
frame.getContentPane().add(tableScrollPane, BorderLayout.CENTER);
frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
// 设置窗口居中
frame.setLocationRelativeTo(null);
// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// 设置可见性
frame.setVisible(true);
} catch (TCException e) {
// TODO: handle exception
e.printStackTrace();
}
}
/**
*
*
* @throws TCException
*/
private void setPanelProperties() throws TCException {
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
importButton = new JButton(ConstantPool.EN_BUTTON_IMPORT);
exportButton = new JButton(ConstantPool.EN_BUTTON_EXPORT);
addButton = new JButton(ConstantPool.EN_BUTTON_ADD);
deleteButton = new JButton(ConstantPool.EN_BUTTON_DELETE);
moveUpButton = new JButton(ConstantPool.EN_BUTTON_MOVE_UP);
moveDownButton = new JButton(ConstantPool.EN_BUTTON_MOVE_DOWN);
}
private JScrollPane getTopPanel() {
// 创建一个使用 GridBagLayout 布局管理器的 JPanel
JPanel centerPanel = new JPanel(new GridBagLayout());
// 创建一个 GridBagConstraints 对象,用于设置组件的布局约束
GridBagConstraints c = new GridBagConstraints();
if (inputLalels.length != inputFields.length) {
throw new IllegalArgumentException("inputLalels and inputFields must have the same length");
}
Font defaultFont = new Font("微软雅黑", Font.BOLD, 13);
for (int i = 0; i < inputLalels.length; i++) {
int count = (i % 2 == 0) ? 0 : 2;
if (i == inputLalels.length - 1) {
c.insets = new Insets(5, 15, 15, 5);
} else {
c.insets = new Insets(10, 15, 5, 5);
}
c.gridx = count;
c.weightx = 0;
c.anchor = GridBagConstraints.LINE_START;
inputLalels[i].setFont(defaultFont);
centerPanel.add(inputLalels[i], c);
if (i == inputLalels.length - 1) {
c.gridx = 1;
c.gridwidth = 3;
c.weightx = 1;
} else {
c.weightx = 1;
c.gridwidth = 1;
c.gridx = count + 1;
}
c.fill = GridBagConstraints.HORIZONTAL;
inputFields[i].setFont(defaultFont);
if (inputFields[i] instanceof JTextField) {
((JTextField) inputFields[i]).setPreferredSize(new Dimension(200, 27));
}
centerPanel.add(inputFields[i], c);
}
return new JScrollPane(centerPanel);
}
public JPanel getButtomPanel() {
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
// 添加监听
okButton.addActionListener(e -> {
String[] valueList = getFormData();
int length = 0;
FormData formData = new FormData(valueList[length++], valueList[length++], valueList[length++]);
List<RowData> tableData = getTableData();
CreateNPIprojectOperation createNPIprojectOperation = new CreateNPIprojectOperation(application,
targetFolder, formData, tableData);
this.application.getSession().queueExcludedOperation(createNPIprojectOperation);
frame.dispose();
});
celButton.addActionListener(e -> {
frame.dispose();
});
bottomPanel.add(okButton);
bottomPanel.add(celButton);
return bottomPanel;
}
public JPanel createTable() {
JPanel panel = new JPanel(new BorderLayout(10, 10));
panel.setBorder(new EmptyBorder(10, 10, 10, 10));
JLabel titleLabel = new JLabel(TABLE_TITLE);
titleLabel.setFont(new Font("Serif", Font.BOLD, 13));
panel.add(titleLabel, BorderLayout.NORTH);
DefaultTableModel model = new DefaultTableModel(data, columnNames);
table = new JTable(model);
table.setRowHeight(30);
table.getTableHeader().setReorderingAllowed(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
// table.setFillsViewportHeight(true);
TableColumnModel columnModel = table.getColumnModel();
columnModel.getColumn(0).setPreferredWidth(50);
for (int i = 1; i < columnModel.getColumnCount(); i++) {
columnModel.getColumn(i).setPreferredWidth(120);
}
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER);
return c;
}
};
for (int i = 0; i < columnModel.getColumnCount(); i++) {
columnModel.getColumn(i).setCellRenderer(centerRenderer);
}
TableCellRenderer dateRenderer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
int column) -> {
JXDatePicker datePicker = new JXDatePicker();
if (value instanceof Date) {
datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
datePicker.setDate((Date) value);
}
return datePicker;
};
TableCellEditor dateEditor = new DatePickerEditor();
int[] dateIndex = new int[] { 4, 6, 7, 8, 9 };
for (int index : dateIndex) {
table.getColumnModel().getColumn(index).setCellRenderer(dateRenderer);
table.getColumnModel().getColumn(index).setCellEditor(dateEditor);
}
JPanel buttonPanel = createTableButton();
JScrollPane scrollPane = new JScrollPane(table);
// scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
panel.add(scrollPane, BorderLayout.CENTER);
panel.add(buttonPanel, BorderLayout.SOUTH);
return panel;
}
public JPanel createTableButton() {
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
buttonPanel.add(importButton);
buttonPanel.add(exportButton);
buttonPanel.add(addButton);
buttonPanel.add(deleteButton);
buttonPanel.add(moveUpButton);
buttonPanel.add(moveDownButton);
importButton.addActionListener(e -> {
createDialog(ConstantPool.EN_TITLE_IMPORT_PATH, ConstantPool.EN_LABEL_UPLOAD_PATH, "import");
System.out.println("本地导入按钮被点击");
});
exportButton.addActionListener(e -> {
createDialog(ConstantPool.EN_TITLE_EXPORT_PATH, ConstantPool.EN_LABEL_UPLOAD_PATH, "export");
System.out.println("本地导出按钮被点击");
});
addButton.addActionListener(e -> {
DefaultTableModel model = (DefaultTableModel) table.getModel();
Object[] newRow = new Object[model.getColumnCount()];
for (int i = 0; i < newRow.length; i++) {
newRow[i] = "";
}
newRow[0] = model.getRowCount() + 1;
model.addRow(newRow);
table.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1);
System.out.println("添加行按钮被点击");
});
deleteButton.addActionListener(e -> {
int[] selectedRows = table.getSelectedRows();
if (selectedRows.length > 0) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
for (int i = selectedRows.length - 1; i >= 0; i--) {
model.removeRow(selectedRows[i]);
}
for (int i = 0; i < model.getRowCount(); i++) {
model.setValueAt(i + 1, i, 0);
}
if (model.getRowCount() > 0) {
int newSelectedRow = Math.min(selectedRows[0], model.getRowCount() - 1);
table.setRowSelectionInterval(newSelectedRow, newSelectedRow);
} else {
table.clearSelection();
}
} else {
JOptionPane.showMessageDialog(table, ConstantPool.EN_MESSAGE_DELETE);
}
System.out.println("删除行按钮被点击");
});
moveUpButton.addActionListener(e -> {
int selectedRow = table.getSelectedRow();
if (selectedRow > 0) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
Object[] row = new Object[model.getColumnCount()];
for (int i = 0; i < model.getColumnCount(); i++) {
row[i] = model.getValueAt(selectedRow, i);
}
int tempIndex = Integer.parseInt(row[0].toString());
row[0] = model.getValueAt(selectedRow - 1, 0);
model.setValueAt(tempIndex, selectedRow - 1, 0);
model.removeRow(selectedRow);
model.insertRow(selectedRow - 1, row);
table.setRowSelectionInterval(selectedRow - 1, selectedRow - 1);
} else {
JOptionPane.showMessageDialog(table, ConstantPool.EN_MESSAGE_MOVE_UP);
}
System.out.println("上移按钮被点击");
});
moveDownButton.addActionListener(e -> {
int selectedRow = table.getSelectedRow();
if (selectedRow >= 0 && selectedRow < table.getRowCount() - 1) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
Object[] row = new Object[model.getColumnCount()];
for (int i = 0; i < model.getColumnCount(); i++) {
row[i] = model.getValueAt(selectedRow, i);
}
int tempIndex = Integer.parseInt(row[0].toString());
row[0] = model.getValueAt(selectedRow + 1, 0);
model.setValueAt(tempIndex, selectedRow + 1, 0);
model.removeRow(selectedRow);
model.insertRow(selectedRow + 1, row);
table.setRowSelectionInterval(selectedRow + 1, selectedRow + 1);
} else {
JOptionPane.showMessageDialog(table, ConstantPool.EN_MESSAGE_MOVE_DOWN);
}
System.out.println("下移按钮被点击");
});
return buttonPanel;
}
public void createDialog(String title, String labelName, String method) {
JDialog dialog = new JDialog((JFrame) SwingUtilities.getWindowAncestor(importButton), title, true);
dialog.setLayout(null);
JLabel label = new JLabel(labelName);
label.setBounds(30, 40, 80, 25);
dialog.add(label);
JTextField pathField = new JTextField(15);
pathField.setBounds(110, 40, 150, 25);
dialog.add(pathField);
JButton selectButton = new JButton(ConstantPool.EN_BUTTON_CHOOSE);
selectButton.setBounds(280, 40, 90, 25);
selectButton.addActionListener(e -> {
JFileChooser fileChooser = new JFileChooser();
FileNameExtensionFilter filter = null;
if (method.equals("import")) {
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
filter = new FileNameExtensionFilter("Excel Files", "xlsx", "xls");
} else if (method.equals("export")) {
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
filter = new FileNameExtensionFilter("CSV Files", "csv");
} else {
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
filter = new FileNameExtensionFilter("CSV Files", "csv");
}
fileChooser.setMultiSelectionEnabled(false);
fileChooser.setFileFilter(filter);
int result = fileChooser.showOpenDialog(dialog);
if (result == JFileChooser.APPROVE_OPTION) {
pathField.setText(fileChooser.getSelectedFile().getAbsolutePath());
}
});
dialog.add(selectButton, BorderLayout.EAST);
JButton localOkButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
// localOkButton.setBounds(80, 70, 100, 25);
localOkButton.setBounds(80, 90, 100, 25);
JButton localCancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
// localCancelButton.setBounds(200, 70, 100, 25);
localCancelButton.setBounds(200, 90, 100, 25);
localOkButton.addActionListener(e -> {
String path = pathField.getText();
if (path.isEmpty()) {
JOptionPane.showMessageDialog(dialog, ConstantPool.EN_MESSAGE_IMPORT);
} else if (method.equals("import")) {
System.out.println(labelName + ":" + path);
// 检查文件扩展名是否为 .xlsx 或 .xls
if (!path.toLowerCase().endsWith(".xlsx") && !path.toLowerCase().endsWith(".xls")) {
JOptionPane.showMessageDialog(dialog, ConstantPool.EN_MESSAGE_EXCEL_ERROR);
} else {
System.out.println(labelName + ":" + path);
importData(path);
dialog.dispose();
}
} else if (method.equals("export")) {
// 检查文件是否为目录
File file = new File(path);
if (!file.isDirectory()) {
JOptionPane.showMessageDialog(dialog, ConstantPool.EN_MESSAGE_FILE_ERROR);
} else {
// 处理导出逻辑
System.out.println(labelName + ":" + path);
exportData(path);
dialog.dispose();
}
}
});
localCancelButton.addActionListener(e -> {
dialog.dispose();
});
dialog.add(localOkButton);
dialog.add(localCancelButton);
// 设置对话框大小和位置
dialog.pack();
dialog.setSize(410, 190);
dialog.setLocationRelativeTo((JFrame) SwingUtilities.getWindowAncestor(importButton));
dialog.setVisible(true);
}
public void importData(String path) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
List<ExcelRowData> excelRowData = ReadExcelData.readExcelFile(path);
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
excelRowData.forEach(rowData -> {
try {
Object[] newRow = new Object[model.getColumnCount()];
int colSno = 0;
newRow[colSno++] = model.getRowCount() + 1;
newRow[colSno++] = rowData.getCustomerPN();
newRow[colSno++] = rowData.getDescription();
newRow[colSno++] = rowData.getRev();
newRow[colSno++] = rowData.getDateOfIssuance().isEmpty() ? ""
: formatter.parse(rowData.getDateOfIssuance());
newRow[colSno++] = rowData.getProductionPIC();
newRow[colSno++] = rowData.getBomDeadline().isEmpty() ? "" : formatter.parse(rowData.getBomDeadline());
newRow[colSno++] = rowData.getDrawingsDeadline().isEmpty() ? ""
: formatter.parse(rowData.getDrawingsDeadline());
newRow[colSno++] = rowData.getTechBomDeadline().isEmpty() ? ""
: formatter.parse(rowData.getTechBomDeadline());
newRow[colSno++] = rowData.getTechDrawingsDeadline().isEmpty() ? ""
: formatter.parse(rowData.getTechDrawingsDeadline());
newRow[colSno] = rowData.getRemarks();
model.addRow(newRow);
} catch (ParseException e) {
throw new RuntimeException(e);
}
});
table.setRowSelectionInterval(model.getRowCount() - 1, model.getRowCount() - 1);
}
public void exportData(String exportPath) {
// exportPath = "C:\Users\Administrator\Desktop";
String excelUid = tcSession.getPreferenceService().getStringValue(PREFERENCE_EXCEL_GETUID);
String templateFilePath = "";
try {
TCComponent comp = tcSession.stringToComponent(excelUid);
if (comp instanceof TCComponentDataset) {
TCComponentDataset dataset = (TCComponentDataset) comp;
String refs = comp.getProperty("ref_names");
String[] ref = refs.split(",");
File file = dataset.getFiles(ref[0], System.getenv("temp"))[0];
templateFilePath = file.getAbsolutePath();
System.out.println("filePath: " + templateFilePath);
exportPath += templateFilePath.substring(templateFilePath.lastIndexOf("\\"));
System.out.println("exportPath: " + exportPath);
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
List<RowData> rowDataList = getTableData();
try (FileInputStream fis = new FileInputStream(templateFilePath); Workbook workbook = new XSSFWorkbook(fis)) {
CellStyle fillStyle = workbook.createCellStyle();
CellStyle centerStyle = workbook.createCellStyle();
org.apache.poi.ss.usermodel.Font font = workbook.createFont();
font.setFontName("Arial");
font.setFontHeightInPoints((short) 12);
fillStyle.setFont(font);
fillStyle.setAlignment(HorizontalAlignment.FILL);
fillStyle.setVerticalAlignment(VerticalAlignment.CENTER);
fillStyle.setWrapText(false);
fillStyle.setBorderTop(BorderStyle.THIN);
fillStyle.setBorderBottom(BorderStyle.THIN);
fillStyle.setBorderLeft(BorderStyle.THIN);
fillStyle.setBorderRight(BorderStyle.THIN);
centerStyle.setFont(font);
centerStyle.setAlignment(HorizontalAlignment.CENTER);
centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
centerStyle.setWrapText(false);
centerStyle.setBorderTop(BorderStyle.THIN);
centerStyle.setBorderBottom(BorderStyle.THIN);
centerStyle.setBorderLeft(BorderStyle.THIN);
centerStyle.setBorderRight(BorderStyle.THIN);
Sheet sheet = workbook.getSheetAt(0);
int startRow = 12;
int rowNum = startRow;
for (RowData rowData : rowDataList) {
int count = 0;
Row row = sheet.createRow(rowNum++);
row.createCell(count++).setCellValue(rowNum - startRow); // 序号
row.createCell(count++).setCellValue(isNull(rowData.getDrawingNumber()));
row.createCell(count++).setCellValue(isNull(rowData.getVersion()));
row.createCell(count++).setCellValue(isNull(rowData.getProductName()));
row.createCell(count++).setCellValue("");
row.createCell(count++)
.setCellValue(transfer(rowData.getIssueDate() != null ? rowData.getIssueDate() : ""));
row.createCell(count++).setCellValue(
transfer(rowData.getMaterialDeliveryTime() != null ? rowData.getMaterialDeliveryTime() : ""));
row.createCell(count++).setCellValue(
transfer(rowData.getDrawingDeliveryTime() != null ? rowData.getDrawingDeliveryTime() : ""));
row.createCell(count++).setCellValue(
transfer(rowData.getMaterialReplyDate() != null ? rowData.getMaterialReplyDate() : ""));
row.createCell(count++).setCellValue(
transfer(rowData.getDrawingReplyDate() != null ? rowData.getDrawingReplyDate() : ""));
row.createCell(count++).setCellValue("");
row.createCell(count++).setCellValue("");
row.createCell(count++).setCellValue(isNull(rowData.getNumber()));
row.createCell(count).setCellValue(isNull(rowData.getNotes()));
for (int colIndex = 0; colIndex <= count; colIndex++) {
Cell cell = row.getCell(colIndex);
if (cell != null) {
if (colIndex == 3) {
cell.setCellStyle(fillStyle);
} else {
cell.setCellStyle(centerStyle);
}
}
}
}
try (FileOutputStream fileOut = new FileOutputStream(exportPath)) {
workbook.write(fileOut);
}
} catch (IOException e) {
System.err.println("Failed to export data:(Template is not exist) " + e.getMessage());
e.printStackTrace();
}
}
public String isNull(String str) {
return str == null || str.isEmpty() ? "" : str;
}
public String transfer(String str) {
if (str == null || str.isEmpty()) {
return "";
}
String[] parts = str.split("[/-]");
String year = parts[0];
String month = parts[1].replaceFirst("^0+", "");
String day = parts[2].replaceFirst("^0+", "");
return year + "/" + month + "/" + day;
}
public String[] getFormData() {
String[] valueList = new String[inputFields.length];
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < inputFields.length; i++) {
if (inputFields[i] instanceof JComboBox) {
valueList[i] = (String) ((JComboBox) inputFields[i]).getSelectedItem();
} else if (inputFields[i] instanceof JXDatePicker) {
Date date = ((JXDatePicker) inputFields[i]).getDate();
if (date != null) {
valueList[i] = simpleDateFormat.format(date);
} else {
valueList[i] = "";
}
} else {
valueList[i] = ((JTextField) inputFields[i]).getText();
}
}
return valueList;
}
public List<RowData> getTableData() {
DefaultTableModel model = (DefaultTableModel) table.getModel();
int rowCount = model.getRowCount();
int columnCount = model.getColumnCount();
List<RowData> data = new ArrayList<RowData>();
for (int row = 0; row < rowCount; row++) {
String[] tempRowData = new String[columnCount];
for (int i = 0; i < columnCount; i++) {
Object obj = model.getValueAt(row, i);
if (obj instanceof Integer) {
tempRowData[i] = (Integer) obj + "";
} else if (obj instanceof Date) {
tempRowData[i] = new SimpleDateFormat("yyyy-MM-dd").format(obj);
} else {
tempRowData[i] = (String) obj;
}
}
int count = 1;
RowData drawingTaskBook = new RowData(tempRowData[count++], tempRowData[count++], tempRowData[count++],
tempRowData[count++], tempRowData[count++], tempRowData[count++], tempRowData[count++],
tempRowData[count++], tempRowData[count++], tempRowData[count++]);
data.add(drawingTaskBook);
}
return data;
}
}

@ -0,0 +1,23 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateNPIprojectHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateNPIprojectAction action = new CreateNPIprojectAction(application, null, null);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,326 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.CountFolder;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.FormData;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity.RowData;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.teamcenter.rac.common.create.BOCreateDefinitionFactory;
import com.teamcenter.rac.common.create.CreateInstanceInput;
import com.teamcenter.rac.common.create.IBOCreateDefinition;
import com.teamcenter.rac.common.create.SOAGenericCreateHelper;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentFolderType;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.services.rac.core.DataManagementService;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn;
import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse;
public class CreateNPIprojectOperation extends AbstractAIFOperation {
private final String PREFERENCES_FILE_FOLDER = "VF5NPI";
private final String PREFERENCES_FILE_FOLDER_CHILD = "VF5NPIChildFolder";
private final String FOLDER_TYPE_NORMAL = "Folder";
private final String FOLDER_TYPE_NPI = "VF5NPI";
private final String ITEM_TYPE_TASK_BOOK = "VF5ctrws";
private AbstractAIFApplication application;
private TCSession tcSession;
public FormData formData;
public List<RowData> tableData;
private TCComponentFolderType folderType;
private TCComponentFolderType npiType;
private TCComponentItemType taskType;
private TCComponentFolder originFolder;
private TCComponentFolder tagFolder;
public CreateNPIprojectOperation(AbstractAIFApplication application, TCComponentFolder targetFolder, FormData lists,
List<RowData> tableData) {
this.application = application;
this.formData = lists;
this.tableData = tableData;
this.tcSession = (TCSession) application.getSession();
this.tagFolder = targetFolder;
try {
folderType = (TCComponentFolderType) tcSession.getTypeComponent(FOLDER_TYPE_NORMAL);
npiType = (TCComponentFolderType) tcSession.getTypeComponent(FOLDER_TYPE_NPI);
// tableRowType = (TCComponentItemType) this.tcSession.getTypeComponent("VF5ctrwsrow");
taskType = (TCComponentItemType) this.tcSession.getTypeComponent(ITEM_TYPE_TASK_BOOK);
TCPreferenceService getFolderUID = tcSession.getPreferenceService();
String value = getFolderUID.getStringValue(PREFERENCES_FILE_FOLDER);
if(value == null || value.isEmpty()) {
MessageBox.post("Preferred VF5NPI not configured", "Error", MessageBox.ERROR);
}
System.out.println("文件夹UID: " + value);
originFolder = (TCComponentFolder) tcSession.stringToComponent(value);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void executeOperation() throws Exception {
System.out.println(formData.toString());
// tableData.stream().forEach(e -> {
// System.out.println(e.toString());
// });
String[] filePath = DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDateTime.now()).split("-");
CountFolder existFolder = isExistFolder(originFolder, filePath, 0);
TCComponentFolder targetFolder = createFolder(existFolder.getFolder(), filePath, existFolder.getCount());
boolean existNpiFolder = isExistNpiFolder(targetFolder, formData.getProjectName());
if (!existNpiFolder) {
MessageBox.post("NPI Already Exists", "Error", MessageBox.ERROR);
return;
}
TCComponentFolder npiFolder = creatNpiChildFolder(targetFolder);
tagFolder.add("contents", npiFolder);
TCComponentItemRevision taskBookRev = setNpiFolderProp(npiFolder);
if (taskBookRev == null) {
System.out.println("NPI Folder is empty!");
} else {
System.out.println("succeed to set property!");
}
TCComponent taskBookMaster = taskBookRev.getRelatedComponent("IMAN_master_form_rev");
String[] propName = { "vf5khth", "vf5cpmc", "vf5khtzbb", "vf5qfrq", "vf5sl", "vf5clqdnq", "vf5ctnq",
"vf5clqdnq2", "vf5ctnq2", "vf5beizhu" };
String rowType = "VF5ctrwsrow";
String tableType = "vf5cpxxTable";
System.out.println("begin set table value");
assignmentTable(tableData, taskBookMaster, propName, rowType, tableType);
System.out.println("after set table value");
}
private boolean isExistNpiFolder(TCComponentFolder targetFolder, String checkName) throws TCException {
// TODO Auto-generated method stub
TCComponent[] childFolder = targetFolder.getTCProperty("contents").getReferenceValueArray();
if (childFolder != null && childFolder.length > 0) {
for (int i = 0; i < childFolder.length; i++) {
if (childFolder[i].getStringProperty("object_name").equals(checkName)) {
return false;
}
}
} else {
return true;
}
return true;
}
public void assignmentTable(List<RowData> data, TCComponent item, String[] propNames, String boName, String prop) {
try {
List<TCComponent> c = new ArrayList<TCComponent>();
DataManagementService service = DataManagementService.getService(tcSession);
CreateIn[] newIn = new CreateIn[data.size()];
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < data.size(); ++i) {
RowData rowData = data.get(i);
CreateIn in = new CreateIn();
Map<String, Calendar> dataPropMap = new HashMap<>();
Map<String, String> stringPropMap = new HashMap<>();
int count = 0;
stringPropMap.put(propNames[count++], rowData.getDrawingNumber());
stringPropMap.put(propNames[count++], rowData.getProductName());
stringPropMap.put(propNames[count++], rowData.getVersion());
transferCalendar(simpleDateFormat, rowData.getIssueDate(), dataPropMap, propNames, count);
count++;
stringPropMap.put(propNames[count++], rowData.getNumber());
transferCalendar(simpleDateFormat, rowData.getMaterialDeliveryTime(), dataPropMap, propNames, count);
count++;
transferCalendar(simpleDateFormat, rowData.getDrawingDeliveryTime(), dataPropMap, propNames, count);
count++;
transferCalendar(simpleDateFormat, rowData.getMaterialReplyDate(), dataPropMap, propNames, count);
count++;
transferCalendar(simpleDateFormat, rowData.getDrawingReplyDate(), dataPropMap, propNames, count);
count++;
stringPropMap.put(propNames[count++], rowData.getNotes());
in.data.boName = boName;
in.data.dateProps = dataPropMap;
in.data.stringProps = stringPropMap;
newIn[i] = in;
}
System.out.println("要创建的数量" + newIn.length);
CreateResponse response = service.createObjects(newIn);
System.out.println("创建数量:" + response.serviceData.sizeOfCreatedObjects());
System.out.println("错误数量:" + response.serviceData.sizeOfPartialErrors());
for (int i = 0; i < response.serviceData.sizeOfPartialErrors(); i++) {
for (int j = 0; j < response.serviceData.getPartialError(i).getErrorValues().length; j++) {
System.out
.println("错误:" + response.serviceData.getPartialError(i).getErrorValues()[j].getMessage());
}
}
if (response.serviceData.sizeOfCreatedObjects() > 0) {
int length = response.serviceData.sizeOfCreatedObjects();
for (int i = 0; i < length; ++i) {
c.add(response.output[i].objects[0]);
}
}
item.getTCProperty(prop).setReferenceValueArray((TCComponent[]) c.toArray(new TCComponent[c.size()]));
} catch (Exception e) {
e.printStackTrace();
}
}
public void transferCalendar(SimpleDateFormat simpleDateFormat, String time, Map<String, Calendar> dataPropMap,
String[] propNames, int count) {
try {
if (time != null && time.isEmpty()) {
return;
}
Date date = simpleDateFormat.parse(time);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
dataPropMap.put(propNames[count], calendar);
} catch (ParseException e) {
e.printStackTrace();
}
}
public CountFolder isExistFolder(TCComponentFolder parentFolder, String[] filePath, int targetFileCount)
throws TCException {
TCComponent[] folderArrays = parentFolder.getTCProperty("contents").getReferenceValueArray();
for (TCComponent tcComponent : folderArrays) {
if (tcComponent.getType().equals("Folder")
&& tcComponent.getStringProperty("object_name").equals(filePath[targetFileCount])) {
parentFolder = (TCComponentFolder) tcComponent;
return isExistFolder(parentFolder, filePath, targetFileCount + 1);
}
}
return new CountFolder(parentFolder, targetFileCount);
}
public TCComponentFolder createFolder(TCComponentFolder parentFolder, String[] filePath, int targetFileCount)
throws TCException {
System.out.println("targetFolder: " + parentFolder.getStringProperty("object_name"));
for (int i = targetFileCount; i < filePath.length; i++) {
TCComponentFolder folder = folderType.create(filePath[i], "", "Folder");
parentFolder.add("contents", folder);
parentFolder = folder;
}
return parentFolder;
}
public TCComponentFolder creatNpiChildFolder(TCComponentFolder targetFolder) {
if (targetFolder != null) {
TCPreferenceService folderStyle = tcSession.getPreferenceService();
try {
System.out.println("创建NPI文件夹之前");
TCComponentFolder npiFolder = soaCreateFolder(formData.getProjectName(), FOLDER_TYPE_NPI);
System.out.println("npiFolder = " + npiFolder.toString());
targetFolder.add("contents", npiFolder);
targetFolder = npiFolder;
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("create npiFolder error !");
e.printStackTrace();
}
String[] npiChildPath = folderStyle.getStringValues(PREFERENCES_FILE_FOLDER_CHILD);
for (String childPath : npiChildPath) {
TCComponentFolder tempFolder = targetFolder;
String[] folderName = childPath.split("/");
for (String childFolderName : folderName) {
try {
TCComponentFolder childFolder = folderType.create(childFolderName, "", FOLDER_TYPE_NORMAL);
tempFolder.add("contents", childFolder);
tempFolder = childFolder;
} catch (TCException e) {
System.out.println("create inner folder error !");
e.printStackTrace();
}
}
}
return targetFolder;
} else {
System.out.println("creatNpiChildFolder method() : targetFolder is null");
return null;
}
}
public TCComponentItemRevision setNpiFolderProp(TCComponentFolder npiFolder) {
if (npiFolder != null) {
try {
System.out.println("设置出图任务书属性");
String orderDate = formData.getOrderDate();
if (orderDate != null && orderDate.length() > 2) {
npiFolder.setDateProperty("vf5ddrq", new SimpleDateFormat("yyyy-MM-dd").parse(orderDate));
}
npiFolder.setStringProperty("vf5tsyq", checkNull(formData.getSpecialRequirements()));
TCComponentItem taskBookItem = taskType.create(taskType.getNewID(), null, ITEM_TYPE_TASK_BOOK,
formData.getProjectName(), "", null);
TCComponentItemRevision taskBookRev = taskBookItem.getLatestItemRevision();
npiFolder.add("contents", taskBookItem);
return taskBookRev;
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("fail to add tagRev !");
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
System.out.println("method setNpiFolderProp() npiFoder is null");
}
return null;
}
public String checkNull(String propValue) {
return propValue != null ? propValue : "";
}
public TCComponentFolder soaCreateFolder(String name, String type) {
System.out.println("创建文件夹" + name);
TCComponentFolder folder = null;
try {
IBOCreateDefinition ibocreatedefinition = BOCreateDefinitionFactory.getInstance()
.getCreateDefinition(tcSession, type);
CreateInstanceInput cii = new CreateInstanceInput(ibocreatedefinition);
List list = new ArrayList();
list.add(cii);
List list1 = SOAGenericCreateHelper.create(tcSession, ibocreatedefinition, list);
if (list1 != null && list1.size() > 0) {
TCComponent tccomponent = (TCComponent) list1.get(0);
folder = (TCComponentFolder) tccomponent;
folder.setProperty("object_name", name);
}
} catch (TCException e) {
e.printStackTrace();
}
return folder;
}
}

@ -0,0 +1,159 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel;
public class ExcelRowData {
private String customerPN;
private String rev;
private String description;
private String customer;
private String dateOfIssuance;
private String bomDeadline;
private String drawingsDeadline;
private String techBomDeadline;
private String techDrawingsDeadline;
private String finalBomDeadline;
private String finalDrawingsDeadline;
private String productionPIC;
private String remarks;
public ExcelRowData(String... params) {
int count =0;
this.customerPN = params[count++];
this.rev = params[count++];
this.description = params[count++];
this.customer = params[count++];
this.dateOfIssuance = params[count++];
this.bomDeadline = params[count++];
this.drawingsDeadline = params[count++];
this.techBomDeadline = params[count++];
this.techDrawingsDeadline = params[count++];
this.finalBomDeadline = params[count++];
this.finalDrawingsDeadline = params[count++];
this.productionPIC = params[count++];
this.remarks = params[count];
}
public String getCustomerPN() {
return customerPN;
}
public void setCustomerPN(String customerPN) {
this.customerPN = customerPN;
}
public String getRev() {
return rev;
}
public void setRev(String rev) {
this.rev = rev;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCustomer() {
return customer;
}
public void setCustomer(String customer) {
this.customer = customer;
}
public String getDateOfIssuance() {
return dateOfIssuance;
}
public void setDateOfIssuance(String dateOfIssuance) {
this.dateOfIssuance = dateOfIssuance;
}
public String getBomDeadline() {
return bomDeadline;
}
public void setBomDeadline(String bomDeadline) {
this.bomDeadline = bomDeadline;
}
public String getDrawingsDeadline() {
return drawingsDeadline;
}
public void setDrawingsDeadline(String drawingsDeadline) {
this.drawingsDeadline = drawingsDeadline;
}
public String getTechBomDeadline() {
return techBomDeadline;
}
public void setTechBomDeadline(String techBomDeadline) {
this.techBomDeadline = techBomDeadline;
}
public String getTechDrawingsDeadline() {
return techDrawingsDeadline;
}
public void setTechDrawingsDeadline(String techDrawingsDeadline) {
this.techDrawingsDeadline = techDrawingsDeadline;
}
public String getFinalBomDeadline() {
return finalBomDeadline;
}
public void setFinalBomDeadline(String finalBomDeadline) {
this.finalBomDeadline = finalBomDeadline;
}
public String getFinalDrawingsDeadline() {
return finalDrawingsDeadline;
}
public void setFinalDrawingsDeadline(String finalDrawingsDeadline) {
this.finalDrawingsDeadline = finalDrawingsDeadline;
}
public String getProductionPIC() {
return productionPIC;
}
public void setProductionPIC(String productionPIC) {
this.productionPIC = productionPIC;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
@Override
public String toString() {
return "DataObject{" +
"customerPN='" + customerPN + '\'' +
", rev='" + rev + '\'' +
", description='" + description + '\'' +
", customer='" + customer + '\'' +
", dateOfIssuance='" + dateOfIssuance + '\'' +
", bomDeadline='" + bomDeadline + '\'' +
", drawingsDeadline='" + drawingsDeadline + '\'' +
", techBomDeadline='" + techBomDeadline + '\'' +
", techDrawingsDeadline='" + techDrawingsDeadline + '\'' +
", finalBomDeadline='" + finalBomDeadline + '\'' +
", finalDrawingsDeadline='" + finalDrawingsDeadline + '\'' +
", productionPIC='" + productionPIC + '\'' +
", remarks='" + remarks + '\'' +
'}';
}
}

@ -0,0 +1,76 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.teamcenter.rac.util.MessageBox;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class ReadExcelData {
public static List<ExcelRowData> readExcelFile(String filePath) {
List<ExcelRowData> excelData = new ArrayList<>();
try (FileInputStream fis = new FileInputStream(new File(filePath));
Workbook workbook = new XSSFWorkbook(fis)) {
// 获取第一个 sheet
Sheet sheet = workbook.getSheetAt(0);
// 遍历每一行从第13行开始索引从0开始
for (int rowNum = 12; rowNum <= sheet.getLastRowNum(); rowNum++) {
Row row = sheet.getRow(rowNum);
if (row != null && !getCellValue(row.getCell(0)).isEmpty()) { // 检查行是否存在
String[] colValues = new String[row.getLastCellNum()];
for (int colNum = 1; colNum < row.getLastCellNum(); colNum++) {
Cell cell = row.getCell(colNum);
if (cell != null) {
colValues[colNum-1]=(getCellValue(cell));
} else {
colValues[colNum-1]=(""); // 如果单元格为空,添加空字符串
}
}
// System.out.println(Arrays.toString(colValues));
// 将数据封装到 DataObject 对象中
ExcelRowData excelRowData = new ExcelRowData(colValues);
excelData.add(excelRowData);
}
}
} catch (IOException e) {
e.printStackTrace();
}
return excelData;
}
private static String getCellValue(Cell cell) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
DataFormatter dataFormatter = new DataFormatter();
switch (cell.getCellType()) {
case STRING:
return cell.getStringCellValue();
case NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
Date date = cell.getDateCellValue();
return dateFormat.format(date);
} else {
// 使用 DataFormatter 按单元格显示格式获取值
return dataFormatter.formatCellValue(cell);
}
case BOOLEAN:
return String.valueOf(cell.getBooleanCellValue());
case FORMULA:
return cell.getCellFormula();
default:
return "";
}
}
}

@ -0,0 +1,37 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
import com.teamcenter.rac.kernel.TCComponentFolder;
public class CountFolder {
private TCComponentFolder folder;
private int count;
public CountFolder(TCComponentFolder folder, int count) {
super();
this.folder = folder;
this.count = count;
}
public TCComponentFolder getFolder() {
return folder;
}
public void setFolder(TCComponentFolder folder) {
this.folder = folder;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
@Override
public String toString() {
return "CountFolder [folder=" + folder + ", count=" + count + "]";
}
}

@ -0,0 +1,49 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.EventObject;
import javax.swing.AbstractCellEditor;
import javax.swing.JTable;
import javax.swing.event.CellEditorListener;
import javax.swing.table.TableCellEditor;
import org.jdesktop.swingx.JXDatePicker;
public class DatePickerEditor extends AbstractCellEditor implements TableCellEditor{
private JXDatePicker datePicker;
public DatePickerEditor() {
datePicker = new JXDatePicker();
// ÉèÖÃÈÕÆÚ¸ñʽ
datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
datePicker.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fireEditingStopped();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (value instanceof Date) {
System.out.println("value : "+value);
datePicker.setDate((Date) value);
} else {
datePicker.setDate(null);
}
return datePicker;
}
@Override
public Object getCellEditorValue() {
return datePicker.getDate();
}
}

@ -0,0 +1,46 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
public class FormData {
private String projectName;
private String orderDate;
private String specialRequirements;
public FormData(String... params) {
int count = 0;
this.projectName = params[count++];
this.orderDate = params[count++];
this.specialRequirements = params[count++];
}
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getOrderDate() {
return orderDate;
}
public void setOrderDate(String orderDate) {
this.orderDate = orderDate;
}
public String getSpecialRequirements() {
return specialRequirements;
}
public void setSpecialRequirements(String specialRequirements) {
this.specialRequirements = specialRequirements;
}
@Override
public String toString() {
return "FormData [projectName=" + projectName + ", orderDate=" + orderDate + ", specialRequirements="
+ specialRequirements + "]";
}
}

@ -0,0 +1,102 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity;
public class RowData {
private String DrawingNumber;
private String ProductName;
private String Version;
private String IssueDate;
private String Number;
private String MaterialDeliveryTime;
private String DrawingDeliveryTime;
private String MaterialReplyDate;
private String DrawingReplyDate;
private String Notes;
public RowData(String... params) {
int count = 0 ;
DrawingNumber = params[count++];
ProductName = params[count++];
Version = params[count++];
IssueDate = params[count++];
Number = params[count++];
MaterialDeliveryTime = params[count++];
DrawingDeliveryTime = params[count++];
MaterialReplyDate = params[count++];
DrawingReplyDate = params[count++];
Notes = params[count++];
}
public String getDrawingNumber() {
return DrawingNumber;
}
public void setDrawingNumber(String drawingNumber) {
DrawingNumber = drawingNumber;
}
public String getProductName() {
return ProductName;
}
public void setProductName(String productName) {
ProductName = productName;
}
public String getVersion() {
return Version;
}
public void setVersion(String version) {
Version = version;
}
public String getIssueDate() {
return IssueDate;
}
public void setIssueDate(String issueDate) {
IssueDate = issueDate;
}
public String getNumber() {
return Number;
}
public void setNumber(String number) {
Number = number;
}
public String getMaterialDeliveryTime() {
return MaterialDeliveryTime;
}
public void setMaterialDeliveryTime(String materialDeliveryTime) {
MaterialDeliveryTime = materialDeliveryTime;
}
public String getDrawingDeliveryTime() {
return DrawingDeliveryTime;
}
public void setDrawingDeliveryTime(String drawingDeliveryTime) {
DrawingDeliveryTime = drawingDeliveryTime;
}
public String getMaterialReplyDate() {
return MaterialReplyDate;
}
public void setMaterialReplyDate(String materialReplyDate) {
MaterialReplyDate = materialReplyDate;
}
public String getDrawingReplyDate() {
return DrawingReplyDate;
}
public void setDrawingReplyDate(String drawingReplyDate) {
DrawingReplyDate = drawingReplyDate;
}
public String getNotes() {
return Notes;
}
public void setNotes(String notes) {
Notes = notes;
}
@Override
public String toString() {
return "DrawingTaskBook [DrawingNumber=" + DrawingNumber + ", ProductName=" + ProductName + ", Version="
+ Version + ", IssueDate=" + IssueDate + ", Number=" + Number + ", MaterialDeliveryTime="
+ MaterialDeliveryTime + ", DrawingDeliveryTime=" + DrawingDeliveryTime + ", MaterialReplyDate="
+ MaterialReplyDate + ", DrawingReplyDate=" + DrawingReplyDate + ", Notes=" + Notes + "]";
}
}

@ -0,0 +1,22 @@
npiProjectDialog.0=Create Npi Projects
npiProjectDialog.1=NPI Project Name
npiProjectDialog.2=Whether test product
npiProjectDialog.3=Inquiry number
npiProjectDialog.4=Emergency status
npiProjectDialog.5=Customer name
npiProjectDialog.6=PLM customer name
npiProjectDialog.7=Order date
npiProjectDialog.8=Sales person in charge
npiProjectDialog.9=Special requirements
npiProjectDialog.10=Serial
npiProjectDialog.11=Customer PN
npiProjectDialog.12=Product Name
npiProjectDialog.13=Rev
npiProjectDialog.14=Date of Issuance
npiProjectDialog.15=Num
npiProjectDialog.16=BOM Deadline
npiProjectDialog.17=Drawings Deadline
npiProjectDialog.18=Tec BOM Deadline
npiProjectDialog.19=Tec Drawings Deadline
npiProjectDialog.20=Remarks

@ -0,0 +1,138 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreateOnQuotation;
import java.awt.Frame;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
import com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.CreateNPIprojectDialog;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateNPIprojectOnQuotationAction extends AbstractAIFAction {
private AbstractAIFApplication application;
private JLabel[] inputLabels;
private JComponent[] inputFields;
private String[] lovArrays;
private Map<String, Map<String, String>> lovMap;
private String[] columnNames;
private Object[][] data;
private TCSession tcSession;
private final String PREFERENCES = "Salespeoples";
public CreateNPIprojectOnQuotationAction(AbstractAIFApplication application, Frame frame, String param) {
super(application, frame, param);
this.application = application;
this.tcSession = (TCSession) application.getSession();
}
@Override
public void run() {
boolean flag = false;
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
TCComponentFolder targetRev = (TCComponentFolder) selectComponent;
System.out.println("选中文件夹类型为: " + targetRev.getType());
if (targetRev.getType().equals("Folder") || targetRev.getType().equals("Fnd0HomeFolder")) {
flag = true;
} else {
MessageBox.post("Please select the correct Folder Type", "error", MessageBox.ERROR);
}
} else {
MessageBox.post("Please select Folder", "error", MessageBox.ERROR);
}
if (flag) {
lovMap = new HashMap();
lovArrays = new String[] { "VF5sflov", "VF5jjztlov" };
inputLabels = new JLabel[] { new JLabel("NPI Project Name"), new JLabel("Whether test product"),
new JLabel("Inquiry number"), new JLabel("Emergency status"), new JLabel("Customer name"),
new JLabel("PLM customer name"), new JLabel("Order date"), new JLabel("Sales person in charge"),
new JLabel("Special requirements") };
JComboBox<String> jComboBox0 = new JComboBox<>(SwingUtil.getKeyValue(lovArrays[0], lovMap));
JComboBox<String> jComboBox1 = new JComboBox<>(SwingUtil.getKeyValue(lovArrays[1], lovMap));
String[] customerName = getCustomerName();
inputFields = new JComponent[] { new JTextField(14), jComboBox0, new JTextField(14), jComboBox1,
new JComboBox<>(customerName), new JTextField(14), createDatePicker(),
new JComboBox<>(getSaleName()), new JTextField(14) };
// 表格列标题
columnNames = new String[] { "Serial", "Customer PN", "Product Name", "Rev", "Date of Issuance", "Num",
"BOM Deadline", "Drawings Deadline", "Tec BOM Deadline", "Tec Drawings Deadline", "Remarks" };
// 表格数据
data = new Object[][] {};
CreateNPIprojectDialog dialog;
dialog = new CreateNPIprojectDialog(this.application, inputLabels, inputFields, lovMap, columnNames, data,
true);
new Thread(dialog).start();
}
}
private JXDatePicker createDatePicker() {
// 创建 JXDatePicker
JXDatePicker datePicker = new JXDatePicker();
// 设置日期格式
datePicker.setFormats(new java.text.SimpleDateFormat("yyyy-MM-dd"));
return datePicker;
}
// 查询、获取、去重 客户名称
public String[] getCustomerName() {
LinkedHashSet<String> customerNameLov = new LinkedHashSet<String>();
Map<String, String> tempLovMap = new HashMap<>();
try {
List<String> entryNames = new ArrayList<String>();
List<String> entryValues = new ArrayList<String>();
entryNames.add("vf5khjc");
entryValues.add("*");
// 参数1查询的名称参数2查询的条目参数3查询的条目对应的需要查询的值
InterfaceAIFComponent[] resultComponents = tcSession.search("MU_FindCustomerList",
entryNames.toArray(new String[entryNames.size()]),
entryValues.toArray(new String[entryNames.size()]));
for (int i = 0; i < resultComponents.length; i++) {
TCComponentItemRevision tcRevision = (TCComponentItemRevision) resultComponents[i];
TCComponent[] tcMaster = tcRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
String khmc = tcRevision.getProperty("object_name");
String khjc = tcMaster[0].getProperty("vf5khjc");
System.out.println("kh : " + khmc + " | " + khjc);
customerNameLov.add(khmc);
tempLovMap.put(khmc, khjc);
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("查询客户名称错误!");
e.printStackTrace();
}
lovMap.put("customerName", tempLovMap);
return customerNameLov.toArray(new String[0]);
}
public String[] getSaleName() {
TCPreferenceService preferenceService = tcSession.getPreferenceService();
return preferenceService.getStringValues(PREFERENCES);
}
}

@ -0,0 +1,23 @@
package com.connor.ferrorTech.metal.NPIproject.NPIprojectCreateOnQuotation;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateNPIprojectOnQuotationHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateNPIprojectOnQuotationAction action = new CreateNPIprojectOnQuotationAction(application, null, null);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,206 @@
package com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate;
import java.awt.Frame;
import java.util.ArrayList;
import java.util.List;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.TcUtil;
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.common.create.BOCreateDefinitionFactory;
import com.teamcenter.rac.common.create.CreateInstanceInput;
import com.teamcenter.rac.common.create.IBOCreateDefinition;
import com.teamcenter.rac.common.create.SOAGenericCreateHelper;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentContextList;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentFolderType;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateClientDrawingAction implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentFolderType folderType;
private TCComponentFolderType productType;
private TCComponentItemType itemType;
public CreateClientDrawingAction(AbstractAIFApplication application) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
try {
this.folderType = (TCComponentFolderType) tcSession.getTypeComponent("Folder");
this.productType = (TCComponentFolderType) tcSession.getTypeComponent("VF5xmwjj");
this.itemType = (TCComponentItemType) tcSession.getTypeComponent("VF5khtz");
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void run() {
// TODO 选中NPI项目文件夹
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
TCComponentForm formItem = null; // 表单对象
try {
// 获取出土任务书下的表单对象
formItem = getFormItem(selectComponent);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] preferenceValues = getPreference("VF5PROJECTCHILDFOLDER");
if (formItem != null) {
if (preferenceValues != null) {
TCComponentFolder npiFolder = (TCComponentFolder) selectComponent;
try {
TCComponent[] rowData = (TCComponent[]) formItem.getTCProperty("vf5cpxxTable")
.getReferenceValueArray();
createProductFolder(npiFolder, rowData, preferenceValues);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
MessageBox.post("Fail To Get Preference VF5PROJECTCHILDFOLDER", "Error", MessageBox.ERROR);
}
}
System.out.println("Fail To Get Form Item !");
}
public TCComponentFolder createProductChildFolder(TCComponentFolder parentFolder, String filePath) {
// TODO Auto-generated method stub
if (parentFolder != null) {
String[] fileName = filePath.split("/");
for (int i = 0; i < fileName.length; i++) {
try {
TCComponentFolder newChildFolder = folderType.create(fileName[i], "", "Folder");
parentFolder.add("contents", newChildFolder);
parentFolder = newChildFolder;
} catch (TCException e) {
// TODO Auto-generated catch block
MessageBox.post("create Folder " + fileName[i] + " error!", "error", MessageBox.ERROR);
e.printStackTrace();
}
}
return parentFolder;
} else {
throw new CustomException("productFolder is not exist");
}
}
public void createProductFolder(TCComponentFolder npiFolder, TCComponent[] itemRows, String[] filePaths)
throws TCException {
// TODO Auto-generated method stub
if (filePaths != null && filePaths.length > 0 && npiFolder != null) {
TCComponentFolder customerFolder = null;
TCComponent[] components = npiFolder.getRelatedComponents("contents");
System.out.println("\u5BA2\u6237\u56FE\u7EB8");
System.out.println("客户图纸");
for (int i = 0; i < components.length; i++) {
String customerFolderName = components[i].getProperty("object_name");
if (customerFolderName.equals("\u5BA2\u6237\u56FE\u7EB8") || customerFolderName.equals("客户图纸")) {
customerFolder = (TCComponentFolder) components[i];
}
}
if (customerFolder != null) {
String rowName = "";
String rowRev = "";
String rowNo = "";
for (TCComponent rowItem : itemRows) {
rowName = rowItem.getStringProperty("vf5cpmc");
rowRev = rowItem.getStringProperty("vf5khtzbb");
rowNo = rowItem.getStringProperty("vf5khth");
TCComponentFolder project = soaCreateFolder(rowNo, "VF5xmwjj");
for (String path : filePaths) {
createProductChildFolder(project, path);
}
System.out.println("rowName = " + rowName + " | rowRev = " + rowRev
+ " | rowNo = " + rowNo);
TCComponentItem khtz = (TCComponentItem) TcUtil.createComponent(application,
new String[] { itemType.getNewID(), rowRev, rowName }, "VF5khtz", "Item");
khtz.getLatestItemRevision().setStringProperty("vf5khth", rowNo);
customerFolder.add("contents", khtz);
project.add("contents", khtz);
npiFolder.add("contents", project);
}
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} else {
throw new CustomException("xjxxdRevForm or customerFolder is null");
}
} else {
throw new CustomException("npiFolder is not exist or Preference error !");
}
}
public TCComponentForm getFormItem(InterfaceAIFComponent selectComponent) throws Exception {
if (selectComponent != null) {
System.out.println("type: " + selectComponent.getType());
if (selectComponent.getType().equals("VF5NPI")) {
TCComponentFolder tarFolder = (TCComponentFolder) selectComponent;
TCComponent[] valueArray = tarFolder.getTCProperty("contents").getReferenceValueArray();
for (TCComponent tcComponent : valueArray) {
if (tcComponent.getStringProperty("object_type").equals("VF5ctrws")) {
TCComponentItem tempItem = (TCComponentItem) tcComponent;
return (TCComponentForm) tempItem.getLatestItemRevision()
.getRelatedComponent("IMAN_master_form_rev");
}
}
} else {
MessageBox.post(ConstantPool.EN_MESSAGE_Folder_TYPE_ERROR, "Error", MessageBox.ERROR);
}
} else {
MessageBox.post(ConstantPool.EN_MESSAGE_Folder_ERROR, "Error", MessageBox.ERROR);
}
return null;
}
public TCComponentFolder soaCreateFolder(String name, String type) {
System.out.println("创建文件夹 : " + name);
TCComponentFolder folder = null;
try {
IBOCreateDefinition ibocreatedefinition = BOCreateDefinitionFactory.getInstance()
.getCreateDefinition(tcSession, type);
CreateInstanceInput cii = new CreateInstanceInput(ibocreatedefinition);
List list = new ArrayList();
list.add(cii);
List list1 = SOAGenericCreateHelper.create(tcSession, ibocreatedefinition, list);
if (list1 != null && list1.size() > 0) {
TCComponent tccomponent = (TCComponent) list1.get(0);
folder = (TCComponentFolder) tccomponent;
folder.setProperty("object_name", name);
}
} catch (TCException e) {
e.printStackTrace();
}
return folder;
}
public String[] getPreference(String prefenenceName) {
TCPreferenceService preferenceService = this.tcSession.getPreferenceService();
String[] stringValues = preferenceService.getStringValues(prefenenceName);
return stringValues;
}
}

@ -0,0 +1,23 @@
package com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateClientDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateClientDrawingAction action = new CreateClientDrawingAction(application);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,450 @@
package com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileNameExtensionFilter;
import com.connor.ferrorTech.metal.constant.ConstantPool;
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.TCComponentDatasetType;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentFolderType;
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 UploadClientDrawingDialog extends AbstractAIFDialog implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private JLabel selectUploadLabel;
private JComponent uploadInput;
private JButton importButton;
private JButton okButton;
private JButton celButton;
private TCComponentFolderType folderType;
private TCComponentItemRevision targetRev;
private TCComponentDatasetType dwgType;
private TCComponentDatasetType pdfType;
private TCComponentDatasetType dxfType;
private TCComponentDatasetType jtType;
private TCComponentDatasetType stpType;
private TCComponentDatasetType docType;
private TCComponentDatasetType xlsType;
private TCComponentDatasetType pptType;
private TCComponentDatasetType wordType;
private TCComponentDatasetType excelType;
private TCComponentDatasetType pptxType;
private TCComponentDatasetType swprtType;
private TCComponentDatasetType swdrwType;
private TCComponentDatasetType swasmType;
private TCComponentDatasetType defaultType;
public UploadClientDrawingDialog(AbstractAIFApplication application) {
super();
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
}
public void initializationComponent() {
selectUploadLabel = new JLabel(ConstantPool.EN_LABEL_UPLOAD_PATH);
uploadInput = new JTextField(14);
importButton = new JButton(ConstantPool.EN_BUTTON_SELECT);
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
SwingUtilities.getWindowAncestor(importButton);
}
@Override
public void run() {
// TODO Auto-generated method stub
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
try {
String type = ((TCComponentItemRevision) selectComponent).getStringProperty("object_type");
System.out.println("type : " + type);
if (selectComponent != null && selectComponent instanceof TCComponentItemRevision
&& type.equals("VF5khtzRevision")) {
targetRev = (TCComponentItemRevision) selectComponent;
initUI();
} else {
MessageBox.post(ConstantPool.EN_MESSAGE_REV_ERROR, "error", MessageBox.ERROR);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public void initUI() {
initializationComponent();
// 创建一个自定义对话框
this.setTitle(ConstantPool.EN_TITLE_UPLOAD_PATH);
this.setLayout(null);
// 创建标签
selectUploadLabel.setBounds(30, 40, 80, 25);
this.add(selectUploadLabel);
// 创建输入框
uploadInput.setBounds(110, 40, 150, 25);
this.add(uploadInput);
// 创建选择按钮
importButton.setBounds(280, 40, 90, 25);
importButton.addActionListener(e -> {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
fileChooser.setMultiSelectionEnabled(false);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
}
});
this.add(importButton, BorderLayout.EAST);
// 创建确定和取消按钮
okButton.setBounds(80, 90, 100, 25);
celButton.setBounds(200, 90, 100, 25);
okButton.addActionListener(e -> {
String path = ((JTextField) uploadInput).getText();
if (path.isEmpty()) {
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_UPLOAD_ERROR);
} else {
// 检查文件是否为目录
File file = new File(path);
if (!file.isDirectory()) {
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_FILE_ERROR);
} else {
// 检查该版本下的数据集对象
// getDrawingsDataSet();
try {
folderType = (TCComponentFolderType) tcSession.getTypeComponent("Folder");
dwgType =(TCComponentDatasetType)tcSession.getTypeComponent("VF5CAD");
pdfType =(TCComponentDatasetType)tcSession.getTypeComponent("PDF");
dxfType =(TCComponentDatasetType)tcSession.getTypeComponent("DXF");
jtType =(TCComponentDatasetType)tcSession.getTypeComponent("DirectModel") ;
stpType =(TCComponentDatasetType)tcSession.getTypeComponent("UGPART");
docType =(TCComponentDatasetType)tcSession.getTypeComponent("MSWord");
xlsType =(TCComponentDatasetType)tcSession.getTypeComponent("MSExcel");
pptType =(TCComponentDatasetType)tcSession.getTypeComponent("MSPowerPoint");
wordType =(TCComponentDatasetType)tcSession.getTypeComponent("MSWordX");
excelType =(TCComponentDatasetType)tcSession.getTypeComponent("MSExcelX");
pptxType =(TCComponentDatasetType)tcSession.getTypeComponent("MSPowerPointX");
swprtType =(TCComponentDatasetType)tcSession.getTypeComponent("SWPrt");
swdrwType =(TCComponentDatasetType)tcSession.getTypeComponent("SWDrw");
swasmType =(TCComponentDatasetType)tcSession.getTypeComponent("SWAsm");
defaultType =(TCComponentDatasetType)tcSession.getTypeComponent("Zip");
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
this.dispose();
// 处理逻辑
try {
uploadDrawings(targetRev, file, false);
MessageBox.post("upload successfully !", "Info", MessageBox.INFORMATION);
} catch (TCException e1) {
// TODO Auto-generated catch block
MessageBox.post("fail to upload !\n"+e1.getMessage(), "Error", MessageBox.ERROR);
e1.printStackTrace();
}
}
}
});
celButton.addActionListener(e -> {
// 关闭
this.setVisible(false);
// 释放
this.disposeDialog();
});
this.add(okButton);
this.add(celButton);
// 设置对话框大小和位置
this.pack();
this.setSize(410, 190);
this.setLocationRelativeTo((Dialog) SwingUtilities.getWindowAncestor(importButton));
this.setVisible(true);
}
public void uploadDrawings(TCComponent item, File file, boolean flag) throws TCException {
// Map<String,TCComponentDataset> fileMap = getFileMap(item);
// String fileName = file.getName();
// if (file.isFile()){
// TCComponentDataset existData = isExistData(fileMap, fileName);
// if(existData!=null && removeData(item,existData)) {
// System.out.println("删除成功,开始添加数据集: "+fileName);
// }
// TCComponentDataset date = addData(item, file.getAbsolutePath());
// if(date == null) {
// StringBuffer str = new StringBuffer();
// str.append("Under the file path: ");
// str.append(file.getAbsolutePath());
// str.append("\nfileName: ");
// str.append(fileName);
// str.append(" add failed");
// JOptionPane.showMessageDialog(this,str.toString());
// }
// } else if (file.isDirectory()) {
// if(flag) {
// // 遍历本地文件夹
// for (File childFile : file.listFiles()){
// uploadDrawings(item,childFile,false);
// }
// }else {
// TCComponentFolder existFolder = isExistFolder(item,fileName);
// if(existFolder==null) {
// existFolder = addFolder(item, file.getName());
// }
//
// // 遍历本地文件夹
// for (File childFile : file.listFiles()){
// uploadDrawings(existFolder,childFile,false);
// }
// }
// }
File[] files = file.listFiles();
String folderName = file.getName();
TCComponent existFolder = item;
if (flag) {
existFolder = isExistFolder(item, folderName);
if (existFolder == null) {
existFolder = addFolder(item, folderName);
}
}
Map<String, TCComponentDataset> fileMap = getFileMap(existFolder);
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
String fileName = files[i].getName();
if (files[i].isDirectory()) {
uploadDrawings(existFolder, files[i], true);
} else {
TCComponentDataset existData = isExistData(fileMap, fileName);
if (existData != null && removeData(existFolder, existData)) {
System.out.println("Delete successfully, start to add data set: " + fileName);
}
TCComponentDataset date = addData(existFolder, files[i].getAbsolutePath());
if (date == null) {
StringBuffer str = new StringBuffer();
str.append("Under the file path: ");
str.append(files[i].getAbsolutePath());
str.append("\nfileName: ");
str.append(fileName);
str.append(" add failed");
JOptionPane.showMessageDialog(this, str.toString());
}
}
}
}
}
public Map<String, TCComponentDataset> getFileMap(TCComponent item) throws TCException {
Map<String, TCComponentDataset> map = new HashMap<String, TCComponentDataset>();
TCComponent[] referenceValueArray = null;
if (item instanceof TCComponentItemRevision) {
TCComponentItemRevision tempItemRev = (TCComponentItemRevision) item;
referenceValueArray = tempItemRev.getTCProperty("IMAN_specification").getReferenceValueArray();
} else if (item instanceof TCComponentFolder) {
referenceValueArray = item.getTCProperty("contents").getReferenceValueArray();
}
if (referenceValueArray.length > 0) {
for (TCComponent tcDataset : referenceValueArray) {
map.put(tcDataset.getStringProperty("object_name"), (TCComponentDataset) tcDataset);
}
}
return map;
}
public TCComponentDataset isExistData(Map<String, TCComponentDataset> tcMap, String fileName) {
if (tcMap != null && tcMap.containsKey(fileName)) {
return tcMap.get(fileName);
}
return null;
}
public TCComponentFolder isExistFolder(TCComponent item, String fileName) throws TCException {
System.out.println("Determine whether this folder is contained in tc:(fileName) " + fileName);
if (item instanceof TCComponentItemRevision) {
TCComponentItemRevision tempItemRev = (TCComponentItemRevision) item;
// 得到tc文件夹对象
TCComponent[] referenceValueArray = tempItemRev.getTCProperty("IMAN_reference").getReferenceValueArray();
for (TCComponent tcFolder : referenceValueArray) {
System.out.println("当前文件夹:" + tcFolder.getStringProperty("object_name"));
if (tcFolder.getType().equals("Folder") && tcFolder.getStringProperty("object_name").equals(fileName)) {
System.out.println("The Folder Exists");
return (TCComponentFolder) tcFolder;
}
}
} else if (item instanceof TCComponentFolder) {
TCComponent[] referenceValueArray = item.getTCProperty("contents").getReferenceValueArray();
for (TCComponent tcFolder : referenceValueArray) {
if (tcFolder.getType().equals("Folder") && tcFolder.getStringProperty("object_name").equals(fileName)) {
return (TCComponentFolder) tcFolder;
}
}
}
return null;
}
public boolean removeData(TCComponent obj, TCComponentDataset dataSet) throws TCException {
if (obj instanceof TCComponentItemRevision) {
TCComponentItemRevision temp = (TCComponentItemRevision) obj;
temp.remove("IMAN_specification", dataSet);
return true;
} else if (obj instanceof TCComponentFolder) {
TCComponentFolder temp = (TCComponentFolder) obj;
temp.remove("contents", dataSet);
return true;
}
return false;
}
public TCComponentDataset addData(TCComponent obj, String filePath) throws TCException {
System.out.println("Add Data Set..." + filePath);
TCComponentDataset tempData = null;
String fileName = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
String lastName = fileName.substring(fileName.lastIndexOf(".")+1).toLowerCase();
switch (lastName) {
case "dwg":{
tempData = dwgType.create(fileName, "", "VF5CAD");
tempData.setFiles(new String[] {filePath},new String[] {"VF5dwg"});
break;
}
case "pdf":{
tempData = pdfType.create(fileName, "", "PDF");
tempData.setFiles(new String[] {filePath},new String[] {"PDF_Reference"});
break;
}
case "dxf":{
tempData = dxfType.create(fileName, "", "DXF");
tempData.setFiles(new String[] {filePath},new String[] {"DXF"});
break;
}
case "jt":{
tempData = jtType.create(fileName, "", "DirectModel");
tempData.setFiles(new String[] {filePath},new String[] {"JTPART"});
break;
}
case "stp":{
tempData = stpType.create(fileName, "", "UGPART");
tempData.setFiles(new String[] {filePath},new String[] {"STEP-files"});
break;
}
case "doc":{
tempData = wordType.create(fileName, "", "MSWord");
tempData.setFiles(new String[] {filePath},new String[] {"word"});
break;
}
case "xls":{
tempData = excelType.create(fileName, "", "MSExcel");
tempData.setFiles(new String[] {filePath},new String[] {"excel"});
break;
}
case "ppt":{
tempData = docType.create(fileName, "", "MSPowerPoint");
tempData.setFiles(new String[] {filePath},new String[] {"powerpoint"});
break;
}
case "docx":{
tempData = xlsType.create(fileName, "", "MSWordX");
tempData.setFiles(new String[] {filePath},new String[] {"word"});
break;
}
case "xlsx":{
tempData = pptType.create(fileName, "", "MSExcelX");
tempData.setFiles(new String[] {filePath},new String[] {"excel"});
break;
}
case "pptx":{
tempData = pptxType.create(fileName, "", "MSPowerPointX");
tempData.setFiles(new String[] {filePath},new String[] {"powerpoint"});
break;
}
case "sldprt":{
tempData = pptxType.create(fileName, "", "SWPrt");
tempData.setFiles(new String[] {filePath},new String[] {"powerpoint"});
break;
}
case "slddrw":{
tempData = pptxType.create(fileName, "", "SWDrw");
tempData.setFiles(new String[] {filePath},new String[] {"PrtFile"});
break;
}
case "sldasm":{
tempData = pptxType.create(fileName, "", "SWAsm");
tempData.setFiles(new String[] {filePath},new String[] {"DrwFile"});
break;
}
default :{
tempData = defaultType.create(fileName, "", "Zip");
tempData.setFiles(new String[] {filePath},new String[] {"AsmFile"});
break;
}
}
if (tempData != null && obj instanceof TCComponentItemRevision) {
TCComponentItemRevision temp = (TCComponentItemRevision) obj;
temp.add("IMAN_specification", tempData);
return tempData;
} else if (tempData != null && obj instanceof TCComponentFolder) {
TCComponentFolder temp = (TCComponentFolder) obj;
temp.add("contents", tempData);
return tempData;
}
return null;
}
public TCComponentFolder addFolder(TCComponent item, String fileName) throws TCException {
System.out.println("Add Folders... " + fileName);
TCComponentFolder newFolder = folderType.create(fileName, "", "Folder");
if (item instanceof TCComponentItemRevision) {
TCComponentItemRevision temp = (TCComponentItemRevision) item;
temp.add("IMAN_reference", newFolder);
return newFolder;
} else if (item instanceof TCComponentFolder) {
TCComponentFolder temp = (TCComponentFolder) item;
temp.add("contents", newFolder);
return newFolder;
}
return null;
}
}

@ -0,0 +1,23 @@
package com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class UploadClientDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
UploadClientDrawingDialog action = new UploadClientDrawingDialog(application);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,13 @@
package com.connor.ferrorTech.metal;
import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
UploadDialog uploadDialog = new UploadDialog(null);
uploadDialog.initUi();
}
}

@ -0,0 +1,406 @@
package com.connor.ferrorTech.metal.batchDownload;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JComponent;
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.FileNameExtensionFilter;
import com.connor.ferrorTech.metal.constant.ConstantPool;
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.AbstractAIFSession;
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.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentFolderType;
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 BatchDownloadDialog extends AbstractAIFDialog {
private AbstractAIFApplication application;
private TCSession tcSession;
private JLabel selectUploadLabel;
private JComponent uploadInput;
private JButton importButton;
private JButton okButton;
private JButton celButton;
private Map<String, String> ccpGx;
private Map<String, String> bcpGx;
private Map<String, String> clGx;
private Map<String, String> gxGx;
private TCComponentBOMWindow view;
public BatchDownloadDialog(AbstractAIFApplication application) {
super(true);
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
}
public void initializationComponent() {
selectUploadLabel = new JLabel(ConstantPool.EN_LABEL_UPLOAD_PATH);
uploadInput = new JTextField(14);
importButton = new JButton(ConstantPool.EN_BUTTON_SELECT);
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
SwingUtilities.getWindowAncestor(importButton);
}
@Override
public void run() {
initUi();
}
/**
*
*/
public void initUi() {
initializationComponent();
this.setTitle(ConstantPool.EN_TITLE_DOWNLOAD_PATH);
this.setLayout(null);
selectUploadLabel.setBounds(30, 40, 80, 25);
this.add(selectUploadLabel);
uploadInput.setBounds(110, 40, 150, 25);
this.add(uploadInput);
importButton.setBounds(280, 40, 90, 25);
importButton.addActionListener(e -> {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV Files", "csv");
fileChooser.setFileFilter(filter);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
}
});
this.add(importButton, BorderLayout.EAST);
okButton.setBounds(80, 90, 100, 25);
celButton.setBounds(200, 90, 100, 25);
okButton.addActionListener(e -> {
String path = ((JTextField) uploadInput).getText();
if (path.isEmpty()) {
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_UPLOAD_ERROR);
} else {
File file = new File(path);
if (!file.exists() || !file.isDirectory()) {
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_FILE_ERROR);
} else {
downloadFiles(file);
this.dispose();
}
}
});
celButton.addActionListener(e -> {
this.setVisible(false);
this.disposeDialog();
});
this.add(okButton);
this.add(celButton);
this.pack();
this.setSize(410, 190);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setLocationRelativeTo((Dialog) SwingUtilities.getWindowAncestor(importButton));
this.setVisible(true);
}
public void downloadFiles(File file) {
ccpGx = new HashMap<>();
ccpGx.put("VF5idgx", "VF5nbtz");
ccpGx.put("VF5pcgx", "VF5procctrl");
ccpGx.put("VF5rdgx", "VF5jctz");
ccpGx.put("VF5ssgx", "VF5setupsheet");
ccpGx.put("VF5rwigx", "VF5rwi");
ccpGx.put("VF5gygx", "VF5gy");
bcpGx = new HashMap<>();
bcpGx.put("VF5spgx", "VF5bcptz");
clGx = new HashMap<>();
clGx.put("VF5rmgx", "VF5ycltz");
gxGx = new HashMap<>();
gxGx.put("VF5ncgx", "VF5ncfile");
gxGx.put("VF5pdgx", "VF5gytz");
gxGx.put("VF5pmgx", "VF5yjgtz");
gxGx.put("VF5tlgx", "VF5tl");
gxGx.put("VF5swigx", "VF5swi");
gxGx.put("VF5rwigx", "VF5rwi");
gxGx.put("VF5ipgx", "VF5ip");
TCSession session = (TCSession) application.getSession();
TCComponentFolder tcFolder = (TCComponentFolder) application.getTargetComponent();
try {
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
view = winType.create(null);
String tarType = tcFolder.getStringProperty("object_type");
if (tarType.equals("Folder") || tarType.equals("VF5xmwjj")) {
mainProcess(tcFolder, file.getAbsolutePath());
} else if (tarType.equals("VF5NPI")) {
TCComponent[] childFolders = tcFolder.getRelatedComponents("contents");
for (TCComponent childFolder : childFolders) {
String childItemType = childFolder.getStringProperty("object_type");
System.out.println("childFolder type is " + childItemType);
System.out.println("childFolder name is " + childFolder.getStringProperty("object_name"));
if (childItemType.equals("Folder") || childItemType.equals("VF5xmwjj")) {
File createNewFolder = createNewFolder(file, childFolder.getStringProperty("object_name"));
mainProcess((TCComponentFolder) childFolder, createNewFolder.getAbsolutePath());
}
}
}
MessageBox.post("DownLoad Successfully !", "Info", MessageBox.INFORMATION);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
MessageBox.post(e.getMessage(), "Info", MessageBox.INFORMATION);
}
}
public File createNewFolder(File file, String folderName) {
String absolutePath = file.getAbsolutePath();
File childFolder = new File(absolutePath + "\\" + folderName);
if (!childFolder.exists()) {
boolean mkdir = childFolder.mkdir();
if (mkdir == false) {
System.out.println("createNewFolder error !");
}
System.out.println("create successful ! " + folderName);
} else {
System.out.println("is exist !");
}
return childFolder;
}
public void mainProcess(TCComponentFolder tcFolder, String filePath) {
try {
Map<String, TCComponentItemRevision> targetsMap = new HashMap<String, TCComponentItemRevision>();
getTargets(tcFolder, targetsMap);
List<TCComponentItemRevision> tcList = new ArrayList<>();
Set<String> keySet = targetsMap.keySet();
for (String key : keySet) {
tcList.add(targetsMap.get(key));
}
List<TCComponentDataset> dataSet = getDataSet(tcList);
for (TCComponentDataset tcComponentDataset : dataSet) {
getToLocal(tcComponentDataset, filePath);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public void getToLocal(TCComponentDataset data, String filePath) {
// 获取文件
String templateFilePath = "";
try {
String fileName = data.getStringProperty("object_name");
System.out.println("begin add file: " + fileName);
if (!fileName.contains(".")) {
return;
}
String refs = data.getProperty("ref_names");
String[] ref = refs.split(",");
File file = data.getFiles(ref[0], filePath)[0];
templateFilePath = file.getAbsolutePath();
// 获取到本地文件的绝对路径templateFilePath
System.out.println("after add file: " + templateFilePath);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 获取数据集
public List<TCComponentDataset> getDataSet(List<TCComponentItemRevision> tcList) throws TCException {
// TODO Auto-generated method stub
List<TCComponentDataset> dataSets = new ArrayList<TCComponentDataset>();
for (TCComponentItemRevision rev : tcList) {
String revType = rev.getStringProperty("object_type");
if (revType.equals("VF5bjtzRevision") || revType.equals("VF5khtzRevision")) {
TCComponentFolder[] folders = (TCComponentFolder[]) rev.getRelatedComponents("IMAN_reference");
for (TCComponentFolder folder : folders) {
TCComponent[] relatedComponents = folder.getRelatedComponents("contents");
for (TCComponent dataSet : relatedComponents) {
if (dataSet != null && dataSet instanceof TCComponentDataset) {
dataSets.add((TCComponentDataset) dataSet);
}
}
}
}
TCComponent[] dataList = rev.getRelatedComponents("IMAN_specification");
for (TCComponent dataSet : dataList) {
if (dataSet != null && dataSet instanceof TCComponentDataset) {
dataSets.add((TCComponentDataset) dataSet);
}
}
}
return dataSets;
}
// 获取文件夹下所有在匹配规则下对象
public boolean getTargets(TCComponentFolder tarFolder, Map<String, TCComponentItemRevision> targetsMap)
throws TCException {
TCComponent[] components = tarFolder.getRelatedComponents("contents");
for (TCComponent childComponent : components) {
getItemRev(childComponent, targetsMap);
}
return false;
}
public void getItemRev(TCComponent childComponent, Map<String, TCComponentItemRevision> targetsMap)
throws TCException {
if (childComponent instanceof TCComponentFolder) {
getTargets((TCComponentFolder) childComponent, targetsMap);
} else if (childComponent instanceof TCComponentItem) {
TCComponentItem childItem = (TCComponentItem) childComponent;
TCComponentItemRevision childRev = childItem.getLatestItemRevision();
String itemType = childItem.getStringProperty("object_type");
System.out.println("type ==> " + itemType + " || " + childRev.toString());
switch (itemType) {
case "VF5ccp": {
getGxTatgets(childRev, ccpGx, targetsMap);
TCComponentBOMLine ccpBomLine = view.setWindowTopLine(childItem, childRev, null, null);
getBomRuleChild(ccpBomLine, new String[] { "VF5bcpRevision", "VF5clRevision" }, targetsMap);
break;
}
case "VF5bcp": {
getGxTatgets(childRev, bcpGx, targetsMap);
TCComponentBOMLine bcpBomLine = view.setWindowTopLine(childItem, childRev, null, null);
getBomRuleChild(bcpBomLine, new String[] { "VF5clRevision" }, targetsMap);
break;
}
case "VF5cl": {
getGxTatgets(childRev, clGx, targetsMap);
break;
}
case "VF5gy": {
TCComponentBOMLine gyBomLine = view.setWindowTopLine(childItem, childRev, null, null);
getBomRuleChild(gyBomLine, new String[] { "VF5gxRevision" }, targetsMap);
break;
}
case "VF5gx": {
getGxTatgets(childRev, gxGx, targetsMap);
break;
}
default: {
break;
}
}
}
}
public void getGxTatgets(TCComponentItemRevision tarItem, Map<String, String> gxMap,
Map<String, TCComponentItemRevision> targetsMap) throws TCException {
Set<String> gxSet = gxMap.keySet();
System.out.println("===> 遍历工序版本下的关系 " + tarItem.toString());
// 遍历版本下所有关系 并获取该关系下符合类型的版本对象
for (String gxValue : gxSet) {
System.out.println("##关系:" + gxValue);
TCComponent[] relatedComponents = tarItem.getRelatedComponents(gxValue);
String targetType = gxMap.get(gxValue);
if (relatedComponents == null) {
continue;
}
for (TCComponent gxChildItem : relatedComponents) {
TCComponentItemRevision targetRev = null;
TCComponentItem targetItem = null;
if (gxChildItem instanceof TCComponentItem) {
targetItem = (TCComponentItem) gxChildItem;
targetRev = targetItem.getLatestItemRevision();
} else if (gxChildItem instanceof TCComponentItemRevision) {
targetRev = (TCComponentItemRevision) gxChildItem;
targetItem = targetRev.getItem();
}
String itemType = targetItem.getStringProperty("object_type");
System.out.println(itemType + " || " + targetRev.toString());
if (gxValue.equals("VF5gygx")) {
System.out.println("***符合关系的有:" + targetRev.toString());
getItemRev(targetItem, targetsMap);
} else if (targetRev != null && targetItem != null && itemType.equals(targetType)) {
System.out.println("***符合关系的有:" + targetRev.toString());
targetsMap.put(targetRev.getUid(), targetRev);
}
}
}
}
public void getBomRuleChild(TCComponentBOMLine gyBomLine, String[] ruleType,
Map<String, TCComponentItemRevision> targetsMap) throws TCException {
boolean hasChildren = gyBomLine.hasChildren();
if (hasChildren) {
AIFComponentContext[] childrena = gyBomLine.getChildren();
for (AIFComponentContext children : childrena) {
TCComponentBOMLine component = (TCComponentBOMLine) children.getComponent();
TCComponentItemRevision childRev = component.getItemRevision();
String revType = childRev.getStringProperty("object_type");
if (ruleType.length == 1 && revType.equals(ruleType[0])) {
switch (revType) {
case "VF5gxRevision": {
getGxTatgets(childRev, gxGx, targetsMap);
break;
}
case "VF5clRevision": {
getGxTatgets(childRev, clGx, targetsMap);
break;
}
default: {
break;
}
}
} else if (ruleType.length == 2 && revType.equals(ruleType[0])) {
// 怀疑这个地方有bug
getGxTatgets(childRev, bcpGx, targetsMap);
} else if (ruleType.length == 2 && revType.equals(ruleType[1])) {
getGxTatgets(childRev, clGx, targetsMap);
}
}
}
}
}

@ -0,0 +1,26 @@
package com.connor.ferrorTech.metal.batchDownload;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class BatchDownloadHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"VF5NPI","VF5xmwjj","Folder"}, "Folder");
if(judgeSingleSelectComponent) {
BatchDownloadDialog dialog = new BatchDownloadDialog(application);
new Thread(dialog).start();
}
return null;
}
}

@ -0,0 +1,172 @@
package com.connor.ferrorTech.metal.bomProcess;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.util.TcUtil;
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.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentProcessType;
import com.teamcenter.rac.kernel.TCComponentTaskTemplate;
import com.teamcenter.rac.kernel.TCComponentTaskTemplateType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand;
public class ApprovalOfBomProcessHandler extends AbstractHandler {
private TCComponentFolder[] targetFolders;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
TCSession tcSession = (TCSession) application.getSession();
String errorName = "";
try {
errorName = judgeFolder(application);
if (errorName != null && !errorName.isEmpty()) {
MessageBox.post(errorName + " Is Not Target Folder !", "error", MessageBox.ERROR);
} else {
List<TCComponent> list = getFilesWithCcp(targetFolders);
TCComponent[] publicItems = filterTComponent(list);
// String preferenceValue = TcUtil.getPreferenceValue(tcSession, "VF5BOM_PROCESS_RELEASE");
// if (preferenceValue != null && !preferenceValue.isEmpty() && publicItems != null
// && publicItems.length > 0) {
if (publicItems != null && publicItems.length > 0) {
// CreateProcess(tcSession, publicItems, preferenceValue);
// MessageBox.post("Public Successful !", "Info", MessageBox.INFORMATION);
// new NewProcessCommand(AIFUtility.getActiveDesktop(), application, publicItems);
NewProcessCommand cmd = new NewProcessCommand(AIFUtility.getActiveDesktop(), application,
publicItems);
cmd.executeModeless();
} else {
MessageBox.post("Preference configuration error or failure to find VF5ccp, VF5gy objects", "error",
MessageBox.ERROR);
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public TCComponent[] filterTComponent(List<TCComponent> list) {
List<TCComponentItemRevision> newList = new ArrayList<>();
if (list != null && list.size() > 0) {
try {
for (int i = 0; i < list.size(); i++) {
TCComponentItem item = (TCComponentItem) list.get(i);
TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
TCComponent[] releaseList = latestItemRevision.getRelatedComponents("release_status_list");
if (releaseList != null && releaseList.length > 0) {
continue;
} else {
newList.add(latestItemRevision);
}
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
return newList.toArray(new TCComponent[newList.size()]);
}
public void CreateProcess(TCSession session, TCComponent[] targets, String processName) throws TCException {
try {
System.out.println("number : " + targets.length);
TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job");
TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session
.getTypeComponent("EPMTaskTemplate");
TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0);
int[] number = new int[targets.length];
for (int i = 0; i < targets.length; i++) {
number[i] = 1;
}
if (taskTemplate != null) {
String name = targets[0].getProperty("object_string");
processType.create(processName + ":" + name, "", taskTemplate, targets, number);
}
} catch (TCException e) {
e.printStackTrace();
throw e;
}
}
public String judgeFolder(AbstractAIFApplication application) throws TCException {
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
if (targetComponents != null && targetComponents.length > 0) {
targetFolders = new TCComponentFolder[targetComponents.length];
for (int i = 0; i < targetComponents.length; i++) {
if (!targetComponents[i].getType().equals("VF5xmwjj")) {
return ((TCComponentFolder) targetComponents[i]).getStringProperty("object_name");
} else {
targetFolders[i] = (TCComponentFolder) targetComponents[i];
}
}
} else {
MessageBox.post("Please Select Folder !", "Error", MessageBox.ERROR);
}
return null;
}
public List<TCComponent> getFilesWithCcp(TCComponentFolder[] targetFolders) {
List<TCComponent> result = new ArrayList<>();
try {
for (TCComponentFolder targetFolder : targetFolders) {
traverseDirectory(targetFolder, result);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
/**
*
*
* @param directory
* @param result
* @throws TCException
*/
private void traverseDirectory(TCComponentFolder targetFolder, List<TCComponent> result) throws TCException {
TCComponent[] childItems = targetFolder.getTCProperty("contents").getReferenceValueArray();
if (childItems != null && childItems.length > 0) {
for (TCComponent childItem : childItems) {
if (childItem.getType().equals("Folder")) {
traverseDirectory((TCComponentFolder) childItem, result);
} else if (childItem.getType().equals("VF5ccp")) {
result.add(childItem);
// 这里可能会有问题,测试没问题,待有问题检查这里
TCComponent[] gyGx = childItem.getRelatedComponents("VF5gygx");
for (TCComponent tcComponent : childItems) {
if (tcComponent.getStringProperty("object_type").equals("VF5gy")) {
result.add(tcComponent);
}
}
} else if (childItem.getType().equals("VF5gy")) {
result.add(childItem);
}
}
}
}
}

@ -0,0 +1,448 @@
package com.connor.ferrorTech.metal.changeManagement.createECO;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import com.connor.ferrorTech.metal.changeManagement.createECR.CustomTableCellRenderer;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import java.awt.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
public class ChangeNoticeFormCreateDialog extends JFrame implements Runnable {
private final String title;
private AbstractAIFApplication application;
private InterfaceAIFComponent targetComponent;
private final JLabel[] jLabels;
private final JComponent[] jComponents;
private JButton confirmButton;
private JButton cancelButton;
private JButton addButton;
private JButton removeButton;
private JTable leftTable;
private JTable rightTable;
private String[][] leftData;
private String[][] rightData;
public ChangeNoticeFormCreateDialog(AbstractAIFApplication application, String title, Object... args) {
int count = 0;
this.title = title;
this.application = application;
jLabels = (JLabel[]) args[count++];
jComponents = (JComponent[]) args[count++];
leftData = (String[][]) args[count];
}
@Override
public void run() {
targetComponent = application.getTargetComponent();
initUI();
}
public void initUI() {
this.setTitle(title);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setSize(780, 450); // 设置窗口大小
this.setLayout(new BorderLayout()); // 设置布局
initializationButton();
try {
JPanel topPanel = createTopPanel();
JPanel centerPanel = createCenterPanel();
JPanel southPanel = createSouthPanel();
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(southPanel, BorderLayout.SOUTH);
this.setLocationRelativeTo(null);
this.setVisible(true);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void initializationButton() {
confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
confirmButton.setPreferredSize(new Dimension(95, 25));
confirmButton.addActionListener(e -> {
String name = ((JTextField) jComponents[0]).getText();
String reason = ((JTextField) jComponents[1]).getText();
if (name.length() >= 40) {
JOptionPane.showMessageDialog(null, "The length of the name cannot exceed 40 characters", "Error",
JOptionPane.ERROR_MESSAGE);
} else {
this.dispose();
if (name != null && name.isEmpty()) {
name = "MECO";
}
doTask(name, reason);
}
});
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
cancelButton.setPreferredSize(new Dimension(95, 25));
cancelButton.addActionListener(e -> {
this.dispose();
});
addButton = new JButton("Add>>");
addButton.setPreferredSize(new Dimension(110, 25));
addButton.addActionListener(e -> {
moveRight();
});
removeButton = new JButton("<<Remove");
removeButton.setPreferredSize(new Dimension(110, 25));
removeButton.addActionListener(e -> {
moveLeft();
});
}
public JPanel createTopPanel() throws Exception {
JPanel topPanel = new JPanel(new GridBagLayout());
topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));
Font serif = new Font("Serif", Font.BOLD, 13);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridy = 0;
gbc.insets = new Insets(5, 20, 5, 20);
int count = 0;
for (int i = 0; i < jLabels.length; i++) {
gbc.gridx = count++;
jLabels[i].setFont(serif);
topPanel.add(jLabels[i], gbc);
gbc.gridx = count++;
jComponents[i].setFont(serif);
if (targetComponent.getProperty("object_type").equals("VF5bgpsd") && i == 1) {
TCComponentItem tcItem = (TCComponentItem) targetComponent;
String reason = tcItem.getLatestItemRevision().getRelatedComponent("IMAN_master_form_rev")
.getProperty("vf5bgyy");
((JTextField) jComponents[i]).setText(reason);
}
topPanel.add(jComponents[i], gbc);
}
return topPanel;
}
private JPanel createSouthPanel() {
JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
southPanel.setBorder(BorderFactory.createEmptyBorder(-10, 5, 10, 80));
southPanel.add(confirmButton);
southPanel.add(cancelButton);
return southPanel;
}
public JPanel createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
centerPanel.add(createLeftPanel(), BorderLayout.WEST);
centerPanel.add(createCenterButton(), BorderLayout.CENTER);
centerPanel.add(createRightPanel(), BorderLayout.EAST);
return centerPanel;
}
public JPanel createLeftPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5));
DefaultTableModel tableModel = new DefaultTableModel(leftData, new Object[] { "Column" }) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public int getRowCount() {
return leftData.length;
}
@Override
public int getColumnCount() {
return 1;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return leftData[rowIndex][1];
}
};
leftTable = new JTable(tableModel);
leftTable.setTableHeader(null);
leftTable.setShowGrid(false);
leftTable.setRowHeight(22);
leftTable.setIntercellSpacing(new Dimension(0, 0));
leftTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
centerPanel.add(new JScrollPane(leftTable), BorderLayout.CENTER);
return centerPanel;
}
public JPanel createCenterButton() {
JPanel jPanel = new JPanel(new GridBagLayout());
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(-30, 5, 30, 5);// 边距
jPanel.add(addButton, gbc);
gbc.insets = new Insets(0, 5, 10, 5);// 边距
gbc.gridy = 1;
jPanel.add(removeButton, gbc);
return jPanel;
}
public JPanel createRightPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10));
rightData = new String[][] {};
DefaultTableModel tableModel = new DefaultTableModel(rightData, new Object[] { "Column" }) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public int getRowCount() {
return rightData.length;
}
@Override
public int getColumnCount() {
return 1;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return rightData[rowIndex][1];
}
};
rightTable = new JTable(tableModel);
rightTable.setTableHeader(null);
rightTable.setShowGrid(false);
rightTable.setRowHeight(22);
rightTable.setIntercellSpacing(new Dimension(0, 0));
rightTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
centerPanel.add(new JScrollPane(rightTable), BorderLayout.CENTER);
return centerPanel;
}
public void moveRight() {
int[] selectedRows = leftTable.getSelectedRows();
if (selectedRows.length == 0) {
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection",
JOptionPane.WARNING_MESSAGE);
return;
}
String[][] newRightData = new String[rightData.length + selectedRows.length][];
System.arraycopy(rightData, 0, newRightData, 0, rightData.length);
for (int i = 0; i < selectedRows.length; i++) {
newRightData[rightData.length + i] = leftData[selectedRows[i]];
}
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
rightTableModel.setDataVector(newRightData, new Object[] { "Column" });
rightData = newRightData;
String[][] newLeftData = new String[leftData.length - selectedRows.length][];
int newIndex = 0;
for (int i = 0; i < leftData.length; i++) {
boolean isSelected = false;
for (int selectedRow : selectedRows) {
if (i == selectedRow) {
isSelected = true;
break;
}
}
if (!isSelected) {
newLeftData[newIndex++] = leftData[i];
}
}
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
leftTableModel.setDataVector(newLeftData, new Object[] { "Column" });
leftData = newLeftData;
}
public void moveLeft() {
int[] selectedRows = rightTable.getSelectedRows();
if (selectedRows.length == 0) {
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection",
JOptionPane.WARNING_MESSAGE);
return;
}
String[][] newLeftData = new String[leftData.length + selectedRows.length][];
System.arraycopy(leftData, 0, newLeftData, 0, leftData.length);
for (int i = 0; i < selectedRows.length; i++) {
newLeftData[leftData.length + i] = rightData[selectedRows[i]];
}
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
leftTableModel.setDataVector(newLeftData, new Object[] { "Column" });
leftData = newLeftData;
String[][] newRightData = new String[rightData.length - selectedRows.length][];
int newIndex = 0;
for (int i = 0; i < rightData.length; i++) {
boolean isSelected = false;
for (int selectedRow : selectedRows) {
if (i == selectedRow) {
isSelected = true;
break;
}
}
if (!isSelected) {
newRightData[newIndex++] = rightData[i];
}
}
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
rightTableModel.setDataVector(newRightData, new Object[] { "Column" });
rightData = newRightData;
}
public void doTask(String name, String reason) {
TCSession session = (TCSession) application.getSession();
int selectedRow = rightTable.getRowCount();
String[] uid = null;
if (selectedRow > 0) {
String[][] selectItems = new String[selectedRow][];
uid = new String[selectItems.length];
for (int i = 0; i < selectedRow; i++) {
String[] selectedItem = rightData[i];
selectItems[i] = selectedItem;
System.out.println("Selected Item: " + Arrays.toString(selectedItem));
}
for (int i = 0; i < selectItems.length; i++) {
uid[i] = selectItems[i][0];
}
}
TCComponentFolder xmwjj = null;
boolean isECR = false;
if (targetComponent instanceof TCComponentFolder) {
xmwjj = (TCComponentFolder) targetComponent;
} else if (targetComponent instanceof TCComponentItem) {
TCComponent changeFolder = ChangeNoticeFormCreateHandler.getLast((TCComponent) targetComponent, "Folder",
"CHANGE DATA");
if (changeFolder == null) {
System.out.println("out Folder is null");
}
xmwjj = (TCComponentFolder) TcUtil.getLastReferenced(changeFolder, "VF5xmwjj", "Folder");
isECR = true;
}
try {
if (xmwjj == null) {
throw new CustomException("xmwjj is null !");
}
setByFolder(xmwjj, uid, session, name, reason, isECR);
} catch (TCException e) {
// TODO Auto-generated catch block
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void setByFolder(TCComponentFolder xmwjj, String[] uid, TCSession session, String name, String reason,
boolean isECR) throws Exception {
TCComponent[] components = xmwjj.getRelatedComponents("contents");
TCComponentFolder changeFolder = null;
for (TCComponent tcComponent : components) {
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
&& tcComponent.getStringProperty("object_name").equals("CHANGE DATA")) {
changeFolder = (TCComponentFolder) tcComponent;
break;
}
}
TCComponentItemRevision revision = null;
if (changeFolder != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM");
String localTime = formatter.format(LocalDateTime.now());
System.out.println("当前时间:" + localTime);
int maxNumber = 0;
InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find ItemRevision",
new String[] { "ID" }, new String[] { "MECO-" + localTime + "-*" });
if(queryList !=null) {
for (InterfaceAIFComponent result : queryList) {
String[] id = result.getProperty("item_id").split("-");
if (id != null && id.length == 3) {
int localNo = Integer.parseInt(id[id.length - 1]);
if (localNo > maxNumber) {
maxNumber = localNo;
}
}
}
}
String itemId = (maxNumber + 1) + "";
int count = 2 - itemId.length();
for (int i = 0; i < count; i++) {
itemId = "0" + itemId;
}
System.out.println("itemId : "+itemId);
TCComponentItem newItem = (TCComponentItem) TcUtil.createComponent(application,
new String[] { "MECO-" + localTime + "-" + itemId, "", name }, "VF5bgtzd", "Item");
revision = newItem.getLatestItemRevision();
TCComponent form = revision.getRelatedComponent("IMAN_master_form_rev");
form.setStringProperty("vf5bgyy", reason);
changeFolder.add("contents", newItem);
if (isECR) {
revision.add("VF5bgpsdgx", (TCComponent) targetComponent);
}
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} else {
throw new CustomException("changeFolder is null !");
}
if (revision != null && uid != null & uid.length > 0) {
TCComponent[] revList = session.stringToComponent(uid);
revision.add("VF5ggqdxgx", revList);
} else {
throw new CustomException("revision is null !");
}
}
}

@ -0,0 +1,218 @@
package com.connor.ferrorTech.metal.changeManagement.createECO;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ChangeNoticeFormCreateHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
TCComponent targetItem = judgeAndGetSingleSelectComponent(application);
try {
if (targetItem != null) {
JLabel[] jLabels = new JLabel[] { new JLabel("Name"), new JLabel("Reason for Change") };
JComponent[] jComponents = new JComponent[] { new JTextField(20), new JTextField(20) };
TCComponentFolder xmwjj = null;
if (targetItem instanceof TCComponentFolder) {
xmwjj = (TCComponentFolder) targetItem;
} else if (targetItem instanceof TCComponentItem) {
TCComponent changeFolder = ChangeNoticeFormCreateHandler.getLast(targetItem, "Folder",
"CHANGE DATA");
if (changeFolder == null) {
throw new CustomException("changeFolder is null !");
}
xmwjj = (TCComponentFolder) TcUtil.getLastReferenced(changeFolder, "VF5xmwjj", "Folder");
}
if (xmwjj == null) {
throw new CustomException("xmwjj is null !");
}
List<TCComponentItemRevision> revisionList = null;
revisionList = getCcpItemRevision(application, xmwjj);
if (revisionList == null) {
throw new CustomException("revisionList is null !");
}
String[][] data = getData(revisionList);
ChangeNoticeFormCreateDialog searchTemplate = new ChangeNoticeFormCreateDialog(application,
"Create ECO", jLabels, jComponents, data);
new Thread(searchTemplate).start();
}
} catch (Exception e) {
// TODO: handle exception
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
}
return null;
}
public static TCComponent getLast(TCComponent targetComponent, String type, String name) {
if (targetComponent != null) {
try {
AIFComponentContext[] parent = targetComponent.whereReferenced();
for (int i = 0; i < parent.length; i++) {
InterfaceAIFComponent component = (TCComponent) parent[i].getComponent();
if (component.getType().equals(type) && component.getProperty("object_name").equals(name)) {
return (TCComponent) parent[i].getComponent();
}
}
System.out.println("Type is not exist !\n" + type);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
} else {
System.out.println("TargetComponent Is Null !");
}
return null;
}
public static TCComponent judgeAndGetSingleSelectComponent(AbstractAIFApplication application) {
InterfaceAIFComponent targetComponent = application.getTargetComponent();
try {
if (targetComponent instanceof TCComponentItem
&& ((TCComponentItem)targetComponent).getStringProperty("object_type").equals("VF5bgpsd")) {
return (TCComponent) targetComponent;
} else if (targetComponent instanceof TCComponentFolder
&& ((TCComponentFolder)targetComponent).getStringProperty("object_type").equals("VF5xmwjj")) {
return (TCComponent) targetComponent;
}
MessageBox.post("The Following Is Not A Specify Type !\n" + targetComponent.getUid(), "Error",
MessageBox.ERROR);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
private String[][] getData(List<TCComponentItemRevision> revisionList) throws TCException {
// TODO Auto-generated method stub
String[][] data = new String[revisionList.size()][];
if (revisionList != null && revisionList.size() > 0) {
int count = 0;
String name = "";
for (TCComponentItemRevision itemRevison : revisionList) {
String type = itemRevison.getStringProperty("object_type");
String[] rowData = new String[2];
String uid = itemRevison.getUid();
if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
String wlbm = itemRevison.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5wlbm");
name = wlbm + "-" + itemRevison.getStringProperty("object_name") + ";"
+ itemRevison.getStringProperty("item_revision_id");
} else if (type.equals("VF5gyRevision")) {
name = itemRevison.getStringProperty("item_id") + "-" + itemRevison.getStringProperty("object_name")
+ ";" + itemRevison.getStringProperty("item_revision_id");
}
rowData[0] = uid;
rowData[1] = name;
data[count++] = rowData;
}
return data;
} else {
return new String[][] {};
}
}
public List<TCComponentItemRevision> getCcpItemRevision(AbstractAIFApplication application, TCComponentFolder xmwjj)
throws TCException {
// TODO Auto-generated method stub
TCSession session = (TCSession) application.getSession();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
// 创建视图
TCComponentBOMWindow view = winType.create(null);
// 发送BOM args:item对象 版本对象 ...
List<TCComponentItemRevision> revList = new ArrayList<>();
TCComponent[] components = xmwjj.getRelatedComponents("contents");
TCComponentFolder materialFolder = null;
TCComponentFolder porFolder = null;
for (TCComponent tcComponent : components) {
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
&& tcComponent.getStringProperty("object_name").equals("MATERIAL AND BOM")) {
materialFolder = (TCComponentFolder) tcComponent;
} else if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
&& tcComponent.getStringProperty("object_name").equals("POR")) {
porFolder = (TCComponentFolder) tcComponent;
}
}
if (materialFolder != null) {
TCComponent[] materialChildren = materialFolder.getRelatedComponents("contents");
for (TCComponent tcItem : materialChildren) {
if (tcItem.getStringProperty("object_type").equals("VF5ccp")) {
TCComponentItem ccpItem = (TCComponentItem) tcItem;
TCComponentItemRevision ccpItemRev = ccpItem.getLatestItemRevision();
revList.add(ccpItemRev);
getBcpRevision(revList, view, ccpItem, ccpItemRev);
}
}
} else {
throw new CustomException("materialFolder is null ! ");
}
if (porFolder != null) {
TCComponent[] porChildren = porFolder.getRelatedComponents("contents");
for (TCComponent tcItem : porChildren) {
if (tcItem.getStringProperty("object_type").equals("VF5gy")) {
TCComponentItem gyItem = (TCComponentItem) tcItem;
TCComponentItemRevision gyItemRev = gyItem.getLatestItemRevision();
revList.add(gyItemRev);
}
}
} else {
throw new CustomException("porFolder is null ! ");
}
return revList;
}
public void getBcpRevision(List<TCComponentItemRevision> revList, TCComponentBOMWindow view,
TCComponentItem ccpItem, TCComponentItemRevision ccpItemRev) throws TCException {
TCComponentBOMLine bomLine = view.setWindowTopLine(ccpItem, ccpItemRev, null, null);
boolean hasChildren = bomLine.hasChildren();
if (hasChildren) {
AIFComponentContext[] childrena = bomLine.getChildren();
for (AIFComponentContext children : childrena) {
// 强转为TCComponentBOMLine类型
TCComponentItemRevision bcpItemRev = ((TCComponentBOMLine) children.getComponent()).getItemRevision();
if (bcpItemRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
revList.add(bcpItemRev);
}
}
}
}
}

@ -0,0 +1,406 @@
package com.connor.ferrorTech.metal.changeManagement.createECR;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import java.awt.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
public class ChangeApplyFormCreateDialog extends JFrame implements Runnable {
private final String title;
private AbstractAIFApplication application;
private final JLabel[] jLabels;
private final JComponent[] jComponents;
private JButton confirmButton;
private JButton cancelButton;
private JButton addButton;
private JButton removeButton;
private JTable leftTable;
private JTable rightTable;
private String[][] leftData;
private String[][] rightData;
public ChangeApplyFormCreateDialog(AbstractAIFApplication application,String title, Object... args) {
int count = 0;
this.title = title;
this.application =application;
jLabels = (JLabel[]) args[count++];
jComponents = (JComponent[]) args[count++];
leftData = (String[][]) args[count];
}
@Override
public void run() {
initUI();
}
public void initUI() {
this.setTitle(title);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setSize(780, 450); // 设置窗口大小
this.setLayout(new BorderLayout()); // 设置布局
initializationButton();
JPanel topPanel = createTopPanel();
JPanel centerPanel = createCenterPanel();
JPanel southPanel = createSouthPanel();
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(southPanel, BorderLayout.SOUTH);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public void initializationButton() {
confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
confirmButton.setPreferredSize(new Dimension(95, 25));
confirmButton.addActionListener(e -> {
String name = ((JTextField) jComponents[0]).getText();
String reason = ((JTextField) jComponents[1]).getText();
if(name.length()>=40){
JOptionPane.showMessageDialog(null, "The length of the name cannot exceed 40 characters", "Error", JOptionPane.ERROR_MESSAGE);
}else{
this.dispose();
try {
if(name !=null && name.isEmpty()) {
name = "MECR";
}
doTask(name,reason);
} catch (TCException e1) {
// TODO Auto-generated catch block
MessageBox.post(e1.getMessage(), "Error", MessageBox.ERROR);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
cancelButton.setPreferredSize(new Dimension(95, 25));
cancelButton.addActionListener(e -> {
this.dispose();
});
addButton = new JButton("Add>>");
addButton.setPreferredSize(new Dimension(110, 25));
addButton.addActionListener(e -> {
moveRight();
});
removeButton = new JButton("<<Remove");
removeButton.setPreferredSize(new Dimension(110, 25));
removeButton.addActionListener(e -> {
moveLeft();
});
}
public JPanel createTopPanel() {
JPanel topPanel = new JPanel(new GridBagLayout());
topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 5));
Font serif = new Font("Serif", Font.BOLD, 13);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridy = 0;
gbc.insets = new Insets(5, 20, 5, 20);
int count = 0;
for (int i = 0; i < jLabels.length; i++) {
gbc.gridx = count++;
jLabels[i].setFont(serif);
topPanel.add(jLabels[i], gbc);
gbc.gridx = count++;
jComponents[i].setFont(serif);
topPanel.add(jComponents[i], gbc);
}
return topPanel;
}
private JPanel createSouthPanel() {
JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 10));
southPanel.setBorder(BorderFactory.createEmptyBorder(-10, 5, 10, 80));
southPanel.add(confirmButton);
southPanel.add(cancelButton);
return southPanel;
}
public JPanel createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
centerPanel.add(createLeftPanel(), BorderLayout.WEST);
centerPanel.add(createCenterButton(), BorderLayout.CENTER);
centerPanel.add(createRightPanel(), BorderLayout.EAST);
return centerPanel;
}
public JPanel createLeftPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 5));
DefaultTableModel tableModel = new DefaultTableModel(leftData, new Object[]{"Column"}) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public int getRowCount() {
return leftData.length;
}
@Override
public int getColumnCount() {
return 1;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return leftData[rowIndex][1];
}
};
leftTable = new JTable(tableModel);
leftTable.setTableHeader(null);
leftTable.setShowGrid(false);
leftTable.setRowHeight(22);
leftTable.setIntercellSpacing(new Dimension(0, 0));
leftTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
centerPanel.add(new JScrollPane(leftTable), BorderLayout.CENTER);
return centerPanel;
}
public JPanel createCenterButton() {
JPanel jPanel = new JPanel(new GridBagLayout());
jPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(-30, 5, 30, 5);// 边距
jPanel.add(addButton, gbc);
gbc.insets = new Insets(0, 5, 10, 5);// 边距
gbc.gridy = 1;
jPanel.add(removeButton, gbc);
return jPanel;
}
public JPanel createRightPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setPreferredSize(new Dimension(this.getWidth() / 2 - 80, this.getHeight()));
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 10));
rightData = new String[][]{};
DefaultTableModel tableModel = new DefaultTableModel(rightData, new Object[]{"Column"}) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
@Override
public int getRowCount() {
return rightData.length;
}
@Override
public int getColumnCount() {
return 1;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return rightData[rowIndex][1];
}
};
rightTable = new JTable(tableModel);
rightTable.setTableHeader(null);
rightTable.setShowGrid(false);
rightTable.setRowHeight(22);
rightTable.setIntercellSpacing(new Dimension(0, 0));
rightTable.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
centerPanel.add(new JScrollPane(rightTable), BorderLayout.CENTER);
return centerPanel;
}
public void moveRight() {
int[] selectedRows = leftTable.getSelectedRows();
if (selectedRows.length == 0) {
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection", JOptionPane.WARNING_MESSAGE);
return;
}
String[][] newRightData = new String[rightData.length + selectedRows.length][];
System.arraycopy(rightData, 0, newRightData, 0, rightData.length);
for (int i = 0; i < selectedRows.length; i++) {
newRightData[rightData.length + i] = leftData[selectedRows[i]];
}
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
rightTableModel.setDataVector(newRightData, new Object[]{"Column"});
rightData = newRightData;
String[][] newLeftData = new String[leftData.length - selectedRows.length][];
int newIndex = 0;
for (int i = 0; i < leftData.length; i++) {
boolean isSelected = false;
for (int selectedRow : selectedRows) {
if (i == selectedRow) {
isSelected = true;
break;
}
}
if (!isSelected) {
newLeftData[newIndex++] = leftData[i];
}
}
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
leftTableModel.setDataVector(newLeftData, new Object[]{"Column"});
leftData = newLeftData;
}
public void moveLeft() {
int[] selectedRows = rightTable.getSelectedRows();
if (selectedRows.length == 0) {
JOptionPane.showMessageDialog(this, "Please select a row to move.", "No Selection", JOptionPane.WARNING_MESSAGE);
return;
}
String[][] newLeftData = new String[leftData.length + selectedRows.length][];
System.arraycopy(leftData, 0, newLeftData, 0, leftData.length);
for (int i = 0; i < selectedRows.length; i++) {
newLeftData[leftData.length + i] = rightData[selectedRows[i]];
}
DefaultTableModel leftTableModel = (DefaultTableModel) leftTable.getModel();
leftTableModel.setDataVector(newLeftData, new Object[]{"Column"});
leftData = newLeftData;
String[][] newRightData = new String[rightData.length - selectedRows.length][];
int newIndex = 0;
for (int i = 0; i < rightData.length; i++) {
boolean isSelected = false;
for (int selectedRow : selectedRows) {
if (i == selectedRow) {
isSelected = true;
break;
}
}
if (!isSelected) {
newRightData[newIndex++] = rightData[i];
}
}
DefaultTableModel rightTableModel = (DefaultTableModel) rightTable.getModel();
rightTableModel.setDataVector(newRightData, new Object[]{"Column"});
rightData = newRightData;
}
public void doTask(String name,String reason) throws Exception {
TCSession session = (TCSession) application.getSession();
int selectedRow = rightTable.getRowCount();
String[] uid = null;
if (selectedRow > 0) {
String[][] selectItems = new String[selectedRow][];
uid = new String[selectItems.length];
for (int i = 0; i < selectedRow; i++) {
String[] selectedItem = rightData[i];
selectItems[i] = selectedItem;
System.out.println("Selected Item: " + Arrays.toString(selectedItem));
}
for (int i = 0; i < selectItems.length; i++) {
uid[i] = selectItems[i][0];
}
}
TCComponentFolder xmwjj = (TCComponentFolder) TcUtil.judgeAndGetSingleSelectComponent(application,
new String[] { "VF5xmwjj" }, "Folder");
TCComponent[] components = xmwjj.getRelatedComponents("contents");
TCComponentFolder changeFolder = null;
for (TCComponent tcComponent : components) {
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
&& tcComponent.getStringProperty("object_name").equals("CHANGE DATA")) {
changeFolder = (TCComponentFolder) tcComponent;
break;
}
}
TCComponentItemRevision revision = null;
if(changeFolder!=null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyMM");
String localTime = formatter.format(LocalDateTime.now());
System.out.println("当前时间:" + localTime);
int maxNumber = 0;
InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find ItemRevision", new String[] {"ID"}, new String[] {"MECR-"+localTime+"-*"});
for (InterfaceAIFComponent result : queryList) {
String[] id = result.getProperty("item_id").split("-");
if(id !=null && id.length==3){
int localNo = Integer.parseInt(id[id.length-1]);
if(localNo>maxNumber) {
maxNumber = localNo;
}
}
}
String itemId = (maxNumber+1) + "";
int count = 2 - itemId.length();
for (int i = 0; i < count; i++) {
itemId = "0"+itemId;
}
TCComponentItem newItem = (TCComponentItem)TcUtil.createComponent(application
, new String[] {"MECR-"+localTime+"-"+itemId,"",name}, "VF5bgpsd", "Item");
revision = newItem.getLatestItemRevision();
TCComponent form = revision.getRelatedComponent("IMAN_master_form_rev");
form.setStringProperty("vf5bgyy", reason);
changeFolder.add("contents", newItem);
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
}else {
throw new CustomException("changeFolder is null !");
}
if(revision!=null && uid!=null & uid.length>0) {
TCComponent[] revList = session.stringToComponent(uid);
revision.add("VF5ggqdxgx", revList);
}else {
throw new CustomException("revision is null !");
}
}
}

@ -0,0 +1,156 @@
package com.connor.ferrorTech.metal.changeManagement.createECR;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
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.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ChangeApplyFormCreateHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
TCComponentFolder xmwjj = (TCComponentFolder) TcUtil.judgeAndGetSingleSelectComponent(application,
new String[] { "VF5xmwjj" }, "Folder");
try {
if (xmwjj != null) {
JLabel[] jLabels = new JLabel[] { new JLabel("Name"), new JLabel("Reason for Change") };
JComponent[] jComponents = new JComponent[] { new JTextField(20), new JTextField(20) };
List<TCComponentItemRevision> revisionList = getCcpItemRevision(application, xmwjj);
String[][] data = getData(revisionList);
ChangeApplyFormCreateDialog searchTemplate = new ChangeApplyFormCreateDialog(application,"Create ECR", jLabels,
jComponents,data);
new Thread(searchTemplate).start();
}
} catch (Exception e) {
// TODO: handle exception
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
}
return null;
}
private String[][] getData(List<TCComponentItemRevision> revisionList) throws TCException {
// TODO Auto-generated method stub
String[][] data = new String[revisionList.size()][];
if(revisionList!=null && revisionList.size()>0) {
int count = 0 ;
String name = "";
for (TCComponentItemRevision itemRevison : revisionList) {
String type = itemRevison.getStringProperty("object_type");
String[] rowData = new String[2];
String uid = itemRevison.getUid();
if(type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
String wlbm = itemRevison.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5wlbm");
name = wlbm +"-"+itemRevison.getStringProperty("object_name")+";"+itemRevison.getStringProperty("item_revision_id");
}else if(type.equals("VF5gyRevision")) {
name = itemRevison.getStringProperty("item_id") +"-"+itemRevison.getStringProperty("object_name")+";"+itemRevison.getStringProperty("item_revision_id");
}
rowData[0] = uid;
rowData[1] = name;
data[count++] = rowData;
}
return data;
}else {
return new String[][] {};
}
}
public List<TCComponentItemRevision> getCcpItemRevision(AbstractAIFApplication application, TCComponentFolder xmwjj) throws TCException {
// TODO Auto-generated method stub
TCSession session = (TCSession) application.getSession();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
// 创建视图
TCComponentBOMWindow view = winType.create(null);
// 发送BOM args:item对象 版本对象 ...
List<TCComponentItemRevision> revList = new ArrayList<>();
TCComponent[] components = xmwjj.getRelatedComponents("contents");
TCComponentFolder materialFolder = null;
TCComponentFolder porFolder = null;
for (TCComponent tcComponent : components) {
if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
&& tcComponent.getStringProperty("object_name").equals("MATERIAL AND BOM")) {
materialFolder = (TCComponentFolder) tcComponent;
} else if (tcComponent instanceof TCComponentFolder && tcComponent.getType().equals("Folder")
&& tcComponent.getStringProperty("object_name").equals("POR")) {
porFolder = (TCComponentFolder) tcComponent;
}
}
if (materialFolder != null) {
TCComponent[] materialChildren = materialFolder.getRelatedComponents("contents");
for (TCComponent tcItem : materialChildren) {
if (tcItem.getStringProperty("object_type").equals("VF5ccp")) {
TCComponentItem ccpItem = (TCComponentItem) tcItem;
TCComponentItemRevision ccpItemRev = ccpItem.getLatestItemRevision();
revList.add(ccpItemRev);
getBcpRevision(revList, view, ccpItem, ccpItemRev);
}
}
} else {
throw new CustomException("materialFolder is null ! ");
}
if (porFolder != null) {
TCComponent[] porChildren = porFolder.getRelatedComponents("contents");
for (TCComponent tcItem : porChildren) {
if (tcItem.getStringProperty("object_type").equals("VF5gy")) {
TCComponentItem gyItem = (TCComponentItem) tcItem;
TCComponentItemRevision gyItemRev = gyItem.getLatestItemRevision();
revList.add(gyItemRev);
}
}
} else {
throw new CustomException("porFolder is null ! ");
}
return revList;
}
public void getBcpRevision(List<TCComponentItemRevision> revList, TCComponentBOMWindow view,
TCComponentItem ccpItem, TCComponentItemRevision ccpItemRev) throws TCException {
TCComponentBOMLine bomLine = view.setWindowTopLine(ccpItem, ccpItemRev, null, null);
boolean hasChildren = bomLine.hasChildren();
if (hasChildren) {
AIFComponentContext[] childrena = bomLine.getChildren();
for (AIFComponentContext children : childrena) {
// 强转为TCComponentBOMLine类型
TCComponentItemRevision bcpItemRev = ((TCComponentBOMLine) children.getComponent()).getItemRevision();
if (bcpItemRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
revList.add(bcpItemRev);
}
}
}
}
}

@ -0,0 +1,24 @@
package com.connor.ferrorTech.metal.changeManagement.createECR;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
public class CustomTableCellRenderer extends DefaultTableCellRenderer {
private final Border noFocusBorder = BorderFactory.createEmptyBorder(1, 1, 1, 1);
private final Border focusBorder = new LineBorder(Color.YELLOW, 1);
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent c = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (isSelected) {
c.setBorder(focusBorder);
} else {
c.setBorder(noFocusBorder);
}
return c;
}
}

@ -0,0 +1,68 @@
package com.connor.ferrorTech.metal.constant;
public class ConstantPool {
public static final String EN_LABEL_UPLOAD_PATH = "Local path";
public static final String EN_TITLE_UPLOAD_PATH = "Please select the upload path";
public static final String EN_TITLE_IMPORT_PATH = "Please select the import path";
public static final String EN_TITLE_EXPORT_PATH = "Please select the export path";
public static final String EN_TITLE_DOWNLOAD_PATH = "Please select the download path";
public static final String EN_BUTTON_CONFIRM = "Confirm";
public static final String EN_BUTTON_CANCEL = "Cancel";
public static final String EN_BUTTON_SEARCH = "Search";
public static final String EN_BUTTON_SELECT = "Select";
public static final String EN_BUTTON_IMPORT = "Local Import";//本地导入
public static final String EN_BUTTON_EXPORT = "Local Export";
public static final String EN_BUTTON_CHOOSE = "CHOOSE";
public static final String EN_BUTTON_ADD = "Add Rows";
public static final String EN_BUTTON_DELETE = "Delete Row";
public static final String EN_BUTTON_MOVE_UP = "Move Up";
public static final String EN_BUTTON_MOVE_DOWN = "Move Down";
public static final String EN_MESSAGE_UPLOAD_ERROR = "Please enter or select the file path";
public static final String EN_MESSAGE_FILE_ERROR = "Invalid file path, not a directory !";
public static final String EN_MESSAGE_EXCEL_ERROR = "Invalid file path, not a directory !";
public static final String EN_MESSAGE_MOVE_UP = "Cannot move up, it is already the first line";
public static final String EN_MESSAGE_MOVE_DOWN = "Cannot move down, it is already the last line";
public static final String EN_MESSAGE_IMPORT = "Please enter or select the file path";
public static final String EN_MESSAGE_DELETE = "Please select the row to delete";
public static final String EN_MESSAGE_REV_ERROR = "Please select a Revision Item";
public static final String EN_MESSAGE_REV_TYPE_ERROR = "Please select the correct version";
public static final String EN_MESSAGE_Folder_ERROR = "Please select a file";
public static final String EN_MESSAGE_Folder_TYPE_ERROR = "Please select the correct file type";
public static final String CH_LABEL_UPLOAD_PATH = "本地上传路径";
public static final String CH_TITLE_UPLOAD_PATH = "请选择上传路径";
public static final String CH_TITLE_IMPORT_PATH = "请选择导入路径";
public static final String CH_TITLE_EXPORT_PATH = "请选择导出路径";
public static final String CH_TITLE_DOWNLOAD_PATH = "请选择下载路径";
public static final String CH_BUTTON_CONFIRM = "确定";
public static final String CH_BUTTON_CANCEL = "取消";
public static final String CH_BUTTON_SEARCH = "搜索";
public static final String CH_BUTTON_SELECT = "选择";
public static final String CH_BUTTON_IMPORT = "本地导入";
public static final String CH_BUTTON_EXPORT = "本地导出";
public static final String CH_BUTTON_CHOOSE = "选择";
public static final String CH_BUTTON_ADD = "添加行";
public static final String CH_BUTTON_DELETE = "删除行";
public static final String CH_BUTTON_MOVE_UP = "上移";
public static final String CH_BUTTON_MOVE_DOWN = "下移";
public static final String CH_MESSAGE_UPLOAD_ERROR = "请选择文件上传路径";
public static final String CH_MESSAGE_FILE_ERROR = "错误的文件路径,请选择一个目录";
public static final String CH_MESSAGE_EXCEL_ERROR = "文件路径无效,不是目录";
public static final String CH_MESSAGE_MOVE_UP = "无法向上移动,它已经是第一行了";
public static final String CH_MESSAGE_MOVE_DOWN = "无法向下移动,它已经是最后一行了";
public static final String CH_MESSAGE_IMPORT = "请输入或选择文件路径";
public static final String CH_MESSAGE_DELETE = "请选择要删除的行";
public static final String CH_MESSAGE_REV_ERROR = "请选择版本对象";
public static final String CH_MESSAGE_REV_TYPE_ERROR = "请选择正确的版本";
public static final String CH_MESSAGE_Folder_ERROR = "请选择文件";
public static final String CH_MESSAGE_Folder_TYPE_ERROR = "请选择正确的文件类型";
}

@ -0,0 +1,19 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.AinternalDrawing;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateInternalDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0){
AbstractAIFApplication application =AIFUtility.getCurrentApplication();
CommonAction commonAction = new CommonAction(application,"VF5idgx","VF5nbtz","Internal Drawing","-ID");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,18 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.BprocessControl;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateProcessControlHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CommonAction commonAction = new CommonAction(application, "VF5pcgx", "VF5procctrl","Process Control","-PC");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,194 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
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 CommonAction implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentItemRevision[] tarRevs;
private String revReference;
private String itemType;
private String itemName;
private String ruleName;
public CommonAction(AbstractAIFApplication application, String revReference, String type, String name,
String ruleName) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.revReference = revReference;
this.itemType = type;
this.ruleName = ruleName;
// TODO Auto-generated constructor stub
}
@Override
public void run() {
boolean revFlag = false;
try {
revFlag = isCcpRevision();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!revFlag) {
MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
} else if (tarRevs == null && tarRevs.length == 0) {
MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
} else {
Map<String, String> nullMap = isExistNull();
if (nullMap.isEmpty()) {
System.out.println("enter createNbtzItem()");
createNbtzItem();
} else {
StringBuffer str = new StringBuffer("");
Set<String> keySet = nullMap.keySet();
for (String key : keySet) {
int count = 0;
if (count == 0) {
str.append("\n" + key + " | " + nullMap.get(key));
} else if (count == keySet.size() - 1) {
str.append(key + " | " + nullMap.get(key) + "\n");
} else {
str.append(key + " | " + nullMap.get(key));
}
}
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
}
}
}
public boolean isCcpRevision() throws TCException {
// TODO Auto-generated method stub
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
System.out.println("length: " + targetComponents.length);
List<TCComponentItemRevision> tempComponents = new ArrayList<>();
for (InterfaceAIFComponent targetComponent : targetComponents) {
System.out.println("enter judge");
if (targetComponent instanceof TCComponentItemRevision) {
TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
if (!tempComponentRev.getStringProperty("object_type").equals("VF5ccpRevision")) {
System.out.println("false");
return false;
} else {
System.out.println("true");
tempComponents.add(tempComponentRev);
}
} else if (targetComponent instanceof TCComponentBOMLine) {
try {
TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
if (!tempComponentRev.getStringProperty("object_type").equals("VF5ccpRevision")) {
return false;
} else {
tempComponents.add(tempComponentRev);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
System.out.println("tempComponents.size: " + tempComponents.size());
tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
return true;
}
public Map<String, String> isExistNull() {
Map<String, String> errorMap = new HashMap<>();
for (InterfaceAIFComponent targetComponent : tarRevs) {
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
try {
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
String property = referenceValueArray[0].getStringProperty("vf5wlbm");
if (property.isEmpty()) {
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
}
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("isExistNull is error !");
e.printStackTrace();
}
}
return errorMap;
}
public void createNbtzItem() {
try {
System.out.println("tarRevs: "+tarRevs.length);
if (tarRevs != null && tarRevs.length > 0) {
boolean flag = true;
for (TCComponentItemRevision targetRev : tarRevs) {
if (judgeIsExist(targetRev)) {
TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
String property = targetRevForm[0].getStringProperty("vf5khth");
String pn = targetRevForm[0].getStringProperty("vf5wlbm");
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
if (tzItem != null) {
TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
newTcItemRevForm[0].setStringProperty("vf5khth", property);
newTcItemRevForm[0].setStringProperty("vf5pn", pn);
targetRev.add(revReference, tzItem);
} else {
flag = false;
}
}
}
if(flag) {
MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
}else {
MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
}
} else {
MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
if(targetRev!=null) {
TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
System.out.println("item: " + targetRev.getStringProperty("object_name"));
if (tzReferences != null && tzReferences.length > 0) {
for (int i = 0; i < tzReferences.length; i++) {
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
System.out.println("it's exist!");
return false;
}
}
}
}else {
throw new CustomException("targetRev is null");
}
return true;
}
}

@ -0,0 +1,20 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateRedlineDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CommonAction commonAction = new CommonAction(application, "VF5rdgx", "VF5jctz","Redline Drawing","-RD");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,194 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
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 CreateRawMaterialDrawingAction implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentItemRevision[] tarRevs;
private String revReference;
private String itemType;
private String itemName;
private String ruleName;
public CreateRawMaterialDrawingAction(AbstractAIFApplication application, String revReference, String type, String name,
String ruleName) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.revReference = revReference;
this.itemType = type;
this.ruleName = ruleName;
// TODO Auto-generated constructor stub
}
@Override
public void run() {
boolean revFlag = false;
try {
revFlag = isCcpRevision();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!revFlag) {
MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
} else if (tarRevs == null && tarRevs.length == 0) {
MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
} else {
Map<String, String> nullMap = isExistNull();
if (nullMap.isEmpty()) {
System.out.println("enter createNbtzItem()");
createNbtzItem();
} else {
StringBuffer str = new StringBuffer("");
Set<String> keySet = nullMap.keySet();
for (String key : keySet) {
int count = 0;
if (count == 0) {
str.append("\n" + key + " | " + nullMap.get(key));
} else if (count == keySet.size() - 1) {
str.append(key + " | " + nullMap.get(key) + "\n");
} else {
str.append(key + " | " + nullMap.get(key));
}
}
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
}
}
}
public boolean isCcpRevision() throws TCException {
// TODO Auto-generated method stub
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
System.out.println("length: " + targetComponents.length);
List<TCComponentItemRevision> tempComponents = new ArrayList<>();
for (InterfaceAIFComponent targetComponent : targetComponents) {
System.out.println("enter judge");
if (targetComponent instanceof TCComponentItemRevision) {
TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
if (!tempComponentRev.getStringProperty("object_type").equals("VF5clRevision")) {
System.out.println("false");
return false;
} else {
System.out.println("true");
tempComponents.add(tempComponentRev);
}
} else if (targetComponent instanceof TCComponentBOMLine) {
try {
TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
if (!tempComponentRev.getStringProperty("object_type").equals("VF5clRevision")) {
return false;
} else {
tempComponents.add(tempComponentRev);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
System.out.println("tempComponents.size: " + tempComponents.size());
tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
return true;
}
public Map<String, String> isExistNull() {
Map<String, String> errorMap = new HashMap<>();
for (InterfaceAIFComponent targetComponent : tarRevs) {
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
try {
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
String property = referenceValueArray[0].getStringProperty("vf5wlbm");
if (property.isEmpty()) {
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
}
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("isExistNull is error !");
e.printStackTrace();
}
}
return errorMap;
}
public void createNbtzItem() {
try {
System.out.println("tarRevs: "+tarRevs.length);
if (tarRevs != null && tarRevs.length > 0) {
boolean flag = true;
for (TCComponentItemRevision targetRev : tarRevs) {
if (judgeIsExist(targetRev)) {
TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
String property = targetRevForm[0].getStringProperty("vf5khth");
String pn = targetRevForm[0].getStringProperty("vf5wlbm");
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
if (tzItem != null) {
TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
newTcItemRevForm[0].setStringProperty("vf5khth", property);
newTcItemRevForm[0].setStringProperty("vf5pn", pn);
targetRev.add(revReference, tzItem);
} else {
flag = false;
}
}
}
if(flag) {
MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
}else {
MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
}
} else {
MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
if(targetRev!=null) {
TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
System.out.println("item: " + targetRev.getStringProperty("object_name"));
if (tzReferences != null && tzReferences.length > 0) {
for (int i = 0; i < tzReferences.length; i++) {
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
System.out.println("it's exist!");
return false;
}
}
}
}else {
throw new CustomException("targetRev is null");
}
return true;
}
}

@ -0,0 +1,21 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateRawMaterialDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateRawMaterialDrawingAction commonAction = new CreateRawMaterialDrawingAction(application, "VF5rmgx", "VF5ycltz","Raw Material Drawing","-RM");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,194 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
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 CreateSubPartsDrawingAction implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentItemRevision[] tarRevs;
private String revReference;
private String itemType;
private String itemName;
private String ruleName;
public CreateSubPartsDrawingAction(AbstractAIFApplication application, String revReference, String type, String name,
String ruleName) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.revReference = revReference;
this.itemType = type;
this.ruleName = ruleName;
// TODO Auto-generated constructor stub
}
@Override
public void run() {
boolean revFlag = false;
try {
revFlag = isCcpRevision();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!revFlag) {
MessageBox.post("There are unexpected types in the selected version !", "error", MessageBox.ERROR);
} else if (tarRevs == null && tarRevs.length == 0) {
MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
} else {
Map<String, String> nullMap = isExistNull();
if (nullMap.isEmpty()) {
System.out.println("enter createNbtzItem()");
createNbtzItem();
} else {
StringBuffer str = new StringBuffer("");
Set<String> keySet = nullMap.keySet();
for (String key : keySet) {
int count = 0;
if (count == 0) {
str.append("\n" + key + " | " + nullMap.get(key));
} else if (count == keySet.size() - 1) {
str.append(key + " | " + nullMap.get(key) + "\n");
} else {
str.append(key + " | " + nullMap.get(key));
}
}
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
}
}
}
public boolean isCcpRevision() throws TCException {
// TODO Auto-generated method stub
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
System.out.println("length: " + targetComponents.length);
List<TCComponentItemRevision> tempComponents = new ArrayList<>();
for (InterfaceAIFComponent targetComponent : targetComponents) {
System.out.println("enter judge");
if (targetComponent instanceof TCComponentItemRevision) {
TCComponentItemRevision tempComponentRev = (TCComponentItemRevision) targetComponent;
if (!tempComponentRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
System.out.println("false");
return false;
} else {
System.out.println("true");
tempComponents.add(tempComponentRev);
}
} else if (targetComponent instanceof TCComponentBOMLine) {
try {
TCComponentItemRevision tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
if (!tempComponentRev.getStringProperty("object_type").equals("VF5bcpRevision")) {
return false;
} else {
tempComponents.add(tempComponentRev);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
System.out.println("tempComponents.size: " + tempComponents.size());
tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
return true;
}
public Map<String, String> isExistNull() {
Map<String, String> errorMap = new HashMap<>();
for (InterfaceAIFComponent targetComponent : tarRevs) {
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
try {
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
String property = referenceValueArray[0].getStringProperty("vf5wlbm");
if (property.isEmpty()) {
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
}
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("isExistNull is error !");
e.printStackTrace();
}
}
return errorMap;
}
public void createNbtzItem() {
try {
System.out.println("tarRevs: "+tarRevs.length);
if (tarRevs != null && tarRevs.length > 0) {
boolean flag = true;
for (TCComponentItemRevision targetRev : tarRevs) {
if (judgeIsExist(targetRev)) {
TCComponent[] targetRevForm = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
String property = targetRevForm[0].getStringProperty("vf5khth");
String pn = targetRevForm[0].getStringProperty("vf5wlbm");
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
TCComponentItem tzItem = tzType.create(pn + ruleName, "", itemType, itemName, "", null);
if (tzItem != null) {
TCComponentItemRevision newTcItemRev = tzItem.getLatestItemRevision();
TCComponent[] newTcItemRevForm = newTcItemRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
newTcItemRevForm[0].setStringProperty("vf5khth", property);
newTcItemRevForm[0].setStringProperty("vf5pn", pn);
targetRev.add(revReference, tzItem);
} else {
flag = false;
}
}
}
if(flag) {
MessageBox.post("Creation Item Succuessful !", "Info", MessageBox.INFORMATION);
}else {
MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
}
} else {
MessageBox.post("targetComponents is null !", "Error", MessageBox.ERROR);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
public boolean judgeIsExist(TCComponentItemRevision targetRev ) throws TCException {
if(targetRev!=null) {
TCComponent[] tzReferences = targetRev.getRelatedComponents(revReference);
System.out.println("item: " + targetRev.getStringProperty("object_name"));
if (tzReferences != null && tzReferences.length > 0) {
for (int i = 0; i < tzReferences.length; i++) {
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
System.out.println("it's exist!");
return false;
}
}
}
}else {
throw new CustomException("targetRev is null");
}
return true;
}
}

@ -0,0 +1,20 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.EsubPartsDrawing;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateSubPartsDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateSubPartsDrawingAction commonAction = new CreateSubPartsDrawingAction(application, "VF5spgx", "VF5bcptz","Sub-Parts Drawing","-SP");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,20 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.FsetupSheet;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.CommonAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateSetupSheetHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CommonAction commonAction = new CommonAction(application, "VF5ssgx", "VF5setupsheet","Setup Sheet","-SS");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,255 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateReworkInstructionAction implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentItemRevision[] tarRevs;
private String revReference;
private String itemType;
private String itemName;
private String ruleName;
private String[][] idList;
public CreateReworkInstructionAction(AbstractAIFApplication application, String revReference, String type,
String name, String ruleName) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.revReference = revReference;
this.itemType = type;
this.itemName = name;
this.ruleName = ruleName;
}
@Override
public void run() {
String errorName = null;
try {
errorName = isCcpOrGxRevision();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (errorName == null) {
MessageBox.post("Please select version object !", "error", MessageBox.ERROR);
} else if (!errorName.isEmpty()) {
MessageBox.post("Please select the finished product or process version !\n" + errorName, "error",
MessageBox.ERROR);
} else {
Map<String, String> nullMap = null;
try {
nullMap = isExistNull();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (nullMap != null && nullMap.isEmpty()) {
createNbtzItem();
} else {
StringBuffer str = new StringBuffer("");
Set<String> keySet = nullMap.keySet();
for (String key : keySet) {
int count = 0;
if (count == 0) {
str.append("\n" + key + " | " + nullMap.get(key));
} else if (count == keySet.size() - 1) {
str.append(key + " | " + nullMap.get(key) + "\n");
} else {
str.append(key + " | " + nullMap.get(key));
}
}
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
}
}
}
public String isCcpOrGxRevision() throws TCException {
// TODO Auto-generated method stub
InterfaceAIFComponent[] targetComponents = application.getTargetComponents();
List<TCComponentItemRevision> tempComponents = new ArrayList<>();
String type = "";
for (InterfaceAIFComponent targetComponent : targetComponents) {
TCComponentItemRevision tempComponentRev = null;
if (targetComponent instanceof TCComponentItemRevision) {
tempComponentRev = (TCComponentItemRevision) targetComponent;
} else if (targetComponent instanceof TCComponentBOMLine) {
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
}
type = tempComponentRev.getStringProperty("object_type");
if (!(type.equals("VF5ccpRevision") || type.equals("VF5gxRevision"))) {
return tempComponentRev.getStringProperty("object_name");
}else {
tempComponents.add(tempComponentRev);
}
}
tarRevs = tempComponents.toArray(new TCComponentItemRevision[tempComponents.size()]);
return "";
}
public Map<String, String> isExistNull() throws TCException {
Map<String, String> errorMap = new HashMap<>();
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
SwingUtil.getKeyValue("VF5gxlxlov", lovMap);
idList = new String[tarRevs.length][3];
for (InterfaceAIFComponent targetComponent : tarRevs) {
int count = 0;
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
TCComponentForm formItem = null;
String pnValue = "";
String processValue = "";
String sequenceValue = "";
String tarType = targetRev.getStringProperty("object_type");
if (tarType.equals("VF5ccpRevision")) {
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
formItem = (TCComponentForm) referenceValueArray[0];
pnValue = formItem.getStringProperty("vf5wlbm");
processValue = "N";
sequenceValue = "0";
} else if (tarType.equals("VF5gxRevision")) {
sequenceValue = getBomLineRowNumber((TCComponentItemRevision) targetRev);
TCComponentItemRevision gyRev = null;
TCComponent[] whereUsed = targetRev.whereUsed((short) 0);
if (whereUsed != null && whereUsed.length > 0) {
for (TCComponent tcItem : whereUsed) {
if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
gyRev = (TCComponentItemRevision) tcItem;
break;
}
}
} else {
MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
}
if (gyRev != null) {
String innerType = "";
TCComponent[] ccpItems = gyRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
for (TCComponent ccpItem : ccpItems) {
innerType = ccpItem.getStringProperty("object_type");
if (innerType.equals("VF5ccpRevision") || innerType.equals("VF5bcpRevision")) {
TCComponentForm gxForm = (TCComponentForm)targetRev.getRelatedComponent("IMAN_master_form_rev");
formItem = (TCComponentForm)ccpItem.getRelatedComponent("IMAN_master_form_rev");
// processValue = lovMap.get("VF5gxlxlov").get(formItem.getStringProperty("vf5gxlx"));
String vf5gxlx = gxForm.getStringProperty("vf5gxlx");
System.out.println("vf5gxlx : "+vf5gxlx);
processValue = vf5gxlx;
pnValue = formItem.getStringProperty("vf5wlbm");
break;
}
}
} else {
throw new CustomException(
targetRev.getStringProperty("object_name") + " : parent's item is not exist !");
}
}
System.out.println(
"pnValue:" + pnValue + " | processValue:" + processValue + " | sequenceValue:" + sequenceValue);
idList[count][0] = pnValue;
idList[count][1] = processValue;
idList[count++][2] = sequenceValue;
if (formItem != null) {
String property = formItem.getStringProperty("vf5wlbm");
if (property.isEmpty()) {
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
}
} else {
System.out.println("cannot get form item !");
}
}
return errorMap;
}
public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
String localId = itemRev.getStringProperty("item_id");
TCComponentBOMLine bomLine = null;
TCComponentBOMWindow view = null;
if (whereUsed != null && whereUsed.length > 0) {
TCComponentItemRevision itemType = (TCComponentItemRevision) whereUsed[0];
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
view = winType.create(null);
bomLine = view.setWindowTopLine(itemType.getItem(), itemType, null, null);
} else {
MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
}
if (bomLine != null && bomLine.hasChildren()) {
// »ñÈ¡×Ó¼þ
AIFComponentContext[] childrena = bomLine.getChildren();
for (int i = 0; i < childrena.length; i++) {
// ǿתΪTCComponentBOMLineÀàÐÍ
TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
return i + 1 + "";
}
}
}
return "";
}
public void createNbtzItem() {
try {
boolean createFlag = true;
for (InterfaceAIFComponent targetComponent : tarRevs) {
int count = 0;
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
boolean flag = true;
if (tzReferences != null && tzReferences.length > 0) {
for (int i = 0; i < tzReferences.length; i++) {
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
flag = false;
}
}
}
if (flag) {
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
TCComponentItem tzItem = tzType.create(
idList[count][0] + ruleName + idList[count][1] + idList[count++][2], "", itemType, itemName,
"", null);
if (tzItem != null) {
targetRev.add(revReference, tzItem);
} else {
createFlag = false;
}
}
}
if(createFlag) {
MessageBox.post("Creation Item Successful !", "Info", MessageBox.INFORMATION);
}else {
MessageBox.post("Creation Item Error !", "Error", MessageBox.ERROR);
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}

@ -0,0 +1,19 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.GreworkInstruction;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateReworkInstructionHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateReworkInstructionAction commonAction = new CreateReworkInstructionAction(application, "VF5rwigx", "VF5rwi","Rework Work Instruction","-RWI-");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,225 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
/**
* used: HncFile || IprocessDrawing || JpreMillDrawing
*
* @author Administrator
*
*/
public class GxTemplateAction implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentItemRevision[] gyRevs;
private TCComponentItemRevision[] gxRevs;
private String revReference;
private String itemType;
private String itemName;
private String ruleName;
public GxTemplateAction(AbstractAIFApplication application, String revReference, String type, String name,
String ruleName) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.revReference = revReference;
this.itemType = type;
this.itemName = name;
this.ruleName = ruleName;
}
@Override
public void run() {
try {
gyRevs = judgeSelectRevision(application);
} catch (Exception e1) {
// TODO Auto-generated catch block
MessageBox.post(e1.getMessage(), "Error", MessageBox.ERROR);
}
if (gyRevs != null) {
Map<String, String> nullMap = null;
String[] pnValue = null;
try {
pnValue = new String[gyRevs.length];
nullMap = isExistNull(pnValue);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (nullMap != null && nullMap.isEmpty()) {
createNbtzItem(pnValue);
} else {
StringBuffer str = new StringBuffer("");
Set<String> keySet = nullMap.keySet();
for (String key : keySet) {
int count = 0;
if (count == 0) {
str.append("\n" + key + " | " + nullMap.get(key));
} else if (count == keySet.size() - 1) {
str.append(key + " | " + nullMap.get(key) + "\n");
} else {
str.append(key + " | " + nullMap.get(key));
}
}
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
}
}
}
public TCComponentItemRevision[] judgeSelectRevision(AbstractAIFApplication application) throws Exception {
InterfaceAIFComponent[] selectComponents = application.getTargetComponents();
List<TCComponentItemRevision> gyRevList = new ArrayList<>();
List<TCComponentItemRevision> gxRevList = new ArrayList<>();
try {
for (InterfaceAIFComponent targetComponent : selectComponents) {
TCComponentItemRevision tempComponentRev = null;
if (targetComponent instanceof TCComponentItemRevision) {
tempComponentRev = (TCComponentItemRevision) targetComponent;
} else if (targetComponent instanceof TCComponentBOMLine) {
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
} else {
MessageBox.post(
"Please Select Rule Version Object !\n" + targetComponent.getProperty("object_name"),
"Error", MessageBox.ERROR);
return null;
}
gxRevList.add(tempComponentRev);
TCComponent[] whereUsed = tempComponentRev.whereUsed((short) 0);
TCComponentItemRevision gyRev = null;
if (whereUsed != null && whereUsed.length > 0) {
for (TCComponent tcItem : whereUsed) {
System.out.println("tcItem : " + tcItem.getStringProperty("object_name"));
System.out.println("tcItem : " + tcItem.getStringProperty("object_type"));
if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
gyRev = (TCComponentItemRevision) tcItem;
gyRevList.add(gyRev);
break;
}
}
if (gyRev == null) {
throw new CustomException(
tempComponentRev.getStringProperty("object_name") + " : parent's item is not exist !");
}
}else {
throw new CustomException(
tempComponentRev.getStringProperty("object_name") + " : parent's item is not exist !");
}
}
} catch (TCException e) {
e.printStackTrace();
}
gxRevs = gxRevList.toArray(new TCComponentItemRevision[gxRevList.size()]);
return gyRevList.toArray(new TCComponentItemRevision[gyRevList.size()]);
}
public Map<String, String> isExistNull(String pnValue[]) throws TCException {
Map<String, String> errorMap = new HashMap<>();
for (TCComponentItemRevision gyItemRev : gyRevs) {
int count = 0;
TCComponentForm formItem = null;
TCComponent[] ccpItems = gyItemRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
for (TCComponent ccpItem : ccpItems) {
String type = ccpItem.getStringProperty("object_type");
if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision") ) {
TCComponent[] referenceValueArray = ccpItem.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
formItem = (TCComponentForm) referenceValueArray[0];
break;
}
}
if (formItem != null) {
String wlbm = formItem.getStringProperty("vf5wlbm");
pnValue[count++] = wlbm;
if (wlbm !=null && (wlbm.isEmpty() || wlbm.equals("null"))) {
errorMap.put(gyItemRev.getStringProperty("item_id"), gyItemRev.getStringProperty("object_name"));
}
} else {
System.out.println("cannot get form item !");
}
}
return errorMap;
}
public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
String localId = itemRev.getStringProperty("item_id");
TCComponentBOMLine bomLine = null;
TCComponentBOMWindow view = null;
if (whereUsed != null && whereUsed.length > 0) {
TCComponentItemRevision itemType = (TCComponentItemRevision) whereUsed[0];
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
view = winType.create(null);
bomLine = view.setWindowTopLine(itemType.getItem(), itemType, null, null);
} else {
MessageBox.post("The current object is not referenced !", "error", MessageBox.ERROR);
}
if (bomLine != null && bomLine.hasChildren()) {
AIFComponentContext[] childrena = bomLine.getChildren();
for (int i = 0; i < childrena.length; i++) {
TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
return i + 1 + "";
}
}
}
return "";
}
public void createNbtzItem(String[] pnValue) {
for (TCComponentItemRevision targetRev : gxRevs) {
int count = 0;
try {
TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
boolean flag = true;
if (tzReferences != null && tzReferences.length > 0) {
for (int i = 0; i < tzReferences.length; i++) {
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
flag = false;
}
}
}
if (flag) {
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
TCComponentItem tzItem = tzType.create(pnValue[count++] + ruleName, "", itemType, itemName, "",
null);
if (tzItem != null) {
targetRev.add(revReference, tzItem);
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} else {
MessageBox.post("Creation Failed !", "Error", MessageBox.ERROR);
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

@ -0,0 +1,20 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.HncFile;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateNcFileHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5ncgx", "VF5ncfile","NC File","-NC");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,20 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.IprocessDrawing;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateProcessDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5pdgx", "VF5gytz","Process Drawing","-PD");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,21 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.JpreMillDrawing;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreatePreMillDrawingHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5pmgx", "VF5yjgtz","Pre-Mill Drawing","-PM");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,174 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing;
import javax.swing.*;
import org.apache.commons.compress.harmony.unpack200.bytecode.forms.LocalForm;
import java.awt.*;
import java.util.LinkedHashMap;
import java.util.Map;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemType;
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 CreateJitFixtureDialog extends AbstractAIFDialog {
private AbstractAIFApplication application;
private String title;
private int[] sizes;
private JLabel[] jLabels;
private JComponent[] jComponents;
private JButton okButton;
private JButton celButton;
private Map<String, Map<String, String>> lovMap;
public CreateJitFixtureDialog(AbstractAIFApplication application, String title, Object... args) {
super(true);
int count = 0;
this.title = title;
this.application = application;
this.sizes = (int[]) args[count++];
this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++];
this.lovMap = (Map<String, Map<String, String>>) args[count];
}
@Override
public void run() {
initUI();
}
public void initUI() {
this.setTitle(title);
this.setSize(sizes[0], sizes[1]);
initializationComponent();
JScrollPane centerPanel = getCenterPanel();
JPanel bottomPanel = getBottomPanel();
this.getContentPane().add(centerPanel, BorderLayout.CENTER);
this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setVisible(true);
}
private void initializationComponent() {
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
}
private JScrollPane getCenterPanel() {
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints customLayout = new GridBagConstraints();
for (int i = 0; i < jLabels.length; i++) {
customLayout.insets = new Insets(5, 30, 5, 20);
customLayout.gridx = 0;
customLayout.weightx = 0;
customLayout.anchor = GridBagConstraints.LINE_START;
jLabels[i].setFont(new Font("΢ÈíÑźÚ", Font.BOLD, 13));
centerPanel.add(jLabels[i], customLayout);
customLayout.insets = new Insets(5, 3, 5, 30);
customLayout.gridx = 1;
customLayout.weightx = 0;
customLayout.fill = GridBagConstraints.HORIZONTAL;
JComponent jComponent = jComponents[i];
jComponent.setFont(new Font("΢ÈíÑźÚ", Font.BOLD, 15));
centerPanel.add(jComponent, customLayout);
}
return new JScrollPane(centerPanel);
}
private JPanel getBottomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
bottomPanel.setBorder(BorderFactory.createEmptyBorder(sizes[2], 0, sizes[3], 0));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
okButton.addActionListener(e -> {
boolean confirmed = confirmFunction();
if (confirmed) {
this.dispose();
}
});
celButton.addActionListener(e -> {
this.dispose();
});
return bottomPanel;
}
public boolean confirmFunction() {
String[] inputValue = new String[jComponents.length];
for (int i = 0; i < jComponents.length; i++) {
if (jComponents[i] instanceof JTextField) {
inputValue[i] = ((JTextField) jComponents[i]).getText();
} else if (jComponents[i] instanceof JComboBox) {
JComboBox comboBox = (JComboBox) jComponents[i];
Object selectedItem = comboBox.getSelectedItem();
inputValue[i] = (selectedItem != null) ? selectedItem.toString() : "";
}
}
try {
createItem(inputValue);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
private void createItem(String[] inputValue) throws Exception {
// TODO Auto-generated method stub
InterfaceAIFComponent[] queryList = TcUtil.queryList(application, "MU_Find Jit_Fixture Flow",
new String[] { "ID" }, new String[] { "MJF*" });
int maxFlowNo = 0;
for (InterfaceAIFComponent tcItem : queryList) {
String itemId = tcItem.getProperty("item_id");
String[] split = itemId.split("-");
if (split != null && split.length > 2) {
int localFlowNo = Integer.parseInt(split[2]);
if (localFlowNo >= maxFlowNo) {
maxFlowNo = localFlowNo;
}
}
}
String strMaxFlowNo = (maxFlowNo + 1) + "";
int addZero = 5 - strMaxFlowNo.length();
for (int i = 0; i < addZero; i++) {
strMaxFlowNo = "0" + strMaxFlowNo;
}
String realProcess = lovMap.get("VF5gxlxlov").get(inputValue[0]);
String name = inputValue[inputValue.length - 1].isEmpty() ? "Jit-Fixture Drawing"
: inputValue[inputValue.length - 1];
String itemId = "MJF-" + realProcess + inputValue[1] + "-" + strMaxFlowNo + "-"
+ inputValue[inputValue.length - 2];
System.out.println("itemId : "+itemId);
TCComponentItem newComponent = (TCComponentItem) TcUtil.createComponent(application,
new String[] { itemId, "", name }, "VF5gzjtz", "Item");
if (newComponent != null) {
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} else {
MessageBox.post("Created Failed !", "Error", MessageBox.ERROR);
}
((TCComponentFolder) application.getTargetComponent()).add("contents", newComponent);
}
}

@ -0,0 +1,51 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.JrjitFixtureDrawing;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCSession;
import javax.swing.*;
import java.util.HashMap;
import java.util.Map;
public class CreateJitFixtureHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"Folder","VF5xmwjj"}, "Folder");
if(judgeSingleSelectComponent) {
String[] enLabelName = new String[]{
"Process", "Process Sequence", "Property","Name"
};
JLabel[] jLabels = new JLabel[enLabelName.length];
JComponent[] jComponents = new JComponent[enLabelName.length];
Map<Integer, String[]> map = new HashMap<>();
Map<String, Map<String, String>> lovMap = new HashMap<String,Map<String, String>>();
map.put(0, SwingUtil.getKeyValue("VF5gxlxlov", lovMap));
map.put(1, TcUtil.getPreferenceValues((TCSession)application.getSession(), "VF5ProcessSequence"));
for (int i = 0; i < enLabelName.length; i++) {
if (map.containsKey(i)) {
jComponents[i] = new JComboBox<>(map.get(i));
} else {
jComponents[i] = new JTextField(14);
}
jLabels[i] = new JLabel(enLabelName[i]);
}
CreateJitFixtureDialog dialog = new CreateJitFixtureDialog(application,"create Jit-Fixture Drawing", new int[]{430, 400,5,5},jLabels, jComponents,lovMap);
new Thread(dialog).start();
}
return null;
}
}

@ -0,0 +1,237 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateToolingListAction implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private InterfaceAIFComponent[] targetComponents;
private String revReference;
private String itemType;
private String itemName;
private String ruleName;
private String[][] idList;
public CreateToolingListAction(AbstractAIFApplication application, String revReference, String type, String name,
String ruleName) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.revReference = revReference;
this.itemType = type;
this.itemName = name;
this.ruleName = ruleName;
}
@Override
public void run() {
try {
targetComponents = judgeSelectRevision(application);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (targetComponents != null) {
Map<String, String> nullMap = null;
try {
nullMap = isExistNull();
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (nullMap != null && nullMap.isEmpty()) {
createNbtzItem();
} else {
StringBuffer str = new StringBuffer("");
Set<String> keySet = nullMap.keySet();
for (String key : keySet) {
int count = 0;
if (count == 0) {
str.append("\n" + key + " | " + nullMap.get(key));
} else if (count == keySet.size() - 1) {
str.append(key + " | " + nullMap.get(key) + "\n");
} else {
str.append(key + " | " + nullMap.get(key));
}
}
MessageBox.post("The material code cannot be empty !" + str.toString(), "error", MessageBox.ERROR);
}
}
}
public TCComponentItemRevision[] judgeSelectRevision(AbstractAIFApplication application) throws Exception {
InterfaceAIFComponent[] selectComponents = application.getTargetComponents();
List<TCComponentItemRevision> gxRevList = new ArrayList<>();
try {
for (InterfaceAIFComponent targetComponent : selectComponents) {
TCComponentItemRevision tempComponentRev = null;
if (targetComponent instanceof TCComponentItemRevision) {
tempComponentRev = (TCComponentItemRevision) targetComponent;
} else if (targetComponent instanceof TCComponentBOMLine) {
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
}
if (tempComponentRev != null
&& tempComponentRev.getStringProperty("object_type").equals("VF5gxRevision")) {
gxRevList.add(tempComponentRev);
} else {
MessageBox.post(
"Please Select Rule Version Object !\n" + targetComponent.getProperty("object_name"),
"Error", MessageBox.ERROR);
return null;
}
}
} catch (TCException e) {
e.printStackTrace();
}
return gxRevList.toArray(new TCComponentItemRevision[gxRevList.size()]);
}
public Map<String, String> isExistNull() throws TCException {
Map<String, String> errorMap = new HashMap<>();
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
SwingUtil.getKeyValue("VF5gxlxlov", lovMap);
idList = new String[targetComponents.length][3];
for (InterfaceAIFComponent targetComponent : targetComponents) {
int count = 0;
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
TCComponent ccpForm = null;
String pnValue = "";
String processValue = "";
String sequenceValue = getBomLineRowNumber((TCComponentItemRevision) targetRev);
TCComponentItemRevision gyRev = null;
TCComponent[] whereUsed = targetRev.whereUsed((short) 0);
if (whereUsed != null && whereUsed.length > 0) {
for (TCComponent tcItem : whereUsed) {
if (tcItem.getStringProperty("object_type").equals("VF5gyRevision")) {
gyRev = (TCComponentItemRevision) tcItem;
break;
}
}
} else {
MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
}
if (gyRev != null) {
TCComponent[] ccpItems = gyRev.getTCProperty("IMAN_METarget").getReferenceValueArray();
String type ="";
for (TCComponent ccpItem : ccpItems) {
type = ccpItem.getStringProperty("object_type");
if (type.equals("VF5ccpRevision") || type.equals("VF5bcpRevision")) {
ccpForm = ccpItem.getRelatedComponent("IMAN_master_form_rev");
pnValue = ccpForm.getStringProperty("vf5wlbm");
TCComponent gxForm = targetRev.getRelatedComponent("IMAN_master_form_rev");
String gxlx = gxForm.getStringProperty("vf5gxlx");
System.out.println("gxForm(vf5gxlx) : " + gxlx);
processValue = gxlx;
break;
}
}
} else {
throw new CustomException(
targetRev.getStringProperty("object_name") + " : parent's item is not exist !");
}
System.out.println(
"pnValue:" + pnValue + " | processValue:" + processValue + " | sequenceValue:" + sequenceValue);
idList[count][0] = pnValue;
idList[count][1] = processValue;
idList[count++][2] = sequenceValue;
if (ccpForm != null) {
String property = ccpForm.getStringProperty("vf5wlbm");
if (property.isEmpty()) {
errorMap.put(targetRev.getStringProperty("item_id"), targetRev.getStringProperty("object_name"));
}
} else {
System.out.println("cannot get form item !");
}
}
return errorMap;
}
public String getBomLineRowNumber(TCComponentItemRevision itemRev) throws TCException {
TCComponent[] whereUsed = itemRev.whereUsed((short) 0);
String localId = itemRev.getStringProperty("item_id");
TCComponentBOMLine bomLine = null;
TCComponentBOMWindow view = null;
if (whereUsed != null && whereUsed.length > 0) {
TCComponentItemRevision tempItemRev = (TCComponentItemRevision) whereUsed[0];
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
view = winType.create(null);
bomLine = view.setWindowTopLine(tempItemRev.getItem(), tempItemRev, null, null);
} else {
MessageBox.post("The current object is not used !", "error", MessageBox.ERROR);
}
if (bomLine != null && bomLine.hasChildren()) {
AIFComponentContext[] childrena = bomLine.getChildren();
for (int i = 0; i < childrena.length; i++) {
TCComponentBOMLine childBomLine = (TCComponentBOMLine) childrena[i].getComponent();
if (childBomLine.getItemRevision().getStringProperty("item_id").equals(localId)) {
return i + 1 + "";
}
}
}
return "";
}
public void createNbtzItem() {
for (InterfaceAIFComponent targetComponent : targetComponents) {
int count = 0;
TCComponentItemRevision targetRev = (TCComponentItemRevision) targetComponent;
try {
TCComponent[] tzReferences = targetRev.getTCProperty(revReference).getReferenceValueArray();
boolean flag = true;
if (tzReferences != null && tzReferences.length > 0) {
for (int i = 0; i < tzReferences.length; i++) {
if (tzReferences[i].getStringProperty("object_type").equals(itemType)) {
flag = false;
}
}
}
if (flag) {
TCComponentItemType tzType = (TCComponentItemType) tcSession.getTypeComponent(itemType);
TCComponentItem tzItem = tzType.create(
idList[count][0] + ruleName + idList[count][1] + idList[count++][2], "", itemType, itemName,
"", null);
if (tzItem != null) {
targetRev.add(revReference, tzItem);
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} else {
MessageBox.post("Creation Failed !", "Error", MessageBox.ERROR);
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}

@ -0,0 +1,21 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateToolingListHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateToolingListAction commonAction = new CreateToolingListAction(application, "VF5tlgx", "VF5tl","ToolList","-TL-");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,21 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.LTinspectionPlan;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.GxTemplateAction;
import com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class InspectionPlanHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
GxTemplateAction commonAction = new GxTemplateAction(application, "VF5ipgx", "VF5ip","In-Process Inspection Plan","-IP");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,20 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.LstandardInstruction;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.createTechnicalDocuments.KtoolingList.CreateToolingListAction;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class CreateStandardInstructionHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateToolingListAction commonAction = new CreateToolingListAction(
application, "VF5swigx", "VF5swi","Standard Work Instruction","-SWI-");
new Thread(commonAction).start();
return null;
}
}

@ -0,0 +1,326 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments;
import java.awt.BorderLayout;
import java.awt.Dialog;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileNameExtensionFilter;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
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.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
@SuppressWarnings("serial")
public class UploadDocumentsDialog extends AbstractAIFDialog {
private AbstractAIFApplication application;
private TCSession tcSession;
private JLabel selectUploadLabel;
private JComponent uploadInput;
private JButton importButton;
private JButton okButton;
private JButton celButton;
private TCComponentDatasetType pdfType;
private TCComponentDatasetType dwgType;
private TCComponentDatasetType docType;
private TCComponentDatasetType docxType;
private TCComponentDatasetType xlsType;
private TCComponentDatasetType xlsxType;
private TCComponentDatasetType defaultType;
public UploadDocumentsDialog(AbstractAIFApplication application) {
super(true);
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
}
public void initializationComponent() {
selectUploadLabel = new JLabel(ConstantPool.EN_LABEL_UPLOAD_PATH);
uploadInput = new JTextField(14);
importButton = new JButton(ConstantPool.EN_BUTTON_SELECT);
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
SwingUtilities.getWindowAncestor(importButton);
}
@Override
public void run() {
try {
pdfType = (TCComponentDatasetType) tcSession.getTypeComponent("PDF");
dwgType = (TCComponentDatasetType) tcSession.getTypeComponent("VF5CAD");
docType = (TCComponentDatasetType) tcSession.getTypeComponent("MSWord");
docxType = (TCComponentDatasetType) tcSession.getTypeComponent("MSWordX");
xlsType = (TCComponentDatasetType) tcSession.getTypeComponent("MSExcel");
xlsxType = (TCComponentDatasetType) tcSession.getTypeComponent("MSExcelX");
defaultType = (TCComponentDatasetType) tcSession.getTypeComponent("Dataset");
} catch (Exception e) {
// TODO: handle exception
}
initUi();
}
/**
* ³õʼ»¯½çÃæ
*/
public void initUi() {
initializationComponent();
this.setTitle(ConstantPool.EN_TITLE_UPLOAD_PATH);
this.setLayout(null);
selectUploadLabel.setBounds(30, 40, 80, 25);
this.add(selectUploadLabel);
uploadInput.setBounds(110, 40, 150, 25);
this.add(uploadInput);
importButton.setBounds(280, 40, 90, 25);
importButton.addActionListener(e -> {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setMultiSelectionEnabled(false);
FileNameExtensionFilter filter = new FileNameExtensionFilter("CSV Files", "csv");
fileChooser.setFileFilter(filter);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.APPROVE_OPTION) {
((JTextField) uploadInput).setText(fileChooser.getSelectedFile().getAbsolutePath());
}
});
this.add(importButton, BorderLayout.EAST);
okButton.setBounds(80, 90, 100, 25);
celButton.setBounds(200, 90, 100, 25);
okButton.addActionListener(e -> {
String path = ((JTextField) uploadInput).getText();
if (path.isEmpty()) {
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_UPLOAD_ERROR);
} else {
File file = new File(path);
if (!file.exists() || !file.isDirectory()) {
JOptionPane.showMessageDialog(this, ConstantPool.EN_MESSAGE_FILE_ERROR);
} else {
this.dispose();
uploadDrawings(file);
}
}
});
celButton.addActionListener(e -> {
this.setVisible(false);
this.disposeDialog();
});
this.add(okButton);
this.add(celButton);
this.pack();
this.setSize(410, 190);
this.setLocationRelativeTo((Dialog) SwingUtilities.getWindowAncestor(importButton));
this.setVisible(true);
}
private void uploadDrawings(File file) {
List<File> localFiles = getFilesInDirectory(file.getAbsolutePath());
// for (File localFile : localFiles) {
// System.out.println("Found file: " + localFile.getAbsolutePath());
// }
try {
addDataSet(localFiles);
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("123");
e.printStackTrace();
}
}
public boolean createDataSet(TCComponentItemRevision rev, File localFile) throws TCException {
String fileName = localFile.getName();
String[] split = fileName.split("\\.");
System.out.println("ÀàÐÍ: " + split[1]);
String type = "";
String tool = "";
TCComponentDatasetType tempType = null;
if (split != null && split.length == 2) {
switch (split[1].toLowerCase()) {
case "pdf": {
type = "PDF";
tool = "PDF_Reference";
tempType = pdfType;
break;
}
case "dwg": {
type = "VF5CAD";
tool = "VF5dwg";
tempType = dwgType;
break;
}
case "doc": {
type = "MSWord";
tool = "word";
tempType = docType;
break;
}
case "docx": {
type = "MSWordX";
tool = "word";
tempType = docxType;
break;
}
case "xls": {
type = "MSExcel";
tool = "excel";
tempType = xlsType;
break;
}
case "xlsx": {
type = "MSExcelX";
tool = "excel";
tempType = xlsxType;
break;
}
default: {
type = "CAEAnalysisDS";
tool = "CAEAnaysisData";
tempType = defaultType;
break;
}
}
TCComponentDataset tempData = tempType.create(fileName, "", type);
try {
tempData.setFiles(new String[] { localFile.getAbsolutePath() }, new String[] { tool });
} catch (Exception e) {
// TODO: handle exception
return false;
}
if (tempData != null) {
rev.add("IMAN_specification", tempData);
return true;
}
} else {
System.out.println("Folder Name Is Error !");
}
return false;
}
public void addDataSet(List<File> localFiles) throws TCException {
// TODO Auto-generated method stub
int successfulCount = 0;
int failedCount = 0;
int notFoundCount = 0;
// StringBuffer successfulData = new StringBuffer("");
StringBuffer failedData = new StringBuffer("");
StringBuffer notFoundData = new StringBuffer("");
for (File localFile : localFiles) {
String fileName = localFile.getName();
String queryValue = fileName.substring(0,
fileName.lastIndexOf(".") == -1 ? fileName.length() : fileName.lastIndexOf("."));
System.out.println("fileName : " + fileName);
System.out.println("queryValue : " + queryValue);
InterfaceAIFComponent[] resultComponents = queryItem(queryValue);
if (resultComponents != null && resultComponents.length > 0) {
TCComponentItemRevision queryRev = null;
if (resultComponents[0] instanceof TCComponentItem) {
queryRev = ((TCComponentItem) resultComponents[0]).getLatestItemRevision();
} else if (resultComponents[0] instanceof TCComponentItemRevision) {
queryRev = (TCComponentItemRevision) resultComponents[0];
}
if (resultComponents[0] != null) {
if (createDataSet(queryRev, localFile)) {
// successfulData.append(fileName);
// successfulData.append(" ");
successfulCount++;
} else {
failedData.append(fileName);
failedData.append(" ");
failedCount++;
}
}
} else {
notFoundData.append(fileName);
notFoundData.append(" ");
notFoundCount++;
}
}
StringBuffer resultData = new StringBuffer("");
resultData.append("Successful: ");
resultData.append(successfulCount);
resultData.append("\n");
resultData.append("Failed: ");
resultData.append(failedCount);
resultData.append(" ->");
resultData.append(failedData);
resultData.append("\n");
resultData.append("Not Found Rev: ");
resultData.append(notFoundCount);
resultData.append(" ->");
resultData.append(notFoundData);
resultData.append("\n");
MessageBox.post(resultData.toString(), "Info", MessageBox.INFORMATION);
}
public InterfaceAIFComponent[] queryItem(String itemId) {
try {
return tcSession.search("MU_Find ItemRevision", new String[] { "ID" }, new String[] { itemId });
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public List<File> getFilesInDirectory(String directoryPath) {
List<File> filesList = new ArrayList<>();
File directory = new File(directoryPath);
if (!directory.exists() || !directory.isDirectory()) {
System.out.println("The specified path is not a valid directory: " + directoryPath);
return filesList;
}
File[] filesAndDirs = directory.listFiles();
if (filesAndDirs != null) {
for (File file : filesAndDirs) {
if (file.isFile()) {
filesList.add(file);
}
}
} else {
System.out.println("Failed to list files in the directory: " + directoryPath);
}
return filesList;
}
}

@ -0,0 +1,26 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.OuploadDocuments;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class UploadDocumentsHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, new String[]{"VF5NPI"}, "Folder");
if(judgeSingleSelectComponent) {
UploadDocumentsDialog dialog = new UploadDocumentsDialog(application);
new Thread(dialog).start();
}
return null;
}
}

@ -0,0 +1,254 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.workflow.commands.newprocess.NewProcessCommand;
import java.awt.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ApprovalofDocumentsDialog extends JFrame implements Runnable {
private final String title;
private JButton okButton;
private JButton cancelButton;
private JCheckBox allCheck;
private String[] columnNames;
private Object[][] data;
private JTable table;
private AbstractAIFApplication application;
public ApprovalofDocumentsDialog(AbstractAIFApplication application ,String title, Object... args) {
int count = 0;
this.title = title;
this.application = application;
columnNames = (String[]) args[count++];
data = (Object[][]) args[count];
}
@Override
public void run() {
initUI();
}
public void initializationButton() {
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
okButton.addActionListener(e -> {
try {
doTask();
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
cancelButton.addActionListener(e -> {
this.dispose();
});
}
public void initUI() {
// 设置窗口居中
this.setTitle(title);
// this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(600, 400); // 设置窗口大小
this.setLayout(new BorderLayout()); // 设置布局
this.setLocationRelativeTo(null);
initializationButton();
JPanel topPanel = createTopPanel();
JPanel centerPanel = createCenterPanel();
JPanel bottomPanel = createBottomPanel();
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(bottomPanel, BorderLayout.SOUTH);
this.setVisible(true);
}
private JPanel createTopPanel() {
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 10, 0));
topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
allCheck = new JCheckBox("AllSelect");
allCheck.addActionListener(e -> {
if (allCheck.isSelected()) {
for (int i = 0; i < table.getRowCount(); i++) {
table.setValueAt(true, i, columnNames.length - 2);
}
} else {
for (int i = 0; i < table.getRowCount(); i++) {
table.setValueAt(false, i, columnNames.length - 2);
}
}
});
topPanel.add(allCheck);
return topPanel;
}
public JPanel createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout(10, 10));
// centerPanel.setBorder(BorderFactory.createTitledBorder(childTitle));
centerPanel.setPreferredSize(new Dimension(400, 200));
DefaultTableModel model = new DefaultTableModel(data, columnNames) {
@Override
public boolean isCellEditable(int row, int column) {
return column != -1;
}
@Override
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == columnNames.length - 1) {
return Boolean.class;
}
return String.class;
}
};
table = new JTable(model);
table.setRowHeight(18);
table.getTableHeader().setReorderingAllowed(false);
table.setAutoCreateRowSorter(true);
TableColumnModel columnModel = table.getColumnModel();
table.setRowHeight(20);
table.removeColumn(columnModel.getColumn(columnModel.getColumnCount() - 2));
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER);
return c;
}
};
TableCellRenderer selectRenderer = (JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
int column) -> {
JCheckBox checkBox = new JCheckBox();
if (value instanceof Boolean) {
checkBox.setSelected((Boolean) value);
} else if (value instanceof String) {
checkBox.setSelected(Boolean.parseBoolean((String) value));
} else {
checkBox.setSelected(false);
}
checkBox.setHorizontalAlignment(SwingConstants.CENTER);
return checkBox;
};
for (int i = 0; i < columnModel.getColumnCount(); i++) {
columnModel.getColumn(i).setCellRenderer(centerRenderer);
}
columnModel.getColumn(columnNames.length - 2).setCellRenderer(selectRenderer);
table.getModel().addTableModelListener(e -> {
if (e.getType() == TableModelEvent.UPDATE) {
int column = e.getColumn();
if (column == columnNames.length - 2) {
boolean allSelected = true;
for (int i = 0; i < table.getRowCount(); i++) {
boolean selected = (boolean) table.getValueAt(i, column);
if (!selected) {
allSelected = false;
break;
}
}
allCheck.setSelected(allSelected);
}
}
});
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(400, 150));
centerPanel.add(scrollPane, BorderLayout.CENTER);
return centerPanel;
}
public JPanel createBottomPanel() {
// 创建底部面板,包含按钮
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 60, 10));
bottomPanel.add(okButton);
bottomPanel.add(cancelButton);
return bottomPanel;
}
public void doTask() throws TCException {
int rowCount = table.getRowCount();
DefaultTableModel model = (DefaultTableModel) table.getModel();
int selectedRowCount = 0;
for (int i = 0; i < rowCount; i++) {
Object value = model.getValueAt(table.convertRowIndexToModel(i), columnNames.length - 1);
boolean isSelected = false;
if (value instanceof Boolean) {
isSelected = (Boolean) value;
} else if (value instanceof String) {
isSelected = Boolean.parseBoolean((String) value);
}
if (isSelected) {
selectedRowCount++;
}
}
TCSession session = (TCSession) application.getSession();
String[][] selectedData = new String[selectedRowCount][model.getColumnCount()];
List<TCComponent> list = new ArrayList<>();
int index = 0;
for (int i = 0; i < rowCount; i++) {
int modelIndex = table.convertRowIndexToModel(i);
boolean isSelected = (Boolean) model.getValueAt(modelIndex, columnNames.length - 1);
if (isSelected) {
String[] rowData = new String[model.getColumnCount()];
for (int j = 0; j < model.getColumnCount(); j++) {
Object value = model.getValueAt(modelIndex, j);
if (value instanceof String) {
rowData[j] = (String) value;
} else if (value instanceof Boolean) {
rowData[j] = value.toString();
} else {
rowData[j] = value == null ? "" : value.toString();
}
}
selectedData[index++] = rowData;
System.out.println("Selected Row Data: " + Arrays.toString(rowData));
list.add((TCComponent) session.stringToComponent(rowData[rowData.length - 2]));
}
}
TCComponent[] tcRev = list.toArray(new TCComponent[list.size()]);
// TcUtil.CreateProcess(session, tcRev, TcUtil.getPreferenceValue(session, "VF5JSWJSPLC"));
if (selectedData.length == 0) {
System.out.println("No rows selected");
}
NewProcessCommand cmd = new NewProcessCommand(AIFUtility.getActiveDesktop(), application, tcRev);
cmd.executeModeless();
this.dispose();
}
}

@ -0,0 +1,226 @@
package com.connor.ferrorTech.metal.createTechnicalDocuments.PapprovalofTecDocuments;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings.UploadDialog;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.AbstractAIFSession;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.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.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ApprovalofDocumentsHandler extends AbstractHandler {
private static final String TCSession = null;
/**
* : --> ,, map--> (VF5ccpRevision) :
* ({"vf5idgx","VF5nbtz","y"},{"vf5pcgx","VF5procctrl","y"})
*/
private Map<String, List<String[]>> preferenceMap;
private TCComponentBOMWindow gxView;
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
TCSession tcSession = (TCSession) application.getSession();
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
new String[] { "VF5ccpRevision", "VF5bcpRevision", "VF5clRevision" }, "ItemRevision");
if (judgeSingleSelectComponent) {
String[] enColumnNames = new String[] { "PN Number", "Name", "Owner", "Creation Date", "", "Select" };
preferenceMap = getPreference(tcSession, "Material_target_Relation");
if (preferenceMap != null) {
Set<String> keySet = preferenceMap.keySet();
for (String key : keySet) {
List<String[]> list = preferenceMap.get(key);
System.out.println("rev: " + key);
for (String[] gx : list) {
System.out.println(Arrays.toString(gx));
}
}
TCComponentItemRevision targetRev = (TCComponentItemRevision) application.getTargetComponent();
List<TCComponentItemRevision> tcList = new ArrayList<>();
try {
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession
.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = winType.create(null);
TCComponentBOMLine topBomLine = view.setWindowTopLine(targetRev.getItem(), targetRev, null, null);
gxView = winType.create(null);
getAllChildrenBomLine(topBomLine, tcList);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String[] prop = new String[] { "item_id", "object_name", "owning_user", "creation_date", "", "Select" };
System.out.println("tcList.length: " + tcList.size());
Object[][] data = assignmentValue(prop, tcList);
ApprovalofDocumentsDialog dialog = new ApprovalofDocumentsDialog(application, "工艺批量审批筛选", enColumnNames,
data);
new Thread(dialog).start();
} else {
MessageBox.post("The Preference Configuration Is Null !", "error", MessageBox.ERROR);
}
}
return null;
}
private Object[][] assignmentValue(String[] prop, List<TCComponentItemRevision> tcList) {
try {
String[] pop = new String[] { "item_id", "object_name", "owning_user", "creation_date" };
Object[][] data = new Object[tcList.size()][];
// TODO Auto-generated method stub
for (int i = 0; i < tcList.size(); i++) {
int length = prop.length;
Object[] rowData = new Object[length];
TCComponentItemRevision tarRev = tcList.get(i);
System.out.println("type ====> " + tarRev.getStringProperty("object_type"));
String[] properties = tarRev.getProperties(pop);
for (int j = 0; j < properties.length; j++) {
rowData[j] = properties[j];
}
rowData[length - 2] = tarRev.getUid();
rowData[length - 1] = false;
System.out.println("properties || " + Arrays.toString(rowData));
data[i] = rowData;
}
return data;
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
public Map<String, List<String[]>> getPreference(TCSession tcSession, String preferenceValue) {
String[] preferenceValues = TcUtil.getPreferenceValues(tcSession, preferenceValue);
if (preferenceValues != null && !preferenceValue.isEmpty()) {
Map<String, List<String[]>> map = new HashMap<>();
for (String reference : preferenceValues) {
String rev = reference.substring(0, reference.indexOf("-"));
String[] gx = reference.substring(reference.indexOf("-") + 1).split("-");
if (map.containsKey(rev)) {
List<String[]> list = map.get(rev);
list.add(gx);
} else {
List<String[]> list = new ArrayList<>();
list.add(gx);
map.put(rev, list);
}
}
return map;
} else {
return null;
}
}
public void getAllChildrenBomLine(TCComponentBOMLine bomLine, List<TCComponentItemRevision> tcList)
throws TCException {
System.out.println("当前BOM对象1"+bomLine.getItemRevision().getStringProperty("object_name"));
System.out.println("hasChildren1 : "+bomLine.hasChildren());
if (bomLine.hasChildren()) {
System.out.println("当前BOM对象2"+bomLine.getItemRevision().getStringProperty("object_name"));
System.out.println("hasChildren2 : "+bomLine.hasChildren());
AIFComponentContext[] children = bomLine.getChildren();
for (AIFComponentContext child : children) {
TCComponentBOMLine component = (TCComponentBOMLine) child.getComponent();
getAllChildrenBomLine(component, tcList);
}
}
addChildrenBomRev(bomLine, tcList);
}
/**
*
*
* @param bomLine
* @param tcList
* @throws TCException
*/
public void addChildrenBomRev(TCComponentBOMLine bomLine, List<TCComponentItemRevision> tcList) throws TCException {
TCComponentItemRevision itemRevision = bomLine.getItemRevision();
String type = itemRevision.getStringProperty("object_type");
System.out.println("当前类型 ==> " + type);
if (preferenceMap.containsKey(type)) {
List<String[]> gxReference = preferenceMap.get(type);
for (String[] gxArray : gxReference) {
System.out.println("当前遍历的关系 :" + gxArray[0] + " || "+ gxArray[1]);
if (gxArray != null && gxArray.length == 3 && !gxArray[0].equals("VF5gygx")) {
System.out.println("enter 1");
TCComponent[] gxComponents = itemRevision.getRelatedComponents(gxArray[0]);
for (TCComponent component : gxComponents) {
String gxType = "";
TCComponentItemRevision targetRev = null;
if (component instanceof TCComponentItem) {
gxType = component.getStringProperty("object_type");
targetRev = ((TCComponentItem) component).getLatestItemRevision();
} else if (component instanceof TCComponentItemRevision) {
targetRev = (TCComponentItemRevision) component;
gxType = targetRev.getItem().getStringProperty("object_type");
}
System.out.println("当前关系中的对象类型 : " + gxType);
if (gxType.equals(gxArray[1])) {
System.out.println("inner1");
TCComponent[] publishStatus = targetRev.getTCProperty("release_status_list")
.getReferenceValueArray();
if ((publishStatus == null || publishStatus.length == 0) && gxArray[2].equals("y")) {
System.out.println("add");
tcList.add(targetRev);
}
}
}
} else if (gxArray != null && gxArray.length == 3 && gxArray[0].equals("VF5gygx")) {
// &&
System.out.println("enter 2");
TCComponent[] gyItems = itemRevision.getRelatedComponents(gxArray[0]);
for (TCComponent gyItem : gyItems) {
TCComponentItemRevision gyRev = ((TCComponentItem) gyItem).getLatestItemRevision();
if (gxArray[2].equals("y")) {
tcList.add(gyRev);
System.out.println("添加工艺对象");
}
TCComponentBOMLine gyBom = gxView.setWindowTopLine((TCComponentItem) gyItem, gyRev, null, null);
if (gyBom.hasChildren()) {
AIFComponentContext[] gyChildren = gyBom.getChildren();
for (AIFComponentContext gyChild : gyChildren) {
TCComponentBOMLine gyChildBom = (TCComponentBOMLine) gyChild.getComponent();
getAllChildrenBomLine(gyChildBom, tcList);
}
}
}
}
}
}
}
}

@ -0,0 +1,10 @@
package com.connor.ferrorTech.metal.exception;
@SuppressWarnings("serial")
public class CustomException extends RuntimeException {
public CustomException(String message) {
super(message);
}
}

@ -0,0 +1,839 @@
package com.connor.ferrorTech.metal.importMaterial;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import javax.swing.border.EmptyBorder;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.json.JSONObject;
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.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCTypeService;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;
public class ImportMaterialDialog extends AbstractAIFDialog {
Registry reg = Registry.getRegistry(this);
/**
*
*/
private static final long serialVersionUID = 1L;
private AbstractAIFUIApplication application;
private TCSession session;
private String url;
private String sapCheck;
private String errorInfo;
private JPanel contentPane;
private JTextField textField;
private File[] selectedFile;
private TCComponent target;
private Map<String, TCComponent> wlbmMap = new HashMap<>();
private Map<String, TCComponent> gxwlbmMap = new HashMap<>();
private Map<String, TCComponentItem> newObjectMap = new HashMap<>();
private Map<String, String> topMap = new HashMap<>();
private Map<String, String> cjCodeMap = new HashMap<>();
private Map<String, List<String>> excelData = new HashMap<>();
public ImportMaterialDialog(AbstractAIFApplication application, TCComponent target) {
super();
this.application = (AbstractAIFUIApplication) application;
this.session = (TCSession) application.getSession();
this.target = target;
}
@Override
public void run() {
initUI();
}
public void initUI() {
setTitle(reg.getString("ImportMaterialDialog.0")); //$NON-NLS-1$
setResizable(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 500, 120);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNewLabel = new JLabel(reg.getString("ImportMaterialDialog.1")); //$NON-NLS-1$
lblNewLabel.setBounds(10, 10, 150, 15);
contentPane.add(lblNewLabel);
textField = new JTextField();
textField.setBounds(160, 7, 180, 21);
contentPane.add(textField);
textField.setColumns(10);
JButton btnNewButton = new JButton(reg.getString("ImportMaterialDialog.2"));
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// 新建一个文件选择器
JFileChooser jFileChooser = new JFileChooser();
jFileChooser.setMultiSelectionEnabled(true);
// 弹出文件选择框
int showOpenDialog = jFileChooser.showOpenDialog(null);
// 如果文件被选中
if (showOpenDialog == jFileChooser.APPROVE_OPTION) {
selectedFile = jFileChooser.getSelectedFiles();
String fileName = "";
for (File file : selectedFile) {
fileName += file.getName() + ";";
}
textField.setText(fileName);
}
}
});
btnNewButton.setBounds(360, 6, 100, 23);
contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton(reg.getString("ImportMaterialDialog.8")); //$NON-NLS-1$
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
btnNewButton_1.setBounds(250, 38, 100, 21);
contentPane.add(btnNewButton_1);
JButton btnNewButton_1_1 = new JButton(reg.getString("ImportMaterialDialog.3")); //$NON-NLS-1$
btnNewButton_1_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
WaitingDialog dia = new WaitingDialog(application.getDesktop(), "INFOMATION",
reg.getString("ImportMaterialDialog.10")); //$NON-NLS-1$
dia.setVisible(true);
if (target != null) {
if (selectedFile.length > 0) {
// 获取首选项SAP_url的值
String[] sapUrls = session.getPreferenceService().getStringValues("SAP_url");
if (sapUrls != null) {
// 获取sap的路径
url = sapUrls[0];
// 获取接口验证
sapCheck = session.getPreferenceService().getStringValue("SAP_check");
if (sapCheck != null) {
boolean comfireFlag = comfire(selectedFile[0]);
dia.setVisible(false);
if (comfireFlag) {
MessageBox.post(reg.getString("ImportMaterialDialog.11"),
reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
} else {
MessageBox.post(reg.getString("ImportMaterialDialog.12"),
reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
}
} else {
dia.setVisible(false);
MessageBox.post(reg.getString("ImportMaterialDialog.5"),
reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
}
} else {
dia.setVisible(false);
MessageBox.post(reg.getString("ImportMaterialDialog.4"),
reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
}
}
} else {
dia.setVisible(false);
MessageBox.post(reg.getString("ImportMaterialDialog.4"), reg.getString("ImportMaterialHandler.0"),
MessageBox.INFORMATION);
}
}
});
btnNewButton_1_1.setBounds(100, 38, 100, 21);
contentPane.add(btnNewButton_1_1);
// 居中打开
setLocationRelativeTo(null);
setVisible(true);
}
private boolean comfire(File file) {
// 读取上传文件
excelData = readExcelData(file);
if (excelData != null && excelData.size() > 0) {
// 通过sap接口获取物料信息
Map<String, MaterialPropertyBean> materialInfoBySap = materialInfoBySap(excelData);
Map<String, Map<String, String>> materialBOMMap = materialBOMNum(excelData);
if (materialInfoBySap != null && materialInfoBySap.size() > 0) {
try {
// 查询物料是否存在
queryMaterial(excelData, materialInfoBySap);
System.out.println("BOM个数:" + materialBOMMap.size());
boolean flag = false;
// 搭建BOM
for (String str : materialBOMMap.keySet()) {
System.out.println("BOM层级:" + str);
if (createMaterialBOM(materialBOMMap.get(str), excelData, str)) {
flag = true;
} else {
flag = false;
}
}
findFolder(target, excelData);
return flag;
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
int length = errorInfo.length();
if (length > 0) {
String str = errorInfo.substring(0, length - 1);
MessageBox.post(
reg.getString("ImportMaterialDialog.13") + str + reg.getString("ImportMaterialDialog.14"),
reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
errorInfo = "";
return false;
}
}
}
return false;
}
/**
* BOM
*
* @param excelData
*/
private Map<String, Map<String, String>> materialBOMNum(Map<String, List<String>> excelData) {
Map<String, Map<String, String>> bomMap = new HashMap<>();
Map<String, String> bomChildrenMap = new HashMap<>();
for (String key : excelData.keySet()) {
// 获取层级号
String cjh = excelData.get(key).get(0);
// 根据逗号分割
String[] split = cjh.split("\\.");
if (split.length > 1) {
if (bomMap.containsKey(split[0])) {
Map<String, String> map = bomMap.get(split[0]);
map.put(cjh, excelData.get(key).get(1));
}
} else {
bomChildrenMap.put(cjh, excelData.get(key).get(1));
if (split.length == 1) {
bomMap.put(cjh, bomChildrenMap);
}
}
}
return bomMap;
}
/**
* BOM
*
* @param excelData
* @throws TCException
*/
private boolean createMaterialBOM(Map<String, String> data, Map<String, List<String>> excelData, String code)
throws TCException {
boolean flag = true;
TCTypeService service = session.getTypeService();
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow");
TCComponentBOMWindow win = winType.create(null);
System.out.println("bom编码:" + code);
String[] split = code.split("\\.");
if (!code.contains(".")) {
String materialCode = cjCodeMap.get(code);
System.out.println("物料编码:" + materialCode);
if (gxwlbmMap.containsKey(materialCode)) {
TCComponent component = gxwlbmMap.get(materialCode);
try {
TCComponentItemRevision itemRevision = (TCComponentItemRevision) component;
// 创建BOM视图
TCComponentBOMLine topLine = win.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null);
// 获取子层
AIFComponentContext[] children = topLine.getChildren();
System.out.println("子层数量:" + children.length);
if (children.length > 0) {
for (AIFComponentContext child : children) {
topLine.remove("", (TCComponent) child.getComponent());
}
}
// 再次搭建BOM
for (String code2 : data.keySet()) {
String[] split2 = code2.split("\\.");
System.out.println("父层编码:" + code);
System.out.println("子层编码:" + code2);
String childrenStr = code + ".";
System.out.println("子层:" + childrenStr);
if (code2.contains(childrenStr)) {
if (split2.length == (split.length + 1) && code2.startsWith(childrenStr)) {
flag = createMaterialBOMLine(data, excelData, topLine, code2);
}
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
} else if (newObjectMap.containsKey(materialCode)) {
TCComponentItem item = newObjectMap.get(materialCode);
try {
// 创建BOM视图
TCComponentBOMLine topLine = win.setWindowTopLine(item, item.getLatestItemRevision(), null, null);
// 搭建BOM
for (String code2 : data.keySet()) {
String[] split2 = code2.split("\\.");
String childrenStr = code + ".";
if (code2.contains(childrenStr)) {
if (split2.length == (split.length + 1) && code2.startsWith(childrenStr)) {
flag = createMaterialBOMLine(data, excelData, topLine, code2);
}
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}
}
win.save();// 会触发保存后操作
win.refresh();
win.close();
return flag;
}
/**
*
*
* @param data
* @param excelData
* @param topLine
* @param num
* @param str
* @throws TCException
*/
private boolean createMaterialBOMLine(Map<String, String> data, Map<String, List<String>> excelData,
TCComponentBOMLine topLine, String str) throws TCException {
String code = str;
String[] split = code.split("\\.");
if (code.equals(str)) {
String materialCode = cjCodeMap.get(code);
String vf5jbyl = "";
String vf5sl = "";
for (String str2 : excelData.keySet()) {
String num2 = excelData.get(str2).get(0);
if (num2.equals(code)) {
vf5jbyl = excelData.get(str2).get(6);
vf5sl = excelData.get(str2).get(7);
}
}
TCComponentItem item = null;
if (gxwlbmMap.containsKey(materialCode)) {
TCComponent component = gxwlbmMap.get(materialCode);
item = ((TCComponentItemRevision) component).getItem();
} else if (newObjectMap.containsKey(materialCode)) {
item = newObjectMap.get(materialCode);
}
try {
if (topLine != null) {
System.out.println("创建子层item:" + item.getStringProperty("object_name"));
TCComponentBOMLine wuLiaoChildLine = topLine.add(item, item.getLatestItemRevision(), null, false,
"");
// 获取子层
AIFComponentContext[] children = wuLiaoChildLine.getChildren();
if (children.length > 0) {
for (AIFComponentContext child : children) {
topLine.remove("", (TCComponent) child.getComponent());
}
}
wuLiaoChildLine.setProperty("VF5jbsl", vf5jbyl);
wuLiaoChildLine.setProperty("VF5sl", vf5sl);
// 搭建BOM
for (String code2 : data.keySet()) {
String[] split2 = code2.split("\\.");
String childrenStr = code + ".";
if (code2.contains(childrenStr)) {
if (split2.length == (split.length + 1) && code2.startsWith(childrenStr)) {
createMaterialBOMLine(data, excelData, wuLiaoChildLine, code2);
}
}
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return false;
}
}
return true;
}
/**
* excel
*
* @param file
* @return
*/
private Map<String, List<String>> readExcelData(File file) {
Map<String, List<String>> tableDataMap = new HashMap<String, List<String>>();
try (FileInputStream fileInputStream = new FileInputStream(selectedFile[0]);
Workbook workbook = new XSSFWorkbook(fileInputStream)) {
Sheet sheet = workbook.getSheetAt(0); // 读取第一个工作表
// 获取数据行
int lastRowNum = sheet.getLastRowNum();
int firstRowNum = sheet.getFirstRowNum();
int num = lastRowNum - firstRowNum;
System.out.println("行数据量:" + num);
int key = 0;
if (num >= 6) {
for (int i = 5; i <= num; i++) {
Row row = sheet.getRow(i);
// 判断行是否为空
if (!isRowEmpty(row)) {
List<String> rowList = new ArrayList<String>();
if (sheet.getRow(i) != null) {
// 获取单元格个数
int lastCellNum = sheet.getRow(i).getLastCellNum();
for (int j = 0; j < lastCellNum; j++) {
Cell cell = sheet.getRow(i).getCell(j);
String value = "";
if (cell != null) {
// 根据不同数据类型,以字符串形式输出数据
switch (cell.getCellType()) {
case STRING:
value = cell.getStringCellValue() != null ? cell.getStringCellValue() : "";
break;
case NUMERIC:
value = String.valueOf(cell.getNumericCellValue()) != null
? String.valueOf(cell.getNumericCellValue())
: "";
if (value.endsWith(".0")) {
value = value.substring(0, value.lastIndexOf("."));
}
break;
case BOOLEAN:
value = String.valueOf(cell.getBooleanCellValue()) != null
? String.valueOf(cell.getBooleanCellValue())
: "";
break;
case FORMULA:
value = String.valueOf(cell.getCellFormula()) != null
? String.valueOf(cell.getCellFormula())
: "";
break;
default:
break;
}
}
if (value != null || value != "") {
if (value.contains(",")) {
value = value.replace(",", ";");
}
}
rowList.add(value);
}
}
System.out.println("表格行数据:" + rowList);
if (rowList.get(0) == null || rowList.get(0) == "" || rowList.get(1) == null
|| rowList.get(1) == "") {
MessageBox.post(reg.getString("ImportMaterialDialog.7"),
reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
return null;
}
tableDataMap.put(String.valueOf(key), rowList);
key++;
}
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
return tableDataMap;
}
/**
*
*
* @param row
* @return
*/
private boolean isRowEmpty(Row row) {
if (row == null) {
return true;
}
for (int c = 0; c < row.getLastCellNum(); c++) {
if (row.getCell(c) != null && row.getCell(c).toString().trim().length() > 0) {
return false;
}
}
return true;
}
/**
*
*
* @param excelData
* @throws Exception
*/
private void findFolder(TCComponent target, Map<String, List<String>> excelData) throws Exception {
TCComponentFolder newStuffFolder = session.getUser().getNewStuffFolder();
// 获取选中文件夹下的子文件夹
TCComponent[] relatedFolders = target.getRelatedComponents("contents");
if (relatedFolders.length > 0) {
Map<String, TCComponent> folders = new HashMap<>();
for (int i = 0; i < relatedFolders.length; i++) {
String name = relatedFolders[i].getStringProperty("object_name");
System.out.println("name:" + name);
folders.put(name, relatedFolders[i]);
}
for (String key : topMap.keySet()) {
String name = topMap.get(key);
if (folders.containsKey(name)) {
TCComponent component = folders.get(name);
TCComponent[] relatedComponents = component.getRelatedComponents("contents");
TCComponent comp = gxwlbmMap.get(cjCodeMap.get(key));
for (TCComponent com : relatedComponents) {
String objectName = com.getStringProperty("object_name");
if (objectName.equals("MATERIAL AND BOM")) {
TCComponent[] relatedComponents2 = com.getRelatedComponents("contents");
List<String> ids = new ArrayList<String>();
for (TCComponent com2 : relatedComponents2) {
ids.add(com2.getStringProperty("item_id"));
}
if (newObjectMap.containsKey(cjCodeMap.get(key))) {
String id = newObjectMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
if (!ids.contains(id)) {
com.add("contents", newObjectMap.get(cjCodeMap.get(key)));
}
} else if (gxwlbmMap.containsKey(cjCodeMap.get(key))) {
String id = (((TCComponentItemRevision) comp)).getStringProperty("item_id");
if (!ids.contains(id)) {
com.add("contents", ((TCComponentItemRevision) comp).getItem());
}
} else if (wlbmMap.containsKey(cjCodeMap.get(key))) {
String id = (((TCComponentItemRevision) comp).getStringProperty("item_id"));
if (!ids.contains(id)) {
com.add("contents", ((TCComponentItemRevision) comp).getItem());
}
}
}
}
} else {
TCComponent[] relatedComponents = newStuffFolder.getRelatedComponents("contents");
List<String> ids = new ArrayList<String>();
for (TCComponent com2 : relatedComponents) {
ids.add(com2.getStringProperty("item_id"));
}
if (newObjectMap.containsKey(cjCodeMap.get(key))) {
String id = newObjectMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
if (!ids.contains(id)) {
newStuffFolder.add("contents", newObjectMap.get(cjCodeMap.get(key)));
}
} else if (gxwlbmMap.containsKey(cjCodeMap.get(key))) {
String id = gxwlbmMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
if (!ids.contains(id)) {
newStuffFolder.add("contents",
((TCComponentItemRevision) gxwlbmMap.get(cjCodeMap.get(key))).getItem());
}
} else if (wlbmMap.containsKey(cjCodeMap.get(key))) {
String id = gxwlbmMap.get(cjCodeMap.get(key)).getStringProperty("item_id");
if (!ids.contains(id)) {
newStuffFolder.add("contents",
((TCComponentItemRevision) gxwlbmMap.get(cjCodeMap.get(key))).getItem());
}
}
}
}
}
}
/**
* SAP
*/
private Map<String, MaterialPropertyBean> materialInfoBySap(Map<String, List<String>> excelData) {
Map<String, MaterialPropertyBean> resultMap = new HashMap<>();
// 获取PN号
for (String key : excelData.keySet()) {
if (excelData.get(key).get(1) != null) {
MaterialPropertyBean materiaPorptry = new MaterialPropertyBean();
// 通过接口获取物料信息
String value = sapConnect("Product", excelData.get(key).get(1));
System.out.println("物料信息json:" + value);
if (value != null) {
JSONObject jsonObject = new JSONObject(value);
materiaPorptry.setVf5wlbm(jsonObject.getString("Product"));
if ("FERT".equals(jsonObject.getString("ProductType"))) {
materiaPorptry.setMaterialType("VF5ccp");
} else if ("HALB".equals(jsonObject.getString("ProductType"))) {
materiaPorptry.setMaterialType("VF5bcp");
} else if ("ROH".equals(jsonObject.getString("ProductType"))) {
materiaPorptry.setMaterialType("VF5cl");
}
String dw = jsonObject.getString("BaseUnit");
if("ST".equals(dw)) {
materiaPorptry.setVf5dw("PC");
}else {
materiaPorptry.setVf5dw(jsonObject.getString("BaseUnit"));
}
materiaPorptry.setVf5zl(String.valueOf(jsonObject.getDouble("GrossWeight")));
materiaPorptry.setVf5sjzl(String.valueOf(jsonObject.getDouble("NetWeight")));
}
// 物料描述信息
String value3 = sapConnect(
"ProductDescription(Product='" + excelData.get(key).get(1) + "',Language='EN')", "");
if (value3 != null) {
System.out.println("物料描述类型json:" + value3);
JSONObject jsonObject = new JSONObject(value3);
materiaPorptry.setObjectName(jsonObject.getString("ProductDescription"));
}
// 物料采购类型
String value2 = sapConnect(
"ProductPlantSupplyPlanning(Product='" + excelData.get(key).get(1) + "',Plant='5410')", "");
if (value2 != null) {
System.out.println("物料采购类型json:" + value2);
JSONObject jsonObject = new JSONObject(value2);
materiaPorptry.setVf5jhmrsx(jsonObject.getString("ProcurementType"));
// if ("E".equals(jsonObject.getString("ProcurementType"))) {
// materiaPorptry.setVf5jhmrsx("In-House Production");
// } else if ("F".equals(jsonObject.getString("ProcurementType"))) {
// materiaPorptry.setVf5jhmrsx("External Procurement");
// } else if ("X".equals(jsonObject.getString("ProcurementType"))) {
// materiaPorptry.setVf5jhmrsx("Both Procurement Type");
// }
materiaPorptry.setVf5jhmrsx(jsonObject.getString("ProcurementType"));
}
String materialType = materiaPorptry.getMaterialType();
if (materialType != null) {
resultMap.put(excelData.get(key).get(1), materiaPorptry);
} else {
if (errorInfo == null) {
errorInfo = excelData.get(key).get(1) + ",";
} else {
errorInfo = errorInfo + excelData.get(key).get(1) + ",";
}
}
}
}
System.out.println("resultMap的大小:" + resultMap.size());
return resultMap;
}
/**
*
*
* @param excelData
* @throws Exception
*/
private void queryMaterial(Map<String, List<String>> excelData, Map<String, MaterialPropertyBean> materialInfoMap)
throws Exception {
List<String> pnNum = new ArrayList<String>();
Map<String, String> khthMap = new HashMap<>();
// 获取PN号
for (String key : excelData.keySet()) {
pnNum.add(excelData.get(key).get(1));
khthMap.put(excelData.get(key).get(1), excelData.get(key).get(2));
cjCodeMap.put(excelData.get(key).get(0), excelData.get(key).get(1));
if (!excelData.get(key).get(0).contains(".")) {
topMap.put(excelData.get(key).get(0), excelData.get(key).get(2));
}
}
System.out.println("pnNum:" + pnNum);
String str = String.join(";", pnNum);
// 根据查询构建器查询
TCComponent[] search = session.search("MU_Find Part", new String[] { "vf5wlbm" }, new String[] { str });
System.out.println("查询个数:" + search.length);
if (search.length > 0) {
for (TCComponent com : search) {
TCComponent wlbmForm = com.getRelatedComponents("IMAN_master_form_rev")[0];
for (int i = 0; i < pnNum.size(); i++) {
if ((wlbmForm.getStringProperty("vf5wlbm")).equals(pnNum.get(i))) {
pnNum.remove(i);
}
}
if (com.getRelatedComponents("release_status_list").length > 0) {
wlbmMap.put(wlbmForm.getStringProperty("vf5wlbm"), com);
} else {
gxwlbmMap.put(wlbmForm.getStringProperty("vf5wlbm"), com);
}
}
}
System.out.println("gxwlbmMap个数:" + gxwlbmMap.size());
if (gxwlbmMap.size() > 0) {
for (String key : gxwlbmMap.keySet()) {
if (materialInfoMap.containsKey(key)) {
// 获取已存在的对象
TCComponent existObj = gxwlbmMap.get(key).getRelatedComponents("IMAN_master_form_rev")[0];
// 获取SAP接口返回的物料信息
MaterialPropertyBean propertyBean = materialInfoMap.get(key);
// 获取属性值
existObj.setStringProperty("vf5khth", khthMap.get(key));
existObj.setStringProperty("vf5dw", propertyBean.getVf5dw());
existObj.setStringProperty("vf5zl", propertyBean.getVf5zl());
existObj.setStringProperty("vf5sjzl", propertyBean.getVf5sjzl());
existObj.setStringProperty("vf5wlbm", propertyBean.getVf5wlbm());
existObj.setStringProperty("vf5jhmrsx", propertyBean.getVf5jhmrsx());
}
}
}
if (pnNum.size() > 0) {
for (String code : pnNum) {
if (materialInfoMap.containsKey(code)) {
TCComponentItemType itemType = (TCComponentItemType) session
.getTypeComponent(materialInfoMap.get(code).getMaterialType());
String itemRev = itemType.getNewRev(null);// 默认
String itemID = itemType.getNewID();
// 获取SAP接口返回的物料信息
MaterialPropertyBean propertyBean = materialInfoMap.get(code);
System.out.println("新建对象类型:" + propertyBean.getMaterialType());
TCComponentItem item = itemType.create(itemID, itemRev, propertyBean.getMaterialType(),
propertyBean.getObjectName(), "", null);
System.out.println("新建对象:" + item.getStringProperty("item_id"));
// 获取版本表单
TCComponent component = item.getLatestItemRevision()
.getRelatedComponents("IMAN_master_form_rev")[0];
component.setStringProperty("vf5khth", khthMap.get(code));
component.setStringProperty("vf5dw", propertyBean.getVf5dw());
component.setStringProperty("vf5zl", propertyBean.getVf5zl());
component.setStringProperty("vf5sjzl", propertyBean.getVf5sjzl());
component.setStringProperty("vf5wlbm", propertyBean.getVf5wlbm());
component.setStringProperty("vf5jhmrsx", propertyBean.getVf5jhmrsx());
newObjectMap.put(code, item);
}
}
}
}
private String sapConnect(String param, String code) {
String result = null;
HttpsURLConnection connection = null;
try {
String[] split = sapCheck.split(":");
// 基本认证用户名和密码
String basicAuth = "Basic "
+ new String(Base64.getEncoder().encode((split[0] + ":" + split[1]).getBytes()));
// 创建URL对象
URL urlObj = null;
if (code != null && code != "") {
urlObj = new URL(url + "/" + param + "/" + code);
} else {
urlObj = new URL(url + "/" + param);
}
// 打开连接
connection = (HttpsURLConnection) urlObj.openConnection();
// 添加认证头
connection.setRequestProperty("Authorization", basicAuth);
// 设置请求方法为GET
connection.setRequestMethod("GET");
// 接收响应码
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// 读取响应内容
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
result = response.toString();
// 打印结果
System.out.println(response.toString());
} catch (Exception e) {
e.getStackTrace();
System.out.println(e.getStackTrace());
} finally {
// 关闭连接
connection.disconnect();
}
return result;
}
}
class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog {
private static final long serialVersionUID = 1L;
public JPanel panel;
JProgressBar progressBar = null;
public WaitingDialog(Frame arg0, String title, String message) {
super(arg0, title);
this.setModal(false);
panel = new JPanel(new BorderLayout());
/*
* JLabel label = new JLabel(message); System.out.println("message:"+message);
* System.out.println("label:"+label); panel.add(label);
*/
progressBar = new JProgressBar(SwingConstants.HORIZONTAL);
progressBar.setVisible(true);
progressBar.setIndeterminate(true);
panel.add(BorderLayout.CENTER, new Label(message));
panel.add(BorderLayout.SOUTH, progressBar);
panel.setPreferredSize(new Dimension(350, 60));
this.getContentPane().add(panel);
centerToScreen();
pack();
}
}

@ -0,0 +1,34 @@
package com.connor.ferrorTech.metal.importMaterial;
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.TCComponent;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;
public class ImportMaterialHandler extends AbstractHandler{
Registry reg=Registry.getRegistry(this);
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// TODO Auto-generated method stub
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
//获取选中的对象
TCComponent selectObject=(TCComponent) application.getTargetComponent();
System.out.println("选中对象类型:" + selectObject.getType());
if(!selectObject.getType().equals("VF5NPI")) {
MessageBox.post(reg.getString("ImportMaterialHandler.1"), reg.getString("ImportMaterialHandler.0"), MessageBox.INFORMATION);
return null;
}
ImportMaterialDialog action = new ImportMaterialDialog(application,selectObject);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,85 @@
package com.connor.ferrorTech.metal.importMaterial;
public class MaterialPropertyBean {
private String vf5wlbm;
private String materialType;
private String itemRevisionId;
private String objectName;
private String vf5dw;
private String vf5sjzl;
private String vf5zl;
private String vf5jhmrsx;
public String getVf5wlbm() {
return vf5wlbm;
}
public void setVf5wlbm(String vf5wlbm) {
this.vf5wlbm = vf5wlbm;
}
public String getMaterialType() {
return materialType;
}
public void setMaterialType(String materialType) {
this.materialType = materialType;
}
public String getItemRevisionId() {
return itemRevisionId;
}
public void setItemRevisionId(String itemRevisionId) {
this.itemRevisionId = itemRevisionId;
}
public String getObjectName() {
return objectName;
}
public void setObjectName(String objectName) {
this.objectName = objectName;
}
public String getVf5dw() {
return vf5dw;
}
public void setVf5dw(String vf5dw) {
this.vf5dw = vf5dw;
}
public String getVf5sjzl() {
return vf5sjzl;
}
public void setVf5sjzl(String vf5sjzl) {
this.vf5sjzl = vf5sjzl;
}
public String getVf5zl() {
return vf5zl;
}
public void setVf5zl(String vf5zl) {
this.vf5zl = vf5zl;
}
public String getVf5jhmrsx() {
return vf5jhmrsx;
}
public void setVf5jhmrsx(String vf5jhmrsx) {
this.vf5jhmrsx = vf5jhmrsx;
}
@Override
public String toString() {
return "MaterialPropertyBean [vf5wlbm=" + vf5wlbm + ", materialType=" + materialType + ", itemRevisionId="
+ itemRevisionId + ", objectName=" + objectName + ", vf5dw=" + vf5dw + ", vf5sjzl=" + vf5sjzl
+ ", vf5zl=" + vf5zl + ", vf5jhmrsx=" + vf5jhmrsx + "]";
}
}

@ -0,0 +1,138 @@
package com.connor.ferrorTech.metal.importMaterial;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.KeyStroke;
import com.teamcenter.rac.aif.AbstractAIFDialog;
@SuppressWarnings("serial")
public class ProgressBar extends AbstractAIFDialog {
private JLabel messageLabel;
private JProgressBar progressBar;
private boolean showBar = false;
public ProgressBar(Dimension dim) {
super(false);
initUI(dim);
}
public ProgressBar(AbstractAIFDialog pd, Dimension dimension) {
super(pd, false);
initUI(dimension);
}
public ProgressBar(Dimension dim,boolean showBar) {
super(false);
this.showBar=showBar;
initUI(dim);
}
public ProgressBar(AbstractAIFDialog pd, Dimension dimension,boolean showBar) {
super(pd, false);
this.showBar=showBar;
initUI(dimension);
}
public ProgressBar(JFrame pd, Dimension dimension,boolean showBar) {
super(pd, false);
this.showBar=showBar;
initUI(dimension);
}
private void initUI(Dimension dim) {
this.setLayout(new BorderLayout(0, 0));
this.setUndecorated(true);
JPanel main = new JPanel(new GridBagLayout());
GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0);
main.setBackground(new Color(53, 53, 53));
if (dim != null) {
this.setPreferredSize(dim);
} else {
this.setPreferredSize(new Dimension(200, 40));
}
messageLabel = new JLabel(" ");
messageLabel.setForeground(Color.white);
progressBar = new JProgressBar();
progressBar.setForeground(Color.black);
progressBar.setIndeterminate(true);
main.add(messageLabel, s);
s.gridy++;
s.insets = new Insets(0, 5, 2, 5);
if(showBar) {
main.add(progressBar, s);
}
this.add(BorderLayout.CENTER, main);
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
this.getRootPane().registerKeyboardAction(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
disposeDialog();
}
}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
MouseAdapter ma = new MouseAdapter() {
private Point pressPoint = new Point();
@Override
public void mousePressed(MouseEvent e) {
pressPoint = e.getPoint();
}
@Override
public void mouseReleased(MouseEvent e) {
pressPoint = new Point();
}
@Override
public void mouseDragged(MouseEvent e) {
Rectangle r = ProgressBar.this.getBounds();
setLocation(r.x + (e.getX() - pressPoint.x), r.y + (e.getY() - pressPoint.y));
}
};
this.addMouseListener(ma);
this.addMouseMotionListener(ma);
}
public void setText(String message) {
messageLabel.setText(message);
}
public void setIndeterminate(boolean b) {
progressBar.setIndeterminate(b);
}
public void setText(String txt, int percent) {
setText(txt);
if (percent > progressBar.getMaximum()) {
percent = progressBar.getMaximum();
}
progressBar.setValue(percent);
}
public void cancel() {
disposeDialog();
}
public void startProgress() {
showDialog();
}
}

@ -0,0 +1,17 @@
ImportMaterialDialog.0=Please select the upload path
ImportMaterialDialog.1=Local upload path:
ImportMaterialDialog.2=Select
ImportMaterialDialog.3=Confirm
ImportMaterialDialog.8=Cancel
ImportMaterialHandler.0=Info
ImportMaterialHandler.1=The selected object type is incorrect!
ImportMaterialDialog.4=Please select Upload file\uff01
ImportMaterialDialog.5=Preference [SAP_check] is not configured\uff01
ImportMaterialDialog.6=Preference [SAP_url] is not configured\uff01
ImportMaterialDialog.7=The level or PN number in the uploaded file is empty, please check!
ImportMaterialDialog.9=execute
ImportMaterialDialog.10=In execution......
ImportMaterialDialog.11=Executed successfully!
ImportMaterialDialog.12=Execution failure!
ImportMaterialDialog.13=Materiel\u3010
ImportMaterialDialog.14=\u3011Failed to call SAP interface, material information could not be obtained!

@ -0,0 +1,17 @@
ImportMaterialDialog.0=\u8bf7\u9009\u62e9\u4e0a\u4f20\u8def\u5f84
ImportMaterialDialog.1=\u672c\u5730\u4e0a\u4f20\u8def\u5f84\uff1a
ImportMaterialDialog.2=\u9009\u62e9
ImportMaterialDialog.3=\u786e\u5b9a
ImportMaterialDialog.8=\u53d6\u6d88
ImportMaterialHandler.0=\u63d0\u793a
ImportMaterialHandler.1=\u9009\u4e2d\u7684\u5bf9\u8c61\u7c7b\u578b\u9519\u8bef\uff01
ImportMaterialDialog.4=\u8bf7\u9009\u62e9\u4e0a\u4f20\u6587\u4ef6\uff01
ImportMaterialDialog.5=\u9996\u9009\u9879\u3010SAP_check\u3011\u672a\u914d\u7f6e\uff01
ImportMaterialDialog.6=\u9996\u9009\u9879\u3010SAP_url\u3011\u672a\u914d\u7f6e\uff01
ImportMaterialDialog.7=\u4e0a\u4f20\u6587\u4ef6\u4e2d\u5c42\u7ea7\u6216\u8005PN\u53f7\u5217\u4e3a\u7a7a\uff0c\u8bf7\u68c0\u67e5\uff01
ImportMaterialDialog.9=\u6267\u884c
ImportMaterialDialog.10=\u6267\u884c\u4e2d......
ImportMaterialDialog.11=\u6267\u884c\u6210\u529f!
ImportMaterialDialog.12=\u6267\u884c\u5931\u8d25!
ImportMaterialDialog.13=\u7269\u6599\u3010
ImportMaterialDialog.14=\u3011\u8c03\u7528SAP\u63a5\u53e3\u5931\u8d25\uff0c\u65e0\u6cd5\u83b7\u53d6\u7269\u6599\u4fe1\u606f\uff01

@ -0,0 +1,88 @@
package com.connor.ferrorTech.metal.material.finishedProducts;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.swing.*;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class FinishedProductsCreateHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
@SuppressWarnings("unused")
String[] chLabelName = new String[] { "物料编码", "物料名称", "客户图号", "材质", "规格", "零件尺寸", "材料尺寸", "表面要求", "切割方式",
"计量单位", "计划默认属性", "备注" };
String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
"Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
"Unit", "Plan default attributes", "Remarks" };
String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
"vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
JLabel[] jLabels = new JLabel[enLabelName.length];
JComponent[] jComponents = new JComponent[enLabelName.length];
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
Map<Integer, String[]> map = new HashMap<>();
String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
map.put(enLabelName.length - 3, inHouse);
map.put(enLabelName.length - 2, eas);
for (int i = 0; i < enLabelName.length; i++) {
if (map.containsKey(i)) {
jComponents[i] = new JComboBox<>(map.get(i));
} else {
jComponents[i] = new JTextField(14);
}
jLabels[i] = new JLabel(enLabelName[i]);
}
System.out.println("In house :" + inHouse);
for (String inhouse : inHouse) {
if (inhouse.equals("In-House Production")) {
((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
}
}
for (String ea : eas) {
if (ea.equals("EA")) {
((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
}
}
Set<String> keySet = lovMap.keySet();
for (String key : keySet) {
StringBuffer str = new StringBuffer();
str.append(key);
str.append(" ==> ");
Map<String, String> map2 = lovMap.get(key);
Set<String> keySet2 = map2.keySet();
for (String key2 : keySet2) {
String value2 = map2.get(key2);
str.append("( ");
str.append(key2);
str.append(" || ");
str.append(value2);
str.append(" )");
}
System.out.println(str.toString());
}
ProductsCreateFrame action = new ProductsCreateFrame(application, "Create finished products",
"finishedProducts", jLabels, jComponents, prop, lovMap);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,435 @@
package com.connor.ferrorTech.metal.material.finishedProducts;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.net.ssl.HttpsURLConnection;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.json.JSONObject;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.importMaterial.MaterialPropertyBean;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.commands.open.OpenCommand;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.Registry;
@SuppressWarnings("serial")
public class ProductsCreateFrame extends JFrame implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private String title;
private String objectName;
private JLabel[] jLabels;
private JComponent[] jComponents;
private String[] prop;
private Map<String, Map<String, String>> lovMap;
private JButton okButton;
private JButton celButton;
private JButton queryButton;
private String url;
private String sapCheck;
private String soaRetrunType;
private Map<String,String> map;
private TCComponentFolder targetFolder;
public ProductsCreateFrame(AbstractAIFApplication application, String title, String objectName, Object... args) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.title = title;
this.objectName = objectName;
this.jLabels = (JLabel[]) args[0];
this.jComponents = (JComponent[]) args[1];
this.prop = (String[]) args[2];
this.lovMap = (Map<String, Map<String, String>>) args[3];
map = new HashMap<String,String>();
map.put("finishedProducts","VF5ccp");
map.put("semiFinishedProducts","VF5bcp");
map.put("material","VF5cl");
}
public void initUI() {
this.setTitle(title);
this.setSize(600, 570);
// 初始化组件
initializationComponent();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getCenterPanel();
JPanel bottomPanel = getBottomPanel();
this.getContentPane().add(centerPanel, BorderLayout.CENTER);
this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
// 设置窗口居中
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// 设置可见性
this.setVisible(true);
}
/**
*
*/
public void initializationComponent() {
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
queryButton = new JButton("Query");
}
public JScrollPane getCenterPanel() {
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints customLayout = new GridBagConstraints();
// 添加第一个JLabel和JTextField
customLayout.insets = new Insets(5, 30, 5, 20); // 边距
customLayout.gridx = 0;
customLayout.weightx = 0;
customLayout.anchor = GridBagConstraints.LINE_START;
jLabels[0].setFont(new Font("微软雅黑", Font.BOLD, 13));
centerPanel.add(jLabels[0], customLayout);
customLayout.insets = new Insets(5, 3, 5, 20); // 边距
customLayout.gridx = 1;
customLayout.fill = GridBagConstraints.HORIZONTAL;
JComponent jComponent = jComponents[0];
jComponent.setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(jComponent, customLayout);
// 将queryButton放在第一个输入框的右边
customLayout.insets = new Insets(5, 3, 5, 20); // 边距
customLayout.gridx = 2;
customLayout.fill = GridBagConstraints.HORIZONTAL;
queryButton.setFont(new Font("微软雅黑", Font.BOLD, 12));
centerPanel.add(queryButton, customLayout);
// 添加剩余的JLabel和JTextField
for (int i = 1; i < jLabels.length; i++) {
customLayout.insets = new Insets(5, 30, 5, 20); // 边距
customLayout.gridx = 0;
customLayout.gridy = i; // 设置垂直位置
customLayout.weightx = 0;
customLayout.anchor = GridBagConstraints.LINE_START;
jLabels[i].setFont(new Font("微软雅黑", Font.BOLD, 13));
centerPanel.add(jLabels[i], customLayout);
customLayout.insets = new Insets(5, 3, 5, 20); // 边距
customLayout.gridx = 1;
customLayout.fill = GridBagConstraints.HORIZONTAL;
jComponent = jComponents[i];
jComponent.setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(jComponent, customLayout);
}
// 创建具有滚动功能的JPanel
return new JScrollPane(centerPanel);
}
public JPanel getBottomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
// 添加监听
okButton.addActionListener(e -> {
this.dispose(); // 关闭窗口
confirmFunction();
});
celButton.addActionListener(e -> {
this.dispose(); // 关闭窗口
});
queryButton.addActionListener(e->{
try {
queryItem();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
return bottomPanel;
}
public void queryItem() throws Exception {
// TODO 校验物料编码是否为空
JTextField codeField = (JTextField)jComponents[0];
String codeName = codeField.getText();
if(codeName.isEmpty()) {
JOptionPane.showMessageDialog(this, "Please fill in the material code!", "Info", JOptionPane.INFORMATION_MESSAGE);
return;
}
InterfaceAIFComponent[] results = tcSession.search("MU_Find Part",new String[] {"vf5wlbm"}, new String[]{codeName});
// 存在则提示已经存在该物料,并打开查询到的物料。
if(results!=null && results.length>0) {
JOptionPane.showMessageDialog(this, "The material already exists!", "Info", JOptionPane.INFORMATION_MESSAGE);
this.dispose();
TCComponent target = (TCComponent) results[0];
com.teamcenter.rac.common.Activator.getDefault()
.openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective");
com.teamcenter.rac.common.Activator.getDefault().openComponents(
"com.teamcenter.rac.ui.perspectives.navigatorPerspective",
new InterfaceAIFComponent[]{target});
}
//如果不存在则调用SAP物料接口获取对应物料信息
String[] sapUrls = tcSession.getPreferenceService().getStringValues("SAP_url");
if(sapUrls!=null && sapUrls.length>0) {
url = sapUrls[0];
}else {
JOptionPane.showMessageDialog(this, "SAP_url preference configuration error!", "Info", JOptionPane.INFORMATION_MESSAGE);
}
sapCheck = tcSession.getPreferenceService().getStringValue("SAP_check");
if(sapCheck.isEmpty()) {
JOptionPane.showMessageDialog(this, "SAP_check preference configuration error!", "Info", JOptionPane.INFORMATION_MESSAGE);
}
MaterialPropertyBean materialInfo = materialInfoBySap(codeName);
if(materialInfo == null) {
JOptionPane.showMessageDialog(this, "SAP does not exist for this material!", "Info", JOptionPane.INFORMATION_MESSAGE);
}else {
System.out.println("get info :"+materialInfo.toString());
String selectType = map.get(objectName);
soaRetrunType = materialInfo.getMaterialType();
if(!selectType.equals(soaRetrunType)) {
JOptionPane.showMessageDialog(this, "The material code entered is incorrect, please re-enter!", "Info", JOptionPane.INFORMATION_MESSAGE);
return;
}
JTextField nameField = (JTextField)jComponents[1];
nameField.setText(materialInfo.getObjectName());
JComboBox<String> unitBox =(JComboBox) jComponents[jComponents.length-3];
unitBox.setSelectedItem(materialInfo.getVf5dw());
JComboBox<String> planBox =(JComboBox) jComponents[jComponents.length-2];
planBox.setSelectedItem(materialInfo.getVf5jhmrsx());
}
}
public boolean confirmFunction() {
Map<String, String> propMap = SwingUtil.getJComponentValue(prop, jComponents);
String selectType = map.get(objectName);
System.out.println("selectType : "+selectType);
if(soaRetrunType!=null && !soaRetrunType.isEmpty() && !selectType.equals(soaRetrunType)) {
JOptionPane.showMessageDialog(this, "The material code entered is incorrect, please re-enter!", "Info", JOptionPane.INFORMATION_MESSAGE);
return false;
}
createItem(selectType, propMap);
return true;
}
public void createItem(String itemType, Map<String, String> propMap) {
// TODO Auto-generated method stub
try {
TCComponentItemType ccpType = (TCComponentItemType) this.tcSession.getTypeComponent(itemType);
TCComponentItem ccpItem = ccpType.create(ccpType.getNewID(), "", itemType, propMap.get("object_name"), "",
null);
TCComponent[] referenceValueArray = ccpItem.getLatestItemRevision().getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
TCComponent form = referenceValueArray[0];
Set<String> keySet = propMap.keySet();
for (String key : keySet) {
if (key.equals("vf5jhmrsx")) {
form.setProperty(key,lovMap.get("VF5jhmrsx").get(propMap.get(key)));
} else {
form.setProperty(key, propMap.get(key));
}
}
targetFolder.add("contents", ccpItem);
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void run() {
InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
String itemType = targetComponent.getType();
if (targetComponent instanceof TCComponentFolder
&& (itemType.equals("VF5NPI") || itemType.equals("VF5xmwjj") || itemType.equals("Folder"))) {
targetFolder = (TCComponentFolder) targetComponent;
initUI();
} else {
JOptionPane.showMessageDialog(null, "not Folder or type error", "Warning", JOptionPane.WARNING_MESSAGE);
}
}
/**
*
*
* @param materialCode
* @return
*/
public boolean queryMaterial(String materialCode) {
try {
TCComponent[] materialObjects = tcSession.search("FTH_Find PartRevisionBywlbm", new String[] { "fth4wlbm" },
new String[] { materialCode });
if (materialObjects.length >= 1) {
TCComponent com = materialObjects[0];
// 打开对象
Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open");
OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand",
new Object[] { AIFUtility.getActiveDesktop(), com });
localOpenCommand.executeModeless();
return false;
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
/**
* sap
*
* @param param
* @param code
* @return
*/
public String sapConnect(String param, String code) {
String result = null;
HttpsURLConnection connection = null;
try {
String[] split = sapCheck.split(":");
// 基本认证用户名和密码
String basicAuth = "Basic "
+ new String(Base64.getEncoder().encode((split[0] + ":" + split[1]).getBytes()));
// 创建URL对象
URL urlObj = null;
if (code != null && code != "") {
urlObj = new URL(url + "/" + param + "/" + code);
} else {
urlObj = new URL(url + "/" + param);
}
// 打开连接
connection = (HttpsURLConnection) urlObj.openConnection();
// 添加认证头
connection.setRequestProperty("Authorization", basicAuth);
// 设置请求方法为GET
connection.setRequestMethod("GET");
// 接收响应码
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// 读取响应内容
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
result = response.toString();
// 打印结果
System.out.println(response.toString());
} catch (Exception e) {
e.getStackTrace();
System.out.println(e.getStackTrace());
} finally {
// 关闭连接
connection.disconnect();
}
return result;
}
/**
* SAP
*/
public MaterialPropertyBean materialInfoBySap(String materialCode) {
MaterialPropertyBean materiaPorptry = new MaterialPropertyBean();
// 通过接口获取物料信息
String value = sapConnect("Product", materialCode);
System.out.println("物料信息json:" + value);
if (value != null) {
JSONObject jsonObject = new JSONObject(value);
materiaPorptry.setVf5wlbm(jsonObject.getString("Product"));
System.out.println("物料编码:" + jsonObject.getString("Product"));
if ("FERT".equals(jsonObject.getString("ProductType"))) {
materiaPorptry.setMaterialType("VF5ccp");
} else if ("HALB".equals(jsonObject.getString("ProductType"))) {
materiaPorptry.setMaterialType("VF5bcp");
} else if ("ROH".equals(jsonObject.getString("ProductType"))) {
materiaPorptry.setMaterialType("VF5cl");
}
String dw = jsonObject.getString("BaseUnit");
if("ST".equals(dw)) {
materiaPorptry.setVf5dw("PC");
}else {
materiaPorptry.setVf5dw(dw);
}
} else {
return null;
}
// 物料描述信息
String value3 = sapConnect("ProductDescription(Product='" + materialCode + "',Language='EN')", "");
if (value3 != null) {
System.out.println("物料描述类型json:" + value3);
JSONObject jsonObject = new JSONObject(value3);
materiaPorptry.setObjectName(jsonObject.getString("ProductDescription"));
} else {
return null;
}
// 物料采购类型
String value2 = sapConnect("ProductPlantSupplyPlanning(Product='" + materialCode + "',Plant='5410')", "");
if (value2 != null) {
System.out.println("物料采购类型json:" + value2);
JSONObject jsonObject = new JSONObject(value2);
if ("E".equals(jsonObject.getString("ProcurementType"))) {
materiaPorptry.setVf5jhmrsx("In-House Production");
} else if ("F".equals(jsonObject.getString("ProcurementType"))) {
materiaPorptry.setVf5jhmrsx("External Procurement");
} else if ("X".equals(jsonObject.getString("ProcurementType"))) {
materiaPorptry.setVf5jhmrsx("Both Procurement Type");
}
} else {
return null;
}
return materiaPorptry;
}
}

@ -0,0 +1,13 @@
finishedProductsDialog.0=Create Finished Products
finishedProductsDialog.1=Material code
finishedProductsDialog.2=Material name
finishedProductsDialog.3=Customer drawing number
finishedProductsDialog.4=Material
finishedProductsDialog.5=Specification
finishedProductsDialog.6=Part size
finishedProductsDialog.7=Material size
finishedProductsDialog.8=Surface requirements
finishedProductsDialog.9=Cutting method
finishedProductsDialog.10=Unit
finishedProductsDialog.11=Plan default attributes
finishedProductsDialog.12=Remarks

@ -0,0 +1,72 @@
package com.connor.ferrorTech.metal.material.material;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.material.finishedProducts.ProductsCreateFrame;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class MaterialCreateHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
@SuppressWarnings("unused")
String[] chLabelName = new String[] { "物料编码", "物料名称", "客户图号", "材质", "规格", "零件尺寸", "材料尺寸", "表面要求", "切割方式",
"计量单位", "计划默认属性", "备注" };
String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
"Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
"Unit", "Plan default attributes", "Remarks" };
String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
"vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
JLabel[] jLabels = new JLabel[enLabelName.length];
JComponent[] jComponents = new JComponent[enLabelName.length];
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
Map<Integer, String[]> map = new HashMap<>();
String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
map.put(enLabelName.length - 3, inHouse);
map.put(enLabelName.length - 2, eas);
for (int i = 0; i < enLabelName.length; i++) {
if (map.containsKey(i)) {
jComponents[i] = new JComboBox<>(map.get(i));
} else {
jComponents[i] = new JTextField(14);
}
jLabels[i] = new JLabel(enLabelName[i]);
}
System.out.println("In house :" + inHouse);
for (String inhouse : inHouse) {
if (inhouse.equals("In-House Production")) {
((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
}
}
for (String ea : eas) {
if (ea.equals("EA")) {
((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
}
}
ProductsCreateFrame action = new ProductsCreateFrame(application, "Create materials", "material", jLabels,
jComponents, prop, lovMap);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,73 @@
package com.connor.ferrorTech.metal.material.semiFinishedProducts;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.material.finishedProducts.ProductsCreateFrame;
import com.connor.ferrorTech.metal.util.SwingUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
public class SemiFinishedProductsCreateHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
@SuppressWarnings("unused")
String[] chLabelName = new String[] { "物料编码", "物料名称", "客户图号", "材质", "规格", "零件尺寸", "材料尺寸", "表面要求", "切割方式",
"计量单位", "计划默认属性", "备注" };
String[] enLabelName = new String[] { "Material code", "Material name", "Customer drawing number", "Material",
"Specification", "Part size", "Material size", "Surface requirements", "Cutting method",
"Unit", "Plan default attributes", "Remarks" };
String[] prop = new String[] { "vf5wlbm", "object_name", "vf5khth", "vf5cz", "vf5gg", "vf5ljcc", "vf5clcc",
"vf5bmyq", "vf5qgfs", "vf5dw", "vf5jhmrsx", "vf5beizhu" };
JLabel[] jLabels = new JLabel[enLabelName.length];
JComponent[] jComponents = new JComponent[enLabelName.length];
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String, String>>();
Map<Integer, String[]> map = new HashMap<>();
String[] inHouse = SwingUtil.getKeyValue("VF5dwlov", lovMap);
String[] eas = SwingUtil.getKeyValue("VF5jhmrsx", lovMap);
map.put(enLabelName.length - 3, inHouse);
map.put(enLabelName.length - 2, eas);
for (int i = 0; i < enLabelName.length; i++) {
if (map.containsKey(i)) {
jComponents[i] = new JComboBox<>(map.get(i));
} else {
jComponents[i] = new JTextField(14);
}
jLabels[i] = new JLabel(enLabelName[i]);
}
System.out.println("In house :" + inHouse);
for (String inhouse : inHouse) {
if (inhouse.equals("In-House Production")) {
((JComboBox) jComponents[enLabelName.length - 2]).setSelectedItem("In-House Production");
}
}
for (String ea : eas) {
if (ea.equals("EA")) {
((JComboBox) jComponents[enLabelName.length - 3]).setSelectedItem("EA");
}
}
ProductsCreateFrame action = new ProductsCreateFrame(application, "Create semi-finished products",
"semiFinishedProducts", jLabels, jComponents, prop, lovMap);
new Thread(action).start();
return null;
}
}

@ -0,0 +1,280 @@
package com.connor.ferrorTech.metal.materialManage;
import java.util.ArrayList;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import com.teamcenter.rac.aif.AbstractAIFCommand;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class DbomTransitionToEbomCommand extends AbstractAIFCommand {
private InterfaceAIFComponent comp;
private TCSession session;
private TCComponentBOMLine bomLine = null;
static ArrayList<String> preList = new ArrayList<String>();
public DbomTransitionToEbomCommand(InterfaceAIFComponent comp, TCSession session) {
// TODO Auto-generated constructor stub
this.comp = comp;
this.session = session;
}
@Override
public void executeModal() throws Exception {
// TODO Auto-generated method stub
// TCComponentType compType = session.getTypeComponent("ML8_Washing");
// String[] allProperties=compType.getPropertyNames();//获取类所有属性
//TCProperty[] allProperties=compType.getPropertyNames();//获取类所有属性
//获取选中的对象
if(!(comp instanceof TCComponentBOMLine))
{
MessageBox.post("请在结构管理器中选中BOMLine对象", "错误", MessageBox.ERROR);
return;
}
//System.out.println("11111111111");
bomLine = (TCComponentBOMLine) comp;
//判断对象类型
TCComponentItem item = bomLine.getItem();
boolean isTypeof=false;
String[] prefValues = session.getPreferenceService().getStringValues("Connor_LY6_DBOM_Type"); //Connor_DBOM_Type
System.out.println("prefValuse"+prefValues.toString());
for(String pref : prefValues) {
if(pref.equals(item.getType())) {
isTypeof = true;
}
}
if(!isTypeof) {
MessageBox.post("请选择Connor_DBOM_Type首选项中配置的对象类型","提示",2);
return;
}
System.out.println(item.getType());
// if(!item.getType().equals("ML8_Design"))
// {
// MessageBox.post("请选中设计对象!", "错误", MessageBox.ERROR);
// return;
// }
//final List<List<Object>> bomPropertyList = this.getBomPropertys(session, bomLine);
String[] prefValueParts = session.getPreferenceService().getStringValues("Connor_LY6_DBOM_PartType");
for (String string : prefValueParts) {
preList.add(string);
}
final DefaultMutableTreeTableNode node = this.getBomPropertyToNode(session, bomLine);
new Thread() {
@Override
public void run() {
DbomTransitionToEbomDialog dialog = new DbomTransitionToEbomDialog(
comp, session,node,preList);
}
}.start();
super.executeModal();
}
/**
* BOM
* @throws TCException
*/
public static DefaultMutableTreeTableNode getBomPropertyToNode(TCSession session, TCComponentBOMLine topBomLine) throws TCException {
// TODO Auto-generated method stub
NodeBean nodeBean = new NodeBean();
//String ss = subline.getStringProperty("bl_indented_title");
//对象ID
nodeBean.setDbom("顶层");
nodeBean.setdId("");
nodeBean.setEbom("");
nodeBean.setEbomId("");
nodeBean.setNum("");
nodeBean.setLabel("");
nodeBean.setRefreshStatus("");
nodeBean.setParentString("");
DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean);
//获取BOM
try {
//getRepresentationPropertysToNode(topBomLine, rootNode, "");
getBomPropertysToNode(topBomLine, rootNode, "");
return rootNode;
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
/***
*
* @param bomLine
* @param rootNode
* @param parentID
* @throws TCException
*/
public static void getRepresentationPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID,String quantity) throws TCException
{
TCComponentItemRevision itemRevision = bomLine.getItemRevision();
//刷新表示关系
//TCComponent referenceProperty = itemRevision.getReferenceProperty("representation_for");
//referenceProperty.refresh();
//获取表示关系下的对象
itemRevision.refresh();
TCComponent[] tcComponents = itemRevision.getReferenceListProperty("representation_for");
for (TCComponent tcComponent : tcComponents) {
TCProperty refreshStatusProperty = tcComponent.getTCProperty("release_status_list");
TCComponent[] refreshStatus = refreshStatusProperty.getReferenceValueArray();
TCProperty processProperty = tcComponent.getTCProperty("process_stage_list");
TCComponent[] processStage = processProperty.getReferenceValueArray();
NodeBean nodeBean = new NodeBean();
nodeBean.setDbom("");
nodeBean.seteRevision((TCComponentItemRevision)tcComponent);
nodeBean.setEbom(tcComponent.getStringProperty("object_string"));
nodeBean.setEbomId(tcComponent.getStringProperty("item_id"));
nodeBean.setEbomDesc(tcComponent.getStringProperty("ld6_materialDesc"));
nodeBean.setNum(quantity);
nodeBean.setLabel("0");
if(refreshStatus.length > 0)
{
StringBuffer stringBuffer = new StringBuffer();
//添加发布状态
for (int i = 0; i < refreshStatus.length; i++) {
stringBuffer.append(refreshStatus[i].toString());
if(i < refreshStatus.length - 1)
{
stringBuffer.append(",");
}
}
nodeBean.setRefreshStatus(stringBuffer.toString());
}
else if(processStage.length > 0)
{
nodeBean.setRefreshStatus("流程中");
}
else
{
nodeBean.setRefreshStatus("");
}
nodeBean.setParentString(itemRevision.getStringProperty("object_string"));
DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean);
rootNode.add(node);
if(tcComponents.length == 1)
{
if(getTopRefresh(node))
{
nodeBean.setLabel("0");
}
else
{
nodeBean.setLabel("1");
}
}
}
}
/***
*
* @param node
* @return
*/
private static boolean getTopRefresh(DefaultMutableTreeTableNode node)
{
boolean result = false;
//判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if(parentNode != null)
{
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if(rootNode != null)
{
for (int i = 0; i < rootNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if(childBean.getLabel().equals("1") && childBean.getRefreshStatus().indexOf("发布") >= 0)
{
//MessageBox.post("上层["+childBean.getEbom()+"]已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return true;
}
else
{
return getTopRefresh(childNode);
}
}
}
}
return result;
}
/**
* BOM
* @param bomLine
* @param bomPropertyList
* @param parentID
*/
public static void getBomPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID)
{
try {
NodeBean nodeBean = new NodeBean();
System.out.println(bomLine.getStringProperty("bl_item_object_type"));
if(bomLine.getStringProperty("bl_item_object_type").equals("LD6_3Ddesign")) {
return;
}
nodeBean.setdId(bomLine.getStringProperty("bl_item_item_id"));
nodeBean.setDbom(bomLine.getStringProperty("bl_item_object_string"));
nodeBean.setNum(bomLine.getStringProperty("bl_quantity"));
nodeBean.setEbom("");
nodeBean.setEbomId("");
if(preList.contains(bomLine.getStringProperty("bl_item_object_type"))) {
nodeBean.setLabel("0");
}else {
nodeBean.setLabel("");
}
nodeBean.setRefreshStatus("");
nodeBean.setParentString("");
DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean);
rootNode.add(node);
getRepresentationPropertysToNode(bomLine, node,bomLine.getStringProperty("bl_item_item_id"),bomLine.getStringProperty("bl_quantity"));
if(bomLine.getChildren().length > 0)
{
AIFComponentContext aif[] = bomLine.getChildren();
for (int i = 0; i < aif.length; i++)
{
TCComponentBOMLine subline = (TCComponentBOMLine) aif[i]
.getComponent();
getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id"));
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

@ -0,0 +1,818 @@
package com.connor.ferrorTech.metal.materialManage;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.tree.TreePath;
import org.jdesktop.swingx.decorator.HighlighterFactory;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import com.connor.ferrorTech.metal.util.Adapter;
import com.connor.ferrorTech.metal.util.MethodUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aif.kernel.AIFComponentContext;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.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.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.TCUserService;
import com.teamcenter.rac.util.MessageBox;
//import com.teamcenter.soa.exceptions.NotLoadedException;
public class DbomTransitionToEbomDialog extends AbstractAIFDialog implements ActionListener, MouseListener {
private TCSession session;
private InterfaceAIFComponent comp;
// private InterfaceAIFComponent comp;//获取选中的对象
private List<Integer> isNotEditableRow = new ArrayList<Integer>();
// private TCComponentBOMLine bomLine;
private DefaultMutableTreeTableNode node;
private String[] header = new String[] { "DBOM对象", "EBOM对象", "选中", "EBOMID", "物料描述", "数量", "发布状态", "对应父节点" };
private String[] needChangeUomTypeList = new String[] { "Part", "Design", "LY6_Product", "LY6_Component",
"LY6_Part", "LY6_EnStandardP", "LY6_StandardP", "LY6_SemiformedP", "LY6_CastingP", "LY6_Equipment",
"LY6_MeasureTool", "LY6_Mold" };
private JPanel titlePanel;
private JLabel titleLabel;
private JTreeTable table;
private JTreeTableModel map;
private JPanel rootPanel;
private JButton okButton;
private JButton celButton;
private JButton refreshButton;
private ArrayList<String> preList;
public DbomTransitionToEbomDialog(InterfaceAIFComponent comp, TCSession session, DefaultMutableTreeTableNode node,
ArrayList<String> preList) {
// TODO Auto-generated constructor stub
super(false);
this.session = session;
this.comp = comp;
this.node = node;
this.preList = preList;
init();
}
private void init() {
// TODO Auto-generated method stub
this.setTitle("DBOM转EBOM");
this.setPreferredSize(new Dimension(800, 600));
// 初始化标题部分控件
this.titlePanel = new JPanel();
this.titleLabel = new JLabel("DBOM转EBOM");
this.titleLabel.setFont(new Font("宋体", 1, 18));
this.titlePanel.add(titleLabel);
JPanel panel = new JPanel();
panel.add(this.titlePanel, BorderLayout.NORTH);
this.table = getJTreeTable(null, null, header, null);
this.table.addMouseListener(this);
Adapter adapter = new Adapter(table);
this.rootPanel = new JPanel(new FlowLayout());
this.okButton = new JButton("确认");
this.celButton = new JButton("取消");
this.refreshButton = new JButton("刷新");
this.rootPanel.add(okButton);
this.rootPanel.add(celButton);
this.rootPanel.add(refreshButton);
// this.rootPanel.add(celValueButton);
// 添加鼠标监听
this.createActionEvent();
this.setLayout(new BorderLayout());
// this.add(centerPanel, BorderLayout.NORTH);
this.add(panel, BorderLayout.NORTH);
this.add(new JScrollPane(this.table), BorderLayout.CENTER);
// dialog.add(tablePanel, BorderLayout.CENTER);
this.add(rootPanel, BorderLayout.SOUTH);
// this.setAlwaysOnTop(true);
this.pack();
this.setLocationRelativeTo(null);
this.show();
}
// 添加监听
public void createActionEvent() {
this.okButton.addActionListener(this);
this.celButton.addActionListener(this);
this.refreshButton.addActionListener(this);
// this.celValueButton.addActionListener(this);
}
// Jtable通用方法
public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames,
Object[][] values) {
int simpleLen = 100;
int totleLen = 1500;
if (partsTable == null) {
this.map = new JTreeTableModel(this.node);
this.map.setIsNotEditableRow(this.isNotEditableRow);
// map.setColumnIdentifiers(titleNames);
partsTable = new JTreeTable(map);
partsTable.setIsNotEditableRow(this.isNotEditableRow);
partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
// partsTable.setRowHeight(1, 50);
// partsTable.setRowHeight(2, 100);
partsTable.setRowHeight(30);
partsTable.expandAll(); // 展开全部节点
// 隐藏列
// partsTable.HiddenCell(0);
partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // 设置第一列宽度
partsTable.getColumnModel().getColumn(1).setPreferredWidth(150); // 设置第二列宽度
partsTable.getColumnModel().getColumn(2).setPreferredWidth(55); // 设置第三列宽度
partsTable.setHighlighters(HighlighterFactory.createSimpleStriping());
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 mouseClicked(MouseEvent e) {
// TODO Auto-generated method stub
if (e.getClickCount() == 2) {
TreePath treePath = table.getPathForLocation(e.getX(), e.getY());
if (treePath != null) {
DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent();
NodeBean nodeBean = (NodeBean) node.getUserObject();
String itemId = nodeBean.getdId();
if (itemId != null && !itemId.isEmpty()) {
try {
// 获取对象
TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item");
TCComponentItem[] item = itemType.findItems(itemId);
com.teamcenter.rac.common.Activator.getDefault()
.openPerspective("com.teamcenter.rac.ui.perspectives.navigatorPerspective");
com.teamcenter.rac.common.Activator.getDefault().openComponents(
"com.teamcenter.rac.ui.perspectives.navigatorPerspective",
new InterfaceAIFComponent[] { item[0] });
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}
} else if (e.getClickCount() > 0) {
// 获得选中列
int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint());
if (selectColumn != 2) {
return;
}
TreePath treePath = table.getPathForLocation(e.getX(), e.getY());
if (treePath != null) {
DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent();
NodeBean nodeBean = (NodeBean) node.getUserObject();
if (getTopRefresh(node)) {
MessageBox.post("上层已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
if (getTopProcessRefresh(node)) {
MessageBox.post("上层已勾选流程中的对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if (parentNode != null) {
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
NodeBean rootNodeBean = (NodeBean) rootNode.getUserObject();
if (!rootNodeBean.getDbom().equals("顶层") && !getTop(node) && nodeBean.getLabel().equals("0")) {
MessageBox.post("上层未勾选对象,下层不允许勾选!", "错误", MessageBox.ERROR);
return;
}
}
try {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
if (nodeBean.getLabel().equals("0")) {
// 判断同一层是否已勾选
if (parentNode != null) {
for (int i = 0; i < parentNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode
.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if (childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty()
&& !nodeBean.getEbom().isEmpty()) {
MessageBox.post("同一层级只允许选中一个!", "错误", MessageBox.ERROR);
return;
}
}
}
nodeBean.setLabel("1");
// isHaveBom(node, nodeBean.getEbomId(), "1", itemType);
} else if (nodeBean.getLabel().equals("1")) {
nodeBean.setLabel("0");
// isHaveBom(node, nodeBean.getEbomId(), "0", itemType);
}
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}
}
/***
*
*
* @param node
* @return
* @throws TCException
*/
private void isHaveBom(DefaultMutableTreeTableNode node, String parentID, String status,
TCComponentItemType itemType) throws TCException {
TCComponentItem[] item = itemType.findItems(parentID);
TCComponentItemRevision itemRevision = item[0].getLatestItemRevision();
TCComponent[] tcComponents = itemRevision.getReferenceListProperty("view");
if (tcComponents.length > 0) {
for (int ii = 0; ii < node.getParent().getChildCount(); ii++) {
DefaultMutableTreeTableNode tableNode = (DefaultMutableTreeTableNode) node.getParent().getChildAt(ii);
if (tableNode.getChildCount() > 0) {
for (int i = 0; i < tcComponents.length; i++) {
TCComponent childBomLine = tcComponents[i];
List<String> haveItemID = new ArrayList<String>();
for (int j = 0; j < tableNode.getChildCount(); j++) {
String childItemId = childBomLine.getStringProperty("item_id");
NodeBean childNodeBean = (NodeBean) tableNode.getChildAt(j).getUserObject();
if (childItemId.equals(childNodeBean.getEbomId())
&& !haveItemID.contains(childNodeBean.getEbomId())) {
haveItemID.add(childNodeBean.getEbomId());
childNodeBean.setLabel(status);
isHaveBom((DefaultMutableTreeTableNode) (tableNode.getChildAt(j)),
childNodeBean.getEbomId(), status, itemType);
}
}
}
}
}
}
}
/***
*
*
* @param node
* @return
*/
private boolean getTop(DefaultMutableTreeTableNode node) {
boolean result = false;
// 判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if (parentNode != null) {
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if (rootNode != null) {
for (int i = 0; i < rootNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if (childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty()) {
// MessageBox.post("上层["+childBean.getEbom()+"]已勾选发布的对象,下层不允许勾选!", "错误",
// MessageBox.ERROR);
return true;
}
}
}
}
return result;
}
/***
*
*
* @param node
* @return
*/
private boolean getTopRefresh(DefaultMutableTreeTableNode node) {
boolean result = false;
// 判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if (parentNode != null) {
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if (rootNode != null) {
for (int i = 0; i < rootNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if (childBean.getLabel().equals("1") && !childBean.getRefreshStatus().equals("属性发布")
&& !childBean.getRefreshStatus().isEmpty()) {
result = true;
break;
} else {
if (getTopRefresh(childNode)) {
result = true;
break;
}
}
}
}
}
return result;
}
/***
*
*
* @param node
* @return
*/
private boolean getTopProcessRefresh(DefaultMutableTreeTableNode node) {
boolean result = false;
// 判断上层是否勾选已发布的对象
DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent();
if (parentNode != null) {
DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent();
if (rootNode != null) {
for (int i = 0; i < rootNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
if (childBean.getLabel().equals("1") && childBean.getRefreshStatus().equals("流程中")) {
result = true;
break;
} else {
if (getTopProcessRefresh(childNode)) {
result = true;
break;
}
}
}
}
}
return result;
}
@Override
public void mousePressed(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Object source = e.getSource();
if (source.equals(this.okButton)) {
// 获取选中的EBOM对象
try {
MethodUtil.openByPass(session);
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item");
this.adaptiveVariants((DefaultMutableTreeTableNode) (this.node.getChildAt(0)), itemType, true);
MethodUtil.closeByPass(session);
MessageBox.post("转换成功!", "成功", MessageBox.INFORMATION);
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else if (source.equals(this.refreshButton)) {
this.dispose();
try {
DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(comp, session);
command.executeModal();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} else {
this.dispose();
}
}
public boolean isEmpty(String str) {
return str == null || "".equals(str.trim());
}
public String getText(TCSession session, String str) throws Exception {
if (isEmpty(str)) {
return str;
} else {
String res = session.getTextService().getTextValue(str);
return !isEmpty(res) ? res : str;
}
}
public TCComponentItem getItemById(String id) {
try {
System.out.println("用户条目:" + getText(session, "ItemID"));
// 设置查询的条件
String[] keys = new String[] { getText(session, "ItemID") };
// 设置查询的id值
String[] values = new String[] { id };
List<TCComponent> comps = queryObject("零组件...", keys, values);
if (comps != null || comps.size() > 0) {
return (TCComponentItem) comps.get(0);
} else {
MessageBox.post("根据首选项配置没有查询到对象", "错误", MessageBox.ERROR);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public List<TCComponent> queryObject(String queryName, String[] keys, String[] values) {
TCComponent[] components = null;
try {
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) app.getSession();
TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery");
TCComponentQuery query = (TCComponentQuery) queryType.find(queryName);
if (query == null) {
MessageBox.post("没有找到查询:" + queryName, "错误", MessageBox.ERROR);
return null;
}
components = query.execute(keys, values);
} catch (TCException e) {
e.printStackTrace();
}
if (components != null && components.length > 0) {
List<TCComponent> compList = Arrays.asList(components);
return compList;
} else {
MessageBox.post("没有查询到对象", "错误", MessageBox.ERROR);
return null;
}
}
TCComponentBOMLine resultTopline = null;
/**
* BOM
*
* @param topItem
* @throws TCException
*/
private void adaptiveVariants(DefaultMutableTreeTableNode tableNode, TCComponentItemType itemType, boolean ifCreate)
throws TCException {
TCComponentItem topItem = null;
// 存放id相同时更新数量
LinkedHashMap<TCComponentItemRevision, Integer> countMap = new LinkedHashMap<TCComponentItemRevision, Integer>();
ArrayList<TCComponentItemRevision> itemList = new ArrayList<TCComponentItemRevision>();
Map<String, String> itemNumMap = new HashMap<String, String>();
System.out.println("adaptiveVariants called with ifCreate: " + ifCreate);
for (int i = 0; i < tableNode.getChildCount(); i++) {
DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i);
NodeBean childBean = (NodeBean) childNode.getUserObject();
System.out.println("Processing child node " + i + " with label: " + childBean.getLabel());
if (childBean.getLabel().equals("1") && !childBean.getEbom().isEmpty()) {
// topItem = itemType.findItems(childBean.getEbomId());
topItem = childBean.geteRevision().getItem();
System.out.println("Found topItem with EBOM ID: " + childBean.getEbomId());
for (int j = 0; j < tableNode.getChildCount(); j++) {
DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) tableNode.getChildAt(j);
if (ifCreate) {
NodeBean childBean2 = (NodeBean) node.getUserObject();
String dbom = childBean2.getDbom();
System.out.println("Processing sub-child node " + j + " with label: " + childBean2.getLabel()
+ ", Dbom: " + dbom);
if (!dbom.isEmpty()) {
String id = childBean2.getdId();
System.out.println("id:" + id);
TCComponentItem[] createItem = itemType.findItems(id);
System.out
.println("Found createItem with ID: " + id + ", Type: " + createItem[0].getType());
if (childBean2.getLabel().equals("1") && preList.contains(createItem[0].getType())) {
System.out.println("child id material ===>" + id);
System.out.println("parent id EBOM ===>" + childBean.getEbomId());
String num = childBean2.getNum();
if (num == null || num.isEmpty() || num.equals("0")) {
num = "1";
}
System.out.println("Updating countMap for "
+ createItem[0].getLatestItemRevision().getProperty("item_id") + " with num: "
+ num);
if (countMap.containsKey(createItem[0].getLatestItemRevision())) {
Integer integer = countMap.get(createItem[0].getLatestItemRevision());
countMap.put(createItem[0].getLatestItemRevision(),
Integer.parseInt(num) + integer);
} else {
countMap.put(createItem[0].getLatestItemRevision(), Integer.parseInt(num));
}
}
}
}
for (int k = 0; k < node.getChildCount(); k++) {
DefaultMutableTreeTableNode childTableNode = (DefaultMutableTreeTableNode) node.getChildAt(k);
NodeBean childNodeBean = (NodeBean) childTableNode.getUserObject();
System.out.println(
"Processing grandchild node " + k + " with label: " + childNodeBean.getLabel());
if (childNodeBean.getLabel().equals("1")) {
TCComponentItem item = null;
if (childNodeBean.getEbomId() == null || childNodeBean.getEbomId().isEmpty()) {
String id = childNodeBean.getdId();
System.out.println("id:" + id);
item = itemType.findItems(id)[0];
System.out.println("Found item with ID: " + id);
} else {
item = childNodeBean.geteRevision().getItem();
System.out.println("Found item with EBOM ID: " + childNodeBean.getEbomId());
}
if (preList.contains(item.getType())) {
continue;
}
String num = childNodeBean.getNum();
if (num == null || num.isEmpty() || num.equals("0")) {
num = "1";
}
System.out.println("Updating countMap for "
+ item.getLatestItemRevision().getProperty("item_id") + " with num: " + num);
if (countMap.containsKey(item.getLatestItemRevision())) {
Integer integer = countMap.get(item.getLatestItemRevision());
countMap.put(item.getLatestItemRevision(), Integer.parseInt(num) + integer);
} else {
countMap.put(item.getLatestItemRevision(), Integer.parseInt(num));
}
itemList.add(item.getLatestItemRevision());
System.out.println("Updating itemNumMap for " + item.getStringProperty("item_id")
+ " with num: " + num);
if (itemNumMap.containsKey(item.getStringProperty("item_id"))) {
String integer = itemNumMap.get(item.getStringProperty("item_id"));
itemNumMap.put(item.getStringProperty("item_id"),
Integer.parseInt(num) + Integer.parseInt(integer) + "");
} else {
itemNumMap.put(item.getStringProperty("item_id"), Integer.parseInt(num) + "");
}
if (childNodeBean.getRefreshStatus().equals("属性发布")
|| childNodeBean.getRefreshStatus().equals("")) {
System.out.println("Calling recursive adaptiveVariants for node " + k);
adaptiveVariants((DefaultMutableTreeTableNode) (childTableNode.getParent()), itemType,
true);
}
}
}
}
}
}
if (topItem != null) {
System.out.println("Processing topItem with ID: " + topItem.getProperty("item_id"));
resultTopline = null;
TCComponentBOMWindow recreateBom = this.recreateBom(topItem.getLatestItemRevision(), itemList, true,
countMap);
if (resultTopline != null) {
resultTopline.lock();
System.out.println("Setting BOM line properties for topItem: " + topItem.getProperty("item_id"));
Map<String, String> qMap = new HashMap<String, String>();
for (int j = 0; j < resultTopline.getChildren().length; j++) {
TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent();
System.out.println("bomLine.getItem().getType():" + bomLine.getItem().getType());
if (Arrays.asList(needChangeUomTypeList).contains(bomLine.getItem().getType())) {
// 修改单位
System.out.println("开始修改单位");
String uomName = "Each.";
try {
TCUserService userservice = session.getUserService();
userservice.call("connor_set_uom", new Object[] { bomLine.getItem(), uomName });
} catch (Exception e) {
e.printStackTrace();
System.out.println("【connor_set_uom】命名的方法未注册有用户服务");
}
System.out.println("修改单位完毕");
}
bomLine.lock();
if (countMap.containsKey(bomLine.getItemRevision())) {
bomLine.setStringProperty("bl_quantity",
String.valueOf(countMap.get(bomLine.getItemRevision())));
System.out.println("Set bl_quantity for item " + bomLine.getItem().getProperty("item_id")
+ " to " + countMap.get(bomLine.getItemRevision()));
}
if (itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) {
String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"));
System.out.println("Found quantity for item " + bomLine.getItem().getProperty("item_id") + ": "
+ quantity);
if (quantity == null || quantity.isEmpty() || quantity.equals("0")) {
String uom = "";
try {
uom = bomLine.getPropertyDisplayableValue("bl_uom");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Unit of measure for item " + bomLine.getItem().getProperty("item_id")
+ ": " + uom);
if (!uom.equals("每个")) {
quantity = "1.00";
}
}
System.out.println("Setting bl_quantity for item " + bomLine.getItem().getProperty("item_id")
+ " to " + quantity);
if (quantity.indexOf(".") > 0) {
Double bomNum = Double.parseDouble(quantity);
System.out.println("bomNum:" + bomNum);
System.out.println("开始设置值bl_quantity为" + bomNum);
bomLine.setStringProperty("bl_quantity", bomNum.toString());
qMap.put(bomLine.getItem().getStringProperty("item_id"), bomNum.toString());
} else {
Integer bomNum = Integer.parseInt(quantity);
System.out.println("bomNum:" + bomNum);
System.out.println("开始设置值bl_quantity为" + bomNum);
bomLine.setStringProperty("bl_quantity", bomNum.toString());
qMap.put(bomLine.getItem().getStringProperty("item_id"), bomNum.toString());
}
}
bomLine.save();
bomLine.unlock();
}
resultTopline.save();
resultTopline.unlock();
resultTopline.refresh();
if (resultTopline.getBOMView() != null) {
resultTopline.getBOMView().save();
resultTopline.getBOMView().unlock();
resultTopline.getBOMView().refresh();
System.out.println("Refreshed BOM view for topItem: " + topItem.getProperty("item_id"));
System.out.println("递归设置值");
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = winType.create(null);
TCComponentBOMLine line = view.setWindowTopLine(topItem, topItem.getLatestItemRevision(), null, null);
reviceQuantity(line, qMap);
view.close();
}
}
recreateBom.close();
}
}
private void reviceQuantity(TCComponentBOMLine topBomLine, Map<String, String> qMap) throws TCException {
// TODO Auto-generated method stub
if (topBomLine.hasChildren()) {
AIFComponentContext[] childrens = topBomLine.getChildren();
for (AIFComponentContext aifComponentContext : childrens) {
TCComponentBOMLine bomLine = (TCComponentBOMLine) aifComponentContext.getComponent();
if(qMap.containsKey(bomLine.getItem().getStringProperty("item_id"))) {
bomLine.lock();
bomLine.setProperty("bl_quantity", qMap.get(bomLine.getItem().getStringProperty("item_id")));
bomLine.save();
bomLine.unlock();
}
reviceQuantity(bomLine,qMap);
}
}
}
/**
* BOM
*
* @param item
* @param itemlists
* @throws TCException
*/
public TCComponentBOMWindow recreateBom(TCComponentItemRevision topItemRev,
ArrayList<TCComponentItemRevision> itemRevisionlists, boolean isDelete,
HashMap<TCComponentItemRevision, Integer> countMap) throws TCException {
TCComponentBOMWindow bomWindow = null;
try {
System.out.println("Starting to recreate BOM for topItemRev: " + topItemRev.getProperty("item_id"));
TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow");
bomWindow = bomWindowType.create(null);
System.out.println("Created BOM window.");
TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null);
resultTopline = topline;
bomWindow.lock();
topline.lock();
System.out.println("Locked BOM window and top line.");
if (isDelete) {
System.out.println("Deleting existing children from top line.");
if (topline.hasChildren()) {
AIFComponentContext[] childrens = topline.getChildren();
for (AIFComponentContext children : childrens) {
((TCComponentBOMLine) children.getComponent()).cut();
System.out.println(
"Deleted child with ID: " + children.getComponent().getProperty("bl_child_id"));
}
}
}
System.out.println("Adding items from countMap to top line.");
Set<Entry<TCComponentItemRevision, Integer>> entrySet = countMap.entrySet();
for (Entry<TCComponentItemRevision, Integer> entry : entrySet) {
topline.add(entry.getKey().getItem(), entry.getKey(), null, false, "");
System.out.println(
"Added item " + entry.getKey().getProperty("item_id") + " with quantity " + entry.getValue());
}
topline.save();
topline.unlock();
topline.refresh();
System.out.println("Saved, unlocked, and refreshed top line.");
if (topline.getBOMView() != null) {
topline.getBOMView().save();
topline.getBOMView().unlock();
topline.getBOMView().refresh();
System.out.println("Saved, unlocked, and refreshed BOM view.");
}
} catch (Exception e) {
System.out.println("Exception occurred while recreating BOM:");
e.printStackTrace();
} finally {
if (bomWindow != null) {
bomWindow.save();
bomWindow.unlock();
bomWindow.refresh();
System.out.println("Saved, unlocked, refreshed, and closed BOM window.");
}
}
return bomWindow;
}
}

@ -0,0 +1,30 @@
package com.connor.ferrorTech.metal.materialManage;
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 DbomTransitionToEbomHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
// TODO Auto-generated method stub
AbstractAIFApplication app = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) app.getSession();
try {
DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(app.getTargetComponent(),session);
command.executeModal();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}

@ -0,0 +1,85 @@
package com.connor.ferrorTech.metal.materialManage;
import java.awt.event.MouseEvent;
import java.util.List;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import org.jdesktop.swingx.JXTreeTable;
public class JTreeTable extends JXTreeTable {
private List<Integer> isNotEditableRow;
//CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this);
TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this);
public List<Integer> getIsNotEditableRow() {
return isNotEditableRow;
}
public void setIsNotEditableRow(List<Integer> isNotEditableRow) {
this.isNotEditableRow = isNotEditableRow;
}
public JTreeTable(JTreeTableModel testTreeTableModel) {
// TODO Auto-generated constructor stub
super(testTreeTableModel);
}
@Override
public boolean isCellEditable(int arg0, int arg1) {
// TODO Auto-generated method stub
return true;//super.isCellEditable(arg0, arg1);
}
@Override
public TableCellEditor getCellEditor(int row, int column) {
// TODO Auto-generated method stub
//if(isNotEditableRow.contains(row) && column == 2)
return cellEditor;
//return super.getCellEditor(row, column);
}
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
public TableCellRenderer getCellRenderer(int row, int column) {
// TODO Auto-generated method stub
if(this.getValueAt(row, 2) != null && (this.getValueAt(row, 2).toString().equals("0") || this.getValueAt(row, 2).toString().equals("1")) && column == 2)
{
return checkboxRenderer;
}
else
{
return super.getCellRenderer(row, column);
}
}
// 茶꾜죗
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);
}
}

@ -0,0 +1,117 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.connor.ferrorTech.metal.materialManage;
import java.util.List;
import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;
import org.jdesktop.swingx.treetable.TreeTableNode;
/**
*
* @author vearn
*/
public class JTreeTableModel extends DefaultTreeTableModel {
private String[] _names = { "DBOM对象", "EBOM对象","选中", "EBOMID", "物料描述","数量","发布状态","对应父节点"};
private List<Integer> isNotEditableRow;
public JTreeTableModel(TreeTableNode node) {
super(node);
}
public List<Integer> getIsNotEditableRow() {
return isNotEditableRow;
}
public void setIsNotEditableRow(List<Integer> isNotEditableRow) {
this.isNotEditableRow = isNotEditableRow;
}
/**
*
*/
@Override
public int getColumnCount() {
return _names.length;
}
/**
*
*/
@Override
public String getColumnName(int column) {
return _names[column];
}
/**
* Object
*/
@Override
public Object getValueAt(Object node, int column) {
Object value = null;
if (node instanceof DefaultMutableTreeTableNode) {
DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node;
Object o = mutableNode.getUserObject();
if (o != null && o instanceof NodeBean) {
NodeBean bean = (NodeBean) o;
switch (column) {
case 0:
value = bean.getDbom();
break;
case 1:
value = bean.getEbom();
break;
case 2:
value = bean.getLabel();
break;
case 3:
value = bean.getEbomId();
break;
case 4:
value = bean.getEbomDesc();
break;
case 5:
value = bean.getNum();
break;
case 6:
value = bean.getRefreshStatus();
break;
case 7:
value = bean.getParentString();
break;
}
}
}
return value;
}
/**
*
*
* @param the node (i.e. row) for which editing is to be determined
* @param the column for which editing is to be determined
* @return false
*/
@Override
public boolean isCellEditable(Object node, int column) {
//if(column == 5)
//{
return true;
//}
//else
//{
// return false;
//}
}
}

@ -0,0 +1,87 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.connor.ferrorTech.metal.materialManage;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
/**
*
* @author vearn
*/
public class NodeBean {
private String dbom;//对象ID
private String dId; //dBOMID
private String ebom;//对象名称
private TCComponentItemRevision eRevision;//eBOm版本对象
private String ebomId;//对象名称
private String ebomDesc;//物料描述
private String num;//数量
private String label;//对象名称
private String refreshStatus;//发布状态
private String parentString;//对应父节点
public TCComponentItemRevision geteRevision() {
return eRevision;
}
public void seteRevision(TCComponentItemRevision eRevision) {
this.eRevision = eRevision;
}
public String getdId() {
return dId;
}
public void setdId(String dId) {
this.dId = dId;
}
public String getDbom() {
return dbom;
}
public void setDbom(String dbom) {
this.dbom = dbom;
}
public String getEbom() {
return ebom;
}
public void setEbom(String ebom) {
this.ebom = ebom;
}
public String getEbomId() {
return ebomId;
}
public void setEbomId(String ebomId) {
this.ebomId = ebomId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getRefreshStatus() {
return refreshStatus;
}
public void setRefreshStatus(String refreshStatus) {
this.refreshStatus = refreshStatus;
}
public String getParentString() {
return parentString;
}
public void setParentString(String parentString) {
this.parentString = parentString;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getEbomDesc() {
return ebomDesc;
}
public void setEbomDesc(String ebomDesc) {
this.ebomDesc = ebomDesc;
}
}

@ -0,0 +1,71 @@
package com.connor.ferrorTech.metal.materialManage;
import java.awt.Component;
import java.util.List;
import javax.swing.JCheckBox;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.EventListenerList;
import javax.swing.table.TableCellRenderer;
public class TableCellCheckboxRenderer extends JCheckBox implements
TableCellRenderer {
private List<Integer> processRows;
protected EventListenerList listenerList = new EventListenerList();
protected ChangeEvent changeEvent = new ChangeEvent(this);
//private TestTreeTableModel tableModel;
public List<Integer> getProcessRows() {
return processRows;
}
public void setProcessRows(List<Integer> processRows) {
this.processRows = processRows;
}
public TableCellCheckboxRenderer(final JTreeTable table) {
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
// TODO Auto-generated method stub
this.setHorizontalAlignment(SwingConstants.CENTER);// ±íÍ·±êÇ©¾çÖÐ
this.setBorderPainted(true);
if(value != null)
{
// if(value.toString().equals("1"))
// {
// if(table.getColumnName(column).equals("¸ÄÖÆ") && hasFocus)
// {
// if(table.getValueAt(row, column + 1).toString().equals("1"))
// {
// table.setValueAt(0, row, column + 1);
// }
// }
// else if(table.getColumnName(column).equals("ɾ³ý") && hasFocus)
// {
// if(table.getValueAt(row, column - 1).toString().equals("1"))
// {
// table.setValueAt(0, row, column - 1);
// }
// }
// }
// if(value.toString().equals("1"))
// {
// System.out.println(value.toString().equals("1") + "====");
// }
this.setSelected(value.toString().equals("1"));
}
else
{
this.setSelected(false);
}
return this;
}
}

@ -0,0 +1,222 @@
package com.connor.ferrorTech.metal.processManagement.classificationCraft;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.processManagement.entity.CustomTableCellRenderer;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCClassificationService;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSSearchResult;
import java.util.Arrays;
public class ClassificationCraftDialog extends JFrame implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private final String title;
private final JLabel[] jLabels;
private final JComponent[] jComponents;
private JButton searchButton;
private JButton confirmButton;
private JButton cancelButton;
private JTable table;
private String[][] data;
private String[][] filteredData;
public ClassificationCraftDialog(AbstractAIFApplication application, String title, Object... args) {
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
int count = 0;
this.title = title;
this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++];
this.data = (String[][]) args[count];
this.filteredData = data;
}
@Override
public void run() {
// TODO Auto-generated method stub
InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
String itemType = targetComponent.getType();
if (itemType.equals("VF5ccpRevision") || itemType.equals("VF5bcpRevision")) {
initUI();
} else {
JOptionPane.showMessageDialog(null, "Incorrect version!", "Error", JOptionPane.WARNING_MESSAGE);
}
}
public void initUI() {
// 设置窗口居中
this.setTitle(title);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setSize(780, 450); // 设置窗口大小
this.setLayout(new BorderLayout()); // 设置布局
initializationButton();
// 创建顶部面板包含工艺ID和工艺名称的输入框
JPanel topPanel = createTopPanel();
// 创建中间面板,包含工艺列表
JPanel centerPanel = createCenterPanel();
// 将面板添加到主窗口
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public void initializationButton() {
searchButton = new JButton(ConstantPool.EN_BUTTON_SEARCH);
searchButton.setPreferredSize(new Dimension(87, 25));
searchButton.addActionListener(e -> {
searchList();
});
confirmButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
confirmButton.setPreferredSize(new Dimension(87, 25)); // 设置确定按钮的长宽为100x30
confirmButton.addActionListener(e -> {
// 在这里执行确定操作,例如关闭窗口等
this.dispose();
doTask();
});
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
cancelButton.setPreferredSize(new Dimension(87, 25)); // 设置取消按钮的长宽为100x30
cancelButton.addActionListener(e -> {
// 在这里执行取消操作,例如关闭窗口等
this.dispose();
});
}
public JPanel createTopPanel() {
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
topPanel.setBorder(BorderFactory.createEmptyBorder(20, 5, 5, 10));
Font serif = new Font("Serif", Font.BOLD, 13);
for (int i = 0; i < jLabels.length; i++) {
jLabels[i].setFont(serif);
topPanel.add(jLabels[i]);
jComponents[i].setFont(serif);
topPanel.add(jComponents[i]);
}
topPanel.add(searchButton);
topPanel.add(confirmButton);
topPanel.add(cancelButton);
return topPanel;
}
public JPanel createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout());
centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
// 创建自定义的 TableModel
AbstractTableModel tableModel = new AbstractTableModel() {
@Override
public int getRowCount() {
return data.length;
}
@Override
public int getColumnCount() {
return 1; // 只有一列
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
// 返回每一行的第一列数据
return data[rowIndex][1];
}
};
// 创建 JTable 并设置模型
table = new JTable(tableModel);
table.setTableHeader(null); // 去掉表头
table.setShowGrid(false); // 去掉网格线
table.setRowHeight(22); // 设置行高为30像素
table.setIntercellSpacing(new Dimension(0, 0)); // 去掉单元格之间的间距
table.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
centerPanel.add(new JScrollPane(table), BorderLayout.CENTER);
return centerPanel;
}
public void searchList() {
String id = ((JTextField) jComponents[0]).getText();
String name = ((JTextField) jComponents[1]).getText();
// 过滤数据
filteredData = new String[data.length][data[0].length];
int row = 0;
for (String[] item : data) {
String[] splitItem = item[1].split(":");
boolean matchId = id.isEmpty() || splitItem[0].contains(id);
boolean matchName = name.isEmpty() || splitItem[1].contains(name);
if (matchId && matchName) {
filteredData[row++] = item;
}
}
AbstractTableModel tableModel = new AbstractTableModel() {
@Override
public int getRowCount() {
return filteredData.length;
}
@Override
public int getColumnCount() {
return 1; // 只有一列
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return filteredData[rowIndex][1];
}
};
table.setModel(tableModel);
}
public void doTask() {
// 获取表格中选中的行索引
int[] selectedRow = table.getSelectedRows();
if (selectedRow.length > 0) {
String[][] selectItems = new String[selectedRow.length][];
for (int i = 0; i < selectedRow.length; i++) {
String[] selectedItem = filteredData[selectedRow[i]];
selectItems[i] = selectedItem;
System.out.println("Selected Item: " + Arrays.toString(selectedItem));
}
String[] uid = new String[selectItems.length];
for (int i = 0; i < selectItems.length; i++) {
uid[i] = selectItems[i][0];
}
ClassificationCraftOperation classificationCraftOperation = new ClassificationCraftOperation(application,
uid);
// 关闭窗口
this.dispose();
this.tcSession.queueExcludedOperation(classificationCraftOperation);
} else {
// 如果没有选中任何行,可以弹出提示信息
JOptionPane.showMessageDialog(this, "Please select a row.", "No Selection", JOptionPane.WARNING_MESSAGE);
}
}
}

@ -0,0 +1,66 @@
package com.connor.ferrorTech.metal.processManagement.classificationCraft;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
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.TCClassificationService;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSSearchResult;
public class ClassificationCraftHandler extends AbstractHandler {
private static final String PREFERNCER = "VF5TYPICAL_GY_LIB";
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
JLabel[] jLabels = new JLabel[]{new JLabel("Technical ID"), new JLabel("Technical Name")};
JComponent[] jComponents = new JComponent[]{new JTextField(10),new JTextField(10)};
String[][] data = null;
try {
data = getClassificationData(application);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ClassificationCraftDialog dialog = new ClassificationCraftDialog(application,"Process Routing Library", jLabels, jComponents,data);
new Thread(dialog).start();
return null;
}
public String[][] getClassificationData(AbstractAIFApplication application) throws TCException {
TCSession tcSession = (TCSession)application.getSession();
String classifyId = tcSession.getPreferenceService().getStringValue(PREFERNCER);
System.out.println("classifyId = " + classifyId);
TCClassificationService classificationService = tcSession.getClassificationService();
ICSAdminClass c = classificationService.newICSAdminClass();
c.load(classifyId);
ICSSearchResult[] results = classificationService.searchICOs(classifyId, null, 0);
String[][] data = new String[results.length][2];
for (int i = 0; i < results.length; i++) {
String uid = results[i].getWsoUid();
data[i][0] = uid;
data[i][1] = results[i].getIcoId() +":" +tcSession.stringToComponent(uid).getStringProperty("object_name");
}
return data;
}
}

@ -0,0 +1,165 @@
package com.connor.ferrorTech.metal.processManagement.classificationCraft;
import java.awt.Frame;
import java.util.ArrayList;
import java.util.List;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.util.TcUtil;
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.DeepCopyInfo;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentBOMWindow;
import com.teamcenter.rac.kernel.TCComponentBOMWindowType;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ClassificationCraftOperation extends AbstractAIFOperation {
private AbstractAIFApplication application;
private TCSession tcSession;
private String[] uid;
private TCComponentItemRevision targetRev;
public ClassificationCraftOperation(AbstractAIFApplication application, String[] itemUid) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.uid = itemUid;
}
@Override
public void executeOperation() throws Exception {
TCComponentFolder targetFolder = getTargetFolder();
if (targetFolder != null) {
TCComponent[] referenceValueArray = targetRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
String name = referenceValueArray[0].getStringProperty("object_name");
TCComponentItemType component = (TCComponentItemType) tcSession.getTypeComponent("VF5gy");
TCComponentItem item = component.create(component.getNewID(), "", "VF5gy", name, "", null);
TCComponentItemRevision gyItemRev = item.getLatestItemRevision();
targetFolder.add("contents", item);
TCComponentItemRevision targetComponent = (TCComponentItemRevision)application.getTargetComponent();
targetComponent.add("VF5gygx", item);
gyItemRev.add("IMAN_METarget", targetComponent);
setReference(gyItemRev, uid);
} else {
MessageBox.post("Currently, no folder named POR was found !", "error", MessageBox.ERROR);
}
}
public TCComponentFolder getTargetFolder() throws TCException {
System.out.println("开始获取target文件夹");
InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
String type = targetComponent.getType();
targetRev = (TCComponentItemRevision) targetComponent;
TCComponentFolder targetFolder = (TCComponentFolder) TcUtil.getLastReferenced(targetRev.getItem(), "Folder","Item");
if(targetFolder!=null) {
targetFolder = (TCComponentFolder) TcUtil.getLastReferenced(targetFolder, "VF5xmwjj","Folder");
}else {
MessageBox.post("The current parent Folder is not referenced !", "error", MessageBox.ERROR);
}
if (targetFolder != null) {
TCComponent[] valueArray = targetFolder.getTCProperty("contents").getReferenceValueArray();
for (TCComponent tcComponent : valueArray) {
if (tcComponent instanceof TCComponentFolder
&& tcComponent.getStringProperty("object_name").equals("POR")) {
return (TCComponentFolder) tcComponent;
}
}
} else {
System.out.println("targetFolder is null");
}
return null;
}
public void setReference(TCComponentItemRevision gyItemRev, String[] itemUid) throws TCException {
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = winType.create(null);
TCComponentBOMWindow newView = winType.create(null);
newView.lock();
String[] formProp = new String[] {
"vf5zbsj","vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw","vf5fjfy","vf5fjfydw"
};
String[] bomProp = new String[] {
"VF5zbsj","VF5zbsjdw","VF5jqsj","VF5jqsjdw","VF5rgsj","VF5rgsjdw","VF5fjfy","VF5fjfydw"
};
// 新的工艺对象顶层Bom
TCComponentBOMLine newTopBomLine = newView.setWindowTopLine(gyItemRev.getItem(),gyItemRev, null, null);
if (itemUid != null) {
TCComponent[] tcComponents = tcSession.stringToComponent(itemUid);
for (TCComponent tcComponent : tcComponents) {
TCComponentItem gyItem = null;
TCComponentItemRevision gyRev = null;
System.out.println("当前item: "+tcComponent.getStringProperty("object_name"));
if(tcComponent instanceof TCComponentItem) {
System.out.println("is TCComponentItem");
gyItem = (TCComponentItem) tcComponent;
gyRev = gyItem.getLatestItemRevision();
}else if(tcComponent instanceof TCComponentItemRevision) {
System.out.println("is TCComponentItemRevision");
gyRev = (TCComponentItemRevision)tcComponent;
gyItem = gyRev.getItem();
}
TCComponentBOMLine bomLine = null;
if(gyItem != null && gyRev != null) {
bomLine = view.setWindowTopLine(gyItem,gyRev, null, null);
}else {
throw new CustomException("tcItem or tcItemRev is null");
}
boolean hasChildren = bomLine.hasChildren();
if (hasChildren) {
AIFComponentContext[] childrenBomLines = bomLine.getChildren();
System.out.println("begin copy bom !");
// 遍历分类库选中的gx Bom对象
for (AIFComponentContext children : childrenBomLines) {
// 强转为TCComponentBOMLine类型
TCComponentBOMLine component = (TCComponentBOMLine) children.getComponent();
TCComponentItemRevision oldGxRev = component.getItemRevision();
String name = oldGxRev.getStringProperty("object_name");
TCComponentItemType gxType = (TCComponentItemType) this.tcSession
.getTypeComponent(oldGxRev.getItem().getStringProperty("object_type"));
TCComponentItem newGxItem = oldGxRev.saveAsItem(gxType.getNewID(), "", name, "", true,
(DeepCopyInfo[]) null);
TCComponentBOMLine newBomLine = newTopBomLine.add(newGxItem,newGxItem.getLatestItemRevision(),null,false,"");
TCComponent oldGxRevForm = oldGxRev.getRelatedComponent("IMAN_master_form_rev");
for (int j = 0; j < formProp.length; j++) {
String prop = oldGxRevForm.getStringProperty(formProp[j]);
System.out.println(bomProp[j] + " : "+prop);
newBomLine.setProperty(bomProp[j], prop);
}
}
}else {
System.out.println("Currently, BomLine has no children");
}
}
newView.save();
newView.unlock();
newView.close();
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} else {
MessageBox.post("Currently no process object selected !", "Info", MessageBox.INFORMATION);
}
}
}

@ -0,0 +1,250 @@
package com.connor.ferrorTech.metal.processManagement.classificationProcesses;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumnModel;
import java.awt.*;
import java.util.Arrays;
import java.util.Objects;
import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.exception.CustomException;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
public class ClassificationProcessesDialog extends JFrame implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private final String title;
private final String subtitle;
private JLabel[] jLabels;
private JComponent[] jComponents;
private JButton searchButton;
private JButton okButton;
private JButton cancelButton;
private String[] columnNames;
private String[][] data;
private JTable table;
public ClassificationProcessesDialog(AbstractAIFApplication application, String title, Object... args) {
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
this.subtitle = "Process List";
int count = 0;
this.title = title;
this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++];
this.columnNames = (String[]) args[count++];
this.data = (String[][]) args[count];
}
@Override
public void run() {
try {
// TODO Auto-generated method stub
InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
TCComponentItemRevision tempComponentRev = null;
if (targetComponent instanceof TCComponentBOMLine) {
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
} else if (targetComponent instanceof TCComponentItemRevision) {
tempComponentRev = (TCComponentItemRevision) targetComponent;
} else {
throw new CustomException("Please Select The Correct Version !");
}
if (tempComponentRev.getStringProperty("object_type").equals("VF5gyRevision")) {
initUI();
} else {
JOptionPane.showMessageDialog(null, "Incorrect version!", "Error", JOptionPane.WARNING_MESSAGE);
}
} catch (Exception e) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.WARNING_MESSAGE);
}
}
public TCComponentBOMLine judgeSingleSelectRevision(AbstractAIFApplication application, String[] revType) {
InterfaceAIFComponent targetComponent = application.getTargetComponent();
try {
TCComponentItemRevision tempComponentRev = null;
if (targetComponent instanceof TCComponentBOMLine) {
tempComponentRev = ((TCComponentBOMLine) targetComponent).getItemRevision();
} else if (targetComponent instanceof TCComponentItemRevision) {
tempComponentRev = (TCComponentItemRevision) targetComponent;
} else {
throw new CustomException("Please Select The Correct Version !");
}
if (tempComponentRev != null && revType != null && revType.length > 0) {
for (int i = 0; i < revType.length; i++) {
if (tempComponentRev.getType().equals(revType[i])) {
return (TCComponentBOMLine) targetComponent;
}
}
} else {
System.out.println("tempComponentRev or revType is null !");
}
} catch (TCException e) {
e.printStackTrace();
}
return null;
}
public void initializationButton() {
searchButton = new JButton(ConstantPool.EN_BUTTON_SEARCH);
searchButton.setPreferredSize(new Dimension(80, 23));
searchButton.addActionListener(e -> {
searchList();
});
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM);
okButton.addActionListener(e -> {
this.dispose();
doTask();
});
cancelButton = new JButton(ConstantPool.EN_BUTTON_CANCEL);
cancelButton.addActionListener(e -> {
this.dispose();
});
}
public void initUI() {
// 设置窗口居中
this.setTitle(title);
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
this.setSize(700, 500); // 设置窗口大小
this.setLayout(new BorderLayout()); // 设置布局
initializationButton();
JPanel topPanel = createTopPanel();
JPanel centerPanel = createCenterPanel();
JPanel bottomPanel = createBottomPanel();
this.add(topPanel, BorderLayout.NORTH);
this.add(centerPanel, BorderLayout.CENTER);
this.add(bottomPanel, BorderLayout.SOUTH);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public JPanel createTopPanel() {
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
topPanel.add(jLabels[0]);
topPanel.add(jComponents[0]);
topPanel.add(jLabels[1]);
topPanel.add(jComponents[1]);
topPanel.add(searchButton);
return topPanel;
}
public JPanel createCenterPanel() {
JPanel centerPanel = new JPanel(new BorderLayout(10, 10));
centerPanel.setBorder(BorderFactory.createTitledBorder(subtitle));
centerPanel.setPreferredSize(new Dimension(400, 200));
table = new JTable(new DefaultTableModel(data, columnNames));
table.setRowHeight(18);
table.getTableHeader().setReorderingAllowed(false);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
TableColumnModel columnModel = table.getColumnModel();
for (int i = 0; i < columnModel.getColumnCount(); i++) {
columnModel.getColumn(i).setPreferredWidth(100); // 设置每列的宽度为120像素
}
table.removeColumn(columnModel.getColumn(columnModel.getColumnCount() - 1));
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER); // 设置文本居中对齐
return c;
}
};
for (int i = 0; i < columnModel.getColumnCount(); i++) {
columnModel.getColumn(i).setCellRenderer(centerRenderer);
}
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setPreferredSize(new Dimension(400, 150));
centerPanel.add(scrollPane, BorderLayout.CENTER);
return centerPanel;
}
public JPanel createBottomPanel() {
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 60, 10));
bottomPanel.add(okButton);
bottomPanel.add(cancelButton);
return bottomPanel;
}
public void searchList() {
if (jComponents.length < 2) {
throw new IllegalArgumentException("jComponents 数组长度不足");
}
String processCode = ((JTextField) jComponents[0]).getText().trim();
String technicalName = ((JTextField) jComponents[1]).getText().trim();
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0); // 清空现有数据
if (data == null || data.length == 0) {
return;
}
for (String[] rowData : data) {
String code = Objects.toString(rowData[0], "");
String name = Objects.toString(rowData[1], "");
if (code.contains(processCode) && name.contains(technicalName)) {
model.addRow(rowData);
}
}
}
public void doTask() {
int[] selectedRows = table.getSelectedRows();
String[][] selectedData = new String[selectedRows.length][];
if (selectedRows.length > 0) {
DefaultTableModel model = (DefaultTableModel) table.getModel();
for (int i = 0; i < selectedRows.length; i++) {
String[] rowData = new String[model.getColumnCount()];
for (int j = 0; j < model.getColumnCount(); j++) {
rowData[j] = (String) model.getValueAt(selectedRows[i], j);
}
selectedData[i] = rowData;
System.out.println("Selected Row Data: " + Arrays.toString(rowData));
}
ClassificationProcessesOperation classificationProcessesOperation = new ClassificationProcessesOperation(
application, selectedData);
this.tcSession.queueExcludedOperation(classificationProcessesOperation);
} else {
System.out.println("No rows selected");
}
this.dispose();
}
}

@ -0,0 +1,105 @@
package com.connor.ferrorTech.metal.processManagement.classificationProcesses;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
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.TCClassificationService;
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.TCSession;
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSSearchResult;
/**
*
* @author Administrator
*
*/
public class ClassificationProcessesHandler extends AbstractHandler {
private static final String PREFERNCER = "VF5TYPICAL_GX_LIB";
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
JLabel[] labels = new JLabel[]{new JLabel("ID"), new JLabel("Name")};
JComponent[] components = {new JTextField(14), new JTextField(14)};
@SuppressWarnings("unused")
String[] chColumnNames = new String[]{
"ID", "名称","工序类型", "准备时间", "准备时间单位",
"工作中心编码","机器时间","机器时间单位", "人工时间", "人工时间单位",
"附加费用","附加费用单位",""
};
String[] enColumnNames = new String[]{
"ID", "Name", "Operate type", "WorkCenterInternalI","Setup",
"Setup Unit","Machine","Machine Unit", "Labor", "Labor Unit",
"Production Overhead","Production Overhead Unit",""
};
String[][] data = null;
try {
String[] rowProp = {
"item_id","object_name","vf5gxlx","vf5gzzxsj","vf5zbsj",
"vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw",
"vf5fjfy","vf5fjfydw"
};
data = getPreference(application,rowProp);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ClassificationProcessesDialog dialog = new ClassificationProcessesDialog(
application,"Operation Library",labels,components,enColumnNames,data);
new Thread(dialog).start();
return null;
}
public String[][] getPreference(AbstractAIFApplication application,String[] rowProp) throws TCException {
TCSession tcSession = (TCSession)application.getSession();
String classifyId = tcSession.getPreferenceService().getStringValue(PREFERNCER);
System.out.println("classifyId = " + classifyId);
TCClassificationService classificationService = tcSession.getClassificationService();
ICSAdminClass c = classificationService.newICSAdminClass();
c.load(classifyId);
ICSSearchResult[] results = classificationService.searchICOs(classifyId, null, 0);
String[][] tableData = new String[results.length][];
int rowIndex = 0;
for (ICSSearchResult result : results) {
String[] rowData = new String[rowProp.length+1];
String wsoUid = result.getWsoUid();
InterfaceAIFComponent targetInstance = tcSession.stringToComponent(wsoUid);
if(targetInstance instanceof TCComponentItemRevision) {
TCComponentItemRevision tempRev = (TCComponentItemRevision)targetInstance;
TCComponent[] referenceValueArray = tempRev.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
TCComponentForm itemForm = (TCComponentForm)referenceValueArray[0];
rowData[0] = tempRev.getStringProperty(rowProp[0]);
rowData[1] = tempRev.getStringProperty(rowProp[1]);
for (int i = 2; i < rowProp.length; i++) {
rowData[i] = itemForm.getStringProperty(rowProp[i]);
}
rowData[rowProp.length] = wsoUid;
tableData[rowIndex++] = rowData;
}
}
return tableData;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save