删减功能

main
ChenZichaoczc 2 weeks ago
parent 2f680a47fb
commit 7a424249b5

@ -38,50 +38,23 @@ Require-Bundle: org.eclipse.ui,
com.teamcenter.rac.workflow.processdesigner;bundle-version="14000.3.0", com.teamcenter.rac.workflow.processdesigner;bundle-version="14000.3.0",
TcSoaWorkflowRac;bundle-version="14000.3.0", TcSoaWorkflowRac;bundle-version="14000.3.0",
com.teamcenter.rac.aifrcp;bundle-version="14000.3.0" com.teamcenter.rac.aifrcp;bundle-version="14000.3.0"
Export-Package: ., Export-Package: com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate,
com.connor.ferrorTech.metal,
com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate,
com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel, com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.daheReadExcel,
com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity, com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.entity,
com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate, com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate,
com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload, com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload,
com.connor.ferrorTech.metal.batchDownload, com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm,
com.connor.ferrorTech.metal.bomProcess, com.connor.ferrorTech.metal.changeManagement.createNotification,
com.connor.ferrorTech.metal.changeManagement.createECO, com.connor.ferrorTech.metal.changeManagement.createProblemReport,
com.connor.ferrorTech.metal.changeManagement.createECR,
com.connor.ferrorTech.metal.constant, 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.exception,
com.connor.ferrorTech.metal.importMaterial, com.connor.ferrorTech.metal.importMaterial,
com.connor.ferrorTech.metal.material.finishedProducts, com.connor.ferrorTech.metal.materialManage,
com.connor.ferrorTech.metal.material.material,
com.connor.ferrorTech.metal.material.semiFinishedProducts,
com.connor.ferrorTech.metal.processManagement.classificationCraft, com.connor.ferrorTech.metal.processManagement.classificationCraft,
com.connor.ferrorTech.metal.processManagement.classificationProcesses, com.connor.ferrorTech.metal.processManagement.classificationProcesses,
com.connor.ferrorTech.metal.processManagement.createCraft, com.connor.ferrorTech.metal.processManagement.createCraft,
com.connor.ferrorTech.metal.processManagement.createProcesses, com.connor.ferrorTech.metal.processManagement.createProcesses,
com.connor.ferrorTech.metal.processManagement.entity, 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.share,
com.connor.ferrorTech.metal.util com.connor.ferrorTech.metal.util
Bundle-Vendor: boxinwei Bundle-Vendor: boxinwei

@ -12,89 +12,32 @@
<extension point="org.eclipse.ui.commands"> <extension point="org.eclipse.ui.commands">
<category name="Double Category" id="com.connor.ferrorTech.metal.commands.category"> <category name="Double Category" id="com.connor.ferrorTech.metal.commands.category">
</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项目" id="com.connor.ferrorTech.metal.NPIproject.createNPIproject"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建NPI项目" id="com.connor.ferrorTech.metal.NPIproject.createNPIproject">
</command> </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="创建客户图纸" id="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建客户图纸" id="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing">
</command> </command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="上传客户图纸" id="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="上传客户图纸" id="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing">
</command> </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="分类库调用工艺" id="com.connor.ferrorTech.metal.processManagement.callCraft"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="分类库调用工艺" id="com.connor.ferrorTech.metal.processManagement.callCraft">
</command> </command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="分类库调用工序" id="com.connor.ferrorTech.metal.processManagement.callProcesses"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="分类库调用工序" id="com.connor.ferrorTech.metal.processManagement.callProcesses">
</command> </command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%gy.3" id="com.connor.ferrorTech.metal.processManagement.createCraft"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建工艺" id="com.connor.ferrorTech.metal.processManagement.createCraft">
</command> </command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%gy.4" id="com.connor.ferrorTech.metal.processManagement.createProcesses"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建工序" id="com.connor.ferrorTech.metal.processManagement.createProcesses">
</command> </command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%cg.1" id="com.connor.ferrorTech.metal.changeManagement.createECR"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建问题报告" id="com.connor.ferrorTech.metal.changeManagement.createPR">
</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>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.10" id="com.connor.ferrorTech.metal.createTechnicalDocuments.preMillDrawing"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建变更申请单" id="com.connor.ferrorTech.metal.changeManagement.createCRF">
</command> </command>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%tech.11" id="com.connor.ferrorTech.metal.createTechnicalDocuments.jitFixtureDrawing"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="创建变更通知单" id="com.connor.ferrorTech.metal.changeManagement.createECN">
</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>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="%BOMgy.0" id="com.connor.ferrorTech.metal.approvalOfBom"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="材料清单导入" id="com.connor.ferrorTech.metal.importMaterial">
</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>
<command categoryId="com.connor.ferrorTech.metal.commands.category" name="DBOM转MBOM" id="com.connor.ah.bxw.DBOMtoEBOM"> <command categoryId="com.connor.ferrorTech.metal.commands.category" name="DBOM转MBOM" id="com.connor.ah.bxw.DBOMtoEBOM">
@ -102,35 +45,14 @@
</extension> </extension>
<extension point="org.eclipse.ui.handlers"> <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 class="com.connor.ferrorTech.metal.NPIproject.NPIprojectCreate.CreateNPIprojectHandler" commandId="com.connor.ferrorTech.metal.NPIproject.createNPIproject">
</handler> </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 class="com.connor.ferrorTech.metal.NPIproject.customerDrawingsCreate.CreateClientDrawingHandler" commandId="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing">
</handler> </handler>
<handler class="com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload.UploadClientDrawingHandler" commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing"> <handler class="com.connor.ferrorTech.metal.NPIproject.customerDrawingsUpload.UploadClientDrawingHandler" commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing">
</handler> </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 class="com.connor.ferrorTech.metal.processManagement.classificationCraft.ClassificationCraftHandler" commandId="com.connor.ferrorTech.metal.processManagement.callCraft">
</handler> </handler>
<handler class="com.connor.ferrorTech.metal.processManagement.classificationProcesses.ClassificationProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.callProcesses"> <handler class="com.connor.ferrorTech.metal.processManagement.classificationProcesses.ClassificationProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.callProcesses">
@ -140,50 +62,13 @@
<handler class="com.connor.ferrorTech.metal.processManagement.createProcesses.CreateProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.createProcesses"> <handler class="com.connor.ferrorTech.metal.processManagement.createProcesses.CreateProcessesHandler" commandId="com.connor.ferrorTech.metal.processManagement.createProcesses">
</handler> </handler>
<handler class="com.connor.ferrorTech.metal.changeManagement.createECR.ChangeApplyFormCreateHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createECR"> <handler class="com.connor.ferrorTech.metal.changeManagement.createProblemReport.CreateProblemReportHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createPR">
</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>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.CredlineDrawing.CreateRedlineDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.redlineDrawing"> <handler class="com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm.CreateChangeRequestFormHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createCRF">
</handler> </handler>
<handler class="com.connor.ferrorTech.metal.createTechnicalDocuments.DrawMaterialDrawing.CreateRawMaterialDrawingHandler" commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.rawMaterialDrawing"> <handler class="com.connor.ferrorTech.metal.changeManagement.createNotification.CreateNotificationHandler" commandId="com.connor.ferrorTech.metal.changeManagement.createECN">
</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>
<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 class="com.connor.ferrorTech.metal.importMaterial.ImportMaterialHandler" commandId="com.connor.ferrorTech.metal.importMaterial">
</handler> </handler>
@ -194,40 +79,14 @@
<extension point="org.eclipse.ui.menus"> <extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=additions"> <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="PLM" 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项目" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.npiProject"> <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 commandId="com.connor.ferrorTech.metal.NPIproject.createNPIproject" id="com.connor.ferrorTech.metal.menus.npiProject.createNpi" mnemonic="S">
</command> </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 commandId="com.connor.ferrorTech.metal.NPIproject.createCustomerDrawing" id="com.connor.ferrorTech.metal.menus.npiProject.createCustomerDrawing" mnemonic="S">
</command> </command>
<command commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing" id="com.connor.ferrorTech.metal.menus.npiProject.uploadCustomerDrawing" mnemonic="S"> <command commandId="com.connor.ferrorTech.metal.NPIproject.uploadCustomerDrawing" id="com.connor.ferrorTech.metal.menus.npiProject.uploadCustomerDrawing" mnemonic="S">
</command> </command>
</menu> </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="工艺管理" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.processManagement"> <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 commandId="com.connor.ferrorTech.metal.processManagement.callCraft" id="com.connor.ferrorTech.metal.menus.processManagement.callCraft" mnemonic="S">
</command> </command>
@ -238,49 +97,15 @@
<command commandId="com.connor.ferrorTech.metal.processManagement.createProcesses" id="com.connor.ferrorTech.metal.menus.processManagement.createProcesses" mnemonic="S"> <command commandId="com.connor.ferrorTech.metal.processManagement.createProcesses" id="com.connor.ferrorTech.metal.menus.processManagement.createProcesses" mnemonic="S">
</command> </command>
</menu> </menu>
<menu label="%cg.0" mnemonic="M" id="com.connor.ferrorTech.metal.menus.metal.changeManagement"> <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 commandId="com.connor.ferrorTech.metal.changeManagement.createPR" id="com.connor.ferrorTech.metal.menus.metal.changeManagement.createPR" 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>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.setupSheet" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.setupSheet" mnemonic="S"> <command commandId="com.connor.ferrorTech.metal.changeManagement.createCRF" id="com.connor.ferrorTech.metal.menus.metal.changeManagement.createCRF" mnemonic="S">
</command> </command>
<command commandId="com.connor.ferrorTech.metal.createTechnicalDocuments.reworkWorkInstruction" id="com.connor.ferrorTech.metal.menus.createTechnicalDocuments.reworkWorkInstruction" mnemonic="S"> <command commandId="com.connor.ferrorTech.metal.changeManagement.createECN" id="com.connor.ferrorTech.metal.menus.metal.changeManagement.createECN" 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> </command>
</menu> </menu>
<command commandId="com.connor.ferrorTech.metal.approvalOfBom" id="com.connor.ferrorTech.metal.menus.approvalOfBom" mnemonic="S"> <command commandId="com.connor.ferrorTech.metal.importMaterial" id="com.connor.ferrorTech.metal.menus.importMaterial" mnemonic="S">
</command>
<command commandId="com.connor.ferrorTech.metal.downloadFiles" id="com.connor.ferrorTech.metal.menus.downloadFiles" mnemonic="S">
</command> </command>
</menu> </menu>
@ -290,7 +115,6 @@
</menu> </menu>
</menuContribution> </menuContribution>
</extension> </extension>
</plugin> </plugin>

@ -1,138 +0,0 @@
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);
}
}

@ -1,23 +0,0 @@
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;
}
}

@ -1,13 +0,0 @@
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();
}
}

@ -1,406 +0,0 @@
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);
}
}
}
}
}

@ -1,26 +0,0 @@
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;
}
}

@ -1,172 +0,0 @@
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,197 @@
package com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm;
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.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
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.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
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.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 CreateChangeRequestFormDialog extends JFrame implements Runnable {
private String title;
// sizes[0] = dialog的宽度sizes[1] = dialog的高度sizes[2] =
// BottomPanel的顶部距离sizes[3] = BottomPanel的底部距离
private int[] sizes;
private JLabel[] jLabels;
private JComponent[] jComponents;
private JButton okButton;
private JButton celButton;
private TCSession tcSession;
private TCComponentFolder folder;
private TCComponentItemRevision rev;
public CreateChangeRequestFormDialog(String title, Object... args) {
this.title = title;
int count = 0;
this.sizes = (int[]) args[count++];
this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++];
this.tcSession = (TCSession) args[count++];
this.folder = (TCComponentFolder) args[count++];
this.rev = (TCComponentItemRevision) args[count++];
}
@Override
public void run() {
String defaultValue = "变更申请单";
initUI(defaultValue);
}
public void initUI(String defaultValue) {
this.setTitle(title);
this.setSize(sizes[0], sizes[1]);
// 初始化组件
initializationComponent();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getCenterPanel();
((JTextField)jComponents[0]).setText(defaultValue);
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("创建");
celButton = new JButton("取消");
}
public JScrollPane getCenterPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints customLayout = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
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);
}
// 创建具有滚动功能的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(sizes[2], 0, sizes[3], 0));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
// 添加监听
okButton.addActionListener(e -> {
try {
boolean confirmed = confirmFunction();
if (confirmed) {
this.dispose(); // 关闭窗口
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
celButton.addActionListener(e -> {
this.dispose(); // 关闭窗口
});
return bottomPanel;
}
public boolean confirmFunction() throws TCException {
Map<String, String> propMap = new LinkedHashMap<>();
String[] prop = new String[] { "object_name" };
SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < jComponents.length; i++) {
if (jComponents[i] instanceof JTextField) {
propMap.put(prop[i], ((JTextField) jComponents[i]).getText());
} else if (jComponents[i] instanceof JComboBox) {
JComboBox comboBox = (JComboBox) jComponents[i];
Object selectedItem = comboBox.getSelectedItem();
propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : "");
} else if (jComponents[i] instanceof JXDatePicker) {
JXDatePicker datePicker = (JXDatePicker) jComponents[i];
Date date = datePicker.getDate();
if (date != null) {
propMap.put(prop[i], simpleFormatter.format(date));
} else {
propMap.put(prop[i], "");
}
}
}
TCComponentItemRevision bgpsdItemRev = createItem(tcSession, "VF5bgpsd", propMap.get("object_name"));
if(folder!=null) {
folder.add("contents", bgpsdItemRev.getItem());
}
if(rev!=null) {
bgpsdItemRev.add("VF5gldwtbggx", rev.getItem());
TCComponentFolder parentFolder = null;
AIFComponentContext[] parent = rev.getItem().whereReferenced();
for (int i = 0; i < parent.length; i++) {
InterfaceAIFComponent component = (TCComponent) parent[i].getComponent();
if (component.getType().equals("Folder") || component.getType().equals("Fnd0HomeFolder")) {
parentFolder = (TCComponentFolder) parent[i].getComponent();
break;
}
}
parentFolder.add("contents", bgpsdItemRev.getItem());
}
MessageBox.post("创建成功", "Error", MessageBox.INFORMATION);
return true;
}
public TCComponentItemRevision createItem(TCSession session, String type, String name) throws TCException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
TCComponentItem item = itemType.create(itemType.getNewID(), "", type, name, "", null);
return item.getLatestItemRevision();
}
}

@ -0,0 +1,82 @@
package com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm;
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.changeManagement.createProblemReport.CreateProblemReportDialog;
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.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateChangeRequestFormHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
InterfaceAIFComponent targetComponent = application.getTargetComponent();
TCSession session = (TCSession) application.getSession();
try {
String type = targetComponent.getType();
System.out.println("type : " + type);
TCComponentFolder folder = null;
TCComponentItemRevision rev = null;
if (targetComponent instanceof TCComponentFolder) {
if (type.equals("Folder") || type.equals("Fnd0HomeFolder")) {
folder = (TCComponentFolder) targetComponent;
} else {
MessageBox.post("请选择文件夹!", "Error", MessageBox.ERROR);
return null;
}
} else if (targetComponent instanceof TCComponentItemRevision) {
if (type.equals("VF5wtbgRevision")) {
rev = (TCComponentItemRevision) targetComponent;
} else {
MessageBox.post("请选择问题报告版本对象!", "Error", MessageBox.ERROR);
return null;
}
} else {
MessageBox.post("请选择文件夹或问题报告版本对象!", "Error", MessageBox.ERROR);
return null;
}
JLabel[] jLabels = new JLabel[] { new JLabel("名称") };
JComponent[] jComponents = new JComponent[] { new JTextField(14) };
CreateChangeRequestFormDialog searchTemplate = new CreateChangeRequestFormDialog("创建变更申请单",
new int[] { 400, 200, 5, 5 }, jLabels, jComponents, session,folder, rev);
new Thread(searchTemplate).start();
} catch (Exception e) {
// TODO: handle exception
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
}
return null;
}
}

@ -1,448 +0,0 @@
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 !");
}
}
}

@ -1,218 +0,0 @@
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);
}
}
}
}
}

@ -1,406 +0,0 @@
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 !");
}
}
}

@ -1,156 +0,0 @@
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);
}
}
}
}
}

@ -1,24 +0,0 @@
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,199 @@
package com.connor.ferrorTech.metal.changeManagement.createNotification;
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.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
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.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
import com.connor.ferrorTech.metal.changeManagement.createChangeRequestForm.CreateChangeRequestFormDialog;
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.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 CreateNotificationDialog extends JFrame implements Runnable {
private String title;
// sizes[0] = dialog的宽度sizes[1] = dialog的高度sizes[2] =
// BottomPanel的顶部距离sizes[3] = BottomPanel的底部距离
private int[] sizes;
private JLabel[] jLabels;
private JComponent[] jComponents;
private JButton okButton;
private JButton celButton;
private TCSession tcSession;
private TCComponentFolder folder;
private TCComponentItemRevision rev;
public CreateNotificationDialog(String title, Object... args) {
this.title = title;
int count = 0;
this.sizes = (int[]) args[count++];
this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++];
this.tcSession = (TCSession) args[count++];
this.folder = (TCComponentFolder) args[count++];
this.rev = (TCComponentItemRevision) args[count++];
}
@Override
public void run() {
String defaultValue = "变更通知单";
initUI(defaultValue);
}
public void initUI(String defaultValue) {
this.setTitle(title);
this.setSize(sizes[0], sizes[1]);
// 初始化组件
initializationComponent();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getCenterPanel();
((JTextField)jComponents[0]).setText(defaultValue);
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("创建");
celButton = new JButton("取消");
}
public JScrollPane getCenterPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints customLayout = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
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);
}
// 创建具有滚动功能的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(sizes[2], 0, sizes[3], 0));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
// 添加监听
okButton.addActionListener(e -> {
try {
boolean confirmed = confirmFunction();
if (confirmed) {
this.dispose(); // 关闭窗口
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
celButton.addActionListener(e -> {
this.dispose(); // 关闭窗口
});
return bottomPanel;
}
public boolean confirmFunction() throws TCException {
Map<String, String> propMap = new LinkedHashMap<>();
String[] prop = new String[] { "object_name" };
SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < jComponents.length; i++) {
if (jComponents[i] instanceof JTextField) {
propMap.put(prop[i], ((JTextField) jComponents[i]).getText());
} else if (jComponents[i] instanceof JComboBox) {
JComboBox comboBox = (JComboBox) jComponents[i];
Object selectedItem = comboBox.getSelectedItem();
propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : "");
} else if (jComponents[i] instanceof JXDatePicker) {
JXDatePicker datePicker = (JXDatePicker) jComponents[i];
Date date = datePicker.getDate();
if (date != null) {
propMap.put(prop[i], simpleFormatter.format(date));
} else {
propMap.put(prop[i], "");
}
}
}
TCComponentItemRevision bgtzdItemRev = createItem(tcSession, "VF5bgtzd", propMap.get("object_name"));
if(folder!=null) {
folder.add("contents", bgtzdItemRev.getItem());
}
if(rev!=null) {
bgtzdItemRev.add("VF5bgpsdgx", rev.getItem());
TCComponentFolder parentFolder = null;
AIFComponentContext[] parent = rev.getItem().whereReferenced();
for (int i = 0; i < parent.length; i++) {
InterfaceAIFComponent component = (TCComponent) parent[i].getComponent();
if (component.getType().equals("Folder") || component.getType().equals("Fnd0HomeFolder")) {
parentFolder = (TCComponentFolder) parent[i].getComponent();
break;
}
}
parentFolder.add("contents", bgtzdItemRev.getItem());
}
MessageBox.post("创建成功", "Error", MessageBox.INFORMATION);
return true;
}
public TCComponentItemRevision createItem(TCSession session, String type, String name) throws TCException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
TCComponentItem item = itemType.create(itemType.getNewID(), "", type, name, "", null);
return item.getLatestItemRevision();
}
}

@ -0,0 +1,66 @@
package com.connor.ferrorTech.metal.changeManagement.createNotification;
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.changeManagement.createChangeRequestForm.CreateChangeRequestFormDialog;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateNotificationHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
InterfaceAIFComponent targetComponent = application.getTargetComponent();
TCSession session = (TCSession) application.getSession();
try {
String type = targetComponent.getType();
System.out.println("type : " + type);
TCComponentFolder folder = null;
TCComponentItemRevision rev = null;
if (targetComponent instanceof TCComponentFolder) {
if (type.equals("Folder") || type.equals("Fnd0HomeFolder")) {
folder = (TCComponentFolder) targetComponent;
} else {
MessageBox.post("请选择文件夹!", "Error", MessageBox.ERROR);
return null;
}
} else if (targetComponent instanceof TCComponentItemRevision) {
if (type.equals("VF5bgpsdRevision")) {
rev = (TCComponentItemRevision) targetComponent;
} else {
MessageBox.post("请选择变更申请单版本对象!", "Error", MessageBox.ERROR);
return null;
}
} else {
MessageBox.post("请选择文件夹或变更申请单版本对象!", "Error", MessageBox.ERROR);
return null;
}
JLabel[] jLabels = new JLabel[] { new JLabel("名称") };
JComponent[] jComponents = new JComponent[] { new JTextField(14) };
CreateNotificationDialog searchTemplate = new CreateNotificationDialog("创建变更通知单",
new int[] { 400, 200, 5, 5 }, jLabels, jComponents, session,folder, rev);
new Thread(searchTemplate).start();
} catch (Exception e) {
// TODO: handle exception
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
}
return null;
}
}

@ -0,0 +1,177 @@
package com.connor.ferrorTech.metal.changeManagement.createProblemReport;
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.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
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.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
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 CreateProblemReportDialog extends JFrame implements Runnable {
private String title;
// sizes[0] = dialog的宽度sizes[1] = dialog的高度sizes[2] =
// BottomPanel的顶部距离sizes[3] = BottomPanel的底部距离
private int[] sizes;
private JLabel[] jLabels;
private JComponent[] jComponents;
private JButton okButton;
private JButton celButton;
private TCSession tcSession;
private TCComponentFolder target;
public CreateProblemReportDialog(String title, Object... args) {
this.title = title;
int count = 0;
this.sizes = (int[]) args[count++];
this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++];
this.tcSession = (TCSession) args[count++];
this.target = (TCComponentFolder) args[count++];
}
@Override
public void run() {
initUI();
}
public void initUI() {
this.setTitle(title);
this.setSize(sizes[0], sizes[1]);
// 初始化组件
initializationComponent();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getCenterPanel();
((JTextField)jComponents[0]).setText("问题报告");
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("创建");
celButton = new JButton("取消");
}
public JScrollPane getCenterPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints customLayout = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
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);
}
// 创建具有滚动功能的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(sizes[2], 0, sizes[3], 0));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
// 添加监听
okButton.addActionListener(e -> {
try {
boolean confirmed = confirmFunction();
if (confirmed) {
this.dispose(); // 关闭窗口
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
celButton.addActionListener(e -> {
this.dispose(); // 关闭窗口
});
return bottomPanel;
}
public boolean confirmFunction() throws TCException {
Map<String, String> propMap = new LinkedHashMap<>();
String[] prop = new String[] { "object_name" };
SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < jComponents.length; i++) {
if (jComponents[i] instanceof JTextField) {
propMap.put(prop[i], ((JTextField) jComponents[i]).getText());
} else if (jComponents[i] instanceof JComboBox) {
JComboBox comboBox = (JComboBox) jComponents[i];
Object selectedItem = comboBox.getSelectedItem();
propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : "");
} else if (jComponents[i] instanceof JXDatePicker) {
JXDatePicker datePicker = (JXDatePicker) jComponents[i];
Date date = datePicker.getDate();
if (date != null) {
propMap.put(prop[i], simpleFormatter.format(date));
} else {
propMap.put(prop[i], "");
}
}
}
TCComponentItemRevision wtbgItemRev = createItem(tcSession, "VF5wtbg", propMap.get("object_name"));
if (wtbgItemRev != null) {
System.out.println("new item : " + wtbgItemRev.getStringProperty("object_name"));
}
target.add("contents",wtbgItemRev.getItem());
System.out.println(propMap);
MessageBox.post("添加成功 !", "Info", MessageBox.INFORMATION);
return true;
}
public TCComponentItemRevision createItem(TCSession session, String type, String name) throws TCException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
TCComponentItem item = itemType.create(itemType.getNewID(), "", type, name, "", null);
return item.getLatestItemRevision();
}
}

@ -0,0 +1,61 @@
package com.connor.ferrorTech.metal.changeManagement.createProblemReport;
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.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateProblemReportHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
TCSession session = (TCSession) application.getSession();
TCComponentFolder targetItem = (TCComponentFolder) judgeAndGetSingleSelectComponent(application);
try {
if (targetItem != null) {
JLabel[] jLabels = new JLabel[] { new JLabel("名称")};
JComponent[] jComponents = new JComponent[] { new JTextField(14)};
CreateProblemReportDialog searchTemplate = new CreateProblemReportDialog("创建问题报告", new int[]{400, 200, 5, 5}, jLabels, jComponents,session,targetItem);
new Thread(searchTemplate).start();
}
} catch (Exception e) {
// TODO: handle exception
MessageBox.post(e.getMessage(), "Error", MessageBox.ERROR);
}
return null;
}
public static TCComponent judgeAndGetSingleSelectComponent(AbstractAIFApplication application) {
InterfaceAIFComponent targetComponent = application.getTargetComponent();
try {
if (targetComponent instanceof TCComponentFolder
&& ((TCComponentFolder)targetComponent).getStringProperty("object_type").equals("Folder")) {
return (TCComponent) targetComponent;
}
MessageBox.post("请选择文件夹类型 !", "Error",
MessageBox.ERROR);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
return null;
}
}

@ -1,19 +0,0 @@
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;
}
}

@ -1,18 +0,0 @@
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;
}
}

@ -1,194 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,194 +0,0 @@
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;
}
}

@ -1,21 +0,0 @@
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;
}
}

@ -1,194 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,255 +0,0 @@
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();
}
}
}

@ -1,19 +0,0 @@
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;
}
}

@ -1,225 +0,0 @@
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();
}
}
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,21 +0,0 @@
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;
}
}

@ -1,174 +0,0 @@
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);
}
}

@ -1,51 +0,0 @@
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;
}
}

@ -1,237 +0,0 @@
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();
}
}
}
}

@ -1,21 +0,0 @@
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;
}
}

@ -1,21 +0,0 @@
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;
}
}

@ -1,20 +0,0 @@
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;
}
}

@ -1,326 +0,0 @@
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;
}
}

@ -1,26 +0,0 @@
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;
}
}

@ -1,254 +0,0 @@
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();
}
}

@ -1,226 +0,0 @@
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);
}
}
}
}
}
}
}
}

@ -1,88 +0,0 @@
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;
}
}

@ -1,435 +0,0 @@
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;
}
}

@ -1,13 +0,0 @@
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

@ -1,72 +0,0 @@
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;
}
}

@ -1,73 +0,0 @@
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;
}
}

@ -48,7 +48,7 @@ public class DbomTransitionToEbomCommand extends AbstractAIFCommand {
//Åж϶ÔÏóÀàÐÍ //Åж϶ÔÏóÀàÐÍ
TCComponentItem item = bomLine.getItem(); TCComponentItem item = bomLine.getItem();
boolean isTypeof=false; boolean isTypeof=false;
String[] prefValues = session.getPreferenceService().getStringValues("Connor_AHBXW_DBOM_Type"); //Connor_DBOM_Type String[] prefValues = session.getPreferenceService().getStringValues("Connor_DBOM_Type"); //Connor_DBOM_Type
System.out.println("prefValuse"+prefValues.toString()); System.out.println("prefValuse"+prefValues.toString());
for(String pref : prefValues) { for(String pref : prefValues) {
if(pref.equals(item.getType())) { if(pref.equals(item.getType())) {
@ -69,7 +69,7 @@ public class DbomTransitionToEbomCommand extends AbstractAIFCommand {
//final List<List<Object>> bomPropertyList = this.getBomPropertys(session, bomLine); //final List<List<Object>> bomPropertyList = this.getBomPropertys(session, bomLine);
String[] prefValueParts = session.getPreferenceService().getStringValues("Connor_AHBXW_DBOM_PartType"); String[] prefValueParts = session.getPreferenceService().getStringValues("Connor_DBOM_PartType");
for (String string : prefValueParts) { for (String string : prefValueParts) {
preList.add(string); preList.add(string);
} }
@ -238,9 +238,9 @@ public class DbomTransitionToEbomCommand extends AbstractAIFCommand {
NodeBean nodeBean = new NodeBean(); NodeBean nodeBean = new NodeBean();
System.out.println(bomLine.getStringProperty("bl_item_object_type")); System.out.println(bomLine.getStringProperty("bl_item_object_type"));
if(bomLine.getStringProperty("bl_item_object_type").equals("LD6_3Ddesign")) { // if(bomLine.getStringProperty("bl_item_object_type").equals("LD6_3Ddesign")) {
return; // return;
} // }
nodeBean.setdId(bomLine.getStringProperty("bl_item_item_id")); nodeBean.setdId(bomLine.getStringProperty("bl_item_item_id"));
nodeBean.setDbom(bomLine.getStringProperty("bl_item_object_string")); nodeBean.setDbom(bomLine.getStringProperty("bl_item_object_string"));
nodeBean.setNum(bomLine.getStringProperty("bl_quantity")); nodeBean.setNum(bomLine.getStringProperty("bl_quantity"));

@ -12,76 +12,102 @@ import com.teamcenter.rac.kernel.TCComponentItemRevision;
*/ */
public class NodeBean { public class NodeBean {
private String dbom;//对象ID private String dbom;// 对象ID
private String dId; //dBOMID private String dId; // dBOMID
private String ebom;//对象名称 private String ebom;// 对象名称
private TCComponentItemRevision eRevision;//eBOm版本对象 private TCComponentItemRevision eRevision;// eBOm版本对象
private String ebomId;//对象名称 private String ebomId;// 对象名称
private String ebomDesc;//物料描述 private String ebomDesc;// 物料描述
private String num;//数量 private String num;// 数量
private String label;//对象名称 private String label;// 对象名称
private String refreshStatus;//发布状态 private String refreshStatus;// 发布状态
private String parentString;//对应父节点 private String parentString;// 对应父节点
public TCComponentItemRevision geteRevision() { public TCComponentItemRevision geteRevision() {
return eRevision; return eRevision;
} }
public void seteRevision(TCComponentItemRevision eRevision) {
this.eRevision = eRevision; public void seteRevision(TCComponentItemRevision eRevision) {
} this.eRevision = eRevision;
public String getdId() { }
return dId;
} public String getdId() {
public void setdId(String dId) { return dId;
this.dId = dId; }
}
public String getDbom() { public void setdId(String dId) {
this.dId = dId;
}
public String getDbom() {
return dbom; return dbom;
} }
public void setDbom(String dbom) { public void setDbom(String dbom) {
this.dbom = dbom; this.dbom = dbom;
} }
public String getEbom() { public String getEbom() {
return ebom; return ebom;
} }
public void setEbom(String ebom) { public void setEbom(String ebom) {
this.ebom = ebom; this.ebom = ebom;
} }
public String getEbomId() { public String getEbomId() {
return ebomId; return ebomId;
} }
public void setEbomId(String ebomId) { public void setEbomId(String ebomId) {
this.ebomId = ebomId; this.ebomId = ebomId;
} }
public String getLabel() { public String getLabel() {
return label; return label;
} }
public void setLabel(String label) { public void setLabel(String label) {
this.label = label; this.label = label;
} }
public String getRefreshStatus() { public String getRefreshStatus() {
return refreshStatus; return refreshStatus;
} }
public void setRefreshStatus(String refreshStatus) { public void setRefreshStatus(String refreshStatus) {
this.refreshStatus = refreshStatus; this.refreshStatus = refreshStatus;
} }
public String getParentString() { public String getParentString() {
return parentString; return parentString;
} }
public void setParentString(String parentString) { public void setParentString(String parentString) {
this.parentString = parentString; this.parentString = parentString;
} }
public String getNum() { public String getNum() {
return num; return num;
} }
public void setNum(String num) { public void setNum(String num) {
this.num = num; this.num = num;
} }
public String getEbomDesc() { public String getEbomDesc() {
return ebomDesc; return ebomDesc;
} }
public void setEbomDesc(String ebomDesc) { public void setEbomDesc(String ebomDesc) {
this.ebomDesc = ebomDesc; this.ebomDesc = ebomDesc;
} }
@Override
public String toString() {
return "NodeBean [dbom=" + dbom + ", dId=" + dId + ", ebom=" + ebom + ", eRevision=" + eRevision + ", ebomId="
+ ebomId + ", ebomDesc=" + ebomDesc + ", num=" + num + ", label=" + label + ", refreshStatus="
+ refreshStatus + ", parentString=" + parentString + "]";
}
} }

@ -13,11 +13,17 @@ import com.connor.ferrorTech.metal.constant.ConstantPool;
import com.connor.ferrorTech.metal.exception.CustomException; import com.connor.ferrorTech.metal.exception.CustomException;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.DeepCopyInfo;
import com.teamcenter.rac.kernel.TCComponent; import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentBOMLine; 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.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ClassificationProcessesDialog extends JFrame implements Runnable { public class ClassificationProcessesDialog extends JFrame implements Runnable {
@ -111,7 +117,12 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable {
}); });
okButton = new JButton(ConstantPool.CH_BUTTON_CONFIRM); okButton = new JButton(ConstantPool.CH_BUTTON_CONFIRM);
okButton.addActionListener(e -> { okButton.addActionListener(e -> {
doTask(); try {
doTask();
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}); });
cancelButton = new JButton(ConstantPool.CH_BUTTON_CANCEL); cancelButton = new JButton(ConstantPool.CH_BUTTON_CANCEL);
cancelButton.addActionListener(e -> { cancelButton.addActionListener(e -> {
@ -145,12 +156,12 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable {
public JPanel createTopPanel() { public JPanel createTopPanel() {
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
topPanel.add(jLabels[0]); topPanel.add(jLabels[0]);
topPanel.add(jComponents[0]); topPanel.add(jComponents[0]);
topPanel.add(jLabels[1]); topPanel.add(jLabels[1]);
topPanel.add(jComponents[1]); topPanel.add(jComponents[1]);
topPanel.add(searchButton); topPanel.add(searchButton);
return topPanel; return topPanel;
} }
@ -222,7 +233,7 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable {
} }
} }
public void doTask() { public void doTask() throws TCException {
int[] selectedRows = table.getSelectedRows(); int[] selectedRows = table.getSelectedRows();
String[][] selectedData = new String[selectedRows.length][]; String[][] selectedData = new String[selectedRows.length][];
@ -237,11 +248,92 @@ public class ClassificationProcessesDialog extends JFrame implements Runnable {
System.out.println("Selected Row Data: " + Arrays.toString(rowData)); System.out.println("Selected Row Data: " + Arrays.toString(rowData));
} }
ClassificationProcessesOperation classificationProcessesOperation = new ClassificationProcessesOperation( // ClassificationProcessesOperation classificationProcessesOperation = new ClassificationProcessesOperation(
application, selectedData); // application, selectedData);
this.tcSession.queueExcludedOperation(classificationProcessesOperation); // this.tcSession.queueExcludedOperation(classificationProcessesOperation);
TCComponentBOMLine targetBomLine = judgeSingleSelectRevision(new String[] { "VF5gyRevision" });
if (targetBomLine != null) {
copyItem(targetBomLine, selectedData);
} else {
MessageBox.post("获取目标BOM失败!", "Error", MessageBox.ERROR);
}
} else { } else {
System.out.println("No rows selected"); System.out.println("No rows selected");
MessageBox.post("未选择行!", "Error", MessageBox.ERROR);
}
}
public TCComponentBOMLine judgeSingleSelectRevision(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("请选择正确的版本!");
}
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 copyItem(TCComponentBOMLine targetBomLine, String[][] data) throws TCException {
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = winType.create(null);
// String[] formProp = new String[] {
// "vf5zbsj","vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw","vf5fjfy","vf5fjfydw"
// };
// String[] bomProp = new String[] {
// "VF5zbsj","VF5zbsjdw","VF5jqsj","VF5jqsjdw","VF5rgsj","VF5rgsjdw","VF5fjfy","VF5fjfydw"
// };
view.lock();
boolean flag = false;
for (int i = 0; i < data.length; i++) {
String[] rowData = data[i];
String uid = rowData[rowData.length - 1];
TCComponent gxComponent = this.tcSession.stringToComponent(uid);
if (gxComponent instanceof TCComponentItemRevision) {
TCComponentItemRevision gxItemRev = (TCComponentItemRevision) gxComponent;
String name = gxItemRev.getStringProperty("object_name");
TCComponentItemType typeComponent = (TCComponentItemType) this.tcSession
.getTypeComponent(gxItemRev.getItem().getStringProperty("object_type"));
TCComponentItem newItem = gxItemRev.saveAsItem(typeComponent.getNewID(), "", name, "", true,
(DeepCopyInfo[]) null);
TCComponentBOMLine newBomLine = targetBomLine.add(newItem, newItem.getLatestItemRevision(), null, false,
"");
// TCComponent gxRevForm = gxItemRev.getRelatedComponent("IMAN_master_form_rev");
// for (int j = 0; j < bomProp.length; j++) {
// String prop = gxRevForm.getStringProperty(formProp[j]);
// System.out.println(bomProp[j] + " : " + prop);
// newBomLine.setProperty(bomProp[j], prop);
// }
flag = true;
}
}
if (flag) {
MessageBox.post("添加成功!", "Info", MessageBox.INFORMATION);
} else {
MessageBox.post("添加失败!", "Rrror", MessageBox.ERROR);
} }
view.save();
view.unlock();
} }
} }

@ -1,115 +0,0 @@
package com.connor.ferrorTech.metal.processManagement.classificationProcesses;
import java.awt.Frame;
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.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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class ClassificationProcessesOperation extends AbstractAIFOperation {
private AbstractAIFApplication application;
private TCSession tcSession;
private String[][] tableData;
public ClassificationProcessesOperation(AbstractAIFApplication application,String[][] tableData) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.tableData = tableData;
}
@Override
public void executeOperation() throws Exception {
TCComponentBOMLine targetBomLine = judgeSingleSelectRevision(application, new String[]{"VF5gyRevision"});
if(targetBomLine!=null) {
copyItem(targetBomLine,tableData);
}else {
MessageBox.post("获取目标BOM失败!", "Error", MessageBox.ERROR);
}
}
public void copyItem(TCComponentBOMLine targetBomLine,String[][] data) throws TCException {
TCComponentBOMWindowType winType = (TCComponentBOMWindowType) tcSession.getTypeComponent("BOMWindow");
TCComponentBOMWindow view = winType.create(null);
// String[] formProp = new String[] {
// "vf5zbsj","vf5zbsjdw","vf5jqsj","vf5jqsjdw","vf5rgsj","vf5rgsjdw","vf5fjfy","vf5fjfydw"
// };
// String[] bomProp = new String[] {
// "VF5zbsj","VF5zbsjdw","VF5jqsj","VF5jqsjdw","VF5rgsj","VF5rgsjdw","VF5fjfy","VF5fjfydw"
// };
view.lock();
boolean flag = false;
for (int i = 0; i < data.length; i++) {
String[] rowData = data[i];
String uid = rowData[rowData.length-1];
TCComponent gxComponent = this.tcSession.stringToComponent(uid);
if(gxComponent instanceof TCComponentItemRevision) {
TCComponentItemRevision gxItemRev = (TCComponentItemRevision)gxComponent;
String name = gxItemRev.getStringProperty("object_name");
TCComponentItemType typeComponent = (TCComponentItemType) this.tcSession
.getTypeComponent(gxItemRev.getItem().getStringProperty("object_type"));
TCComponentItem newItem = gxItemRev.saveAsItem(typeComponent.getNewID(), "", name, "", true,(DeepCopyInfo[]) null);
TCComponentBOMLine newBomLine = targetBomLine.add(newItem,newItem.getLatestItemRevision(),null,false,"");
// TCComponent gxRevForm = gxItemRev.getRelatedComponent("IMAN_master_form_rev");
// for (int j = 0; j < bomProp.length; j++) {
// String prop = gxRevForm.getStringProperty(formProp[j]);
// System.out.println(bomProp[j] + " : " + prop);
// newBomLine.setProperty(bomProp[j], prop);
// }
flag =true;
}
}
if(flag) {
MessageBox.post("添加成功!", "Info", MessageBox.INFORMATION);
}else {
MessageBox.post("添加失败!", "Rrror", MessageBox.ERROR);
}
view.save();
view.unlock();
}
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("请选择正确的版本!");
}
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;
}
}

@ -0,0 +1,175 @@
package com.connor.ferrorTech.metal.processManagement.createCraft;
import org.jdesktop.swingx.JXDatePicker;
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;
import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* @ClassName FormTest
* @Description TODO
* @Author chenzc
* @Date 2024/11/29 10:40
**/
public class CreateCraftDialog extends JFrame implements Runnable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String title;
// sizes[0] = dialog的宽度sizes[1] = dialog的高度sizes[2] = BottomPanel的顶部距离sizes[3] = BottomPanel的底部距离
private int[] sizes;
private JLabel[] jLabels;
private JComponent[] jComponents;
private JButton okButton;
private JButton celButton;
private TCSession tcSession;
private TCComponentFolder targetFolder;
public CreateCraftDialog(String title, Object... args) {
this.title = title;
int count = 0;
this.sizes = (int[]) args[count++];
this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++];
this.tcSession = (TCSession) args[count++];
this.targetFolder = (TCComponentFolder) args[count++];
}
@Override
public void run() {
initUI();
}
public void initUI() {
this.setTitle(title);
this.setSize(sizes[0], sizes[1]);
// 初始化组件
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);
}
/**
*
*/
private void initializationComponent() {
okButton = new JButton("创建");
celButton = new JButton("取消");
}
private JScrollPane getCenterPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints customLayout = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
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);
}
// 创建具有滚动功能的JPanel
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 -> {
try {
boolean confirmed = confirmFunction();
if (confirmed) {
this.dispose(); // 关闭窗口
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
});
celButton.addActionListener(e -> {
this.dispose(); // 关闭窗口
});
return bottomPanel;
}
public boolean confirmFunction() throws TCException {
Map<String, String> propMap = new LinkedHashMap<>();
String[] prop = new String[]{
"object_name"
};
SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < jComponents.length; i++) {
if (jComponents[i] instanceof JTextField) {
propMap.put(prop[i], ((JTextField) jComponents[i]).getText());
} else if (jComponents[i] instanceof JComboBox) {
JComboBox comboBox = (JComboBox) jComponents[i];
Object selectedItem = comboBox.getSelectedItem();
propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : "");
} else if (jComponents[i] instanceof JXDatePicker) {
JXDatePicker datePicker = (JXDatePicker) jComponents[i];
Date date = datePicker.getDate();
if (date != null) {
propMap.put(prop[i], simpleFormatter.format(date));
} else {
propMap.put(prop[i], "");
}
}
}
TCComponentItemRevision gyItemRev = createItem(tcSession, "VF5gy", propMap.get("object_name"));
if(gyItemRev!=null) {
System.out.println("new item : "+gyItemRev.getStringProperty("object_name"));
}
targetFolder.add("contents", gyItemRev.getItem());;
System.out.println(propMap);
MessageBox.post("创建成功 !", "Info", MessageBox.INFORMATION);
return true;
}
public TCComponentItemRevision createItem(TCSession session, String type,
String name) throws TCException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
TCComponentItem item = itemType.create(itemType.getNewID(), "", type, name, "", null);
return item.getLatestItemRevision();
}
}

@ -1,10 +1,15 @@
package com.connor.ferrorTech.metal.processManagement.createCraft; package com.connor.ferrorTech.metal.processManagement.createCraft;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTextField;
import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.exception.CustomException; import com.connor.ferrorTech.metal.exception.CustomException;
import com.connor.ferrorTech.metal.processManagement.createProcesses.CreateProcessesDialog;
import com.connor.ferrorTech.metal.util.TcUtil; import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.AIFComponentContext; import com.teamcenter.rac.aif.kernel.AIFComponentContext;
@ -32,39 +37,33 @@ public class CreateCraftHandler extends AbstractHandler {
this.tcSession = (TCSession) application.getSession(); this.tcSession = (TCSession) application.getSession();
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application, boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
new String[] { "VF5ccpRevision", "VF5bcpRevision" }, "ItemRevision"); new String[] { "Folder","Fnd0HomeFolder" }, "Folder");
if (judgeSingleSelectComponent) { if (judgeSingleSelectComponent) {
TCComponentFolder targetFolder = null; TCComponentFolder targetFolder = null;
try { try {
targetFolder = getTargetFolder(); // targetFolder = getTargetFolder();
} catch (TCException e) { InterfaceAIFComponent targetComponent = this.application.getTargetComponent();
// TODO Auto-generated catch block targetFolder = (TCComponentFolder) targetComponent;
e.printStackTrace();
} catch (CustomException e1) { } catch (CustomException e1) {
e1.printStackTrace(); e1.printStackTrace();
} catch (Exception e2) { } catch (Exception e2) {
e2.printStackTrace(); e2.printStackTrace();
} }
if (targetFolder != null) { if (targetFolder != null) {
try { String[] chLabelName = new String[]{
String name = targetRev.getStringProperty("object_name"); "工序名称" };
System.out.println("target Folder is :" + targetFolder.getStringProperty("object_name")); JLabel[] jLabels = new JLabel[chLabelName.length];
TCComponentItemRevision gyItemRev = createItem(tcSession, "VF5gy", name); JComponent[] jComponents = new JComponent[chLabelName.length];
if(gyItemRev!=null) {
System.out.println("new item : "+gyItemRev.getStringProperty("object_name"));
}
gyItemRev.add("IMAN_METarget", targetRev);
targetRev.add("VF5gygx", gyItemRev.getItem());
targetFolder.add("contents", gyItemRev.getItem());
MessageBox.post("Created Successfully !", "Info", MessageBox.INFORMATION);
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
for (int i = 0; i < chLabelName.length; i++) {
jComponents[i] = new JTextField(14);
jLabels[i] = new JLabel(chLabelName[i]);
}
CreateCraftDialog action = new CreateCraftDialog("创建工序", new int[]{400, 200, 5, 5}, jLabels, jComponents,tcSession,targetFolder);
new Thread(action).start();
} else { } else {
MessageBox.post("Currently, no folder named POR was found !", "error", MessageBox.ERROR); MessageBox.post("选中文件夹为空!", "error", MessageBox.ERROR);
} }
} }
return null; return null;
@ -125,10 +124,5 @@ public class CreateCraftHandler extends AbstractHandler {
return null; return null;
} }
public TCComponentItemRevision createItem(TCSession session, String type,
String name) throws TCException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
TCComponentItem item = itemType.create(itemType.getNewID(), "", type, name, "", null);
return item.getLatestItemRevision();
}
} }

@ -1,53 +1,60 @@
package com.connor.ferrorTech.metal.processManagement.createProcesses; package com.connor.ferrorTech.metal.processManagement.createProcesses;
import java.awt.Frame; 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.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
import com.connor.ferrorTech.metal.constant.ConstantPool; import com.teamcenter.rac.kernel.TCComponentBOMLine;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
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.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem; import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision; import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentType; import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCProperty; import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession; import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox; import com.teamcenter.rac.util.MessageBox;
import javax.swing.*;
import java.awt.*;
import java.util.LinkedHashMap;
import java.util.Map;
@SuppressWarnings("serial")
public class CreateProcessesDialog extends JFrame implements Runnable { public class CreateProcessesDialog extends JFrame implements Runnable {
private AbstractAIFApplication application;
private TCSession tcSession;
private String title; private String title;
// sizes[0] = dialog的宽度sizes[1] = dialog的高度sizes[2] =
// BottomPanel的顶部距离sizes[3] = BottomPanel的底部距离
private int[] sizes;
private JLabel[] jLabels; private JLabel[] jLabels;
private JComponent[] jComponents; private JComponent[] jComponents;
private String[] lovArrays;
private JButton okButton; private JButton okButton;
private JButton celButton; private JButton celButton;
private Map<String, Map<String, String>> lovMap; private TCSession tcSession;
private TCComponentBOMLine target;
public CreateProcessesDialog(AbstractAIFApplication application, Object... args) { public CreateProcessesDialog(String title, Object... args) {
this.application = application; this.title = title;
this.tcSession = (TCSession) application.getSession();
int count = 0; int count = 0;
this.title = (String) args[count++]; this.sizes = (int[]) args[count++];
this.jLabels = (JLabel[]) args[count++]; this.jLabels = (JLabel[]) args[count++];
this.jComponents = (JComponent[]) args[count++]; this.jComponents = (JComponent[]) args[count++];
this.lovMap = (Map<String, Map<String, String>>) args[count]; this.tcSession = (TCSession) args[count++];
this.target = (TCComponentBOMLine) args[count++];
} }
@Override @Override
@ -57,7 +64,7 @@ public class CreateProcessesDialog extends JFrame implements Runnable {
public void initUI() { public void initUI() {
this.setTitle(title); this.setTitle(title);
this.setSize(460, 570); this.setSize(sizes[0], sizes[1]);
// 初始化组件 // 初始化组件
initializationComponent(); initializationComponent();
// 添加内容到JFrame 并设置它的位置 // 添加内容到JFrame 并设置它的位置
@ -76,12 +83,12 @@ public class CreateProcessesDialog extends JFrame implements Runnable {
/** /**
* *
*/ */
private void initializationComponent() { public void initializationComponent() {
okButton = new JButton(ConstantPool.EN_BUTTON_CONFIRM); okButton = new JButton("创建");
celButton = new JButton(ConstantPool.EN_BUTTON_CANCEL); celButton = new JButton("取消");
} }
private JScrollPane getCenterPanel() { public JScrollPane getCenterPanel() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout()); JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints customLayout = new GridBagConstraints(); GridBagConstraints customLayout = new GridBagConstraints();
@ -100,26 +107,29 @@ public class CreateProcessesDialog extends JFrame implements Runnable {
customLayout.fill = GridBagConstraints.HORIZONTAL; customLayout.fill = GridBagConstraints.HORIZONTAL;
JComponent jComponent = jComponents[i]; JComponent jComponent = jComponents[i];
jComponent.setFont(new Font("微软雅黑", Font.BOLD, 15)); jComponent.setFont(new Font("微软雅黑", Font.BOLD, 15));
if (i > 3 && jComponent instanceof JComboBox) {
((JComboBox) jComponent).setSelectedItem("MIN");
}
centerPanel.add(jComponent, customLayout); centerPanel.add(jComponent, customLayout);
} }
// 创建具有滚动功能的JPanel // 创建具有滚动功能的JPanel
return new JScrollPane(centerPanel); return new JScrollPane(centerPanel);
} }
private JPanel getBottomPanel() { public JPanel getBottomPanel() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10)); JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 70, 10));
bottomPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); bottomPanel.setBorder(BorderFactory.createEmptyBorder(sizes[2], 0, sizes[3], 0));
bottomPanel.add(this.okButton); bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton); bottomPanel.add(this.celButton);
// 添加监听 // 添加监听
okButton.addActionListener(e -> { okButton.addActionListener(e -> {
this.dispose(); // ¹Ø±Õ´°¿Ú try {
boolean confirmed = confirmFunction(); boolean confirmed = confirmFunction();
if (confirmed) {
this.dispose(); // 关闭窗口
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}); });
celButton.addActionListener(e -> { celButton.addActionListener(e -> {
this.dispose(); // 关闭窗口 this.dispose(); // 关闭窗口
@ -127,32 +137,41 @@ public class CreateProcessesDialog extends JFrame implements Runnable {
return bottomPanel; return bottomPanel;
} }
public boolean confirmFunction() { public boolean confirmFunction() throws TCException {
Map<String, String> propMap = new LinkedHashMap<>(); Map<String, String> propMap = new LinkedHashMap<>();
String[] prop = new String[] { "object_name", "vf5gxlx", "vf5gzzxsj", "vf5zbsj", "vf5zbsjdw", "vf5jqsj", String[] prop = new String[] { "object_name" };
"vf5jqsjdw", "vf5rgsj", "vf5rgsjdw", "vf5fjfy", "vf5fjfydw" }; SimpleDateFormat simpleFormatter = new SimpleDateFormat("yyyy-MM-dd");
for (int i = 0; i < jComponents.length; i++) { for (int i = 0; i < jComponents.length; i++) {
if (jComponents[i] instanceof JTextField) { if (jComponents[i] instanceof JTextField) {
propMap.put(prop[i], ((JTextField) jComponents[i]).getText()); propMap.put(prop[i], ((JTextField) jComponents[i]).getText());
} else if (jComponents[i] instanceof JComboBox) { } else if (jComponents[i] instanceof JComboBox) {
JComboBox comboBox = (JComboBox) jComponents[i]; JComboBox comboBox = (JComboBox) jComponents[i];
Object selectedItem = comboBox.getSelectedItem(); Object selectedItem = comboBox.getSelectedItem();
String displayValue = selectedItem != null ? selectedItem.toString() : ""; propMap.put(prop[i], selectedItem != null ? selectedItem.toString() : "");
} else if (jComponents[i] instanceof JXDatePicker) {
if (i == 1) { JXDatePicker datePicker = (JXDatePicker) jComponents[i];
Map<String, String> map = lovMap.get("vf5gxlxlov"); Date date = datePicker.getDate();
propMap.put(prop[i], map.get(displayValue)); if (date != null) {
} else if (i == 4 || i == 6 || i == 8 || i == 10) { propMap.put(prop[i], simpleFormatter.format(date));
Map<String, String> map = lovMap.get("VF5dwlov");
propMap.put(prop[i], map.get(displayValue));
} else { } else {
propMap.put(prop[i], displayValue); propMap.put(prop[i], "");
} }
} }
} }
TCComponentItemRevision gxItemRev = createItem(tcSession, "VF5gy", propMap.get("object_name"));
if (gxItemRev != null) {
System.out.println("new item : " + gxItemRev.getStringProperty("object_name"));
}
target.add(gxItemRev.getItem(),gxItemRev,null,false,"");
System.out.println(propMap); System.out.println(propMap);
CreateProcessesOperation createProcessesOperation = new CreateProcessesOperation(application, propMap); MessageBox.post("添加成功 !", "Info", MessageBox.INFORMATION);
this.tcSession.queueExcludedOperation(createProcessesOperation);
return true; return true;
} }
public TCComponentItemRevision createItem(TCSession session, String type, String name) throws TCException {
TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type);
TCComponentItem item = itemType.create(itemType.getNewID(), "", type, name, "", null);
return item.getLatestItemRevision();
}
} }

@ -13,6 +13,7 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.ExecutionException;
import com.connor.ferrorTech.metal.processManagement.createCraft.CreateCraftDialog;
import com.connor.ferrorTech.metal.util.SwingUtil; import com.connor.ferrorTech.metal.util.SwingUtil;
import com.connor.ferrorTech.metal.util.TcUtil; import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication; import com.teamcenter.rac.aif.AbstractAIFApplication;
@ -32,6 +33,7 @@ public class CreateProcessesHandler extends AbstractHandler {
private AbstractAIFApplication application; private AbstractAIFApplication application;
private TCSession tcSession; private TCSession tcSession;
private TCComponentBOMLine tar;
@Override @Override
public Object execute(ExecutionEvent arg0) throws ExecutionException { public Object execute(ExecutionEvent arg0) throws ExecutionException {
@ -47,39 +49,16 @@ public class CreateProcessesHandler extends AbstractHandler {
} }
if(flag) { if(flag) {
String[] chLabelName = new String[]{ String[] chLabelName = new String[]{
"工序名称", "工序类型", "工作中心编码", "准备时间", "准备时间单位", "工序名称"
"机器时间", "机器时间单位", "人工时间", "人工时间单位", "附加费用",
"附加费用单位"
}; };
String[] enLabelName = new String[]{ JLabel[] jLabels = new JLabel[chLabelName.length];
"Operate Name", "Operate type", "WorkCenterInternalI", "Setup", "Setup Unit", JComponent[] jComponents = new JComponent[chLabelName.length];
"Machine Time", "Machine Unit", "Labor", "Labor Unit", "Production Overhead",
"Production Overhead Unit"
};
JLabel[] jLabels = new JLabel[enLabelName.length];
JComponent[] jComponents = new JComponent[enLabelName.length];
Map<Integer,String> map = new HashMap<>();
map.put(1, "vf5gxlxlov");
map.put(2, "VF5gzzxlov2");
map.put(4, "VF5dwlov");
map.put(6, "VF5dwlov");
map.put(8, "VF5dwlov");
map.put(10, "VF5dwlov");
Map<String, Map<String, String>> lovMap = new HashMap<String, Map<String,String>>();
Map<String, Map<String, String>> dynamicLovMap = new HashMap<String, Map<String,String>>();
for (int i = 0; i < enLabelName.length; i++) { for (int i = 0; i < chLabelName.length; i++) {
if(i ==2) { jComponents[i] = new JTextField(14);
jComponents[i] = new JComboBox<>(TcUtil.getDynamicLOV(tcSession, map.get(i), dynamicLovMap)); jLabels[i] = new JLabel(chLabelName[i]);
}else if(map.containsKey(i)){
jComponents[i] = new JComboBox<>(SwingUtil.getKeyValue(map.get(i), lovMap));
}else{
jComponents[i] = new JTextField(14);
}
jLabels[i] = new JLabel(enLabelName[i]);
} }
CreateProcessesDialog action = new CreateProcessesDialog("创建工序", new int[]{400, 200, 5, 5}, jLabels, jComponents,tcSession,tar);
CreateProcessesDialog action = new CreateProcessesDialog(application,"Create Operation",jLabels,jComponents,lovMap);
new Thread(action).start(); new Thread(action).start();
} }
@ -92,13 +71,14 @@ public class CreateProcessesHandler extends AbstractHandler {
if(targetComponent instanceof TCComponentBOMLine) { if(targetComponent instanceof TCComponentBOMLine) {
String itemType = ((TCComponentBOMLine)targetComponent).getItemRevision().getStringProperty("object_type"); String itemType = ((TCComponentBOMLine)targetComponent).getItemRevision().getStringProperty("object_type");
if (itemType.equals("VF5gyRevision")) { if (itemType.equals("VF5gyRevision")) {
tar = (TCComponentBOMLine) targetComponent;
return true; return true;
} else { } else {
JOptionPane.showMessageDialog(null, "Incorrect version!", "Error", JOptionPane.WARNING_MESSAGE); JOptionPane.showMessageDialog(null, "请选择工艺对象!", "Error", JOptionPane.WARNING_MESSAGE);
return false; return false;
} }
}else { }else {
MessageBox.post("Please select the Bom Item !", "error", MessageBox.ERROR); MessageBox.post("请选择Bom对象!", "Error", MessageBox.ERROR);
return false; return false;
} }
} }

@ -1,68 +0,0 @@
package com.connor.ferrorTech.metal.processManagement.createProcesses;
import java.awt.Frame;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFOperation;
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.TCComponentType;
import com.teamcenter.rac.kernel.TCSession;
public class CreateProcessesOperation extends AbstractAIFOperation {
private AbstractAIFApplication application;
private TCSession tcSession;
private Map<String, String> propMap;
public CreateProcessesOperation(AbstractAIFApplication application, Map<String, String> propMap) {
this.application = application;
this.tcSession = (TCSession) application.getSession();
this.propMap = propMap;
}
@Override
public void executeOperation() throws Exception {
TCComponentItemType typeComponent = (TCComponentItemType) tcSession.getTypeComponent("VF5gx");
TCComponentItem item = typeComponent.create(typeComponent.getNewID(), "", "VF5gx", propMap.get("object_name"),
"", null);
TCComponentItemRevision itemRevision = item.getLatestItemRevision();
TCComponentForm form = (TCComponentForm) itemRevision.getRelatedComponent("IMAN_master_form_rev");
System.out.println("item uid : " + item.getUid());
TCComponentBOMLine targetBomLine = (TCComponentBOMLine) this.application.getTargetComponent();
TCComponentBOMLine bomLine = targetBomLine.add(item, itemRevision, null, false, "");
Set<String> keySet = propMap.keySet();
for (String key : keySet) {
System.out.println("µ±Ç°ÊôÐÔÖµ=> key:"+key + " || value: "+propMap.get(key));
if (key.equals("object_name")) {
continue;
}
form.setStringProperty(key, propMap.get(key));
if (key.equals("vf5gxlx") || key.equals("vf5gzzxsj")) {
continue;
}
bomLine.setProperty(capitalizeFirstTwo(key), propMap.get(key));
}
targetBomLine.save();
}
public String capitalizeFirstTwo(String input) {
if (input == null || input.length() < 2) {
return input == null ? "" : input.toUpperCase();
}
return input.substring(0, 2).toUpperCase() + input.substring(2);
}
}

@ -1,21 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
import java.awt.Frame;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
public class CreateClientFileAction extends AbstractAIFAction {
private AbstractAIFApplication application;
public CreateClientFileAction(AbstractAIFApplication application, Frame frame, String param) {
super(application, frame, param);
this.application = application;
}
@Override
public void run() {
CreateClientFileDialog dialog = new CreateClientFileDialog(this.application);
}
}

@ -1,328 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
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.util.HashMap;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentDatasetType;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemRevisionType;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCProperty;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateClientFileDialog {
private AbstractAIFApplication application;
private TCSession tcSession;
private JFrame frame;
private JLabel[] inputLalels;
private JTextField[] inputFields;
private JLabel[] selectLabels;
private JComboBox<String>[] selectFields;
private String[] fieldName;
private String[] lovArrays;
private JButton okButton;
private JButton celButton;
private Map<String,Map<String,String>> lovMap;
private final String Type = "VF5khda";
private TCComponentItemType itemType;
private TCComponentFolder targetFolder;
public CreateClientFileDialog(AbstractAIFApplication application) {
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
run();
}
/**
*
*/
private void initUi() {
try {
frame = new JFrame("Create Customer Profiles");
frame.setSize(520, 520);
// 初始化所有信息
setPanelProperties();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getTopPanel();
JPanel bottomPanel = getButtomPanel();
frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
// 设置窗口居中
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// 设置可见性
frame.setVisible(true);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
}
}
/**
*
*/
private void setPanelProperties() {
fieldName = new String[]{"vf5khjc","vf5lxr","vf5lxdh","vf5khhy","vf5gs","vf5khjl","vf5lx","vf5zt"};
lovArrays = new String[] {"VF5khhylov","VF5gslov","VF5lxlov","VF5ztlov"};
lovMap = new HashMap<String,Map<String,String>>();
inputLalels =new JLabel[]{
new JLabel("Customer name"), new JLabel("Customer abbreviation"), new JLabel("Contact person"),
new JLabel("Telephone number"),new JLabel("Account manager")};
selectLabels = new JLabel[]{new JLabel("Customer industry"),new JLabel("Business unit/company"),new JLabel("Type"),new JLabel("Status")};
try {
inputFields = new JTextField[] {new JTextField(14),new JTextField(14),new JTextField(14),new JTextField(14),new JTextField(14)};
selectFields = new JComboBox[lovArrays.length];
for (int i = 0; i < lovArrays.length; i++) {
selectFields[i]= new JComboBox<String>(getRealLoveName(lovArrays[i]));
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
MessageBox.post("get LOV error", "error", MessageBox.ERROR);
}
okButton = new JButton("Confirm");
celButton = new JButton("Cancel");
}
private JScrollPane getTopPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
for (int i = 0; i < inputLalels.length; i++) {
c.insets = new Insets(5, 30, 5, 5);// 边距
c.gridx = 0;
c.weightx = 0;
c.anchor = GridBagConstraints.LINE_START;
inputLalels[i].setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(inputLalels[i], c);
c.insets = new Insets(5, 3, 5, 30);// 边距
c.gridx = 1;
c.weightx = 0;
c.fill = GridBagConstraints.HORIZONTAL;
JTextField jTextField = inputFields[i];
jTextField.setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(jTextField, c);
}
// 将每个JLabel和JTextField添加到formPanel
for (int i = 0; i < selectLabels.length; i++) {
c.insets = new Insets(5, 30, 5, 5);// 边距
c.gridx = 0;
c.weightx = 0;
c.anchor = GridBagConstraints.LINE_START;
selectLabels[i].setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(selectLabels[i], c);
c.insets = new Insets(5, 3, 5, 30);// 边距
c.gridx = 1;
c.weightx = 1;
c.fill = GridBagConstraints.HORIZONTAL;
JComboBox jComboBox = selectFields[i];
jComboBox.setFont(new Font("微软雅黑", Font.BOLD, 15));
jComboBox.setSelectedIndex(-1);
centerPanel.add(jComboBox, c);
}
// 创建具有滚动功能的JPanel
return new JScrollPane(centerPanel);
}
private JPanel getButtomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
//添加监听
okButton.addActionListener(e->{
frame.dispose(); // 关闭窗口
createUser();
});
celButton.addActionListener(e->{
frame.dispose(); // 关闭窗口
});
return bottomPanel;
}
public void run() {
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
if (selectComponent !=null && selectComponent instanceof TCComponentFolder) {
targetFolder = (TCComponentFolder) selectComponent;
initUi();
} else {
MessageBox.post("Please select a folder", "error", MessageBox.ERROR);
}
}
// 获取lov的值
public String[] getRealLoveName(String lovName) throws TCException {
String[] myLovArray =null;
Map<String,String> tempLovMap = new HashMap<>();
TCComponentListOfValues lobList = TCComponentListOfValuesType
.findLOVByName(lovName);
System.out.println("lovName:"+lovName);
try {
if (lobList != null) {
ListOfValuesInfo info = lobList.getListOfValues();
String[] valuesList = info.getStringListOfValues();
myLovArray = new String[valuesList.length];
for (int w = 0; w < valuesList.length; w++) {
String disValue = info.getDisplayableValue(valuesList[w]);
myLovArray[w]=disValue;
tempLovMap.put(disValue,(String)valuesList[w]);
System.out.println("Lov dis = "+valuesList[w]+" | "+disValue);
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("get Lov is error!");
}
lovMap.put(lovName, tempLovMap);
return myLovArray;
}
/**
*
userNameInput;
userSmallNameInput;
contactsInput;
contactNumberInput;
industryBox;
ascriptionBox;
managerInput;
saleBox;
typeBox;
stateBox
*/
@SuppressWarnings("unused")
private Boolean createUser(){
String userName = inputFields[0].getText();
String userSmallName = inputFields[1].getText();
String contacts = inputFields[2].getText();
String contactNumber = inputFields[3].getText();
String manager = inputFields[4].getText();
String industry = (String)selectFields[0].getSelectedItem();
String ascription = (String)selectFields[1].getSelectedItem();
// String sale = (String)this.saleBox.getSelectedItem();
String type = (String)selectFields[2].getSelectedItem();
String state = (String)selectFields[3].getSelectedItem();
// StringBuffer info = new StringBuffer("");
// info.append("userName = "+userName);
// info.append("\nuserSmallName = "+userSmallName);
// info.append("\ncontacts = "+contacts);
// info.append("\ncontactNumber = "+contactNumber);
// info.append("\nindustry = "+industry);
// info.append("\nascription = "+ascription);
// info.append("\nmanager = "+manager);
// info.append("\nsale = "+sale);
// info.append("\ntype = "+type);
// info.append("\nstate = "+state);
String[] contentField = new String[] {userSmallName,contacts,contactNumber,industry
,ascription,manager,type,state};
// MessageBox.post(info.toString(),"info",MessageBox.INFORMATION);
if(userName == null) {
MessageBox.post("Customer name cannot be empty","create error",MessageBox.ERROR);
return false;
}
try {
System.out.println("Type = "+ Type);
itemType = (TCComponentItemType) this.tcSession.getTypeComponent(Type);
String itemID = itemType.getNewID();
TCComponentItem item = itemType.create(itemID,null,Type,userName, "", null);
TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
TCComponent[] referenceValueArray = latestItemRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
if(referenceValueArray.length>0) {
for (int i = 0; i < contentField.length; i++) {
String trueValue = "";
Map<String, String> tempMap = null;
switch(fieldName[i]){
case "vf5khhy":{
tempMap = lovMap.get("VF5khhylov");
break;
}case "vf5gs":{
tempMap = lovMap.get("VF5gslov");
break;
}case "vf5lx":{
tempMap = lovMap.get("VF5lxlov");
break;
}case "vf5zt":{
tempMap = lovMap.get("VF5ztlov");
break;
}default:{
break;
}}
if(tempMap!=null) {
System.out.println(fieldName[i] + "lov => " + tempMap.toString());
trueValue = tempMap.get(contentField[i]);
}else {
trueValue = contentField[i];
}
System.out.println(" => 设置属性:" + fieldName[i]+ " = "+trueValue);
referenceValueArray[0].setProperty(fieldName[i],trueValue);
}
}else {
// 创建form表单对象
}
if(item!=null) {
targetFolder.add("contents", item);
targetFolder.refresh();
MessageBox.post("Successfully created customer profile!","Tip",MessageBox.INFORMATION);
}else {
MessageBox.post("Failed to create customer profile!","Tip",MessageBox.ERROR);
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
}

@ -1,23 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createClientFile;
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 CreateClientFileHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateClientFileAction action = new CreateClientFileAction(application, null, null);
new Thread(action).start();
return null;
}
}

@ -1,10 +0,0 @@
customerProfilesDialog.0=Create Customer Profiles
customerProfilesDialog.1=Customer name
customerProfilesDialog.2=Customer abbreviation
customerProfilesDialog.3=Contact person
customerProfilesDialog.4=Telephone number
customerProfilesDialog.5=Account manager
customerProfilesDialog.6=Customer industry
customerProfilesDialog.7=Business unit/company
customerProfilesDialog.8=Type
customerProfilesDialog.9=Status

@ -1,97 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings;
import java.awt.Frame;
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.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateQuotationDrawingsAction extends AbstractAIFAction {
private AbstractAIFApplication application;
private TCSession tcSession;
private TCComponentItemRevision targetRev;
private TCComponentItemType drawType ;
private final static String DRAW_TYPE = "VF5bjtz";
public CreateQuotationDrawingsAction(AbstractAIFApplication application, Frame frame, String param) {
super(application, frame, param);
this.application = application;
this.tcSession = (TCSession)application.getSession();
}
@Override
public void run() {
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
if (selectComponent !=null && selectComponent instanceof TCComponentItemRevision) {
targetRev = (TCComponentItemRevision) selectComponent;
System.out.println("选中对象版本类型为: "+ targetRev.getType());
if(targetRev.getType().equals("VF5bjxmRevision")) {
try {
boolean judgeReference = judgeReference(targetRev);
if(judgeReference) {
drawType =(TCComponentItemType)tcSession.getTypeComponent(DRAW_TYPE);
TCComponentItem targetItem = targetRev.getItem();
// 获取目标对象下VF5xjxxdgx关系的询价信息单对象
TCComponent[] targetRevItem = targetRev.getTCProperty("VF5xjxxdgx").getReferenceValueArray();
if(targetRevItem.length<1) {
throw new IndexOutOfBoundsException("VF5xjxxdgx 关系下没有对象");
}
TCComponentItemRevision xjxxdItemRev = ((TCComponentItem) targetRevItem[0]).getLatestItemRevision();
String newID = drawType.getNewID();
TCComponentItem drawItem = drawType.create(newID, null, DRAW_TYPE, targetItem.getStringProperty("object_name"), "", null);
TCComponentItemRevision drawItemRevision = drawItem.getLatestItemRevision();
TCComponent[] drawItemRevisionMaster = drawItemRevision.getTCProperty("IMAN_master_form_rev").getReferenceValueArray();
drawItemRevisionMaster[0].setProperty("vf5khmc", xjxxdItemRev.getRelatedComponent("IMAN_master_form_rev").getStringProperty("vf5khmc"));
// 挂载在报价项目对象版本的报价图纸关系vf5bjtzgx关系下
targetRev.add("VF5tzgx", drawItem);
MessageBox.post("Successfully created quotation drawing !", "Success", MessageBox.INFORMATION);
}else {
MessageBox.post("The Quotation Drawing Object Already Exists. !", "Success", MessageBox.WARNING);
}
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("Failed to create object type !");
e.printStackTrace();
} catch (IndexOutOfBoundsException e) {
MessageBox.post("There are no objects in the current version relationship", "Warning", MessageBox.WARNING);
// TODO Auto-generated catch block
e.printStackTrace();
}
}else {
MessageBox.post("Please Select A Collect Revision !", "error", MessageBox.ERROR);
}
} else {
MessageBox.post("Please Select A Revision Item !", "error", MessageBox.ERROR);
}
}
public boolean judgeReference(TCComponentItemRevision targetRev) throws TCException {
TCComponent[] relatedComponents = targetRev.getRelatedComponents("VF5tzgx");
for (TCComponent tcComponent : relatedComponents) {
if(tcComponent.getType().equals(DRAW_TYPE)) {
return false;
}
}
return true;
}
}

@ -1,23 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createQuotationDrawings;
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 CreateQuotationDrawingsHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateQuotationDrawingsAction action = new CreateQuotationDrawingsAction(application, null, null);
new Thread(action).start();
return null;
}
}

@ -1,21 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
import java.awt.Frame;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.common.actions.AbstractAIFAction;
public class CreateQuotationProjectAction extends AbstractAIFAction {
private AbstractAIFApplication application;
public CreateQuotationProjectAction(AbstractAIFApplication application, Frame frame, String param) {
super(application, frame, param);
this.application = application;
}
@Override
public void run() {
CreateQuotationProjectDialog dialog = new CreateQuotationProjectDialog(this.application);
}
}

@ -1,513 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
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.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.ListOfValuesInfo;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentFolder;
import com.teamcenter.rac.kernel.TCComponentFolderType;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCComponentListOfValues;
import com.teamcenter.rac.kernel.TCComponentListOfValuesType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCPreferenceService;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateQuotationProjectDialog extends JFrame {
private AbstractAIFApplication application;
private TCSession tcSession;
private JFrame frame;
private JLabel[] inputLalels;
private JComponent[] inputFields;
private JLabel[] selectLabels;
private JComboBox<String>[] selectFields;
private String[] fieldName;
private String[] lovArrays;
private JButton okButton;
private JButton celButton;
private Map<String, Map<String, String>> lovMap;
private final String Type = "VF5bjxm";
private final String InnerType = "VF5xjxxd";
private final String InnerTypeRevision = "VF5xjxxdRevision";
private final String Preferences = "Salespeoples";
private final String FolderUIDPreferences = "VF5bjxm";
private TCComponentItemType itemType;
private TCComponentItemType innerItemType;
private TCComponentFolderType folderType;
private TCComponentFolder targetFolder;
private TCComponentFolder originFolder;
public CreateQuotationProjectDialog(AbstractAIFApplication application) {
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
run();
}
/**
*
*/
private void initUi() {
try {
frame = new JFrame("Create Quotation Projects");
frame.setSize(700, 650);
// 初始化所有信息
setPanelProperties();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getTopPanel();
JPanel bottomPanel = getButtomPanel();
frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
// 设置窗口居中
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// 设置可见性
frame.setVisible(true);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
}
}
/**
*
*/
private void setPanelProperties() {
// Project Name、 Quotation drawing number、AnnualDemand、 Target price、Wishes
// completing time、Customer Namebox、Is surveying productbox
// Salespersonbox、State of emergencybox、Technical requirement、Notes
fieldName = new String[] { "vf5bjtzth", "vf5nxql", "vf5mbjg", "vf5khqwwcrq", "vf5khmc", "vf5sfchp", "vf5xsry",
"vf5jjzt", "vf5jsyq", "vf5beizhu" };
// 是否测绘、 State of emergency
lovArrays = new String[] { "VF5sflov", "VF5jjztlov" };
lovMap = new HashMap<String, Map<String, String>>();
inputLalels = new JLabel[] { new JLabel("Project name"), new JLabel("Quotation drawing number"),
new JLabel("Annual demand"), new JLabel("Target price"),
new JLabel("Customer expects quotation completion date"), new JLabel("Technical requirements"),
new JLabel("Remarks") };
selectLabels = new JLabel[] { new JLabel("Customer name"), new JLabel("Whether surveying product"),
new JLabel("Salesperson"), new JLabel("Emergency status") };
try {
inputFields = new JComponent[inputLalels.length];
for (int i = 0; i < inputLalels.length; i++) {
if (i == 4) {
inputFields[i] = createDatePicker();
} else {
inputFields[i] = new JTextField(14);
}
}
selectFields = new JComboBox[selectLabels.length];
selectFields[0] = new JComboBox<String>(getCustomerName());
selectFields[1] = new JComboBox<String>(getRealLoveName(lovArrays[0]));
selectFields[2] = new JComboBox<String>(getSaleName());
selectFields[3] = new JComboBox<String>(getRealLoveName(lovArrays[1]));
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
MessageBox.post("get LOV error", "error", MessageBox.ERROR);
}
okButton = new JButton("Confirm");
celButton = new JButton("Cancel");
}
private static JXDatePicker createDatePicker() {
// 创建 JXDatePicker
JXDatePicker datePicker = new JXDatePicker();
// 设置日期格式
datePicker.setFormats(new SimpleDateFormat("yyyy-MM-dd"));
return datePicker;
}
private JScrollPane getTopPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints g = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
for (int i = 0; i < inputLalels.length; i++) {
if (i == inputLalels.length - 2) {
// 将每个JLabel和JTextField添加到formPanel
for (int j = 0; j < selectLabels.length; j++) {
g.insets = new Insets(5, 30, 5, 5);// 边距
g.gridx = 0;
g.weightx = 0;
g.anchor = GridBagConstraints.LINE_START;
selectLabels[j].setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(selectLabels[j], g);
g.insets = new Insets(5, 3, 5, 30);// 边距
g.gridx = 1;
g.weightx = 1;
g.fill = GridBagConstraints.HORIZONTAL;
selectFields[j].setFont(new Font("微软雅黑", Font.BOLD, 15));
selectFields[j].setSelectedIndex(-1);
centerPanel.add(selectFields[j], g);
}
}
g.insets = new Insets(5, 30, 5, 5);// 边距
g.gridx = 0;
g.weightx = 0;
g.anchor = GridBagConstraints.LINE_START;
inputLalels[i].setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(inputLalels[i], g);
g.insets = new Insets(5, 3, 5, 30);// 边距
g.gridx = 1;
g.weightx = 0;
g.fill = GridBagConstraints.HORIZONTAL;
inputFields[i].setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(inputFields[i], g);
}
// 创建具有滚动功能的JPanel
return new JScrollPane(centerPanel);
}
private JPanel getButtomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
// 添加监听
okButton.addActionListener(e -> {
Boolean flag = createUser();
if (flag) {
frame.dispose(); // 关闭窗口
}
});
celButton.addActionListener(e -> {
frame.dispose(); // 关闭窗口
});
return bottomPanel;
}
public void run() {
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
if (selectComponent != null && selectComponent instanceof TCComponentFolder) {
targetFolder = (TCComponentFolder) selectComponent;
initUi();
} else {
MessageBox.post("Please select a folder", "error", MessageBox.ERROR);
}
}
// 获取lov的值
public String[] getRealLoveName(String lovName) throws TCException {
String[] myLovArray = null;
Map<String, String> tempLovMap = new HashMap<>();
TCComponentListOfValues lobList = TCComponentListOfValuesType.findLOVByName(lovName);
System.out.println("lovName:" + lovName);
try {
if (lobList != null) {
ListOfValuesInfo info = lobList.getListOfValues();
String[] valuesList = info.getStringListOfValues();
myLovArray = new String[valuesList.length];
for (int w = 0; w < valuesList.length; w++) {
String disValue = info.getDisplayableValue(valuesList[w]);
myLovArray[w] = disValue;
tempLovMap.put(disValue, (String) valuesList[w]);
System.out.println("Lov dis = " + valuesList[w] + " | " + disValue);
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("get Lov is error!");
}
lovMap.put(lovName, tempLovMap);
return myLovArray;
}
// 查询、获取、去重 客户名称
public String[] getCustomerName() {
LinkedHashSet<String> customerNameLov = new LinkedHashSet<String>();
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();
customerNameLov.add(tcRevision.getStringProperty("object_name"));
}
} catch (Exception e) {
// TODO: handle exception
System.out.println("查询客户名称错误!");
e.printStackTrace();
}
return customerNameLov.toArray(new String[0]);
}
public String[] getSaleName() {
TCPreferenceService preferenceService = tcSession.getPreferenceService();
return preferenceService.getStringValues(Preferences);
}
/**
*
* userNameInput; userSmallNameInput; contactsInput; contactNumberInput;
* industryBox; ascriptionBox; managerInput; saleBox; typeBox; stateBox
*/
@SuppressWarnings("unused")
private Boolean createUser() {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String quotationName = ((JTextField) inputFields[0]).getText();
String drawingNumber = ((JTextField) inputFields[1]).getText();
String AnnualDemand = ((JTextField) inputFields[2]).getText();
String TargetPrice = ((JTextField) inputFields[3]).getText();
JXDatePicker datePicker = (JXDatePicker) inputFields[4];
String fileTime = "";
if(datePicker.getDate()!=null) {
fileTime = simpleDateFormat.format(datePicker.getDate());
}else {
fileTime = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now());
}
String TechnicalRequireMent = ((JTextField) inputFields[5]).getText();
String Notes = ((JTextField) inputFields[6]).getText();
String customerName = (String) selectFields[0].getSelectedItem();
String IsSurveying = (String) selectFields[1].getSelectedItem();
String SalePerson = (String) selectFields[2].getSelectedItem();
String StateOfEmergency = (String) selectFields[3].getSelectedItem();
System.out.println("fileTime = " + fileTime);
String[] split = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now()).split("-");
System.out.println("split = " + Arrays.toString(split));
String id = "";
StringBuffer fileTimeStr = new StringBuffer("");
fileTimeStr.append(split[0]);
fileTimeStr.append(split[1]);
fileTimeStr.append(split[2]);
id = fileTimeStr.toString();
try {
// 判断是否存在该文件夹
Boolean flag = isExistFolder(customerName, split);
System.out.println("targetFolder : " + targetFolder.getStringProperty("object_name"));
String[] contentField = new String[] { drawingNumber, AnnualDemand, TargetPrice, fileTime, customerName,
IsSurveying, SalePerson, StateOfEmergency, TechnicalRequireMent, Notes };
if (quotationName == null) {
MessageBox.post("QuotationName cannot be empty", "create error", MessageBox.ERROR);
return false;
}
// 创建报价项目对象
itemType = (TCComponentItemType) this.tcSession.getTypeComponent(Type);
String itemID = itemType.getNewID();
TCComponentItem item = itemType.create(itemID, null, Type, quotationName, "", null);
TCComponentItemRevision latestItemRevision = item.getLatestItemRevision();
// 创建询价信息单对象
innerItemType = (TCComponentItemType) this.tcSession.getTypeComponent(InnerType);
TCComponentItem innerItem = innerItemType.create(id + "_" + queryLatestNo(id + "*"), null, InnerType,
quotationName, "", null);
TCComponentItemRevision innerRev = innerItem.getLatestItemRevision();
// 设置相关属性
latestItemRevision.add("VF5xjxxdgx", innerItem);
TCComponent innerRevForm = innerRev.getRelatedComponent("IMAN_master_form_rev");
if (innerRevForm != null) {
for (int i = 0; i < contentField.length; i++) {
String trueValue = "";
Map<String, String> tempMap = null;
switch (fieldName[i]) {
case "vf5sfchp": {
tempMap = lovMap.get("VF5sflov");
break;
}
case "vf5jjzt": {
tempMap = lovMap.get("VF5jjztlov");
break;
}
default: {
break;
}
}
if (tempMap != null) {
System.out.println(fieldName[i] + "lov => " + tempMap.toString());
trueValue = tempMap.get(contentField[i]);
} else {
trueValue = contentField[i];
}
System.out.println(" => 设置属性:" + fieldName[i] + " = " + trueValue);
innerRevForm.setProperty(fieldName[i], trueValue);
}
targetFolder.add("contents", item);
((TCComponentFolder) application.getTargetComponent()).add("contents", item);
targetFolder.refresh();
MessageBox.post("Succeed To Create Quotation Project!", "Tip", MessageBox.INFORMATION);
} else {
MessageBox.post("Failed To Create Quotation Project!", "Tip", MessageBox.ERROR);
}
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (Exception e2) {
e2.printStackTrace();
}
return true;
}
public String queryLatestNo(String value) throws Exception {
InterfaceAIFComponent[] resultComponents = tcSession.search("MU_Find Inquiry Information Sheet",
new String[] { "ID" }, new String[] { value });
int maxValue = 0;
if (resultComponents.length == 0) {
return "01";
}
for (InterfaceAIFComponent interfaceAIFComponent : resultComponents) {
if (interfaceAIFComponent instanceof TCComponent) {
String itemId = ((TCComponent) interfaceAIFComponent).getStringProperty("item_id");
String[] split = itemId.split("_");
if (split.length >= 2) {
int localValue = Integer.parseInt(split[1]);
if (maxValue < localValue) {
maxValue = localValue;
}
}
}
}
if (maxValue != 0) {
maxValue ++;
return maxValue > 9 ? maxValue + "" : "0" + maxValue;
} else {
return "01";
}
}
public Boolean isExistFolder(String customerName, String[] folderName) {
TCPreferenceService getFolderUID = tcSession.getPreferenceService();
String value = getFolderUID.getStringValue(FolderUIDPreferences);
System.out.println("文件夹UID: " + value);
try {
folderType = (TCComponentFolderType) tcSession.getTypeComponent("Folder");
originFolder = (TCComponentFolder) tcSession.stringToComponent(value);
// AIFComponentContext[] children = originFolder.getChildren();
TCComponent[] customerFolders = originFolder.getTCProperty("contents").getReferenceValueArray();
boolean customerFlag = true;
boolean yearFlag = true;
boolean monthFlag = true;// true == 不存在
for (int i = 0; i < customerFolders.length; i++) {
TCComponentFolder selectCustomerFolder = (TCComponentFolder) customerFolders[i];
if (selectCustomerFolder.getStringProperty("object_name").equals(customerName)) {
TCComponent[] yearFolders = selectCustomerFolder.getTCProperty("contents").getReferenceValueArray();
for (int j = 0; j < yearFolders.length; j++) {
TCComponentFolder selectYearFolder = (TCComponentFolder) yearFolders[j];
if (selectYearFolder.getStringProperty("object_name").equals(folderName[0])) {
TCComponent[] monthFolder = selectYearFolder.getTCProperty("contents")
.getReferenceValueArray();
for (int k = 0; k < monthFolder.length; k++) {
TCComponentFolder selectMonthFolder = (TCComponentFolder) monthFolder[k];
System.out.println(
"文件夹object_name = " + selectMonthFolder.getStringProperty("object_name"));
if (selectMonthFolder.getStringProperty("object_name").equals(folderName[1])) {
System.out.println("存在该文件夹");
targetFolder = selectMonthFolder;
monthFlag = false;
return true;
}
}
if (monthFlag) {
TCComponentFolder createMonthFolder = folderType.create(folderName[1], "", "Folder");
selectYearFolder.add("contents", createMonthFolder);
originFolder.refresh();
System.out.println("不存在月份文件夹,已经创建");
}
yearFlag = false;
return true;
}
}
if (yearFlag) {
TCComponentFolder createMonthFolder = folderType.create(folderName[1], "", "Folder");
TCComponentFolder createYearFolder = folderType.create(folderName[0], "", "Folder");
createYearFolder.add("contents", createMonthFolder);
selectCustomerFolder.add("contents", createYearFolder);
targetFolder = createMonthFolder;
originFolder.refresh();
System.out.println("不存在年份文件夹,已经创建");
}
customerFlag = false;
return true;
}
}
if (customerFlag) {
// 开始新建
System.out.println("111");
TCComponentFolder createMonthFolder = folderType.create(folderName[1], "", "Folder");
TCComponentFolder createYearFolder = folderType.create(folderName[0], "", "Folder");
createYearFolder.add("contents", createMonthFolder);
TCComponentFolder createCustomerFolder = folderType.create(customerName, "", "Folder");
createCustomerFolder.add("contents", createYearFolder);
System.out.println("222 = " + originFolder.toString());
originFolder.add("contents", createCustomerFolder);
targetFolder = createMonthFolder;
originFolder.refresh();
System.out.println("不存在客户文件夹,已经创建");
return true;
}
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("创建文件夹错误");
e.printStackTrace();
}
return false;
}
}

@ -1,23 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createQuotationProject;
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 CreateQuotationProjectHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateQuotationProjectAction action = new CreateQuotationProjectAction(application, null, null);
new Thread(action).start();
return null;
}
}

@ -1,12 +0,0 @@
quotationProjectsDialog.0=Create Quotation Projects
quotationProjectsDialog.1=Project name
quotationProjectsDialog.2=Quotation drawing number
quotationProjectsDialog.3=Annual demand
quotationProjectsDialog.4=Target price
quotationProjectsDialog.5=Customer expects quotation completion date
quotationProjectsDialog.6=Customer name
quotationProjectsDialog.7=Whether surveying product
quotationProjectsDialog.8=Salesperson
quotationProjectsDialog.9=Emergency status
quotationProjectsDialog.10=Technical requirements
quotationProjectsDialog.11=Remarks

@ -1,193 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import org.jdesktop.swingx.JXDatePicker;
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.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import com.teamcenter.rac.util.PropertyLayout;
import com.teamcenter.rac.util.UIUtilities;
public class CreateTechnicalDialog extends JFrame implements Runnable {
private AbstractAIFApplication application;
private JFrame frame;
private JLabel nameLable;
private JTextField nameField;
private JButton okButton;
private JButton celButton;
private TCSession tcSession;
private TCComponentItemRevision targetRev;
private TCComponentItemType technicalType;
private final String TECHINICAL_TYPE = "VF5jsbjd";
public CreateTechnicalDialog(AbstractAIFApplication app) {
this.application = app;
this.tcSession = (TCSession) this.application.getSession();
}
@Override
public void run() {
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
new String[] { "VF5bjxmRevision" }, "ItemRevision");
if (judgeSingleSelectComponent) {
initUi();
}
}
/**
*
*/
private void initUi() {
try {
frame = new JFrame("创建技术报价单");
frame.setSize(500, 300);
setPanelProperties();
JScrollPane centerPanel = getTopPanel();
JPanel bottomPanel = getButtomPanel();
frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setVisible(true);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
}
}
/**
*
*/
private void setPanelProperties() {
nameLable = new JLabel("Technical quotation name");
nameField = new JTextField(14);
okButton = new JButton("Confirm");
celButton = new JButton("Cancel");
}
private JScrollPane getTopPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints g = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
g.insets = new Insets(5, 30, 5, 5);// 边距
g.gridx = 0;
g.weightx = 0;
g.anchor = GridBagConstraints.LINE_START;
nameLable.setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(nameLable, g);
g.insets = new Insets(5, 3, 5, 30);// 边距
g.gridx = 1;
g.weightx = 1;
g.fill = GridBagConstraints.HORIZONTAL;
nameField.setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(nameField, g);
// 创建具有滚动功能的JPanel
return new JScrollPane(centerPanel);
}
private JPanel getButtomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
// 添加监听
okButton.addActionListener(e -> {
Boolean flag = create(nameField.getText());
if (flag) {
MessageBox.post("Successfully created technical quotation !", "Success", MessageBox.INFORMATION);
frame.dispose(); // 关闭窗口
} else {
frame.dispose(); // 关闭窗口
}
});
celButton.addActionListener(e -> {
frame.dispose(); // 关闭窗口
});
return bottomPanel;
}
public Boolean create(String name) {
Boolean flag = true;
targetRev = (TCComponentItemRevision) application.getTargetContext().getComponent();
try {
technicalType = (TCComponentItemType) tcSession.getTypeComponent(TECHINICAL_TYPE);
String newID = technicalType.getNewID();
TCComponentItem technicalItem = technicalType.create(newID, null, TECHINICAL_TYPE, name, "", null);
// 获取目标对象下VF5xjxxdgx关系的询价信息单对象
TCComponent[] targetRevItem = targetRev.getTCProperty("VF5xjxxdgx").getReferenceValueArray();
if (targetRevItem.length < 1) {
throw new IndexOutOfBoundsException("VF5xjxxdgx 关系下没有对象");
}
TCComponentItemRevision xjxxdItemRev = ((TCComponentItem) targetRevItem[0]).getLatestItemRevision();
TCComponent[] xjxxdItemRevMaster = xjxxdItemRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
TCComponentItemRevision technicalItemRevision = technicalItem.getLatestItemRevision();
TCComponent[] techItemRevisionMaster = technicalItemRevision.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
techItemRevisionMaster[0].setProperty("vf5bjtzth", xjxxdItemRevMaster[0].getStringProperty("vf5bjtzth"));
techItemRevisionMaster[0].setProperty("vf5khmc", xjxxdItemRevMaster[0].getStringProperty("vf5khmc"));
// 挂载在报价项目对象版本的报价图纸关系vf5bjtzgx关系下
targetRev.add("VF5jsbjdgx", technicalItem);
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("Failed to create object type !");
e.printStackTrace();
flag = false;
} catch (IndexOutOfBoundsException e) {
MessageBox.post("There are no objects in the current version relationship", "Warning", MessageBox.WARNING);
// TODO Auto-generated catch block
e.printStackTrace();
flag = false;
}
return flag;
}
}

@ -1,23 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.createTechnicalQuotation;
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 CreateTechnicalHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateTechnicalDialog createTechnicalDialog = new CreateTechnicalDialog(application);
new Thread(createTechnicalDialog).start();
return null;
}
}

@ -1,182 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate;
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 javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.apache.commons.lang.StringUtils;
import com.connor.ferrorTech.metal.util.TcUtil;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentItem;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCComponentItemType;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
public class CreateExternalQuotationDialog extends JFrame implements Runnable {
/**
*
*/
private static final long serialVersionUID = 1L;
private AbstractAIFApplication application;
private TCSession tcSession;
private JFrame frame;
private JLabel nameLable;
private JTextField nameField;
private JButton okButton;
private JButton celButton;
private TCComponentItemRevision targetRev;
private TCComponentItemType technicalType;
private final String TECHINICAL_TYPE = "VF5xsbjd";
public CreateExternalQuotationDialog(AbstractAIFApplication application) {
this.application = application;
this.tcSession = (TCSession) this.application.getSession();
}
@Override
public void run() {
boolean judgeSingleSelectComponent = TcUtil.judgeSingleSelectComponent(application,
new String[] { "VF5bjxmRevision" }, "ItemRevision");
if (judgeSingleSelectComponent) {
initUi();
}
}
/**
*
*/
private void initUi() {
try {
frame = new JFrame("Create sales quotation");
frame.setSize(500, 300);
// 初始化所有信息
setPanelProperties();
// 添加内容到JFrame 并设置它的位置
JScrollPane centerPanel = getTopPanel();
JPanel bottomPanel = getButtomPanel();
frame.getContentPane().add(centerPanel, BorderLayout.CENTER);
frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
// 设置窗口居中
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
// 设置可见性
frame.setVisible(true);
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
MessageBox.post("InitUi Error!!", "error", MessageBox.ERROR);
}
}
/**
*
*/
private void setPanelProperties() {
nameLable = new JLabel("Sales quotation name");
nameField = new JTextField(14);
okButton = new JButton("Confirm");
celButton = new JButton("Cancel");
}
private JScrollPane getTopPanel() {
// TODO Auto-generated method stub
JPanel centerPanel = new JPanel(new GridBagLayout());
GridBagConstraints g = new GridBagConstraints();
// 将每个JLabel和JTextField添加到formPanel
g.insets = new Insets(5, 40, 5, 5);// 边距
g.gridx = 0;
g.weightx = 0;
g.anchor = GridBagConstraints.LINE_START;
nameLable.setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(nameLable, g);
g.insets = new Insets(5, 3, 5, 40);// 边距
g.gridx = 1;
g.weightx = 1;
g.fill = GridBagConstraints.HORIZONTAL;
nameField.setFont(new Font("微软雅黑", Font.BOLD, 15));
centerPanel.add(nameField, g);
// 创建具有滚动功能的JPanel
return new JScrollPane(centerPanel);
}
private JPanel getButtomPanel() {
// TODO Auto-generated method stub
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
bottomPanel.add(this.okButton);
bottomPanel.add(this.celButton);
// 添加监听
okButton.addActionListener(e -> {
Boolean flag = create(nameField.getText());
if (flag) {
MessageBox.post("Successfully created external quotation !", "Success", MessageBox.INFORMATION);
frame.dispose(); // 关闭窗口
} else {
frame.dispose(); // 关闭窗口
}
});
celButton.addActionListener(e -> {
frame.dispose(); // 关闭窗口
});
return bottomPanel;
}
public Boolean create(String name) {
Boolean flag = true;
if (StringUtils.isEmpty(name)) {
name = "Sale quotation";
}
targetRev = (TCComponentItemRevision) application.getTargetContext().getComponent();
try {
technicalType = (TCComponentItemType) tcSession.getTypeComponent(TECHINICAL_TYPE);
String newID = technicalType.getNewID();
TCComponentItem technicalItem = technicalType.create(newID, null, TECHINICAL_TYPE, name, "", null);
// 获取目标对象下VF5xjxxdgx关系的询价信息单对象
TCComponent[] targetRevItem = targetRev.getTCProperty("VF5xjxxdgx").getReferenceValueArray();
TCComponentItemRevision xjxxdItemRev = ((TCComponentItem) targetRevItem[0]).getLatestItemRevision();
TCComponent[] xjxxdItemRevMaster = xjxxdItemRev.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
TCComponentItemRevision technicalItemRevision = technicalItem.getLatestItemRevision();
TCComponent[] techItemRevisionMaster = technicalItemRevision.getTCProperty("IMAN_master_form_rev")
.getReferenceValueArray();
techItemRevisionMaster[0].setProperty("vf5bjtzth", xjxxdItemRevMaster[0].getStringProperty("vf5bjtzth"));
techItemRevisionMaster[0].setProperty("vf5khmc", xjxxdItemRevMaster[0].getStringProperty("vf5khmc"));
// 挂载在报价项目对象版本的报价图纸关系vf5bjtzgx关系下
targetRev.add("VF5xsbjdgx", technicalItem);
} catch (TCException e) {
// TODO Auto-generated catch block
System.out.println("Failed to create object type !");
e.printStackTrace();
flag = false;
}
return flag;
}
}

@ -1,23 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.externalQuotationCreate;
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 CreateExternalQuotationHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
CreateExternalQuotationDialog action = new CreateExternalQuotationDialog(application);
new Thread(action).start();
return null;
}
}

@ -1,408 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings;
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.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
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.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 UploadDialog extends AbstractAIFDialog{
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 defaultType;
// private Map<String,TCComponentDataset> parentMap;
// private Map<String,Map<String,TCComponentDataset>> childMap;
public UploadDialog(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() {
// TODO Auto-generated method stub
InterfaceAIFComponent selectComponent = application.getTargetContext().getComponent();
if (selectComponent != null && selectComponent instanceof TCComponentItemRevision) {
targetRev = (TCComponentItemRevision) selectComponent;
String type ="";
try {
type = targetRev.getStringProperty("object_type");
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("The selected object version type is " + type);
if (type.equals("VF5bjtzRevision")) {
// 初始化界面
initUi();
} else {
MessageBox.post("Please select the correct version again !", "error", MessageBox.ERROR);
}
} else {
MessageBox.post("Please select a Revision Item !", "error", MessageBox.ERROR);
}
}
/**
*
*/
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!=null && !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");
defaultType =(TCComponentDatasetType)tcSession.getTypeComponent("Zip");
} catch (TCException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
this.dispose();
// 处理上传逻辑
uploadDrawings(targetRev,file,true);
}
}
});
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) {
try {
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("Delete successfully, start to add data set: "+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);
}
}
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
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!=null && referenceValueArray.length>0) {
for (TCComponent tcDataset : referenceValueArray) {
if(tcDataset instanceof TCComponentDataset) {
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) {
if(tcFolder.getType().equals("Folder") && tcFolder.getStringProperty("object_name").equals(fileName)) {
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){
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();
try {
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;
}
default :{
tempData = defaultType.create(fileName, "", "Zip");
tempData.setFiles(new String[] {filePath},new String[] {"ZIPFILE"});
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;
}
} catch (TCException e) {
// TODO Auto-generated catch block
e.printStackTrace();
MessageBox.post(e.getMessage(), "error", MessageBox.ERROR);
}
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;
}
}

@ -1,23 +0,0 @@
package com.connor.ferrorTech.metal.quotationManagement.uploadQuotationDrawings;
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 UploadHandler extends AbstractHandler {
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
AbstractAIFApplication application = AIFUtility.getCurrentApplication();
UploadDialog action = new UploadDialog(application);
new Thread(action).start();
return null;
}
}

@ -419,14 +419,14 @@ public class MethodUtil {
TCUserService userservice = session.getUserService(); TCUserService userservice = session.getUserService();
Object[] obj = new Object[1]; Object[] obj = new Object[1];
obj[0] = "origin"; obj[0] = "origin";
userservice.call("Supor_open_bypass", obj); userservice.call("Connor_open_bypass", obj);
} }
public static void closeByPass(TCSession session) throws TCException { public static void closeByPass(TCSession session) throws TCException {
TCUserService userservice = session.getUserService(); TCUserService userservice = session.getUserService();
Object[] obj = new Object[1]; Object[] obj = new Object[1];
obj[0] = "origin"; obj[0] = "origin";
userservice.call("Supor_close_bypass", obj); userservice.call("Connor_close_bypass", obj);
} }
public static void setProperty(TCSession session,TCComponent[] items,String propname,String propvalue) throws TCException { public static void setProperty(TCSession session,TCComponent[] items,String propname,String propvalue) throws TCException {
TCUserService userservice = session.getUserService(); TCUserService userservice = session.getUserService();

Loading…
Cancel
Save