commit 2382ee84f1ffb84577e022f82bd2ee374cc76df9 Author: xiongcz Date: Mon Jun 9 10:59:29 2025 +0800 commit diff --git a/com.connor.ml.tcm/.classpath b/com.connor.ml.tcm/.classpath new file mode 100644 index 0000000..4d34011 --- /dev/null +++ b/com.connor.ml.tcm/.classpath @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.connor.ml.tcm/.idea/.gitignore b/com.connor.ml.tcm/.idea/.gitignore new file mode 100644 index 0000000..463c03e --- /dev/null +++ b/com.connor.ml.tcm/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/com.connor.ml.tcm/.idea/git_toolbox_blame.xml b/com.connor.ml.tcm/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/com.connor.ml.tcm/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/com.connor.ml.tcm/.idea/misc.xml b/com.connor.ml.tcm/.idea/misc.xml new file mode 100644 index 0000000..385999e --- /dev/null +++ b/com.connor.ml.tcm/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/com.connor.ml.tcm/.idea/vcs.xml b/com.connor.ml.tcm/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/com.connor.ml.tcm/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/com.connor.ml.tcm/.project b/com.connor.ml.tcm/.project new file mode 100644 index 0000000..409f788 --- /dev/null +++ b/com.connor.ml.tcm/.project @@ -0,0 +1,29 @@ + + + com.connor.ml.tcm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jem.workbench.JavaEMFNature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/com.connor.ml.tcm/.settings/org.eclipse.jdt.core.prefs b/com.connor.ml.tcm/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9f6ece8 --- /dev/null +++ b/com.connor.ml.tcm/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/com.connor.ml.tcm/META-INF/MANIFEST.MF b/com.connor.ml.tcm/META-INF/MANIFEST.MF new file mode 100644 index 0000000..a3d39d4 --- /dev/null +++ b/com.connor.ml.tcm/META-INF/MANIFEST.MF @@ -0,0 +1,1973 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: MlTCM +Bundle-SymbolicName: com.connor.ml.tcm;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Activator: com.connor.ml.tcm.Activator +Bundle-Vendor: CONNOR +Require-Bundle: org.eclipse.ui.forms;bundle-version="3.7.400", + org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.aifrcp;bundle-version="13000.1.0", + com.teamcenter.rac.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.external;bundle-version="13000.1.0", + com.teamcenter.rac.tcapps;bundle-version="13000.1.0", + com.teamcenter.rac.util;bundle-version="13000.1.0", + com.teamcenter.rac.common;bundle-version="13000.1.0", + com.teamcenter.rac.ui;bundle-version="13000.1.0", + com.teamcenter.rac.viewer;bundle-version="13000.1.0", + com.teamcenter.rac.pca;bundle-version="13000.0.0", + com.teamcenter.rac.pca.kernel;bundle-version="13000.0.0", + com.teamcenter.rac.pse;bundle-version="13000.1.0", + TcSoaCoreTypes;bundle-version="13000.1.0", + TcSoaCoreRac;bundle-version="13000.1.0", + TcSoaCommon;bundle-version="13000.1.0", + TcSoaCadRac;bundle-version="13000.1.0", + com.teamcenter.rac.cme.framework;bundle-version="13000.1.0", + com.teamcenter.rac.cme.kernel;bundle-version="13000.1.0", + com.teamcenter.rac.ms.util;bundle-version="13000.1.0", + com.teamcenter.rac.cme.bvr.connect;bundle-version="13000.1.0", + com.teamcenter.rac.ui.commands;bundle-version="13000.1.0", + com.teamcenter.rac.cme.license;bundle-version="13000.1.0", + TcSoaStructureManagementRac;bundle-version="13000.1.0", + com.teamcenter.rac.classification.icm;bundle-version="13000.1.0", + TcSoaWorkflowRac;bundle-version="13000.1.0", + TcSoaManufacturingRac;bundle-version="13000.1.0", + com.teamcenter.rac.schedule;bundle-version="13000.1.0", + CAE0SoaSimProcRac;bundle-version="13000.1.0", + Cfg0SoaConfiguratorLoose;bundle-version="13000.0.0", + Ex2SoaExpressAddonsRac;bundle-version="13000.1.0", + Fnd0SoaAuditManagerRac;bundle-version="13000.1.0", + Fnd0SoaConfigFilterCriteriaLoose;bundle-version="13000.1.0", + Fnd0SoaConfigFilterCriteriaRac;bundle-version="13000.1.0", + Fnd0SoaDebugMonitorLoose;bundle-version="13000.1.0", + Fnd0SoaDebugMonitorRac;bundle-version="13000.1.0", + Fnd0SoaDiagrammingRac;bundle-version="13000.1.0", + Fnd0SoaEditContextLoose;bundle-version="13000.1.0", + Fnd0SoaNotificationRac;bundle-version="13000.1.0", + Fnd0SoaQualificationRac;bundle-version="13000.1.0", + Fnd0SoaWProxyRac;bundle-version="13000.1.0", + FoundationViewer;bundle-version="1.0.0", + JGoodies;bundle-version="2.6.1", + Lis0SoaLdfRac;bundle-version="13000.1.0", + PDFJS;bundle-version="1.0.0", + SingleEmbeddedViewer;bundle-version="13.1.0", + Smc0SoaStructureManagementLoose;bundle-version="13000.0.0", + TCImportHistoryDatas;bundle-version="1.0.0", + TcGlobalMultiSiteRac;bundle-version="13000.1.0", + TcSoaAdministrationLoose;bundle-version="13000.1.0", + TcSoaAdministrationRac;bundle-version="13000.1.0", + TcSoaAiRac;bundle-version="13000.1.0", + TcSoaAllocationsRac;bundle-version="13000.1.0", + TcSoaAuthorizedDataAccessRac;bundle-version="13000.1.0", + TcSoaBomLoose;bundle-version="13000.1.0", + TcSoaBomRac;bundle-version="13000.1.0", + TcSoaBusinessModelerLoose;bundle-version="13000.1.0", + TcSoaBusinessModelerRac;bundle-version="13000.1.0", + TcSoaCadBomAlignmentLoose;bundle-version="13000.1.0", + TcSoaCaeRac;bundle-version="13000.1.0", + TcSoaCalendarManagementRac;bundle-version="13000.1.0", + TcSoaChangeManagementRac;bundle-version="13000.1.0", + TcSoaClassificationLoose;bundle-version="13000.1.0", + TcSoaClassificationRac;bundle-version="13000.1.0", + TcSoaConfigurationRac;bundle-version="13000.1.0", + TcSoaCoreLoose;bundle-version="13000.1.0", + TcSoaDocumentManagementRac;bundle-version="13000.1.0", + TcSoaGdisRac;bundle-version="13000.1.0", + TcSoaGlobalMultiSiteLoose;bundle-version="13000.1.0", + TcSoaGlobalMultiSiteRac;bundle-version="13000.1.0", + TcSoaImportExportRac;bundle-version="13000.1.0", + TcSoaIssueManagementRac;bundle-version="13000.1.0", + TcSoaMESRac;bundle-version="13000.1.0", + TcSoaMultisiteRac;bundle-version="13000.1.0", + TcSoaProductionManagementRac;bundle-version="13000.1.0", + TcSoaProjectManagementLoose;bundle-version="13000.1.0", + TcSoaProjectManagementRac;bundle-version="13000.1.0", + TcSoaProjectManagementTypes;bundle-version="13000.1.0", + TcSoaQueryLoose;bundle-version="13000.1.0", + TcSoaQueryRac;bundle-version="13000.1.0", + TcSoaRdvRac;bundle-version="13000.1.0", + TcSoaReportsRac;bundle-version="13000.1.0", + TcSoaRequirementsManagementRac;bundle-version="13000.1.0", + TcSoaStructureManagementLoose;bundle-version="13000.1.0", + TcSoaTranslationRac;bundle-version="13000.1.0", + TcSoaValidationRac;bundle-version="13000.1.0", + TcSoaVisualizationRac;bundle-version="13000.1.0", + TcSoaWorkflowLoose;bundle-version="13000.1.0", + antlr_340;bundle-version="3.4.0", + applauncher;bundle-version="13000.1.0", + ca.odell.glazedlists;bundle-version="1.8.0", + cn.com.connor.bh.plm;bundle-version="1.0.0", + cn.com.ebewin.ysr;bundle-version="1.0.0", + cn.com.origin.autocode;bundle-version="1.0.0", + cn.net.connor.std.aifrcp;bundle-version="13000.1.0", + cn.net.connor.std.fx;bundle-version="13000.1.0", + cn.net.connor.std.gdtex;bundle-version="13000.1.0", + com.connor.bhdz.derive;bundle-version="1.0.0", + com.connor.bhdz.stoCapp;bundle-version="1.0.0", + com.connor.jd;bundle-version="1.0.0", + com.connor.jd.plm;bundle-version="1.0.0", + com.connor.ldy;bundle-version="1.0.0", + com.connor.lp.sheet;bundle-version="1.0.0", + com.connor.ly.plm;bundle-version="1.0.0", + com.connor.rb.plm;bundle-version="1.0.0", + com.connor.sbplm.plm1;bundle-version="1.0.0", + com.google.gson;bundle-version="2.8.5", + com.ibm.icu;bundle-version="63.1.0", + com.jcraft.jsch;bundle-version="0.1.54", + com.siemens.softwareanalytics;bundle-version="2.7.0", + com.siemens.splm.browserinterop.infrastructure;bundle-version="4.3.0", + com.siemens.splm.browserinterop.solutions;bundle-version="4.3.0", + com.sun.el;bundle-version="2.2.0", + com.teamcenter.SecurityServices;bundle-version="13000.1.0", + com.teamcenter.bce.core;bundle-version="13000.1.0", + com.teamcenter.bce.dialog;bundle-version="13000.1.0", + com.teamcenter.bce.editor;bundle-version="13000.1.0", + com.teamcenter.bce.model;bundle-version="13000.1.0", + com.teamcenter.rac.accessmanager;bundle-version="13000.1.0", + com.teamcenter.rac.activex;bundle-version="13000.1.0", + com.teamcenter.rac.activity;bundle-version="13000.1.0", + com.teamcenter.rac.adalicense;bundle-version="13000.1.0", + com.teamcenter.rac.aif.registryeditor;bundle-version="13000.1.0", + com.teamcenter.rac.appearanceconfiguration;bundle-version="13000.1.0", + com.teamcenter.rac.applications.integration;bundle-version="13000.1.0", + com.teamcenter.rac.aps0apscore.kernel;bundle-version="13000.0.0", + com.teamcenter.rac.architecturemodeler;bundle-version="13000.1.0", + com.teamcenter.rac.auditmanager;bundle-version="13000.1.0", + com.teamcenter.rac.authorization;bundle-version="13000.1.0", + com.teamcenter.rac.awchostinterop;bundle-version="13000.1.0", + com.teamcenter.rac.barchart;bundle-version="13000.1.0", + com.teamcenter.rac.basedon;bundle-version="13000.1.0", + com.teamcenter.rac.bczownershipxferview;bundle-version="13000.1.0", + com.teamcenter.rac.bom;bundle-version="13000.1.0", + com.teamcenter.rac.briefcasebrowser;bundle-version="13000.1.0", + com.teamcenter.rac.cae.ase;bundle-version="13000.1.0", + com.teamcenter.rac.caese;bundle-version="13000.1.0", + com.teamcenter.rac.charts;bundle-version="13000.1.0", + com.teamcenter.rac.classification.icadmin;bundle-version="13000.1.0", + com.teamcenter.rac.cm;bundle-version="13000.1.0", + com.teamcenter.rac.cme.accountabilitycheck;bundle-version="13000.1.0", + com.teamcenter.rac.cme.accountabilitycheck.bom;bundle-version="13000.1.0", + com.teamcenter.rac.cme.accountabilitycheck.properties;bundle-version="13000.1.0", + com.teamcenter.rac.cme.accountabilitycheck.relations;bundle-version="13000.1.0", + com.teamcenter.rac.cme.activity;bundle-version="13000.1.0", + com.teamcenter.rac.cme.assemblyincontext;bundle-version="13000.1.0", + com.teamcenter.rac.cme.biw.module;bundle-version="13000.1.0", + com.teamcenter.rac.cme.ccadmin;bundle-version="13000.1.0", + com.teamcenter.rac.cme.changetracker;bundle-version="13000.1.0", + com.teamcenter.rac.cme.closureruleeditor;bundle-version="13000.1.0", + com.teamcenter.rac.cme.cmereport;bundle-version="13000.1.0", + com.teamcenter.rac.cme.collaborationcontext;bundle-version="13000.1.0", + com.teamcenter.rac.cme.common;bundle-version="13000.1.0", + com.teamcenter.rac.cme.designpartalignment;bundle-version="13000.1.0", + com.teamcenter.rac.cme.ebop.module;bundle-version="13000.1.0", + com.teamcenter.rac.cme.exeposition;bundle-version="13000.1.0", + com.teamcenter.rac.cme.fse;bundle-version="13000.1.0", + com.teamcenter.rac.cme.futurerevisions;bundle-version="13000.1.0", + com.teamcenter.rac.cme.graphics;bundle-version="13000.1.0", + com.teamcenter.rac.cme.idc;bundle-version="13000.1.0", + com.teamcenter.rac.cme.ipa;bundle-version="13000.1.0", + com.teamcenter.rac.cme.lb;bundle-version="13000.1.0", + com.teamcenter.rac.cme.legacy;bundle-version="13000.1.0", + com.teamcenter.rac.cme.mbm;bundle-version="13000.1.0", + com.teamcenter.rac.cme.mbomassessmentrepair;bundle-version="13000.1.0", + com.teamcenter.rac.cme.mbomrecipe;bundle-version="13000.1.0", + com.teamcenter.rac.cme.mcnmanagement;bundle-version="13000.1.0", + com.teamcenter.rac.cme.mpp;bundle-version="13000.1.0", + com.teamcenter.rac.cme.mrm;bundle-version="13000.1.0", + com.teamcenter.rac.cme.pad;bundle-version="13000.1.0", + com.teamcenter.rac.cme.pmp;bundle-version="13000.1.0", + com.teamcenter.rac.cme.processsimulate;bundle-version="13000.1.0", + com.teamcenter.rac.cme.resource;bundle-version="13000.1.0", + com.teamcenter.rac.cme.reusesubassembly;bundle-version="13000.1.0", + com.teamcenter.rac.cme.sequence;bundle-version="13000.1.0", + com.teamcenter.rac.cme.study;bundle-version="13000.1.0", + com.teamcenter.rac.cme.stylesheet;bundle-version="13000.1.0", + com.teamcenter.rac.cme.tcpublishwrapper;bundle-version="13000.1.0", + com.teamcenter.rac.cme.time;bundle-version="13000.1.0", + com.teamcenter.rac.cme.twod;bundle-version="13000.1.0", + com.teamcenter.rac.cme.twp;bundle-version="13000.1.0", + com.teamcenter.rac.cme.variants;bundle-version="13000.1.0", + com.teamcenter.rac.commands.report.reportdesigner;bundle-version="13000.1.0", + com.teamcenter.rac.commandsuppression;bundle-version="13000.1.0", + com.teamcenter.rac.common.win32.x86_64;bundle-version="13000.1.0", + com.teamcenter.rac.commonclient;bundle-version="13000.1.0", + com.teamcenter.rac.contextmenusuppression;bundle-version="13000.1.0", + com.teamcenter.rac.crf;bundle-version="13000.1.0", + com.teamcenter.rac.databaseutilities;bundle-version="13000.1.0", + com.teamcenter.rac.datadic;bundle-version="13000.1.0", + com.teamcenter.rac.debug;bundle-version="13000.1.0", + com.teamcenter.rac.designcontext;bundle-version="13000.1.0", + com.teamcenter.rac.diagramming.communication;bundle-version="13000.1.0", + com.teamcenter.rac.diagramming.dtoolext;bundle-version="13000.1.0", + com.teamcenter.rac.diagrammingtools;bundle-version="13000.1.0", + com.teamcenter.rac.dpv;bundle-version="13000.1.0", + com.teamcenter.rac.ecmanagement;bundle-version="13000.1.0", + com.teamcenter.rac.editcontext;bundle-version="13000.1.0", + com.teamcenter.rac.effectivity;bundle-version="13000.0.0", + com.teamcenter.rac.emailpolling;bundle-version="13000.1.0", + com.teamcenter.rac.ets;bundle-version="13000.1.0", + com.teamcenter.rac.express;bundle-version="13000.1.0", + com.teamcenter.rac.gantt;bundle-version="13000.1.0", + com.teamcenter.rac.gdis;bundle-version="13000.1.0", + com.teamcenter.rac.geolus.extract;bundle-version="13000.1.0", + com.teamcenter.rac.geolus.results;bundle-version="13000.1.0", + com.teamcenter.rac.geolus.search;bundle-version="13000.1.0", + com.teamcenter.rac.grb;bundle-version="13000.1.0", + com.teamcenter.rac.gsClient;bundle-version="13000.0.0", + com.teamcenter.rac.gsLogin;bundle-version="13000.0.0", + com.teamcenter.rac.idc;bundle-version="13000.1.0", + com.teamcenter.rac.issuemanager;bundle-version="13000.1.0", + com.teamcenter.rac.massupdate;bundle-version="13000.1.0", + com.teamcenter.rac.ms.ui;bundle-version="13000.1.0", + com.teamcenter.rac.multistructures;bundle-version="13000.1.0", + com.teamcenter.rac.neva;bundle-version="2.0.0", + com.teamcenter.rac.ocspresence;bundle-version="13000.1.0", + com.teamcenter.rac.officeapplauncher;bundle-version="13000.1.0", + com.teamcenter.rac.operationaldata;bundle-version="13000.1.0", + com.teamcenter.rac.operationaldata.docmgt;bundle-version="13000.1.0", + com.teamcenter.rac.operationaldata.edaserver;bundle-version="13000.1.0", + com.teamcenter.rac.operationaldata.options;bundle-version="13000.1.0", + com.teamcenter.rac.organization;bundle-version="13000.1.0", + com.teamcenter.rac.padpdf;bundle-version="13000.1.0", + com.teamcenter.rac.plmxmlexportimportadministration;bundle-version="13000.1.0", + com.teamcenter.rac.por;bundle-version="13000.1.0", + com.teamcenter.rac.presentation;bundle-version="13000.1.0", + com.teamcenter.rac.processhistory;bundle-version="13000.1.0", + com.teamcenter.rac.project;bundle-version="13000.1.0", + com.teamcenter.rac.pse.pca;bundle-version="13000.0.0", + com.teamcenter.rac.qualifications;bundle-version="13000.1.0", + com.teamcenter.rac.querybuilder;bundle-version="13000.1.0", + com.teamcenter.rac.requirementsmanager;bundle-version="13000.1.0", + com.teamcenter.rac.requirementsmanager.win.embeddedword;bundle-version="13000.1.0", + com.teamcenter.rac.rmoffice;bundle-version="13000.1.0", + com.teamcenter.rac.se.core;bundle-version="13000.1.0", + com.teamcenter.rac.search;bundle-version="13000.1.0", + com.teamcenter.rac.setupwizard;bundle-version="13000.1.0", + com.teamcenter.rac.siemens.theme;bundle-version="13000.1.0", + com.teamcenter.rac.smartnavigator;bundle-version="13000.1.0", + com.teamcenter.rac.smb;bundle-version="13000.1.0", + com.teamcenter.rac.softwareanalytics;bundle-version="13000.1.0", + com.teamcenter.rac.structure.search;bundle-version="13000.1.0", + com.teamcenter.rac.subscriptionmanager;bundle-version="13000.1.0", + com.teamcenter.rac.subscriptionmonitor;bundle-version="13000.1.0", + com.teamcenter.rac.substitutegroup;bundle-version="13000.1.0", + com.teamcenter.rac.tcgrb;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.accountabilitycheck;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.analysis;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.common;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.composite;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.dashboard;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.derivativerules;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.desktopsupport;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.inspector;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.model;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.packages;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.product;bundle-version="13000.1.0", + com.teamcenter.rac.tcsim.toolmanagement;bundle-version="13000.1.0", + com.teamcenter.rac.tctdv;bundle-version="13000.1.0", + com.teamcenter.rac.tdv;bundle-version="13000.1.0", + com.teamcenter.rac.toolbar.customization;bundle-version="13000.1.0", + com.teamcenter.rac.tracelinks.ui;bundle-version="13000.1.0", + com.teamcenter.rac.ui.advanced;bundle-version="13000.1.0", + com.teamcenter.rac.ui.gridframework;bundle-version="13000.1.0", + com.teamcenter.rac.ui.gridframework.extension.nebula;bundle-version="13000.1.0", + com.teamcenter.rac.ui.views;bundle-version="13000.1.0", + com.teamcenter.rac.validation;bundle-version="13000.1.0", + com.teamcenter.rac.vis;bundle-version="13000.1.0", + com.teamcenter.rac.vis.api;bundle-version="13000.1.0", + com.teamcenter.rac.vis.mv;bundle-version="13000.1.0", + com.teamcenter.rac.vm;bundle-version="13000.1.0", + com.teamcenter.rac.vns;bundle-version="13000.1.0", + com.teamcenter.rac.widgets;bundle-version="13000.1.0", + com.teamcenter.rac.workflow;bundle-version="13000.1.0", + com.teamcenter.rac.workflow.processdesigner;bundle-version="13000.1.0", + com.teamcenter.rac.workflow.processviewer;bundle-version="13000.1.0", + com.teamcenter.siemens.lookandfeel;bundle-version="13000.1.0", + commons_xmlschema;bundle-version="1.3.2", + httpclient;bundle-version="4.5.10", + javax.annotation;bundle-version="1.2.0", + javax.el;bundle-version="2.2.0", + javax.servlet;bundle-version="3.1.0", + javax.servlet.jsp;bundle-version="2.2.0", + javax.wsdl;bundle-version="1.6.2", + javax.xml.rpc;bundle-version="1.1.0", + javax.xml.soap;bundle-version="1.2.0", + jfreechart;bundle-version="1.0.4", + k.util;bundle-version="1.0.0", + org.apache.ant;bundle-version="1.10.5", + org.apache.batik.constants;bundle-version="1.10.0", + org.apache.batik.css;bundle-version="1.10.0", + org.apache.batik.i18n;bundle-version="1.10.0", + org.apache.batik.util;bundle-version="1.10.0", + org.apache.commons.codec;bundle-version="1.10.0", + org.apache.commons.io;bundle-version="2.2.0", + org.apache.commons.jxpath;bundle-version="1.3.0", + org.apache.commons.lang;bundle-version="2.3.0", + org.apache.commons.logging;bundle-version="1.2.0", + org.apache.felix.gogo.command;bundle-version="1.0.2", + org.apache.felix.gogo.runtime;bundle-version="1.1.0", + org.apache.felix.gogo.shell;bundle-version="1.1.0", + org.apache.felix.scr;bundle-version="2.0.14", + org.apache.fop;bundle-version="2.4.0", + org.apache.jasper.glassfish;bundle-version="2.2.2", + org.apache.lucene.analyzers-common;bundle-version="7.5.0", + org.apache.lucene.analyzers-smartcn;bundle-version="7.5.0", + org.apache.lucene.core;bundle-version="7.5.0", + org.apache.poi;bundle-version="3.6.0", + org.apache.poi.315;bundle-version="3.15.0", + org.apache.poi.39;bundle-version="3.9.0", + org.apache.thrift;bundle-version="0.13.2", + org.apache.xml.serializer;bundle-version="2.7.1", + org.apache.xmlgraphics;bundle-version="2.2.0", + org.aspectj.runtime;bundle-version="1.8.9", + org.eclipse.ant.core;bundle-version="3.5.200", + org.eclipse.compare;bundle-version="3.7.400", + org.eclipse.compare.core;bundle-version="3.6.300", + org.eclipse.compare.win32;bundle-version="1.2.300", + org.eclipse.core.databinding.beans;bundle-version="1.4.300", + org.eclipse.core.databinding.property;bundle-version="1.6.300", + org.eclipse.core.expressions;bundle-version="3.6.200", + org.eclipse.core.externaltools;bundle-version="1.1.200", + org.eclipse.core.filebuffers;bundle-version="3.6.400", + org.eclipse.core.filesystem;bundle-version="1.7.200", + org.eclipse.core.net;bundle-version="1.3.400", + org.eclipse.core.resources;bundle-version="3.13.200", + org.eclipse.core.variables;bundle-version="3.4.300", + org.eclipse.debug.core;bundle-version="3.13.100", + org.eclipse.draw2d;bundle-version="3.10.100", + org.eclipse.e4.core.commands;bundle-version="0.12.400", + org.eclipse.e4.core.contexts;bundle-version="1.7.100", + org.eclipse.e4.core.di;bundle-version="1.7.100", + org.eclipse.e4.core.di.annotations;bundle-version="1.6.200", + org.eclipse.e4.core.di.extensions;bundle-version="0.15.200", + org.eclipse.e4.core.di.extensions.supplier;bundle-version="0.15.200", + org.eclipse.e4.core.services;bundle-version="2.1.300", + org.eclipse.e4.emf.xpath;bundle-version="0.2.200", + org.eclipse.e4.ui.bindings;bundle-version="0.12.300", + org.eclipse.e4.ui.css.core;bundle-version="0.12.400", + org.eclipse.e4.ui.css.swt;bundle-version="0.13.300", + org.eclipse.e4.ui.css.swt.theme;bundle-version="0.12.100", + org.eclipse.e4.ui.di;bundle-version="1.2.400", + org.eclipse.e4.ui.dialogs;bundle-version="1.1.300", + org.eclipse.e4.ui.model.workbench;bundle-version="2.1.200", + org.eclipse.e4.ui.services;bundle-version="1.3.300", + org.eclipse.e4.ui.widgets;bundle-version="1.2.300", + org.eclipse.e4.ui.workbench.addons.swt;bundle-version="1.3.300", + org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.14.400", + org.eclipse.e4.ui.workbench.swt;bundle-version="0.14.400", + org.eclipse.emf.common;bundle-version="2.15.0", + org.eclipse.emf.ecore;bundle-version="2.16.0", + org.eclipse.emf.ecore.change;bundle-version="2.13.0", + org.eclipse.emf.ecore.xmi;bundle-version="2.15.0", + org.eclipse.equinox.bidi;bundle-version="1.1.200", + org.eclipse.equinox.concurrent;bundle-version="1.1.200", + org.eclipse.equinox.console;bundle-version="1.3.200", + org.eclipse.equinox.event;bundle-version="1.5.0", + org.eclipse.equinox.frameworkadmin;bundle-version="2.1.100", + org.eclipse.equinox.frameworkadmin.equinox;bundle-version="1.1.100", + org.eclipse.equinox.http.jetty;bundle-version="3.6.200", + org.eclipse.equinox.http.registry;bundle-version="1.1.600", + org.eclipse.equinox.http.servlet;bundle-version="1.5.200", + org.eclipse.equinox.jsp.jasper;bundle-version="1.1.100", + org.eclipse.equinox.jsp.jasper.registry;bundle-version="1.1.100", + org.eclipse.equinox.launcher;bundle-version="1.5.200", + org.eclipse.equinox.p2.artifact.repository;bundle-version="1.2.200", + org.eclipse.equinox.p2.core;bundle-version="2.5.100", + org.eclipse.equinox.p2.engine;bundle-version="2.6.100", + org.eclipse.equinox.p2.garbagecollector;bundle-version="1.1.100", + org.eclipse.equinox.p2.jarprocessor;bundle-version="1.1.200", + org.eclipse.equinox.p2.metadata;bundle-version="2.4.200", + org.eclipse.equinox.p2.metadata.repository;bundle-version="1.3.100", + org.eclipse.equinox.p2.publisher;bundle-version="1.5.100", + org.eclipse.equinox.p2.repository;bundle-version="2.4.200", + org.eclipse.equinox.p2.touchpoint.natives;bundle-version="1.3.200", + org.eclipse.equinox.security;bundle-version="1.3.0", + org.eclipse.equinox.security.ui;bundle-version="1.2.200", + org.eclipse.equinox.simpleconfigurator;bundle-version="1.3.200", + org.eclipse.equinox.util;bundle-version="1.1.200", + org.eclipse.gef;bundle-version="3.11.0", + org.eclipse.help;bundle-version="3.8.200", + org.eclipse.help.base;bundle-version="4.2.400", + org.eclipse.help.ui;bundle-version="4.1.300", + org.eclipse.jetty.continuation;bundle-version="9.4.14", + org.eclipse.jetty.http;bundle-version="9.4.14", + org.eclipse.jetty.io;bundle-version="9.4.14", + org.eclipse.jetty.security;bundle-version="9.4.14", + org.eclipse.jetty.server;bundle-version="9.4.14", + org.eclipse.jetty.servlet;bundle-version="9.4.14", + org.eclipse.jetty.util;bundle-version="9.4.14", + org.eclipse.jface.databinding;bundle-version="1.8.400", + org.eclipse.jface.text;bundle-version="3.15.0", + org.eclipse.jsch.core;bundle-version="1.3.300", + org.eclipse.jsch.ui;bundle-version="1.3.300", + org.eclipse.ltk.core.refactoring;bundle-version="3.9.200", + org.eclipse.nebula.cwt;bundle-version="1.1.0", + org.eclipse.nebula.widgets.cdatetime;bundle-version="1.3.0", + org.eclipse.nebula.widgets.gallery;bundle-version="1.0.0", + org.eclipse.nebula.widgets.grid;bundle-version="1.1.0", + org.eclipse.nebula.widgets.nattable.core;bundle-version="1.1.0", + org.eclipse.nebula.widgets.nattable.extension.glazedlists;bundle-version="1.1.0", + org.eclipse.nebula.widgets.nattable.extension.poi;bundle-version="1.1.0", + org.eclipse.nebula.widgets.tablecombo;bundle-version="1.2.0", + org.eclipse.osgi.services;bundle-version="3.7.100", + org.eclipse.osgi.util;bundle-version="3.5.100", + org.eclipse.platform;bundle-version="4.10.0", + org.eclipse.rcp;bundle-version="4.10.0", + org.eclipse.team.genericeditor.diff.extension;bundle-version="1.0.200", + org.eclipse.text;bundle-version="3.8.0", + org.eclipse.ui.console;bundle-version="3.8.300", + org.eclipse.ui.editors;bundle-version="3.11.300" +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: com.connor.ml +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: allib/cglib-3.1.jar, + allib/com.ibm.icu-4.4.2.jar, + allib/commons-collections4-4.1.jar, + allib/commons-math3-3.6.1.jar, + allib/easyexcel-2.1.4.jar, + allib/ehcache-3.7.1.jar, + allib/FastInfoset-1.2.15.jar, + allib/fastjson-1.2.76.jar, + allib/istack-commons-runtime-3.0.7.jar, + allib/javax.activation-api-1.2.0.jar, + allib/jaxb-runtime-2.3.1.jar, + allib/poi-3.17.jar, + allib/poi-examples-3.17.jar, + allib/poi-excelant-3.17.jar, + allib/poi-ooxml-3.17.jar, + allib/poi-ooxml-schemas-3.17.jar, + allib/poi-scratchpad-3.17.jar, + allib/slf4j-api-1.7.26.jar, + allib/stax-api-1.0.1.jar, + allib/stax-ex-1.8.jar, + allib/txw2-2.3.1.jar, + allib/xmlbeans-2.6.0.jar, + axis2_lib/activation-1.1.jar, + axis2_lib/annogen-0.1.0.jar, + axis2_lib/axiom-api-1.2.7.jar, + axis2_lib/axiom-dom-1.2.7.jar, + axis2_lib/axiom-impl-1.2.7.jar, + axis2_lib/axis2-adb-1.4.1.jar, + axis2_lib/axis2-adb-codegen-1.4.1.jar, + axis2_lib/axis2-ant-plugin-1.4.1.jar, + axis2_lib/axis2-clustering-1.4.1.jar, + axis2_lib/axis2-codegen-1.4.1.jar, + axis2_lib/axis2-corba-1.4.1.jar, + axis2_lib/axis2-fastinfoset-1.4.1.jar, + axis2_lib/axis2-java2wsdl-1.4.1.jar, + axis2_lib/axis2-jaxbri-1.4.1.jar, + axis2_lib/axis2-jaxws-1.4.1.jar, + axis2_lib/axis2-jaxws-api-1.4.1.jar, + axis2_lib/axis2-jibx-1.4.1.jar, + axis2_lib/axis2-json-1.4.1.jar, + axis2_lib/axis2-jws-api-1.4.1.jar, + axis2_lib/axis2-kernel-1.4.1.jar, + axis2_lib/axis2-metadata-1.4.1.jar, + axis2_lib/axis2-mtompolicy-1.4.1.jar, + axis2_lib/axis2-saaj-1.4.1.jar, + axis2_lib/axis2-saaj-api-1.4.1.jar, + axis2_lib/axis2-spring-1.4.1.jar, + axis2_lib/axis2-xmlbeans-1.4.1.jar, + lib/Cat2errormessagehandler.jar, + lib/Cat2journaling.jar, + lib/Cat2tciccommon.jar, + lib/classes12.jar, + lib/commons-beanutils-1.7.0.jar, + lib/commons-codec-1.3.jar, + lib/commons-collections-3.2.jar, + lib/commons-httpclient-3.1.jar, + lib/commons-lang-2.4.jar, + lib/commons-logging-1.1.jar, + lib/ezmorph-1.0.4.jar, + lib/httpclient-4.5.10.jar, + lib/httpcore-4.4.12.jar, + lib/httpmime-4.5.10.jar, + lib/itextpdf-5.5.3.jar, + lib/jacob.jar, + lib/jaxrpc.jar, + lib/json-lib-2.2.2-jdk15.jar, + lib/json-lib-2.2.3-jdk13.jar, + lib/json-org.jar, + lib/mailapi.jar, + lib/msbase.jar, + lib/mssqlserver.jar, + lib/msutil.jar, + lib/neethi-3.0.2.jar, + lib/ojdbc5.jar, + lib/saaj.jar, + lib/sapjco3.jar, + lib/sqljdbc4.jar, + lib/swingx-1.6.1.jar, + lib/woden-core-1.0M10.jar, + lib/wsdl4j-1.6.2.jar, + lib/xmlschema-core-2.2.1.jar, + lib/xmlsec.jar, + axis2_lib/backport-util-concurrent-3.1.jar, + ., + lib/Spire.Xls.jar, + lib/gson-2.9.0.jar, + lib/itext-2.0.3.jar, + lib/iText-5.0.2.jar, + lib/iTextAsian.jar, + lib/iTextAsianCmaps.jar +Export-Package: ., + cn.net.connor.ml.plm.exportExcel, + cn.net.connor.ml.plm.sendBomSap, + cn.net.connor.ml.plm.tcm, + com.alibaba.excel, + com.alibaba.excel.analysis, + com.alibaba.excel.analysis.v03, + com.alibaba.excel.analysis.v03.handlers, + com.alibaba.excel.analysis.v07, + com.alibaba.excel.analysis.v07.handlers, + com.alibaba.excel.annotation, + com.alibaba.excel.annotation.format, + com.alibaba.excel.annotation.write.style, + com.alibaba.excel.cache, + com.alibaba.excel.cache.selector, + com.alibaba.excel.constant, + com.alibaba.excel.context, + com.alibaba.excel.converters, + com.alibaba.excel.converters.bigdecimal, + com.alibaba.excel.converters.booleanconverter, + com.alibaba.excel.converters.bytearray, + com.alibaba.excel.converters.byteconverter, + com.alibaba.excel.converters.date, + com.alibaba.excel.converters.doubleconverter, + com.alibaba.excel.converters.file, + com.alibaba.excel.converters.floatconverter, + com.alibaba.excel.converters.inputstream, + com.alibaba.excel.converters.integer, + com.alibaba.excel.converters.longconverter, + com.alibaba.excel.converters.shortconverter, + com.alibaba.excel.converters.string, + com.alibaba.excel.converters.url, + com.alibaba.excel.enums, + com.alibaba.excel.event, + com.alibaba.excel.exception, + com.alibaba.excel.metadata, + com.alibaba.excel.metadata.property, + com.alibaba.excel.parameter, + com.alibaba.excel.read.builder, + com.alibaba.excel.read.listener, + com.alibaba.excel.read.listener.event, + com.alibaba.excel.read.metadata, + com.alibaba.excel.read.metadata.holder, + com.alibaba.excel.read.metadata.property, + com.alibaba.excel.support, + com.alibaba.excel.util, + com.alibaba.excel.write, + com.alibaba.excel.write.builder, + com.alibaba.excel.write.executor, + com.alibaba.excel.write.handler, + com.alibaba.excel.write.merge, + com.alibaba.excel.write.metadata, + com.alibaba.excel.write.metadata.fill, + com.alibaba.excel.write.metadata.holder, + com.alibaba.excel.write.metadata.style, + com.alibaba.excel.write.property, + com.alibaba.excel.write.style, + com.alibaba.excel.write.style.column, + com.alibaba.excel.write.style.row, + com.alibaba.fastjson, + com.alibaba.fastjson.annotation, + com.alibaba.fastjson.asm, + com.alibaba.fastjson.parser, + com.alibaba.fastjson.parser.deserializer, + com.alibaba.fastjson.serializer, + com.alibaba.fastjson.spi, + com.alibaba.fastjson.support.config, + com.alibaba.fastjson.support.geo, + com.alibaba.fastjson.support.hsf, + com.alibaba.fastjson.support.jaxrs, + com.alibaba.fastjson.support.moneta, + com.alibaba.fastjson.support.retrofit, + com.alibaba.fastjson.support.spring, + com.alibaba.fastjson.support.spring.annotation, + com.alibaba.fastjson.support.spring.messaging, + com.alibaba.fastjson.support.springfox, + com.alibaba.fastjson.util, + com.connor.ml.plm.paste.MLOperation, + com.connor.ml.tcm, + com.connor.ml.tcm.AssignItemID, + com.connor.ml.tcm.AssignProductName, + com.connor.ml.tcm.ChangeBomView, + com.connor.ml.tcm.CreateMBOM, + com.connor.ml.tcm.CreateTimeSheet, + com.connor.ml.tcm.ML_01, + com.connor.ml.tcm.ML_02, + com.connor.ml.tcm.ML_03, + com.connor.ml.tcm.ML_04, + com.connor.ml.tcm.ML_05, + com.connor.ml.tcm.ML_06, + com.connor.ml.tcm.ML_07, + com.connor.ml.tcm.ML_08, + com.connor.ml.tcm.ML_08澶囦唤, + com.connor.ml.tcm.ML_09, + com.connor.ml.tcm.ML_10, + com.connor.ml.tcm.ML_11, + com.connor.ml.tcm.ML_12, + com.connor.ml.tcm.ML_13, + com.connor.ml.tcm.ML_14, + com.connor.ml.tcm.ML_15, + com.connor.ml.tcm.ML_16, + com.connor.ml.tcm.ML_17, + com.connor.ml.tcm.ML_18, + com.connor.ml.tcm.ML_19, + com.connor.ml.tcm.ML_20, + com.connor.ml.tcm.ML_21, + com.connor.ml.tcm.ML_22, + com.connor.ml.tcm.OrderBOMTB, + com.connor.ml.tcm.bean, + com.connor.ml.tcm.changeBlocc, + com.connor.ml.tcm.checkMBOM, + com.connor.ml.tcm.cloneProcess, + com.connor.ml.tcm.export_worktime, + com.connor.ml.tcm.knowledgeBase, + com.connor.ml.tcm.ls, + com.connor.ml.tcm.metarialChange, + com.connor.ml.tcm.outfile, + com.connor.ml.tcm.outfile.ML_01, + com.connor.ml.tcm.outfile.ML_02, + com.connor.ml.tcm.outfile.ML_03, + com.connor.ml.tcm.outfile.ML_09, + com.connor.ml.tcm.outfile.ML_10, + com.connor.ml.tcm.outfile.bean, + com.connor.ml.tcm.outfile.util, + com.connor.ml.tcm.setTemplateID, + com.connor.ml.tcm.showOrderReviewInfo, + com.connor.ml.tcm.synchronization_MBOM_prop, + com.connor.ml.tcm.synchronization_MBOM_structure, + com.connor.ml.tcm.test, + com.connor.ml.tcm.turntobop, + com.connor.ml.tcm.util, + com.ebsolutions.catiman, + com.ebsolutions.catiman.actions, + com.ebsolutions.catiman.commands, + com.ebsolutions.catiman.config, + com.ebsolutions.catiman.extensions, + com.ebsolutions.catiman.fileTransferManagement, + com.ebsolutions.catiman.plugin, + com.ebsolutions.catiman.progressbar, + com.ebsolutions.catiman.soa, + com.ebsolutions.catiman.utility, + com.ebsolutions.catiman.utility.logging, + com.ebsolutions.catiman.utility.net, + com.ebsolutions.catiman.utility.ui, + com.ebsolutions.errormessagehandler, + com.ebsolutions.errormessagehandler.plugin, + com.ebsolutions.journaling, + com.ebsolutions.journaling.plugin, + com.google.gson, + com.google.gson.annotations, + com.google.gson.internal, + com.google.gson.internal.bind, + com.google.gson.internal.bind.util, + com.google.gson.internal.reflect, + com.google.gson.internal.sql, + com.google.gson.reflect, + com.google.gson.stream, + com.ibm.icu.impl, + com.ibm.icu.impl.data, + com.ibm.icu.impl.duration, + com.ibm.icu.impl.duration.impl, + com.ibm.icu.impl.locale, + com.ibm.icu.lang, + com.ibm.icu.math, + com.ibm.icu.text, + com.ibm.icu.util, + com.ibm.wsdl, + com.ibm.wsdl.extensions, + com.ibm.wsdl.extensions.http, + com.ibm.wsdl.extensions.mime, + com.ibm.wsdl.extensions.schema, + com.ibm.wsdl.extensions.soap, + com.ibm.wsdl.extensions.soap12, + com.ibm.wsdl.factory, + com.ibm.wsdl.util, + com.ibm.wsdl.util.xml, + com.ibm.wsdl.xml, + com.itextpdf.awt, + com.itextpdf.awt.geom, + com.itextpdf.awt.geom.gl, + com.itextpdf.awt.geom.misc, + com.itextpdf.testutils, + com.itextpdf.text, + com.itextpdf.text.api, + com.itextpdf.text.error_messages, + com.itextpdf.text.exceptions, + com.itextpdf.text.factories, + com.itextpdf.text.html, + com.itextpdf.text.html.simpleparser, + com.itextpdf.text.io, + com.itextpdf.text.log, + com.itextpdf.text.pdf, + com.itextpdf.text.pdf.codec, + com.itextpdf.text.pdf.codec.wmf, + com.itextpdf.text.pdf.collection, + com.itextpdf.text.pdf.crypto, + com.itextpdf.text.pdf.draw, + com.itextpdf.text.pdf.events, + com.itextpdf.text.pdf.fonts, + com.itextpdf.text.pdf.fonts.cmaps, + com.itextpdf.text.pdf.fonts.otf, + com.itextpdf.text.pdf.hyphenation, + com.itextpdf.text.pdf.interfaces, + com.itextpdf.text.pdf.internal, + com.itextpdf.text.pdf.languages, + com.itextpdf.text.pdf.parser, + com.itextpdf.text.pdf.qrcode, + com.itextpdf.text.pdf.richmedia, + com.itextpdf.text.pdf.security, + com.itextpdf.text.xml, + com.itextpdf.text.xml.simpleparser, + com.itextpdf.text.xml.simpleparser.handler, + com.itextpdf.text.xml.xmp, + com.itextpdf.xmp, + com.itextpdf.xmp.impl, + com.itextpdf.xmp.impl.xpath, + com.itextpdf.xmp.options, + com.itextpdf.xmp.properties, + com.jacob.activeX, + com.jacob.com, + com.lowagie.text, + com.lowagie.text.factories, + com.lowagie.text.html, + com.lowagie.text.html.simpleparser, + com.lowagie.text.pdf, + com.lowagie.text.pdf.codec, + com.lowagie.text.pdf.codec.wmf, + com.lowagie.text.pdf.collection, + com.lowagie.text.pdf.crypto, + com.lowagie.text.pdf.events, + com.lowagie.text.pdf.hyphenation, + com.lowagie.text.pdf.interfaces, + com.lowagie.text.pdf.internal, + com.lowagie.text.rtf, + com.lowagie.text.rtf.direct, + com.lowagie.text.rtf.document, + com.lowagie.text.rtf.document.output, + com.lowagie.text.rtf.field, + com.lowagie.text.rtf.graphic, + com.lowagie.text.rtf.headerfooter, + com.lowagie.text.rtf.list, + com.lowagie.text.rtf.style, + com.lowagie.text.rtf.table, + com.lowagie.text.rtf.text, + com.lowagie.text.xml, + com.lowagie.text.xml.simpleparser, + com.lowagie.text.xml.xmp, + com.lowagie.tools, + com.microsoft.jdbc.base, + com.microsoft.jdbc.extensions, + com.microsoft.jdbc.sqlserver, + com.microsoft.jdbc.sqlserver.tds, + com.microsoft.jdbc.vprt, + com.microsoft.jdbcx.base, + com.microsoft.jdbcx.sqlserver, + com.microsoft.schemas.office.excel, + com.microsoft.schemas.office.excel.impl, + com.microsoft.schemas.office.office, + com.microsoft.schemas.office.office.impl, + com.microsoft.schemas.office.visio.x2012.main, + com.microsoft.schemas.office.visio.x2012.main.impl, + com.microsoft.schemas.office.x2006.digsig, + com.microsoft.schemas.office.x2006.digsig.impl, + com.microsoft.schemas.office.x2006.encryption, + com.microsoft.schemas.office.x2006.encryption.impl, + com.microsoft.schemas.office.x2006.keyEncryptor.certificate, + com.microsoft.schemas.office.x2006.keyEncryptor.certificate.impl, + com.microsoft.schemas.office.x2006.keyEncryptor.password, + com.microsoft.schemas.office.x2006.keyEncryptor.password.impl, + com.microsoft.schemas.vml, + com.microsoft.schemas.vml.impl, + com.microsoft.sqlserver.jdbc, + com.microsoft.util, + com.sap.conn.jco, + com.sap.conn.jco.ext, + com.sap.conn.jco.monitor, + com.sap.conn.jco.rt, + com.sap.conn.jco.server, + com.sap.conn.jco.session, + com.sap.conn.jco.support, + com.sap.conn.jco.util, + com.sap.conn.rfc.api, + com.sap.conn.rfc.data, + com.sap.conn.rfc.driver, + com.sap.conn.rfc.engine, + com.sap.conn.rfc.exceptions, + com.sap.conn.rfc.sysfunc, + com.sap.i18n.cp, + com.sap.i18n.decfloat, + com.sap.tc.logging, + com.sap.tc.logging.exceptions, + com.sap.tc.logging.interfaces, + com.sap.tc.logging.messagedepot, + com.sap.tc.logging.messagedepot.impl, + com.sap.tc.logging.perf, + com.sap.tc.logging.reader, + com.sap.tc.logging.schema, + com.sap.tc.logging.standard, + com.sap.tc.logging.tools.lv, + com.sap.tc.logging.tools.monitor, + com.spire.data.table, + com.spire.data.table.common, + com.spire.license, + com.spire.ms.System, + com.spire.ms.System.Collections, + com.spire.ms.System.Collections.Generic, + com.spire.ms.System.Collections.ObjectModel, + com.spire.ms.System.Collections.Specialized, + com.spire.ms.System.Diagnostics, + com.spire.ms.System.Reflection, + com.spire.ms.System.Security.Cryptography, + com.spire.ms.System.Security.Cryptography.X509Certificates, + com.spire.ms.System.Xml, + com.spire.ms.charsets, + com.spire.ms.charsets.euc_kr, + com.spire.ms.charsets.iso_8859_1, + com.spire.ms.charsets.iso_8859_8, + com.spire.ms.charsets.ms_936, + com.spire.ms.charsets.utf_7, + com.spire.ms.core.System.Security.Cryptography.X509Certificates, + com.spire.ms.imagecodecs.bmp.spi, + com.spire.ms.imagecodecs.gif.spi, + com.spire.ms.imagecodecs.ico.spi, + com.spire.ms.imagecodecs.jpeg.spi, + com.spire.ms.imagecodecs.png.spi, + com.spire.ms.imagecodecs.tiff.spi, + com.spire.ms.lang, + com.spire.pdf, + com.spire.pdf.actions, + com.spire.pdf.annotations, + com.spire.pdf.annotations.appearance, + com.spire.pdf.attachments, + com.spire.pdf.automaticfields, + com.spire.pdf.barcode, + com.spire.pdf.bookmarks, + com.spire.pdf.collections, + com.spire.pdf.colorspace, + com.spire.pdf.exporting, + com.spire.pdf.exporting.text, + com.spire.pdf.exporting.xps.schema, + com.spire.pdf.fields, + com.spire.pdf.general, + com.spire.pdf.general.find, + com.spire.pdf.general.paper.drawing.ps, + com.spire.pdf.general.paper.font.common, + com.spire.pdf.general.paper.font.postscript.path, + com.spire.pdf.general.paper.font.rendering.hinting, + com.spire.pdf.general.paper.font.ttf.internals, + com.spire.pdf.general.paper.font.type1.internals, + com.spire.pdf.general.paper.font.type1.internals.parsing.objects, + com.spire.pdf.graphics, + com.spire.pdf.graphics.fonts, + com.spire.pdf.graphics.layer, + com.spire.pdf.grid, + com.spire.pdf.htmlconverter, + com.spire.pdf.htmlconverter.qt, + com.spire.pdf.interfacess, + com.spire.pdf.lists, + com.spire.pdf.security, + com.spire.pdf.tables, + com.spire.pdf.tables.table, + com.spire.pdf.tables.table.common, + com.spire.pdf.widget, + com.spire.pdf.xmp, + com.spire.xls, + com.spire.xls.charts, + com.spire.xls.collections, + com.spire.xls.core, + com.spire.xls.core.converter, + com.spire.xls.core.converter.exporting, + com.spire.xls.core.converter.rendering.chart.charts.common, + com.spire.xls.core.converter.rendering.chart.charts.xlscharts.general, + com.spire.xls.core.converter.rendering.chart.charts.xlsxcharts.general, + com.spire.xls.core.converter.rendering.chart.shapes.xlsshaps.general, + com.spire.xls.core.converter.rendering.chart.shapes.xlsshaps.general.gradient, + com.spire.xls.core.converter.rendering.chart.shapes.xlsxshaps.general, + com.spire.xls.core.converter.rendering.chart.shapes.xlsxshaps.general.gradient, + com.spire.xls.core.converter.spreadsheet, + com.spire.xls.core.converter.spreadsheet.autofilter, + com.spire.xls.core.converter.spreadsheet.charts, + com.spire.xls.core.converter.spreadsheet.conditionalformatting, + com.spire.xls.core.converter.spreadsheet.conditionalformatting.xlsx, + com.spire.xls.core.converter.spreadsheet.excelstyle, + com.spire.xls.core.converter.spreadsheet.extensions, + com.spire.xls.core.converter.spreadsheet.formulaop, + com.spire.xls.core.converter.spreadsheet.pagesetup, + com.spire.xls.core.converter.spreadsheet.pivottable, + com.spire.xls.core.converter.spreadsheet.query, + com.spire.xls.core.converter.spreadsheet.shapes, + com.spire.xls.core.converter.spreadsheet.shapes.msodrawing, + com.spire.xls.core.converter.spreadsheet.sparkline, + com.spire.xls.core.converter.spreadsheet.xmlmapping, + com.spire.xls.core.converter.tables, + com.spire.xls.core.interfaces, + com.spire.xls.core.interfacess, + com.spire.xls.core.spreadsheet, + com.spire.xls.core.spreadsheet.autofilter, + com.spire.xls.core.spreadsheet.charts, + com.spire.xls.core.spreadsheet.collections, + com.spire.xls.core.spreadsheet.conditionalformatting, + com.spire.xls.core.spreadsheet.pivottables, + com.spire.xls.core.spreadsheet.shapes, + com.spire.xls.core.spreadsheet.sorting, + com.spire.xls.packages, + com.sun.activation.registries, + com.sun.activation.viewers, + com.sun.istack, + com.sun.istack.localization, + com.sun.istack.logging, + com.sun.mail.handlers, + com.sun.mail.util, + com.sun.xml.bind, + com.sun.xml.bind.annotation, + com.sun.xml.bind.api, + com.sun.xml.bind.api.impl, + com.sun.xml.bind.marshaller, + com.sun.xml.bind.unmarshaller, + com.sun.xml.bind.util, + com.sun.xml.bind.v2, + com.sun.xml.bind.v2.bytecode, + com.sun.xml.bind.v2.model.annotation, + com.sun.xml.bind.v2.model.core, + com.sun.xml.bind.v2.model.impl, + com.sun.xml.bind.v2.model.nav, + com.sun.xml.bind.v2.model.runtime, + com.sun.xml.bind.v2.model.util, + com.sun.xml.bind.v2.runtime, + com.sun.xml.bind.v2.runtime.output, + com.sun.xml.bind.v2.runtime.property, + com.sun.xml.bind.v2.runtime.reflect, + com.sun.xml.bind.v2.runtime.reflect.opt, + com.sun.xml.bind.v2.runtime.unmarshaller, + com.sun.xml.bind.v2.schemagen, + com.sun.xml.bind.v2.schemagen.episode, + com.sun.xml.bind.v2.schemagen.xmlschema, + com.sun.xml.bind.v2.util, + com.sun.xml.fastinfoset, + com.sun.xml.fastinfoset.algorithm, + com.sun.xml.fastinfoset.alphabet, + com.sun.xml.fastinfoset.dom, + com.sun.xml.fastinfoset.org.apache.xerces.util, + com.sun.xml.fastinfoset.sax, + com.sun.xml.fastinfoset.stax, + com.sun.xml.fastinfoset.stax.events, + com.sun.xml.fastinfoset.stax.factory, + com.sun.xml.fastinfoset.stax.util, + com.sun.xml.fastinfoset.tools, + com.sun.xml.fastinfoset.util, + com.sun.xml.fastinfoset.vocab, + com.sun.xml.txw2, + com.sun.xml.txw2.annotation, + com.sun.xml.txw2.output, + com.teamcenter.rac.cme.application, + com.teamcenter.rac.commands.newitem, + com.teamcenter.rac.commands.paste, + edu.emory.mathcs.backport.java.util, + edu.emory.mathcs.backport.java.util.concurrent, + edu.emory.mathcs.backport.java.util.concurrent.atomic, + edu.emory.mathcs.backport.java.util.concurrent.helpers, + edu.emory.mathcs.backport.java.util.concurrent.locks, + javax.activation, + javax.jws, + javax.jws.soap, + javax.mail, + javax.mail.event, + javax.mail.internet, + javax.mail.search, + javax.sql, + javax.wsdl, + javax.wsdl.extensions, + javax.wsdl.extensions.http, + javax.wsdl.extensions.mime, + javax.wsdl.extensions.schema, + javax.wsdl.extensions.soap, + javax.wsdl.extensions.soap12, + javax.wsdl.factory, + javax.wsdl.xml, + javax.xml, + javax.xml.messaging, + javax.xml.namespace, + javax.xml.rpc, + javax.xml.rpc.encoding, + javax.xml.rpc.handler, + javax.xml.rpc.handler.soap, + javax.xml.rpc.holders, + javax.xml.rpc.server, + javax.xml.rpc.soap, + javax.xml.soap, + javax.xml.stream, + javax.xml.stream.events, + javax.xml.stream.util, + javax.xml.ws, + javax.xml.ws.handler, + javax.xml.ws.handler.soap, + javax.xml.ws.http, + javax.xml.ws.soap, + javax.xml.ws.spi, + javax.xml.ws.wsaddressing, + microsoft.sql, + net.sf.cglib.beans, + net.sf.cglib.core, + net.sf.cglib.proxy, + net.sf.cglib.reflect, + net.sf.cglib.transform, + net.sf.cglib.transform.impl, + net.sf.cglib.util, + net.sf.ezmorph, + net.sf.ezmorph.array, + net.sf.ezmorph.bean, + net.sf.ezmorph.object, + net.sf.ezmorph.primitive, + net.sf.ezmorph.test, + net.sf.json, + net.sf.json.filters, + net.sf.json.groovy, + net.sf.json.processors, + net.sf.json.regexp, + net.sf.json.test, + net.sf.json.util, + net.sf.json.xml, + oracle.core.lmx, + oracle.core.lvf, + oracle.jdbc, + oracle.jdbc.aq, + oracle.jdbc.connector, + oracle.jdbc.dcn, + oracle.jdbc.driver, + oracle.jdbc.internal, + oracle.jdbc.oci, + oracle.jdbc.oracore, + oracle.jdbc.pool, + oracle.jdbc.rowset, + oracle.jdbc.util, + oracle.jdbc.xa, + oracle.jdbc.xa.client, + oracle.jpub.runtime, + oracle.net.TNSAddress, + oracle.net.ano, + oracle.net.aso, + oracle.net.jndi, + oracle.net.nl, + oracle.net.nl.mesg, + oracle.net.ns, + oracle.net.nt, + oracle.net.resolver, + oracle.security.o3logon, + oracle.security.o5logon, + oracle.sql, + oracle.sql.converter, + org.apache.axiom.attachments, + org.apache.axiom.attachments.impl, + org.apache.axiom.attachments.lifecycle, + org.apache.axiom.attachments.lifecycle.impl, + org.apache.axiom.attachments.utils, + org.apache.axiom.om, + org.apache.axiom.om.ds, + org.apache.axiom.om.ds.custombuilder, + org.apache.axiom.om.impl, + org.apache.axiom.om.impl.builder, + org.apache.axiom.om.impl.dom, + org.apache.axiom.om.impl.dom.factory, + org.apache.axiom.om.impl.dom.jaxp, + org.apache.axiom.om.impl.exception, + org.apache.axiom.om.impl.llom, + org.apache.axiom.om.impl.llom.factory, + org.apache.axiom.om.impl.llom.util, + org.apache.axiom.om.impl.serialize, + org.apache.axiom.om.impl.traverse, + org.apache.axiom.om.impl.util, + org.apache.axiom.om.util, + org.apache.axiom.om.xpath, + org.apache.axiom.soap, + org.apache.axiom.soap.impl.builder, + org.apache.axiom.soap.impl.dom, + org.apache.axiom.soap.impl.dom.factory, + org.apache.axiom.soap.impl.dom.soap11, + org.apache.axiom.soap.impl.dom.soap12, + org.apache.axiom.soap.impl.llom, + org.apache.axiom.soap.impl.llom.soap11, + org.apache.axiom.soap.impl.llom.soap12, + org.apache.axis2, + org.apache.axis2.addressing, + org.apache.axis2.addressing.metadata, + org.apache.axis2.addressing.wsdl, + org.apache.axis2.builder, + org.apache.axis2.classloader, + org.apache.axis2.client, + org.apache.axis2.client.async, + org.apache.axis2.clustering, + org.apache.axis2.clustering.configuration, + org.apache.axis2.clustering.configuration.commands, + org.apache.axis2.clustering.context, + org.apache.axis2.clustering.context.commands, + org.apache.axis2.clustering.control, + org.apache.axis2.clustering.tribes, + org.apache.axis2.context, + org.apache.axis2.context.externalize, + org.apache.axis2.corba.deployer, + org.apache.axis2.corba.exceptions, + org.apache.axis2.corba.idl, + org.apache.axis2.corba.idl.parser, + org.apache.axis2.corba.idl.types, + org.apache.axis2.corba.idl.values, + org.apache.axis2.corba.receivers, + org.apache.axis2.databinding, + org.apache.axis2.databinding.i18n, + org.apache.axis2.databinding.typemapping, + org.apache.axis2.databinding.types, + org.apache.axis2.databinding.types.soapencoding, + org.apache.axis2.databinding.types.xsd, + org.apache.axis2.databinding.utils, + org.apache.axis2.databinding.utils.reader, + org.apache.axis2.databinding.utils.writer, + org.apache.axis2.dataretrieval, + org.apache.axis2.dataretrieval.client, + org.apache.axis2.datasource, + org.apache.axis2.datasource.jaxb, + org.apache.axis2.deployment, + org.apache.axis2.deployment.repository.util, + org.apache.axis2.deployment.resolver, + org.apache.axis2.deployment.scheduler, + org.apache.axis2.deployment.util, + org.apache.axis2.description, + org.apache.axis2.description.java2wsdl, + org.apache.axis2.description.java2wsdl.bytecode, + org.apache.axis2.dispatchers, + org.apache.axis2.engine, + org.apache.axis2.extensions.spring.receivers, + org.apache.axis2.fastinfoset, + org.apache.axis2.handlers, + org.apache.axis2.i18n, + org.apache.axis2.java.security, + org.apache.axis2.jaxbri, + org.apache.axis2.jaxws, + org.apache.axis2.jaxws.addressing, + org.apache.axis2.jaxws.addressing.factory, + org.apache.axis2.jaxws.addressing.factory.impl, + org.apache.axis2.jaxws.addressing.migrator, + org.apache.axis2.jaxws.addressing.util, + org.apache.axis2.jaxws.binding, + org.apache.axis2.jaxws.catalog, + org.apache.axis2.jaxws.catalog.impl, + org.apache.axis2.jaxws.client, + org.apache.axis2.jaxws.client.async, + org.apache.axis2.jaxws.client.config, + org.apache.axis2.jaxws.client.dispatch, + org.apache.axis2.jaxws.client.proxy, + org.apache.axis2.jaxws.context, + org.apache.axis2.jaxws.context.factory, + org.apache.axis2.jaxws.context.utils, + org.apache.axis2.jaxws.core, + org.apache.axis2.jaxws.core.controller, + org.apache.axis2.jaxws.core.controller.impl, + org.apache.axis2.jaxws.core.util, + org.apache.axis2.jaxws.description, + org.apache.axis2.jaxws.description.builder, + org.apache.axis2.jaxws.description.builder.converter, + org.apache.axis2.jaxws.description.impl, + org.apache.axis2.jaxws.description.validator, + org.apache.axis2.jaxws.description.xml.handler, + org.apache.axis2.jaxws.dispatchers, + org.apache.axis2.jaxws.feature, + org.apache.axis2.jaxws.framework, + org.apache.axis2.jaxws.handler, + org.apache.axis2.jaxws.handler.factory, + org.apache.axis2.jaxws.handler.factory.impl, + org.apache.axis2.jaxws.handler.impl, + org.apache.axis2.jaxws.handler.lifecycle.factory, + org.apache.axis2.jaxws.handler.lifecycle.impl, + org.apache.axis2.jaxws.i18n, + org.apache.axis2.jaxws.injection, + org.apache.axis2.jaxws.lifecycle, + org.apache.axis2.jaxws.marshaller, + org.apache.axis2.jaxws.marshaller.factory, + org.apache.axis2.jaxws.marshaller.impl.alt, + org.apache.axis2.jaxws.message, + org.apache.axis2.jaxws.message.attachments, + org.apache.axis2.jaxws.message.databinding, + org.apache.axis2.jaxws.message.databinding.impl, + org.apache.axis2.jaxws.message.factory, + org.apache.axis2.jaxws.message.impl, + org.apache.axis2.jaxws.message.util, + org.apache.axis2.jaxws.message.util.impl, + org.apache.axis2.jaxws.registry, + org.apache.axis2.jaxws.runtime.description.injection, + org.apache.axis2.jaxws.runtime.description.injection.impl, + org.apache.axis2.jaxws.runtime.description.marshal, + org.apache.axis2.jaxws.runtime.description.marshal.impl, + org.apache.axis2.jaxws.server, + org.apache.axis2.jaxws.server.config, + org.apache.axis2.jaxws.server.dispatcher, + org.apache.axis2.jaxws.server.dispatcher.factory, + org.apache.axis2.jaxws.server.endpoint, + org.apache.axis2.jaxws.server.endpoint.injection, + org.apache.axis2.jaxws.server.endpoint.injection.factory, + org.apache.axis2.jaxws.server.endpoint.injection.impl, + org.apache.axis2.jaxws.server.endpoint.lifecycle, + org.apache.axis2.jaxws.server.endpoint.lifecycle.factory, + org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.impl, + org.apache.axis2.jaxws.server.endpoint.lifecycle.impl, + org.apache.axis2.jaxws.spi, + org.apache.axis2.jaxws.spi.handler, + org.apache.axis2.jaxws.spi.migrator, + org.apache.axis2.jaxws.util, + org.apache.axis2.jaxws.utility, + org.apache.axis2.jaxws.wrapper, + org.apache.axis2.jaxws.wrapper.impl, + org.apache.axis2.jaxws.wsdl, + org.apache.axis2.jaxws.wsdl.impl, + org.apache.axis2.jibx, + org.apache.axis2.json, + org.apache.axis2.metadata.factory, + org.apache.axis2.metadata.registry, + org.apache.axis2.metadata.resource, + org.apache.axis2.metadata.resource.impl, + org.apache.axis2.modules, + org.apache.axis2.namespace, + org.apache.axis2.phaseresolver, + org.apache.axis2.policy.builders, + org.apache.axis2.policy.model, + org.apache.axis2.receivers, + org.apache.axis2.rpc.client, + org.apache.axis2.rpc.receivers, + org.apache.axis2.rpc.receivers.ejb, + org.apache.axis2.saaj, + org.apache.axis2.saaj.util, + org.apache.axis2.schema, + org.apache.axis2.schema.i18n, + org.apache.axis2.schema.typemap, + org.apache.axis2.schema.util, + org.apache.axis2.schema.writer, + org.apache.axis2.service, + org.apache.axis2.tool.ant, + org.apache.axis2.transport, + org.apache.axis2.transport.http, + org.apache.axis2.transport.http.server, + org.apache.axis2.transport.http.util, + org.apache.axis2.transport.java, + org.apache.axis2.transport.jms, + org.apache.axis2.transport.local, + org.apache.axis2.transport.mail, + org.apache.axis2.transport.mail.server, + org.apache.axis2.transport.nhttp, + org.apache.axis2.transport.nhttp.util, + org.apache.axis2.transport.tcp, + org.apache.axis2.transport.xmpp, + org.apache.axis2.transport.xmpp.util, + org.apache.axis2.util, + org.apache.axis2.util.threadpool, + org.apache.axis2.wsdl, + org.apache.axis2.wsdl.codegen, + org.apache.axis2.wsdl.codegen.emitter, + org.apache.axis2.wsdl.codegen.emitter.jaxws, + org.apache.axis2.wsdl.codegen.extension, + org.apache.axis2.wsdl.codegen.schema, + org.apache.axis2.wsdl.codegen.schema.exception, + org.apache.axis2.wsdl.codegen.writer, + org.apache.axis2.wsdl.databinding, + org.apache.axis2.wsdl.i18n, + org.apache.axis2.wsdl.util, + org.apache.axis2.xmlbeans, + org.apache.commons.beanutils, + org.apache.commons.beanutils.converters, + org.apache.commons.beanutils.locale, + org.apache.commons.beanutils.locale.converters, + org.apache.commons.codec, + org.apache.commons.codec.binary, + org.apache.commons.codec.digest, + org.apache.commons.codec.language, + org.apache.commons.codec.net, + org.apache.commons.collections, + org.apache.commons.collections.bag, + org.apache.commons.collections.bidimap, + org.apache.commons.collections.buffer, + org.apache.commons.collections.collection, + org.apache.commons.collections.comparators, + org.apache.commons.collections.functors, + org.apache.commons.collections.iterators, + org.apache.commons.collections.keyvalue, + org.apache.commons.collections.list, + org.apache.commons.collections.map, + org.apache.commons.collections.set, + org.apache.commons.collections4, + org.apache.commons.collections4.bag, + org.apache.commons.collections4.bidimap, + org.apache.commons.collections4.collection, + org.apache.commons.collections4.comparators, + org.apache.commons.collections4.functors, + org.apache.commons.collections4.iterators, + org.apache.commons.collections4.keyvalue, + org.apache.commons.collections4.list, + org.apache.commons.collections4.map, + org.apache.commons.collections4.multimap, + org.apache.commons.collections4.multiset, + org.apache.commons.collections4.queue, + org.apache.commons.collections4.sequence, + org.apache.commons.collections4.set, + org.apache.commons.collections4.splitmap, + org.apache.commons.collections4.trie, + org.apache.commons.collections4.trie.analyzer, + org.apache.commons.httpclient, + org.apache.commons.httpclient.auth, + org.apache.commons.httpclient.cookie, + org.apache.commons.httpclient.methods, + org.apache.commons.httpclient.methods.multipart, + org.apache.commons.httpclient.params, + org.apache.commons.httpclient.protocol, + org.apache.commons.httpclient.util, + org.apache.commons.lang, + org.apache.commons.lang.builder, + org.apache.commons.lang.enum, + org.apache.commons.lang.enums, + org.apache.commons.lang.exception, + org.apache.commons.lang.math, + org.apache.commons.lang.mutable, + org.apache.commons.lang.text, + org.apache.commons.lang.time, + org.apache.commons.logging, + org.apache.commons.logging.impl, + org.apache.commons.math3, + org.apache.commons.math3.analysis, + org.apache.commons.math3.analysis.differentiation, + org.apache.commons.math3.analysis.function, + org.apache.commons.math3.analysis.integration, + org.apache.commons.math3.analysis.integration.gauss, + org.apache.commons.math3.analysis.interpolation, + org.apache.commons.math3.analysis.polynomials, + org.apache.commons.math3.analysis.solvers, + org.apache.commons.math3.complex, + org.apache.commons.math3.dfp, + org.apache.commons.math3.distribution, + org.apache.commons.math3.distribution.fitting, + org.apache.commons.math3.exception, + org.apache.commons.math3.exception.util, + org.apache.commons.math3.filter, + org.apache.commons.math3.fitting, + org.apache.commons.math3.fitting.leastsquares, + org.apache.commons.math3.fraction, + org.apache.commons.math3.genetics, + org.apache.commons.math3.geometry, + org.apache.commons.math3.geometry.enclosing, + org.apache.commons.math3.geometry.euclidean.oned, + org.apache.commons.math3.geometry.euclidean.threed, + org.apache.commons.math3.geometry.euclidean.twod, + org.apache.commons.math3.geometry.euclidean.twod.hull, + org.apache.commons.math3.geometry.hull, + org.apache.commons.math3.geometry.partitioning, + org.apache.commons.math3.geometry.partitioning.utilities, + org.apache.commons.math3.geometry.spherical.oned, + org.apache.commons.math3.geometry.spherical.twod, + org.apache.commons.math3.linear, + org.apache.commons.math3.ml.clustering, + org.apache.commons.math3.ml.clustering.evaluation, + org.apache.commons.math3.ml.distance, + org.apache.commons.math3.ml.neuralnet, + org.apache.commons.math3.ml.neuralnet.oned, + org.apache.commons.math3.ml.neuralnet.sofm, + org.apache.commons.math3.ml.neuralnet.sofm.util, + org.apache.commons.math3.ml.neuralnet.twod, + org.apache.commons.math3.ml.neuralnet.twod.util, + org.apache.commons.math3.ode, + org.apache.commons.math3.ode.events, + org.apache.commons.math3.ode.nonstiff, + org.apache.commons.math3.ode.sampling, + org.apache.commons.math3.optim, + org.apache.commons.math3.optim.linear, + org.apache.commons.math3.optim.nonlinear.scalar, + org.apache.commons.math3.optim.nonlinear.scalar.gradient, + org.apache.commons.math3.optim.nonlinear.scalar.noderiv, + org.apache.commons.math3.optim.nonlinear.vector, + org.apache.commons.math3.optim.nonlinear.vector.jacobian, + org.apache.commons.math3.optim.univariate, + org.apache.commons.math3.optimization, + org.apache.commons.math3.optimization.direct, + org.apache.commons.math3.optimization.fitting, + org.apache.commons.math3.optimization.general, + org.apache.commons.math3.optimization.linear, + org.apache.commons.math3.optimization.univariate, + org.apache.commons.math3.primes, + org.apache.commons.math3.random, + org.apache.commons.math3.special, + org.apache.commons.math3.stat, + org.apache.commons.math3.stat.clustering, + org.apache.commons.math3.stat.correlation, + org.apache.commons.math3.stat.descriptive, + org.apache.commons.math3.stat.descriptive.moment, + org.apache.commons.math3.stat.descriptive.rank, + org.apache.commons.math3.stat.descriptive.summary, + org.apache.commons.math3.stat.inference, + org.apache.commons.math3.stat.interval, + org.apache.commons.math3.stat.ranking, + org.apache.commons.math3.stat.regression, + org.apache.commons.math3.transform, + org.apache.commons.math3.util, + org.apache.http, + org.apache.http.annotation, + org.apache.http.auth, + org.apache.http.auth.params, + org.apache.http.client, + org.apache.http.client.config, + org.apache.http.client.entity, + org.apache.http.client.methods, + org.apache.http.client.params, + org.apache.http.client.protocol, + org.apache.http.client.utils, + org.apache.http.concurrent, + org.apache.http.config, + org.apache.http.conn, + org.apache.http.conn.params, + org.apache.http.conn.routing, + org.apache.http.conn.scheme, + org.apache.http.conn.socket, + org.apache.http.conn.ssl, + org.apache.http.conn.util, + org.apache.http.cookie, + org.apache.http.cookie.params, + org.apache.http.entity, + org.apache.http.entity.mime, + org.apache.http.entity.mime.content, + org.apache.http.impl, + org.apache.http.impl.auth, + org.apache.http.impl.bootstrap, + org.apache.http.impl.client, + org.apache.http.impl.conn, + org.apache.http.impl.conn.tsccm, + org.apache.http.impl.cookie, + org.apache.http.impl.entity, + org.apache.http.impl.execchain, + org.apache.http.impl.io, + org.apache.http.impl.pool, + org.apache.http.io, + org.apache.http.message, + org.apache.http.params, + org.apache.http.pool, + org.apache.http.protocol, + org.apache.http.ssl, + org.apache.http.util, + org.apache.neethi, + org.apache.neethi.builders, + org.apache.neethi.builders.converters, + org.apache.neethi.builders.xml, + org.apache.neethi.util, + org.apache.poi, + org.apache.poi.common.usermodel, + org.apache.poi.common.usermodel.fonts, + org.apache.poi.crypt.examples, + org.apache.poi.ddf, + org.apache.poi.dev, + org.apache.poi.examples.util, + org.apache.poi.extractor, + org.apache.poi.hdgf, + org.apache.poi.hdgf.chunks, + org.apache.poi.hdgf.dev, + org.apache.poi.hdgf.exceptions, + org.apache.poi.hdgf.extractor, + org.apache.poi.hdgf.pointers, + org.apache.poi.hdgf.streams, + org.apache.poi.hemf.extractor, + org.apache.poi.hemf.hemfplus.record, + org.apache.poi.hemf.record, + org.apache.poi.hmef, + org.apache.poi.hmef.attribute, + org.apache.poi.hmef.dev, + org.apache.poi.hmef.extractor, + org.apache.poi.hpbf, + org.apache.poi.hpbf.dev, + org.apache.poi.hpbf.extractor, + org.apache.poi.hpbf.model, + org.apache.poi.hpbf.model.qcbits, + org.apache.poi.hpsf, + org.apache.poi.hpsf.examples, + org.apache.poi.hpsf.extractor, + org.apache.poi.hpsf.wellknown, + org.apache.poi.hslf.blip, + org.apache.poi.hslf.dev, + org.apache.poi.hslf.examples, + org.apache.poi.hslf.exceptions, + org.apache.poi.hslf.extractor, + org.apache.poi.hslf.model, + org.apache.poi.hslf.model.textproperties, + org.apache.poi.hslf.record, + org.apache.poi.hslf.usermodel, + org.apache.poi.hslf.util, + org.apache.poi.hsmf, + org.apache.poi.hsmf.datatypes, + org.apache.poi.hsmf.dev, + org.apache.poi.hsmf.examples, + org.apache.poi.hsmf.exceptions, + org.apache.poi.hsmf.extractor, + org.apache.poi.hsmf.parsers, + org.apache.poi.hssf, + org.apache.poi.hssf.converter, + org.apache.poi.hssf.dev, + org.apache.poi.hssf.eventmodel, + org.apache.poi.hssf.eventusermodel, + org.apache.poi.hssf.eventusermodel.dummyrecord, + org.apache.poi.hssf.eventusermodel.examples, + org.apache.poi.hssf.extractor, + org.apache.poi.hssf.model, + org.apache.poi.hssf.record, + org.apache.poi.hssf.record.aggregates, + org.apache.poi.hssf.record.cf, + org.apache.poi.hssf.record.chart, + org.apache.poi.hssf.record.common, + org.apache.poi.hssf.record.cont, + org.apache.poi.hssf.record.crypto, + org.apache.poi.hssf.record.pivottable, + org.apache.poi.hssf.usermodel, + org.apache.poi.hssf.usermodel.examples, + org.apache.poi.hssf.usermodel.helpers, + org.apache.poi.hssf.util, + org.apache.poi.hssf.view, + org.apache.poi.hssf.view.brush, + org.apache.poi.hwmf.draw, + org.apache.poi.hwmf.record, + org.apache.poi.hwmf.usermodel, + org.apache.poi.hwpf, + org.apache.poi.hwpf.converter, + org.apache.poi.hwpf.dev, + org.apache.poi.hwpf.extractor, + org.apache.poi.hwpf.model, + org.apache.poi.hwpf.model.io, + org.apache.poi.hwpf.model.types, + org.apache.poi.hwpf.sprm, + org.apache.poi.hwpf.usermodel, + org.apache.poi.openxml4j.exceptions, + org.apache.poi.openxml4j.opc, + org.apache.poi.openxml4j.opc.internal, + org.apache.poi.openxml4j.opc.internal.marshallers, + org.apache.poi.openxml4j.opc.internal.unmarshallers, + org.apache.poi.openxml4j.util, + org.apache.poi.poifs.common, + org.apache.poi.poifs.crypt, + org.apache.poi.poifs.crypt.agile, + org.apache.poi.poifs.crypt.binaryrc4, + org.apache.poi.poifs.crypt.cryptoapi, + org.apache.poi.poifs.crypt.dsig, + org.apache.poi.poifs.crypt.dsig.facets, + org.apache.poi.poifs.crypt.dsig.services, + org.apache.poi.poifs.crypt.standard, + org.apache.poi.poifs.crypt.temp, + org.apache.poi.poifs.crypt.xor, + org.apache.poi.poifs.dev, + org.apache.poi.poifs.eventfilesystem, + org.apache.poi.poifs.filesystem, + org.apache.poi.poifs.macros, + org.apache.poi.poifs.nio, + org.apache.poi.poifs.poibrowser, + org.apache.poi.poifs.property, + org.apache.poi.poifs.storage, + org.apache.poi.sl.draw, + org.apache.poi.sl.draw.binding, + org.apache.poi.sl.draw.geom, + org.apache.poi.sl.image, + org.apache.poi.sl.usermodel, + org.apache.poi.ss, + org.apache.poi.ss.examples, + org.apache.poi.ss.examples.formula, + org.apache.poi.ss.examples.html, + org.apache.poi.ss.excelant, + org.apache.poi.ss.excelant.util, + org.apache.poi.ss.extractor, + org.apache.poi.ss.format, + org.apache.poi.ss.formula, + org.apache.poi.ss.formula.atp, + org.apache.poi.ss.formula.constant, + org.apache.poi.ss.formula.eval, + org.apache.poi.ss.formula.eval.forked, + org.apache.poi.ss.formula.function, + org.apache.poi.ss.formula.functions, + org.apache.poi.ss.formula.ptg, + org.apache.poi.ss.formula.udf, + org.apache.poi.ss.usermodel, + org.apache.poi.ss.usermodel.charts, + org.apache.poi.ss.usermodel.helpers, + org.apache.poi.ss.util, + org.apache.poi.ss.util.cellwalk, + org.apache.poi.util, + org.apache.poi.wp.usermodel, + org.apache.poi.xdgf.exceptions, + org.apache.poi.xdgf.extractor, + org.apache.poi.xdgf.geom, + org.apache.poi.xdgf.usermodel, + org.apache.poi.xdgf.usermodel.section, + org.apache.poi.xdgf.usermodel.section.geometry, + org.apache.poi.xdgf.usermodel.shape, + org.apache.poi.xdgf.usermodel.shape.exceptions, + org.apache.poi.xdgf.util, + org.apache.poi.xdgf.xml, + org.apache.poi.xslf.extractor, + org.apache.poi.xslf.model, + org.apache.poi.xslf.usermodel, + org.apache.poi.xslf.usermodel.tutorial, + org.apache.poi.xslf.util, + org.apache.poi.xssf, + org.apache.poi.xssf.binary, + org.apache.poi.xssf.dev, + org.apache.poi.xssf.eventusermodel, + org.apache.poi.xssf.eventusermodel.examples, + org.apache.poi.xssf.extractor, + org.apache.poi.xssf.model, + org.apache.poi.xssf.streaming, + org.apache.poi.xssf.streaming.examples, + org.apache.poi.xssf.usermodel, + org.apache.poi.xssf.usermodel.charts, + org.apache.poi.xssf.usermodel.examples, + org.apache.poi.xssf.usermodel.extensions, + org.apache.poi.xssf.usermodel.helpers, + org.apache.poi.xssf.util, + org.apache.poi.xwpf.extractor, + org.apache.poi.xwpf.model, + org.apache.poi.xwpf.usermodel, + org.apache.poi.xwpf.usermodel.examples, + org.apache.woden, + org.apache.woden.internal, + org.apache.woden.internal.resolver, + org.apache.woden.internal.schema, + org.apache.woden.internal.util, + org.apache.woden.internal.util.dom, + org.apache.woden.internal.wsdl20, + org.apache.woden.internal.wsdl20.assertions, + org.apache.woden.internal.wsdl20.extensions, + org.apache.woden.internal.wsdl20.extensions.http, + org.apache.woden.internal.wsdl20.extensions.rpc, + org.apache.woden.internal.wsdl20.extensions.soap, + org.apache.woden.internal.wsdl20.validation, + org.apache.woden.internal.xml, + org.apache.woden.internal.xpointer, + org.apache.woden.resolver, + org.apache.woden.schema, + org.apache.woden.types, + org.apache.woden.wsdl20, + org.apache.woden.wsdl20.editable, + org.apache.woden.wsdl20.enumeration, + org.apache.woden.wsdl20.extensions, + org.apache.woden.wsdl20.extensions.http, + org.apache.woden.wsdl20.extensions.rpc, + org.apache.woden.wsdl20.extensions.soap, + org.apache.woden.wsdl20.fragids, + org.apache.woden.wsdl20.validation, + org.apache.woden.wsdl20.xml, + org.apache.woden.xml, + org.apache.woden.xpointer, + org.apache.ws.commons.schema, + org.apache.ws.commons.schema.constants, + org.apache.ws.commons.schema.extensions, + org.apache.ws.commons.schema.internal, + org.apache.ws.commons.schema.resolver, + org.apache.ws.commons.schema.utils, + org.apache.ws.java2wsdl, + org.apache.ws.java2wsdl.utils, + org.apache.xml.security, + org.apache.xml.security.algorithms, + org.apache.xml.security.algorithms.implementations, + org.apache.xml.security.c14n, + org.apache.xml.security.c14n.helper, + org.apache.xml.security.c14n.implementations, + org.apache.xml.security.encryption, + org.apache.xml.security.exceptions, + org.apache.xml.security.keys, + org.apache.xml.security.keys.content, + org.apache.xml.security.keys.content.keyvalues, + org.apache.xml.security.keys.content.x509, + org.apache.xml.security.keys.keyresolver, + org.apache.xml.security.keys.keyresolver.implementations, + org.apache.xml.security.keys.storage, + org.apache.xml.security.keys.storage.implementations, + org.apache.xml.security.signature, + org.apache.xml.security.transforms, + org.apache.xml.security.transforms.implementations, + org.apache.xml.security.transforms.params, + org.apache.xml.security.utils, + org.apache.xml.security.utils.resolver, + org.apache.xml.security.utils.resolver.implementations, + org.apache.xmlbeans, + org.apache.xmlbeans.impl.common, + org.apache.xmlbeans.impl.config, + org.apache.xmlbeans.impl.inst2xsd, + org.apache.xmlbeans.impl.inst2xsd.util, + org.apache.xmlbeans.impl.jam, + org.apache.xmlbeans.impl.jam.annotation, + org.apache.xmlbeans.impl.jam.internal, + org.apache.xmlbeans.impl.jam.internal.classrefs, + org.apache.xmlbeans.impl.jam.internal.elements, + org.apache.xmlbeans.impl.jam.internal.javadoc, + org.apache.xmlbeans.impl.jam.internal.parser, + org.apache.xmlbeans.impl.jam.internal.reflect, + org.apache.xmlbeans.impl.jam.mutable, + org.apache.xmlbeans.impl.jam.provider, + org.apache.xmlbeans.impl.jam.visitor, + org.apache.xmlbeans.impl.jam.xml, + org.apache.xmlbeans.impl.piccolo.io, + org.apache.xmlbeans.impl.piccolo.util, + org.apache.xmlbeans.impl.piccolo.xml, + org.apache.xmlbeans.impl.regex, + org.apache.xmlbeans.impl.richParser, + org.apache.xmlbeans.impl.schema, + org.apache.xmlbeans.impl.soap, + org.apache.xmlbeans.impl.store, + org.apache.xmlbeans.impl.tool, + org.apache.xmlbeans.impl.util, + org.apache.xmlbeans.impl.validator, + org.apache.xmlbeans.impl.values, + org.apache.xmlbeans.impl.xb.ltgfmt, + org.apache.xmlbeans.impl.xb.ltgfmt.impl, + org.apache.xmlbeans.impl.xb.substwsdl, + org.apache.xmlbeans.impl.xb.substwsdl.impl, + org.apache.xmlbeans.impl.xb.xmlconfig, + org.apache.xmlbeans.impl.xb.xmlconfig.impl, + org.apache.xmlbeans.impl.xb.xmlschema, + org.apache.xmlbeans.impl.xb.xmlschema.impl, + org.apache.xmlbeans.impl.xb.xsdownload, + org.apache.xmlbeans.impl.xb.xsdownload.impl, + org.apache.xmlbeans.impl.xb.xsdschema, + org.apache.xmlbeans.impl.xb.xsdschema.impl, + org.apache.xmlbeans.impl.xpathgen, + org.apache.xmlbeans.impl.xsd2inst, + org.apache.xmlbeans.soap, + org.apache.xmlbeans.xml.stream, + org.apache.xmlbeans.xml.stream.events, + org.apache.xmlbeans.xml.stream.utils, + org.codehaus.annogen.generate, + org.codehaus.annogen.generate.internal.joust, + org.codehaus.annogen.override, + org.codehaus.annogen.override.internal, + org.codehaus.annogen.override.internal.jam, + org.codehaus.annogen.override.internal.javadoc, + org.codehaus.annogen.override.internal.reflect, + org.codehaus.annogen.view, + org.codehaus.annogen.view.internal, + org.codehaus.annogen.view.internal.jam, + org.codehaus.annogen.view.internal.javadoc, + org.codehaus.annogen.view.internal.reflect, + org.codehaus.jam, + org.codehaus.jam.annotation, + org.codehaus.jam.internal, + org.codehaus.jam.internal.classrefs, + org.codehaus.jam.internal.elements, + org.codehaus.jam.internal.javadoc, + org.codehaus.jam.internal.parser, + org.codehaus.jam.internal.reflect, + org.codehaus.jam.mutable, + org.codehaus.jam.provider, + org.codehaus.jam.visitor, + org.codehaus.jam.xml, + org.ehcache, + org.ehcache.config, + org.ehcache.config.builders, + org.ehcache.config.units, + org.ehcache.core, + org.ehcache.core.collections, + org.ehcache.core.config, + org.ehcache.core.config.store, + org.ehcache.core.events, + org.ehcache.core.exceptions, + org.ehcache.core.internal.resilience, + org.ehcache.core.internal.util, + org.ehcache.core.osgi, + org.ehcache.core.resilience, + org.ehcache.core.spi, + org.ehcache.core.spi.service, + org.ehcache.core.spi.store, + org.ehcache.core.spi.store.events, + org.ehcache.core.spi.store.heap, + org.ehcache.core.spi.store.tiering, + org.ehcache.core.spi.time, + org.ehcache.core.statistics, + org.ehcache.core.store, + org.ehcache.core.util, + org.ehcache.event, + org.ehcache.expiry, + org.ehcache.impl.config.copy, + org.ehcache.impl.config.event, + org.ehcache.impl.config.executor, + org.ehcache.impl.config.loaderwriter, + org.ehcache.impl.config.loaderwriter.writebehind, + org.ehcache.impl.config.persistence, + org.ehcache.impl.config.resilience, + org.ehcache.impl.config.serializer, + org.ehcache.impl.config.store.disk, + org.ehcache.impl.config.store.heap, + org.ehcache.impl.copy, + org.ehcache.impl.events, + org.ehcache.impl.internal, + org.ehcache.impl.internal.classes, + org.ehcache.impl.internal.classes.commonslang, + org.ehcache.impl.internal.classes.commonslang.reflect, + org.ehcache.impl.internal.concurrent, + org.ehcache.impl.internal.events, + org.ehcache.impl.internal.executor, + org.ehcache.impl.internal.loaderwriter.writebehind, + org.ehcache.impl.internal.loaderwriter.writebehind.operations, + org.ehcache.impl.internal.persistence, + org.ehcache.impl.internal.resilience, + org.ehcache.impl.internal.sizeof, + org.ehcache.impl.internal.sizeof.listeners, + org.ehcache.impl.internal.sizeof.listeners.exceptions, + org.ehcache.impl.internal.spi.copy, + org.ehcache.impl.internal.spi.event, + org.ehcache.impl.internal.spi.loaderwriter, + org.ehcache.impl.internal.spi.resilience, + org.ehcache.impl.internal.spi.serialization, + org.ehcache.impl.internal.statistics, + org.ehcache.impl.internal.store, + org.ehcache.impl.internal.store.basic, + org.ehcache.impl.internal.store.disk, + org.ehcache.impl.internal.store.disk.factories, + org.ehcache.impl.internal.store.heap, + org.ehcache.impl.internal.store.heap.holders, + org.ehcache.impl.internal.store.loaderwriter, + org.ehcache.impl.internal.store.offheap, + org.ehcache.impl.internal.store.offheap.factories, + org.ehcache.impl.internal.store.offheap.portability, + org.ehcache.impl.internal.store.tiering, + org.ehcache.impl.internal.util, + org.ehcache.impl.persistence, + org.ehcache.impl.serialization, + org.ehcache.impl.store, + org.ehcache.jsr107, + org.ehcache.jsr107.config, + org.ehcache.jsr107.internal, + org.ehcache.jsr107.internal.tck, + org.ehcache.sizeof, + org.ehcache.sizeof.annotations, + org.ehcache.sizeof.filters, + org.ehcache.sizeof.impl, + org.ehcache.sizeof.util, + org.ehcache.spi.copy, + org.ehcache.spi.loaderwriter, + org.ehcache.spi.persistence, + org.ehcache.spi.resilience, + org.ehcache.spi.serialization, + org.ehcache.spi.service, + org.ehcache.xml, + org.ehcache.xml.exceptions, + org.ehcache.xml.model, + org.ehcache.xml.multi, + org.ehcache.xml.multi.model, + org.ehcache.xml.provider, + org.ehcache.xml.service, + org.etsi.uri.x01903.v13, + org.etsi.uri.x01903.v13.impl, + org.jdesktop.beans, + org.jdesktop.swingx, + org.jdesktop.swingx.action, + org.jdesktop.swingx.auth, + org.jdesktop.swingx.autocomplete, + org.jdesktop.swingx.autocomplete.workarounds, + org.jdesktop.swingx.border, + org.jdesktop.swingx.calendar, + org.jdesktop.swingx.color, + org.jdesktop.swingx.combobox, + org.jdesktop.swingx.decorator, + org.jdesktop.swingx.error, + org.jdesktop.swingx.event, + org.jdesktop.swingx.geom, + org.jdesktop.swingx.graphics, + org.jdesktop.swingx.hyperlink, + org.jdesktop.swingx.icon, + org.jdesktop.swingx.image, + org.jdesktop.swingx.multislider, + org.jdesktop.swingx.multisplitpane, + org.jdesktop.swingx.painter, + org.jdesktop.swingx.painter.effects, + org.jdesktop.swingx.plaf, + org.jdesktop.swingx.plaf.basic, + org.jdesktop.swingx.plaf.basic.core, + org.jdesktop.swingx.plaf.linux, + org.jdesktop.swingx.plaf.macosx, + org.jdesktop.swingx.plaf.metal, + org.jdesktop.swingx.plaf.misc, + org.jdesktop.swingx.plaf.motif, + org.jdesktop.swingx.plaf.nimbus, + org.jdesktop.swingx.plaf.synth, + org.jdesktop.swingx.plaf.windows, + org.jdesktop.swingx.prompt, + org.jdesktop.swingx.renderer, + org.jdesktop.swingx.rollover, + org.jdesktop.swingx.search, + org.jdesktop.swingx.sort, + org.jdesktop.swingx.table, + org.jdesktop.swingx.tips, + org.jdesktop.swingx.tree, + org.jdesktop.swingx.treetable, + org.jdesktop.swingx.util, + org.json, + org.jvnet.fastinfoset, + org.jvnet.fastinfoset.sax, + org.jvnet.fastinfoset.sax.helpers, + org.jvnet.fastinfoset.stax, + org.jvnet.staxex, + org.jvnet.staxex.util, + org.openxmlformats.schemas.drawingml.x2006.chart, + org.openxmlformats.schemas.drawingml.x2006.chart.impl, + org.openxmlformats.schemas.drawingml.x2006.main, + org.openxmlformats.schemas.drawingml.x2006.main.impl, + org.openxmlformats.schemas.drawingml.x2006.picture, + org.openxmlformats.schemas.drawingml.x2006.picture.impl, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing, + org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.impl, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing, + org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.impl, + org.openxmlformats.schemas.officeDocument.x2006.customProperties, + org.openxmlformats.schemas.officeDocument.x2006.customProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes, + org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes.impl, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties, + org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.impl, + org.openxmlformats.schemas.officeDocument.x2006.relationships, + org.openxmlformats.schemas.officeDocument.x2006.relationships.impl, + org.openxmlformats.schemas.presentationml.x2006.main, + org.openxmlformats.schemas.presentationml.x2006.main.impl, + org.openxmlformats.schemas.spreadsheetml.x2006.main, + org.openxmlformats.schemas.spreadsheetml.x2006.main.impl, + org.openxmlformats.schemas.wordprocessingml.x2006.main, + org.openxmlformats.schemas.wordprocessingml.x2006.main.impl, + org.openxmlformats.schemas.xpackage.x2006.digitalSignature, + org.openxmlformats.schemas.xpackage.x2006.digitalSignature.impl, + org.slf4j, + org.slf4j.event, + org.slf4j.helpers, + org.slf4j.spi, + org.terracotta.context, + org.terracotta.context.annotations, + org.terracotta.context.extractor, + org.terracotta.context.query, + org.terracotta.offheapstore, + org.terracotta.offheapstore.buffersource, + org.terracotta.offheapstore.concurrent, + org.terracotta.offheapstore.disk.paging, + org.terracotta.offheapstore.disk.persistent, + org.terracotta.offheapstore.disk.storage, + org.terracotta.offheapstore.disk.storage.portability, + org.terracotta.offheapstore.eviction, + org.terracotta.offheapstore.exceptions, + org.terracotta.offheapstore.paging, + org.terracotta.offheapstore.pinning, + org.terracotta.offheapstore.set, + org.terracotta.offheapstore.storage, + org.terracotta.offheapstore.storage.allocator, + org.terracotta.offheapstore.storage.listener, + org.terracotta.offheapstore.storage.portability, + org.terracotta.offheapstore.util, + org.terracotta.statistics, + org.terracotta.statistics.archive, + org.terracotta.statistics.derived, + org.terracotta.statistics.derived.histogram, + org.terracotta.statistics.derived.latency, + org.terracotta.statistics.observer, + org.terracotta.statistics.registry, + org.w3.x2000.x09.xmldsig, + org.w3.x2000.x09.xmldsig.impl, + repackage, + schemaorg_apache_xmlbeans.system.s8C3F193EE11A2F798ACF65489B9E6078, + schemaorg_apache_xmlbeans.system.sF1327CCA741569E70F9CA8C9AF9B44B2, + schemaorg_apache_xmlbeans.system.sXMLCONFIG, + schemaorg_apache_xmlbeans.system.sXMLLANG, + schemaorg_apache_xmlbeans.system.sXMLSCHEMA, + schemaorg_apache_xmlbeans.system.sXMLTOOLS diff --git a/com.connor.ml.tcm/SCP.properties b/com.connor.ml.tcm/SCP.properties new file mode 100644 index 0000000..e58551c --- /dev/null +++ b/com.connor.ml.tcm/SCP.properties @@ -0,0 +1 @@ +url=http://scpml.changhong.com \ No newline at end of file diff --git a/com.connor.ml.tcm/allib/FastInfoset-1.2.15.jar b/com.connor.ml.tcm/allib/FastInfoset-1.2.15.jar new file mode 100644 index 0000000..2671209 Binary files /dev/null and b/com.connor.ml.tcm/allib/FastInfoset-1.2.15.jar differ diff --git a/com.connor.ml.tcm/allib/cglib-3.1.jar b/com.connor.ml.tcm/allib/cglib-3.1.jar new file mode 100644 index 0000000..25a5df1 Binary files /dev/null and b/com.connor.ml.tcm/allib/cglib-3.1.jar differ diff --git a/com.connor.ml.tcm/allib/com.ibm.icu-4.4.2.jar b/com.connor.ml.tcm/allib/com.ibm.icu-4.4.2.jar new file mode 100644 index 0000000..5261d46 Binary files /dev/null and b/com.connor.ml.tcm/allib/com.ibm.icu-4.4.2.jar differ diff --git a/com.connor.ml.tcm/allib/commons-collections4-4.1.jar b/com.connor.ml.tcm/allib/commons-collections4-4.1.jar new file mode 100644 index 0000000..43a9413 Binary files /dev/null and b/com.connor.ml.tcm/allib/commons-collections4-4.1.jar differ diff --git a/com.connor.ml.tcm/allib/commons-math3-3.6.1.jar b/com.connor.ml.tcm/allib/commons-math3-3.6.1.jar new file mode 100644 index 0000000..0ff582c Binary files /dev/null and b/com.connor.ml.tcm/allib/commons-math3-3.6.1.jar differ diff --git a/com.connor.ml.tcm/allib/easyexcel-2.1.4.jar b/com.connor.ml.tcm/allib/easyexcel-2.1.4.jar new file mode 100644 index 0000000..b14f5f8 Binary files /dev/null and b/com.connor.ml.tcm/allib/easyexcel-2.1.4.jar differ diff --git a/com.connor.ml.tcm/allib/ehcache-3.7.1.jar b/com.connor.ml.tcm/allib/ehcache-3.7.1.jar new file mode 100644 index 0000000..dd0088d Binary files /dev/null and b/com.connor.ml.tcm/allib/ehcache-3.7.1.jar differ diff --git a/com.connor.ml.tcm/allib/fastjson-1.2.76.jar b/com.connor.ml.tcm/allib/fastjson-1.2.76.jar new file mode 100644 index 0000000..c241c1d Binary files /dev/null and b/com.connor.ml.tcm/allib/fastjson-1.2.76.jar differ diff --git a/com.connor.ml.tcm/allib/istack-commons-runtime-3.0.7.jar b/com.connor.ml.tcm/allib/istack-commons-runtime-3.0.7.jar new file mode 100644 index 0000000..2fe5b82 Binary files /dev/null and b/com.connor.ml.tcm/allib/istack-commons-runtime-3.0.7.jar differ diff --git a/com.connor.ml.tcm/allib/javax.activation-api-1.2.0.jar b/com.connor.ml.tcm/allib/javax.activation-api-1.2.0.jar new file mode 100644 index 0000000..986c365 Binary files /dev/null and b/com.connor.ml.tcm/allib/javax.activation-api-1.2.0.jar differ diff --git a/com.connor.ml.tcm/allib/jaxb-runtime-2.3.1.jar b/com.connor.ml.tcm/allib/jaxb-runtime-2.3.1.jar new file mode 100644 index 0000000..0b9ef67 Binary files /dev/null and b/com.connor.ml.tcm/allib/jaxb-runtime-2.3.1.jar differ diff --git a/com.connor.ml.tcm/allib/poi-3.17.jar b/com.connor.ml.tcm/allib/poi-3.17.jar new file mode 100644 index 0000000..353ce76 Binary files /dev/null and b/com.connor.ml.tcm/allib/poi-3.17.jar differ diff --git a/com.connor.ml.tcm/allib/poi-examples-3.17.jar b/com.connor.ml.tcm/allib/poi-examples-3.17.jar new file mode 100644 index 0000000..a923b04 Binary files /dev/null and b/com.connor.ml.tcm/allib/poi-examples-3.17.jar differ diff --git a/com.connor.ml.tcm/allib/poi-excelant-3.17.jar b/com.connor.ml.tcm/allib/poi-excelant-3.17.jar new file mode 100644 index 0000000..da9f5ed Binary files /dev/null and b/com.connor.ml.tcm/allib/poi-excelant-3.17.jar differ diff --git a/com.connor.ml.tcm/allib/poi-ooxml-3.17.jar b/com.connor.ml.tcm/allib/poi-ooxml-3.17.jar new file mode 100644 index 0000000..68086e8 Binary files /dev/null and b/com.connor.ml.tcm/allib/poi-ooxml-3.17.jar differ diff --git a/com.connor.ml.tcm/allib/poi-ooxml-schemas-3.17.jar b/com.connor.ml.tcm/allib/poi-ooxml-schemas-3.17.jar new file mode 100644 index 0000000..2e9b3e7 Binary files /dev/null and b/com.connor.ml.tcm/allib/poi-ooxml-schemas-3.17.jar differ diff --git a/com.connor.ml.tcm/allib/poi-scratchpad-3.17.jar b/com.connor.ml.tcm/allib/poi-scratchpad-3.17.jar new file mode 100644 index 0000000..12ba1f1 Binary files /dev/null and b/com.connor.ml.tcm/allib/poi-scratchpad-3.17.jar differ diff --git a/com.connor.ml.tcm/allib/slf4j-api-1.7.26.jar b/com.connor.ml.tcm/allib/slf4j-api-1.7.26.jar new file mode 100644 index 0000000..d2f27ac Binary files /dev/null and b/com.connor.ml.tcm/allib/slf4j-api-1.7.26.jar differ diff --git a/com.connor.ml.tcm/allib/stax-api-1.0.1.jar b/com.connor.ml.tcm/allib/stax-api-1.0.1.jar new file mode 100644 index 0000000..d9a1665 Binary files /dev/null and b/com.connor.ml.tcm/allib/stax-api-1.0.1.jar differ diff --git a/com.connor.ml.tcm/allib/stax-ex-1.8.jar b/com.connor.ml.tcm/allib/stax-ex-1.8.jar new file mode 100644 index 0000000..5e60637 Binary files /dev/null and b/com.connor.ml.tcm/allib/stax-ex-1.8.jar differ diff --git a/com.connor.ml.tcm/allib/txw2-2.3.1.jar b/com.connor.ml.tcm/allib/txw2-2.3.1.jar new file mode 100644 index 0000000..75ed519 Binary files /dev/null and b/com.connor.ml.tcm/allib/txw2-2.3.1.jar differ diff --git a/com.connor.ml.tcm/allib/xmlbeans-2.6.0.jar b/com.connor.ml.tcm/allib/xmlbeans-2.6.0.jar new file mode 100644 index 0000000..d1b6627 Binary files /dev/null and b/com.connor.ml.tcm/allib/xmlbeans-2.6.0.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/activation-1.1.jar b/com.connor.ml.tcm/axis2_lib/activation-1.1.jar new file mode 100644 index 0000000..53f82a1 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/activation-1.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/annogen-0.1.0.jar b/com.connor.ml.tcm/axis2_lib/annogen-0.1.0.jar new file mode 100644 index 0000000..869ea95 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/annogen-0.1.0.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axiom-api-1.2.7.jar b/com.connor.ml.tcm/axis2_lib/axiom-api-1.2.7.jar new file mode 100644 index 0000000..7ff5072 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axiom-api-1.2.7.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axiom-dom-1.2.7.jar b/com.connor.ml.tcm/axis2_lib/axiom-dom-1.2.7.jar new file mode 100644 index 0000000..5a30fe9 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axiom-dom-1.2.7.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axiom-impl-1.2.7.jar b/com.connor.ml.tcm/axis2_lib/axiom-impl-1.2.7.jar new file mode 100644 index 0000000..d6ab571 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axiom-impl-1.2.7.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-adb-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-adb-1.4.1.jar new file mode 100644 index 0000000..1a13e3e Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-adb-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-adb-codegen-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-adb-codegen-1.4.1.jar new file mode 100644 index 0000000..cb5221a Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-adb-codegen-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-ant-plugin-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-ant-plugin-1.4.1.jar new file mode 100644 index 0000000..0689058 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-ant-plugin-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-clustering-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-clustering-1.4.1.jar new file mode 100644 index 0000000..687ba6d Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-clustering-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-codegen-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-codegen-1.4.1.jar new file mode 100644 index 0000000..d2dcad1 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-codegen-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-corba-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-corba-1.4.1.jar new file mode 100644 index 0000000..543a796 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-corba-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-fastinfoset-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-fastinfoset-1.4.1.jar new file mode 100644 index 0000000..400cb48 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-fastinfoset-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-java2wsdl-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-java2wsdl-1.4.1.jar new file mode 100644 index 0000000..7031ad3 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-java2wsdl-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-jaxbri-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-jaxbri-1.4.1.jar new file mode 100644 index 0000000..2654a92 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-jaxbri-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-jaxws-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-jaxws-1.4.1.jar new file mode 100644 index 0000000..388b087 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-jaxws-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-jaxws-api-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-jaxws-api-1.4.1.jar new file mode 100644 index 0000000..7cf2e8e Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-jaxws-api-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-jibx-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-jibx-1.4.1.jar new file mode 100644 index 0000000..ba03475 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-jibx-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-json-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-json-1.4.1.jar new file mode 100644 index 0000000..20762d5 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-json-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-jws-api-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-jws-api-1.4.1.jar new file mode 100644 index 0000000..b7694d1 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-jws-api-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-kernel-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-kernel-1.4.1.jar new file mode 100644 index 0000000..dff9bb8 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-kernel-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-metadata-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-metadata-1.4.1.jar new file mode 100644 index 0000000..1390bbe Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-metadata-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-mtompolicy-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-mtompolicy-1.4.1.jar new file mode 100644 index 0000000..e9b82c3 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-mtompolicy-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-saaj-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-saaj-1.4.1.jar new file mode 100644 index 0000000..714b248 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-saaj-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-saaj-api-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-saaj-api-1.4.1.jar new file mode 100644 index 0000000..b032540 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-saaj-api-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-spring-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-spring-1.4.1.jar new file mode 100644 index 0000000..f9f2e29 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-spring-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/axis2-xmlbeans-1.4.1.jar b/com.connor.ml.tcm/axis2_lib/axis2-xmlbeans-1.4.1.jar new file mode 100644 index 0000000..43f6c72 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/axis2-xmlbeans-1.4.1.jar differ diff --git a/com.connor.ml.tcm/axis2_lib/backport-util-concurrent-3.1.jar b/com.connor.ml.tcm/axis2_lib/backport-util-concurrent-3.1.jar new file mode 100644 index 0000000..3a4c279 Binary files /dev/null and b/com.connor.ml.tcm/axis2_lib/backport-util-concurrent-3.1.jar differ diff --git a/com.connor.ml.tcm/bin/.gitignore b/com.connor.ml.tcm/bin/.gitignore new file mode 100644 index 0000000..c2d9872 --- /dev/null +++ b/com.connor.ml.tcm/bin/.gitignore @@ -0,0 +1 @@ +/com/ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/exportExcel/TCUtil.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/exportExcel/TCUtil.class new file mode 100644 index 0000000..3277880 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/exportExcel/TCUtil.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/DbPool.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/DbPool.class new file mode 100644 index 0000000..7ed9524 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/DbPool.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SAPConn.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SAPConn.class new file mode 100644 index 0000000..0bbaaf4 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SAPConn.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SelectDialog.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SelectDialog.class new file mode 100644 index 0000000..effe149 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SelectDialog.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomOperation.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomOperation.class new file mode 100644 index 0000000..22d8222 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomOperation.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomSapDialog.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomSapDialog.class new file mode 100644 index 0000000..2c2769e Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomSapDialog.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomSapHandler.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomSapHandler.class new file mode 100644 index 0000000..3791305 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendBomSapHandler.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapBomBean.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapBomBean.class new file mode 100644 index 0000000..3d506b1 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapBomBean.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapBomChildBean.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapBomChildBean.class new file mode 100644 index 0000000..9095827 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapBomChildBean.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapDisopBean.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapDisopBean.class new file mode 100644 index 0000000..1b9a411 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/SendSapDisopBean.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/utils.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/utils.class new file mode 100644 index 0000000..3351308 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/sendBomSap/utils.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KAction.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KAction.class new file mode 100644 index 0000000..ff7b8b1 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KAction.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KCommand.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KCommand.class new file mode 100644 index 0000000..a854268 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KCommand.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KHandler.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KHandler.class new file mode 100644 index 0000000..5bbb856 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KHandler.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KLocale.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KLocale.class new file mode 100644 index 0000000..4cfeb20 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KLocale.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KOperation.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KOperation.class new file mode 100644 index 0000000..1e03ce8 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KOperation.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KOperation2.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KOperation2.class new file mode 100644 index 0000000..5862b31 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KOperation2.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KUtil.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KUtil.class new file mode 100644 index 0000000..534e1e1 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/KUtil.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/ProgressBar.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/ProgressBar.class new file mode 100644 index 0000000..bef911e Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/ProgressBar.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/TCM01Command.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/TCM01Command.class new file mode 100644 index 0000000..2629789 Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/TCM01Command.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/TCM01Operation.class b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/TCM01Operation.class new file mode 100644 index 0000000..5d5529f Binary files /dev/null and b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/TCM01Operation.class differ diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/k_locale.properties b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/k_locale.properties new file mode 100644 index 0000000..ac8931f --- /dev/null +++ b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/k_locale.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=Project +dsuidinpref.ERROR1=Error dataset uid set in preference\: %s +valuenotinlov.ERROR2=LOV "%s" does not contain value\: %s +writedata=Write Data +querynotexist.ERROR1=Query not exist\: %s +dialoginit.ERROR=Init Error +preferror.ERROR1=Preference error\: %s +norefindataset.ERROR1=Download file from dataset "%s" failed. No ref file. +cancel=Cancel +exeop.STATUS=Execute... +initop.STATUS=Checking Data... +noflowkey.ERROR=Missing key for flow number. +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=Property is not defined in type "%s"\: %s. +getflowno.ERROR1=Error getting new flow number for key\: %s +formsave.ERRORTITLE=Error Saving Data +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=Title row in sheet does not have any relation info. +selectProject=Select Project +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=Can't find title row in excel sheet. +loadCompFromUid.Error2=Error loading component "%s", UID \= "%s". +uploadfilewhencheckout.ERROR1=Dataset "%s" is checked out. Upload file failed. +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=No Data in File\: %s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=Error +mergefile=Merge File... +index=Index +forminit.ERRORTITLE=Error Loading Rendering +ok=OK +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=Find multiple users by id\: %s +preparedata=Prepare Data +dbconn.ERROR=Connect to database failed. +typenotfound.ERROR1=Type not found\: %s +filenotexist.ERROR1=File not exist\: %s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=Read Data +clearcache=Clear Cache +exportsuccess.INFO=Export Complete. +uploadfile=Upload File +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=Folder not exist\: %s +info=Info +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=Find multiple users by name\: %s +exportopenfile.INFO=Export complete. Open file? +prefnotconfiged.ERROR1=Prefernce not found\: %s +export=Export diff --git a/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/k_locale_zh_CN.properties b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/k_locale_zh_CN.properties new file mode 100644 index 0000000..902d489 --- /dev/null +++ b/com.connor.ml.tcm/bin/cn/net/connor/ml/plm/tcm/k_locale_zh_CN.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=\u9879\u76EE +dsuidinpref.ERROR1=\u8BF7\u68C0\u67E5\u9996\u9009\u9879<%s>\uFF0C\u901A\u8FC7\u914D\u7F6EUID\u672A\u627E\u5230\u6570\u636E\u96C6 +valuenotinlov.ERROR2=LOV "%s" \u4E2D\u672A\u5B9A\u4E49\u6570\u503C\uFF1A%s +writedata=\u5199\u5165\u6570\u636E +querynotexist.ERROR1=\u67E5\u8BE2\u4E0D\u5B58\u5728\uFF1A%s +dialoginit.ERROR=\u521D\u59CB\u5316\u5F02\u5E38 +preferror.ERROR1=\u9996\u9009\u9879\u914D\u7F6E\u9519\u8BEF\uFF1A%s +norefindataset.ERROR1=\u4ECE\u6570\u636E\u96C6\u201C%s\u201D\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25\uFF0C\u6CA1\u6709\u627E\u5230\u5F15\u7528\u6587\u4EF6\u3002 +cancel=\u53D6\u6D88 +exeop.STATUS=\u6B63\u5728\u6267\u884C... +initop.STATUS=\u68C0\u67E5\u6570\u636E... +noflowkey.ERROR=\u6D41\u6C34\u7801\u952E\u503C\u4E0D\u53EF\u4E3A\u7A7A +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u4E0D\u5B58\u5728\u5C5E\u6027\uFF1A%s +getflowno.ERROR1=\u83B7\u53D6\u6D41\u6C34\u7801\u5931\u8D25\uFF1A%s +formsave.ERRORTITLE=\u4FDD\u5B58\u6570\u636E\u51FA\u9519 +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=\u6807\u9898\u884C\u6CA1\u6709\u89E3\u6790\u5230\u6620\u5C04\u5185\u5BB9 +selectProject=\u9009\u62E9\u9879\u76EE +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=\u672A\u627E\u5230\u5DE5\u4F5C\u8868\u4E2D\u7684\u6807\u9898\u884C +loadCompFromUid.Error2=\u52A0\u8F7D\u5BF9\u8C61\u201C%s\u201D\u5931\u8D25\uFF0CUID\=\u201C%s\u201D\u3002 +uploadfilewhencheckout.ERROR1=\u6570\u636E\u96C6\u201C%s\u201D\u5DF2\u7B7E\u51FA\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\u3002\u8BF7\u7B7E\u5165\u540E\u518D\u8FDB\u884C\u64CD\u4F5C\u3002 +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=\u6587\u4EF6\u4E2D\u6CA1\u6709\u6570\u636E\uFF1A%s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=\u9519\u8BEF +mergefile=\u5408\u5E76\u6587\u4EF6 +index=\u5E8F\u53F7 +forminit.ERRORTITLE=\u521D\u59CB\u5316\u754C\u9762\u5F02\u5E38 +ok=\u786E\u5B9A +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=\u901A\u8FC7id\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +preparedata=\u51C6\u5907\u6570\u636E +dbconn.ERROR=\u8FDE\u63A5\u6570\u636E\u5E93\u5931\u8D25\u3002 +typenotfound.ERROR1=\u672A\u627E\u5230\u7C7B\u578B\uFF1A%s +filenotexist.ERROR1=\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A%s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=\u8BFB\u53D6\u6570\u636E +clearcache=\u6E05\u7406\u7F13\u5B58 +exportsuccess.INFO=\u5BFC\u51FA\u5B8C\u6210 +uploadfile=\u4E0A\u4F20\u6587\u4EF6 +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A%s +info=\u63D0\u793A +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=\u901A\u8FC7\u59D3\u540D\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +exportopenfile.INFO=\u5BFC\u51FA\u5B8C\u6210\uFF0C\u6253\u5F00\u6587\u4EF6\uFF1F +prefnotconfiged.ERROR1=\u672A\u914D\u7F6E\u9996\u9009\u9879\uFF1A%s +export=\u5BFC\u51FA diff --git a/com.connor.ml.tcm/bin/plm.properties b/com.connor.ml.tcm/bin/plm.properties new file mode 100644 index 0000000..d6a7cfe --- /dev/null +++ b/com.connor.ml.tcm/bin/plm.properties @@ -0,0 +1,7 @@ +EXCEL3.SQL=SELECT DISTINCT p1.puid, p3.pcreation_date, CASE WHEN p4.pitem_revision_id = 'A' AND p7.pname IN ('ML8_SXFB', 'ML8_JGFB') THEN p4.puid ELSE p4.puid END AS puid FROM PITEM p1 INNER JOIN PWORKSPACEOBJECT p2 ON p1.puid = p2.puid AND p2.pobject_type = 'ML8_Part' AND ( SELECT count(puid) FROM PPSOCCURRENCE WHERE rchild_itemu = p2.puid ) = 0 INNER JOIN PPOM_APPLICATION_OBJECT p3 ON p1.puid = p3.puid AND p3.pcreation_date < ( SELECT CONVERT( varchar(70), dateadd(MONTH, -2, CAST(GETDATE() AS datetime)), 21 )) INNER JOIN PITEMREVISION p4 ON p1.puid = p4.ritems_tagu AND p4.pitem_revision_id =( SELECT max(pitem_revision_id) AS item_revision_id FROM PITEMREVISION WHERE ritems_tagu = p1.puid GROUP BY ritems_tagu ) INNER JOIN PML8_PART p5 ON p1.puid = p5.puid AND p5.pml8_Status IN (?, ?, ?) INNER JOIN PRELEASE_STATUS_LIST p6 ON p4.puid = p6.puid INNER JOIN PRELEASESTATUS p7 ON p6.pvalu_0 = p7.puid +EXCEL4.SQL=SELECT DISTINCT ritems_tagu FROM ( SELECT T7.pname, isnull(T9.pml8_Status, '') pml8_Status, T1.ritems_tagu, T4.puid, CASE WHEN T7.pname IN('ML8_Replaced', 'ML8_Freeze') AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others')THEN 'ok' WHEN (pml8_Status = ? OR T7.pname = 'ML8_Replaced') AND T8.pobject_type = 'ML8_Part' THEN 'ok' ELSE 'no' END OTHERS FROM AAA T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.ritems_tagu INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid INNER JOIN PRELEASE_STATUS_LIST T6 ON T5.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid INNER JOIN PWORKSPACEOBJECT T8 ON T5.ritems_tagu = T8.puid AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others', 'ML8_Part') LEFT JOIN PML8_PART T9 ON T5.ritems_tagu = T9.puid) TTT1 WHERE OTHERS = 'ok' AND ritems_tagu NOT IN( SELECT DISTINCT ritems_tagu FROM ( SELECT T7.pname, isnull(T9.pml8_Status, '') pml8_Status, T1.ritems_tagu, T4.puid, CASE WHEN T7.pname IN('ML8_Replaced', 'ML8_Freeze') AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others')THEN 'ok' WHEN (pml8_Status = ? OR T7.pname = 'ML8_Replaced') AND T8.pobject_type = 'ML8_Part' THEN 'ok' ELSE 'no' END OTHERS FROM AAA T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.ritems_tagu INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid INNER JOIN PRELEASE_STATUS_LIST T6 ON T5.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid INNER JOIN PWORKSPACEOBJECT T8 ON T5.ritems_tagu = T8.puid AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others', 'ML8_Part') LEFT JOIN PML8_PART T9 ON T5.ritems_tagu = T9.puid) sss WHERE OTHERS = 'no') GROUP BY ritems_tagu +EXCEL5.SQL=WITH TEMP AS( SELECT T5.ritems_tagu AS parent_uid FROM ( SELECT * FROM PITEM WHERE puid = ? ) T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.puid INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid UNION ALL SELECT T5.ritems_tagu AS parent_uid FROM TEMP A INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = A.parent_uid INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid) SELECT DISTINCT * FROM TEMP +#截图比例原理:由宽度来产生对应比例的高度 +#截图比例:x/y (HEIGHT=WIDTH*y/x) +IMAGE.WIDTH=7 +IMAGE.HEIGHT=5 \ No newline at end of file diff --git a/com.connor.ml.tcm/bin/sql.properties b/com.connor.ml.tcm/bin/sql.properties new file mode 100644 index 0000000..9c521ac --- /dev/null +++ b/com.connor.ml.tcm/bin/sql.properties @@ -0,0 +1,2 @@ +ML_WEBSERVICE_LOGINSERTSQL=INSERT INTO ML_WEBSERVICE_LOG (NAME,JSON,CREATE_DATE,TYPE) VALUES(\'%s\',\'%s\',\'%s\',\'%s\') +ML_TCMSENDSAPBOMINSERTSQL=INSERT INTO ML_TCMSENDSAPBOM VALUES (\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\') \ No newline at end of file diff --git a/com.connor.ml.tcm/bin/sqlconn.properties b/com.connor.ml.tcm/bin/sqlconn.properties new file mode 100644 index 0000000..956ac8d --- /dev/null +++ b/com.connor.ml.tcm/bin/sqlconn.properties @@ -0,0 +1,9 @@ +#DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +#Connection=jdbc:sqlserver://10.18.1.100:1433; DatabaseName=TC +#User=infodba +#Password=Plm_8023 + +DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +Connection=jdbc:sqlserver://10.18.1.100:1433; DatabaseName=TC +User=infodba +Password=Plm_8023 \ No newline at end of file diff --git a/com.connor.ml.tcm/bin/toERP.properties b/com.connor.ml.tcm/bin/toERP.properties new file mode 100644 index 0000000..0911e10 --- /dev/null +++ b/com.connor.ml.tcm/bin/toERP.properties @@ -0,0 +1,6 @@ +#url=http://mlapp.meiling.com/plmwebapi/sap/setinfo +#涓枃闇瑕佺敤unicode +#娴嬭瘯绯荤粺 +#infoname=\u6d4b\u8bd5\u7cfb\u7edf +#姝e紡绯荤粺 +infoname=\u6b63\u5f0f\u7cfb\u7edf \ No newline at end of file diff --git a/com.connor.ml.tcm/build.properties b/com.connor.ml.tcm/build.properties new file mode 100644 index 0000000..11e9aea --- /dev/null +++ b/com.connor.ml.tcm/build.properties @@ -0,0 +1,100 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + icons/,\ + sql.properties,\ + sqlconn.properties,\ + src/com/teamcenter/,\ + allib/cglib-3.1.jar,\ + allib/com.ibm.icu-4.4.2.jar,\ + allib/commons-collections4-4.1.jar,\ + allib/commons-math3-3.6.1.jar,\ + allib/easyexcel-2.1.4.jar,\ + allib/ehcache-3.7.1.jar,\ + allib/FastInfoset-1.2.15.jar,\ + allib/fastjson-1.2.76.jar,\ + allib/istack-commons-runtime-3.0.7.jar,\ + allib/javax.activation-api-1.2.0.jar,\ + allib/jaxb-runtime-2.3.1.jar,\ + allib/poi-3.17.jar,\ + allib/poi-examples-3.17.jar,\ + allib/poi-excelant-3.17.jar,\ + allib/poi-ooxml-3.17.jar,\ + allib/poi-ooxml-schemas-3.17.jar,\ + allib/poi-scratchpad-3.17.jar,\ + allib/slf4j-api-1.7.26.jar,\ + allib/stax-api-1.0.1.jar,\ + allib/stax-ex-1.8.jar,\ + allib/txw2-2.3.1.jar,\ + allib/xmlbeans-2.6.0.jar,\ + axis2_lib/activation-1.1.jar,\ + axis2_lib/annogen-0.1.0.jar,\ + axis2_lib/axiom-api-1.2.7.jar,\ + axis2_lib/axiom-dom-1.2.7.jar,\ + axis2_lib/axiom-impl-1.2.7.jar,\ + axis2_lib/axis2-adb-1.4.1.jar,\ + axis2_lib/axis2-adb-codegen-1.4.1.jar,\ + axis2_lib/axis2-ant-plugin-1.4.1.jar,\ + axis2_lib/axis2-clustering-1.4.1.jar,\ + axis2_lib/axis2-codegen-1.4.1.jar,\ + axis2_lib/axis2-corba-1.4.1.jar,\ + axis2_lib/axis2-fastinfoset-1.4.1.jar,\ + axis2_lib/axis2-java2wsdl-1.4.1.jar,\ + axis2_lib/axis2-jaxbri-1.4.1.jar,\ + axis2_lib/axis2-jaxws-1.4.1.jar,\ + axis2_lib/axis2-jaxws-api-1.4.1.jar,\ + axis2_lib/axis2-jibx-1.4.1.jar,\ + axis2_lib/axis2-json-1.4.1.jar,\ + axis2_lib/axis2-jws-api-1.4.1.jar,\ + axis2_lib/axis2-kernel-1.4.1.jar,\ + axis2_lib/axis2-metadata-1.4.1.jar,\ + axis2_lib/axis2-mtompolicy-1.4.1.jar,\ + axis2_lib/axis2-saaj-1.4.1.jar,\ + axis2_lib/axis2-saaj-api-1.4.1.jar,\ + axis2_lib/axis2-spring-1.4.1.jar,\ + axis2_lib/axis2-xmlbeans-1.4.1.jar,\ + lib/Cat2errormessagehandler.jar,\ + lib/Cat2journaling.jar,\ + lib/Cat2tciccommon.jar,\ + lib/classes12.jar,\ + lib/commons-beanutils-1.7.0.jar,\ + lib/commons-codec-1.3.jar,\ + lib/commons-collections-3.2.jar,\ + lib/commons-httpclient-3.1.jar,\ + lib/commons-lang-2.4.jar,\ + lib/commons-logging-1.1.jar,\ + lib/ezmorph-1.0.4.jar,\ + lib/httpclient-4.5.10.jar,\ + lib/httpcore-4.4.12.jar,\ + lib/httpmime-4.5.10.jar,\ + lib/itextpdf-5.5.3.jar,\ + lib/jacob.jar,\ + lib/jaxrpc.jar,\ + lib/json-lib-2.2.2-jdk15.jar,\ + lib/json-lib-2.2.3-jdk13.jar,\ + lib/json-org.jar,\ + lib/mailapi.jar,\ + lib/msbase.jar,\ + lib/mssqlserver.jar,\ + lib/msutil.jar,\ + lib/neethi-3.0.2.jar,\ + lib/ojdbc5.jar,\ + lib/saaj.jar,\ + lib/sapjco3.jar,\ + lib/sqljdbc4.jar,\ + lib/swingx-1.6.1.jar,\ + lib/woden-core-1.0M10.jar,\ + lib/wsdl4j-1.6.2.jar,\ + lib/xmlschema-core-2.2.1.jar,\ + lib/xmlsec.jar,\ + axis2_lib/backport-util-concurrent-3.1.jar,\ + .,\ + lib/Spire.Xls.jar,\ + lib/gson-2.9.0.jar,\ + SCP.properties,\ + lib/itext-2.0.3.jar,\ + lib/iText-5.0.2.jar,\ + lib/iTextAsian.jar,\ + lib/iTextAsianCmaps.jar +source.. = src/ diff --git a/com.connor.ml.tcm/com.teamcenter.rac.common_13000.1.0.jar b/com.connor.ml.tcm/com.teamcenter.rac.common_13000.1.0.jar new file mode 100644 index 0000000..7581bc4 Binary files /dev/null and b/com.connor.ml.tcm/com.teamcenter.rac.common_13000.1.0.jar differ diff --git a/com.connor.ml.tcm/icons/eclipse128.png b/com.connor.ml.tcm/icons/eclipse128.png new file mode 100644 index 0000000..11b6f46 Binary files /dev/null and b/com.connor.ml.tcm/icons/eclipse128.png differ diff --git a/com.connor.ml.tcm/icons/eclipse16.png b/com.connor.ml.tcm/icons/eclipse16.png new file mode 100644 index 0000000..7fc6951 Binary files /dev/null and b/com.connor.ml.tcm/icons/eclipse16.png differ diff --git a/com.connor.ml.tcm/icons/eclipse256.png b/com.connor.ml.tcm/icons/eclipse256.png new file mode 100644 index 0000000..7e5bbdc Binary files /dev/null and b/com.connor.ml.tcm/icons/eclipse256.png differ diff --git a/com.connor.ml.tcm/icons/eclipse32.png b/com.connor.ml.tcm/icons/eclipse32.png new file mode 100644 index 0000000..bf85680 Binary files /dev/null and b/com.connor.ml.tcm/icons/eclipse32.png differ diff --git a/com.connor.ml.tcm/icons/eclipse48.png b/com.connor.ml.tcm/icons/eclipse48.png new file mode 100644 index 0000000..f9706a7 Binary files /dev/null and b/com.connor.ml.tcm/icons/eclipse48.png differ diff --git a/com.connor.ml.tcm/icons/eclipse512.png b/com.connor.ml.tcm/icons/eclipse512.png new file mode 100644 index 0000000..825137f Binary files /dev/null and b/com.connor.ml.tcm/icons/eclipse512.png differ diff --git a/com.connor.ml.tcm/icons/eclipse64.png b/com.connor.ml.tcm/icons/eclipse64.png new file mode 100644 index 0000000..5a5df2d Binary files /dev/null and b/com.connor.ml.tcm/icons/eclipse64.png differ diff --git a/com.connor.ml.tcm/lib/Cat2errormessagehandler.jar b/com.connor.ml.tcm/lib/Cat2errormessagehandler.jar new file mode 100644 index 0000000..f7bc140 Binary files /dev/null and b/com.connor.ml.tcm/lib/Cat2errormessagehandler.jar differ diff --git a/com.connor.ml.tcm/lib/Cat2journaling.jar b/com.connor.ml.tcm/lib/Cat2journaling.jar new file mode 100644 index 0000000..a3d450e Binary files /dev/null and b/com.connor.ml.tcm/lib/Cat2journaling.jar differ diff --git a/com.connor.ml.tcm/lib/Cat2tciccommon.jar b/com.connor.ml.tcm/lib/Cat2tciccommon.jar new file mode 100644 index 0000000..3c231ae Binary files /dev/null and b/com.connor.ml.tcm/lib/Cat2tciccommon.jar differ diff --git a/com.connor.ml.tcm/lib/Spire.Xls.jar b/com.connor.ml.tcm/lib/Spire.Xls.jar new file mode 100644 index 0000000..2d1af62 Binary files /dev/null and b/com.connor.ml.tcm/lib/Spire.Xls.jar differ diff --git a/com.connor.ml.tcm/lib/classes12.jar b/com.connor.ml.tcm/lib/classes12.jar new file mode 100644 index 0000000..9eaf0b4 Binary files /dev/null and b/com.connor.ml.tcm/lib/classes12.jar differ diff --git a/com.connor.ml.tcm/lib/commons-beanutils-1.7.0.jar b/com.connor.ml.tcm/lib/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/com.connor.ml.tcm/lib/commons-beanutils-1.7.0.jar differ diff --git a/com.connor.ml.tcm/lib/commons-codec-1.3.jar b/com.connor.ml.tcm/lib/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/com.connor.ml.tcm/lib/commons-codec-1.3.jar differ diff --git a/com.connor.ml.tcm/lib/commons-collections-3.2.jar b/com.connor.ml.tcm/lib/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/com.connor.ml.tcm/lib/commons-collections-3.2.jar differ diff --git a/com.connor.ml.tcm/lib/commons-httpclient-3.1.jar b/com.connor.ml.tcm/lib/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/com.connor.ml.tcm/lib/commons-httpclient-3.1.jar differ diff --git a/com.connor.ml.tcm/lib/commons-lang-2.4.jar b/com.connor.ml.tcm/lib/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/com.connor.ml.tcm/lib/commons-lang-2.4.jar differ diff --git a/com.connor.ml.tcm/lib/commons-logging-1.1.jar b/com.connor.ml.tcm/lib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/com.connor.ml.tcm/lib/commons-logging-1.1.jar differ diff --git a/com.connor.ml.tcm/lib/ezmorph-1.0.4.jar b/com.connor.ml.tcm/lib/ezmorph-1.0.4.jar new file mode 100644 index 0000000..7625af6 Binary files /dev/null and b/com.connor.ml.tcm/lib/ezmorph-1.0.4.jar differ diff --git a/com.connor.ml.tcm/lib/gson-2.9.0.jar b/com.connor.ml.tcm/lib/gson-2.9.0.jar new file mode 100644 index 0000000..fb62e05 Binary files /dev/null and b/com.connor.ml.tcm/lib/gson-2.9.0.jar differ diff --git a/com.connor.ml.tcm/lib/httpclient-4.5.10.jar b/com.connor.ml.tcm/lib/httpclient-4.5.10.jar new file mode 100644 index 0000000..d0c7821 Binary files /dev/null and b/com.connor.ml.tcm/lib/httpclient-4.5.10.jar differ diff --git a/com.connor.ml.tcm/lib/httpcore-4.4.12.jar b/com.connor.ml.tcm/lib/httpcore-4.4.12.jar new file mode 100644 index 0000000..1838672 Binary files /dev/null and b/com.connor.ml.tcm/lib/httpcore-4.4.12.jar differ diff --git a/com.connor.ml.tcm/lib/httpmime-4.5.10.jar b/com.connor.ml.tcm/lib/httpmime-4.5.10.jar new file mode 100644 index 0000000..0fae6d0 Binary files /dev/null and b/com.connor.ml.tcm/lib/httpmime-4.5.10.jar differ diff --git a/com.connor.ml.tcm/lib/iText-5.0.2.jar b/com.connor.ml.tcm/lib/iText-5.0.2.jar new file mode 100644 index 0000000..ed95653 Binary files /dev/null and b/com.connor.ml.tcm/lib/iText-5.0.2.jar differ diff --git a/com.connor.ml.tcm/lib/iTextAsian.jar b/com.connor.ml.tcm/lib/iTextAsian.jar new file mode 100644 index 0000000..3fa2157 Binary files /dev/null and b/com.connor.ml.tcm/lib/iTextAsian.jar differ diff --git a/com.connor.ml.tcm/lib/iTextAsianCmaps.jar b/com.connor.ml.tcm/lib/iTextAsianCmaps.jar new file mode 100644 index 0000000..aa2b429 Binary files /dev/null and b/com.connor.ml.tcm/lib/iTextAsianCmaps.jar differ diff --git a/com.connor.ml.tcm/lib/itext-2.0.3.jar b/com.connor.ml.tcm/lib/itext-2.0.3.jar new file mode 100644 index 0000000..3c0f688 Binary files /dev/null and b/com.connor.ml.tcm/lib/itext-2.0.3.jar differ diff --git a/com.connor.ml.tcm/lib/itextpdf-5.5.3.jar b/com.connor.ml.tcm/lib/itextpdf-5.5.3.jar new file mode 100644 index 0000000..41d331b Binary files /dev/null and b/com.connor.ml.tcm/lib/itextpdf-5.5.3.jar differ diff --git a/com.connor.ml.tcm/lib/jacob.jar b/com.connor.ml.tcm/lib/jacob.jar new file mode 100644 index 0000000..926df65 Binary files /dev/null and b/com.connor.ml.tcm/lib/jacob.jar differ diff --git a/com.connor.ml.tcm/lib/jaxrpc.jar b/com.connor.ml.tcm/lib/jaxrpc.jar new file mode 100644 index 0000000..3af30d0 Binary files /dev/null and b/com.connor.ml.tcm/lib/jaxrpc.jar differ diff --git a/com.connor.ml.tcm/lib/json-lib-2.2.2-jdk15.jar b/com.connor.ml.tcm/lib/json-lib-2.2.2-jdk15.jar new file mode 100644 index 0000000..27e7c7c Binary files /dev/null and b/com.connor.ml.tcm/lib/json-lib-2.2.2-jdk15.jar differ diff --git a/com.connor.ml.tcm/lib/json-lib-2.2.3-jdk13.jar b/com.connor.ml.tcm/lib/json-lib-2.2.3-jdk13.jar new file mode 100644 index 0000000..a6513db Binary files /dev/null and b/com.connor.ml.tcm/lib/json-lib-2.2.3-jdk13.jar differ diff --git a/com.connor.ml.tcm/lib/json-org.jar b/com.connor.ml.tcm/lib/json-org.jar new file mode 100644 index 0000000..21e09db Binary files /dev/null and b/com.connor.ml.tcm/lib/json-org.jar differ diff --git a/com.connor.ml.tcm/lib/mailapi.jar b/com.connor.ml.tcm/lib/mailapi.jar new file mode 100644 index 0000000..0b494b8 Binary files /dev/null and b/com.connor.ml.tcm/lib/mailapi.jar differ diff --git a/com.connor.ml.tcm/lib/msbase.jar b/com.connor.ml.tcm/lib/msbase.jar new file mode 100644 index 0000000..0e8bff2 Binary files /dev/null and b/com.connor.ml.tcm/lib/msbase.jar differ diff --git a/com.connor.ml.tcm/lib/mssqlserver.jar b/com.connor.ml.tcm/lib/mssqlserver.jar new file mode 100644 index 0000000..d70d63f Binary files /dev/null and b/com.connor.ml.tcm/lib/mssqlserver.jar differ diff --git a/com.connor.ml.tcm/lib/msutil.jar b/com.connor.ml.tcm/lib/msutil.jar new file mode 100644 index 0000000..db9d0f9 Binary files /dev/null and b/com.connor.ml.tcm/lib/msutil.jar differ diff --git a/com.connor.ml.tcm/lib/neethi-3.0.2.jar b/com.connor.ml.tcm/lib/neethi-3.0.2.jar new file mode 100644 index 0000000..383efde Binary files /dev/null and b/com.connor.ml.tcm/lib/neethi-3.0.2.jar differ diff --git a/com.connor.ml.tcm/lib/ojdbc5.jar b/com.connor.ml.tcm/lib/ojdbc5.jar new file mode 100644 index 0000000..ceb1f0f Binary files /dev/null and b/com.connor.ml.tcm/lib/ojdbc5.jar differ diff --git a/com.connor.ml.tcm/lib/saaj.jar b/com.connor.ml.tcm/lib/saaj.jar new file mode 100644 index 0000000..a23b03e Binary files /dev/null and b/com.connor.ml.tcm/lib/saaj.jar differ diff --git a/com.connor.ml.tcm/lib/sapjco3.jar b/com.connor.ml.tcm/lib/sapjco3.jar new file mode 100644 index 0000000..a83319b Binary files /dev/null and b/com.connor.ml.tcm/lib/sapjco3.jar differ diff --git a/com.connor.ml.tcm/lib/sqljdbc4.jar b/com.connor.ml.tcm/lib/sqljdbc4.jar new file mode 100644 index 0000000..d6b7f6d Binary files /dev/null and b/com.connor.ml.tcm/lib/sqljdbc4.jar differ diff --git a/com.connor.ml.tcm/lib/swingx-1.6.1.jar b/com.connor.ml.tcm/lib/swingx-1.6.1.jar new file mode 100644 index 0000000..b0bcc87 Binary files /dev/null and b/com.connor.ml.tcm/lib/swingx-1.6.1.jar differ diff --git a/com.connor.ml.tcm/lib/woden-core-1.0M10.jar b/com.connor.ml.tcm/lib/woden-core-1.0M10.jar new file mode 100644 index 0000000..9777ad9 Binary files /dev/null and b/com.connor.ml.tcm/lib/woden-core-1.0M10.jar differ diff --git a/com.connor.ml.tcm/lib/wsdl4j-1.6.2.jar b/com.connor.ml.tcm/lib/wsdl4j-1.6.2.jar new file mode 100644 index 0000000..b9ffc36 Binary files /dev/null and b/com.connor.ml.tcm/lib/wsdl4j-1.6.2.jar differ diff --git a/com.connor.ml.tcm/lib/xmlschema-core-2.2.1.jar b/com.connor.ml.tcm/lib/xmlschema-core-2.2.1.jar new file mode 100644 index 0000000..cab69fd Binary files /dev/null and b/com.connor.ml.tcm/lib/xmlschema-core-2.2.1.jar differ diff --git a/com.connor.ml.tcm/lib/xmlsec.jar b/com.connor.ml.tcm/lib/xmlsec.jar new file mode 100644 index 0000000..6b69b80 Binary files /dev/null and b/com.connor.ml.tcm/lib/xmlsec.jar differ diff --git a/com.connor.ml.tcm/plm.properties b/com.connor.ml.tcm/plm.properties new file mode 100644 index 0000000..d6a7cfe --- /dev/null +++ b/com.connor.ml.tcm/plm.properties @@ -0,0 +1,7 @@ +EXCEL3.SQL=SELECT DISTINCT p1.puid, p3.pcreation_date, CASE WHEN p4.pitem_revision_id = 'A' AND p7.pname IN ('ML8_SXFB', 'ML8_JGFB') THEN p4.puid ELSE p4.puid END AS puid FROM PITEM p1 INNER JOIN PWORKSPACEOBJECT p2 ON p1.puid = p2.puid AND p2.pobject_type = 'ML8_Part' AND ( SELECT count(puid) FROM PPSOCCURRENCE WHERE rchild_itemu = p2.puid ) = 0 INNER JOIN PPOM_APPLICATION_OBJECT p3 ON p1.puid = p3.puid AND p3.pcreation_date < ( SELECT CONVERT( varchar(70), dateadd(MONTH, -2, CAST(GETDATE() AS datetime)), 21 )) INNER JOIN PITEMREVISION p4 ON p1.puid = p4.ritems_tagu AND p4.pitem_revision_id =( SELECT max(pitem_revision_id) AS item_revision_id FROM PITEMREVISION WHERE ritems_tagu = p1.puid GROUP BY ritems_tagu ) INNER JOIN PML8_PART p5 ON p1.puid = p5.puid AND p5.pml8_Status IN (?, ?, ?) INNER JOIN PRELEASE_STATUS_LIST p6 ON p4.puid = p6.puid INNER JOIN PRELEASESTATUS p7 ON p6.pvalu_0 = p7.puid +EXCEL4.SQL=SELECT DISTINCT ritems_tagu FROM ( SELECT T7.pname, isnull(T9.pml8_Status, '') pml8_Status, T1.ritems_tagu, T4.puid, CASE WHEN T7.pname IN('ML8_Replaced', 'ML8_Freeze') AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others')THEN 'ok' WHEN (pml8_Status = ? OR T7.pname = 'ML8_Replaced') AND T8.pobject_type = 'ML8_Part' THEN 'ok' ELSE 'no' END OTHERS FROM AAA T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.ritems_tagu INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid INNER JOIN PRELEASE_STATUS_LIST T6 ON T5.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid INNER JOIN PWORKSPACEOBJECT T8 ON T5.ritems_tagu = T8.puid AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others', 'ML8_Part') LEFT JOIN PML8_PART T9 ON T5.ritems_tagu = T9.puid) TTT1 WHERE OTHERS = 'ok' AND ritems_tagu NOT IN( SELECT DISTINCT ritems_tagu FROM ( SELECT T7.pname, isnull(T9.pml8_Status, '') pml8_Status, T1.ritems_tagu, T4.puid, CASE WHEN T7.pname IN('ML8_Replaced', 'ML8_Freeze') AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others')THEN 'ok' WHEN (pml8_Status = ? OR T7.pname = 'ML8_Replaced') AND T8.pobject_type = 'ML8_Part' THEN 'ok' ELSE 'no' END OTHERS FROM AAA T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.ritems_tagu INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid INNER JOIN PRELEASE_STATUS_LIST T6 ON T5.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid INNER JOIN PWORKSPACEOBJECT T8 ON T5.ritems_tagu = T8.puid AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others', 'ML8_Part') LEFT JOIN PML8_PART T9 ON T5.ritems_tagu = T9.puid) sss WHERE OTHERS = 'no') GROUP BY ritems_tagu +EXCEL5.SQL=WITH TEMP AS( SELECT T5.ritems_tagu AS parent_uid FROM ( SELECT * FROM PITEM WHERE puid = ? ) T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.puid INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid UNION ALL SELECT T5.ritems_tagu AS parent_uid FROM TEMP A INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = A.parent_uid INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid) SELECT DISTINCT * FROM TEMP +#截图比例原理:由宽度来产生对应比例的高度 +#截图比例:x/y (HEIGHT=WIDTH*y/x) +IMAGE.WIDTH=7 +IMAGE.HEIGHT=5 \ No newline at end of file diff --git a/com.connor.ml.tcm/plugin.xml b/com.connor.ml.tcm/plugin.xml new file mode 100644 index 0000000..1d13417 --- /dev/null +++ b/com.connor.ml.tcm/plugin.xml @@ -0,0 +1,2027 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +sdfsdf + + + + + + + + + + + + + + diff --git a/com.connor.ml.tcm/sql.properties b/com.connor.ml.tcm/sql.properties new file mode 100644 index 0000000..bfe959e --- /dev/null +++ b/com.connor.ml.tcm/sql.properties @@ -0,0 +1,16 @@ +ML8_ORDMBOMITEMSELECTSQL=select T1.pitem_id,T2.pobject_name,T3.pcreation_date,T5.* from PITEM T1 INNER join PWORKSPACEOBJECT T2 on T1.puid=T2.puid AND T2.pobject_type = 'ML8_OrdMBOMItem' %s INNER join PPOM_APPLICATION_OBJECT T3 on T1.puid=T3.puid %s INNER join PITEMREVISION T4 on T1.puid=T4.ritems_tagu and T4.pitem_revision_id=(select max(pitem_revision_id) as item_revision_id from PITEMREVISION WHERE ritems_tagu=T1.puid group by ritems_tagu) INNER join PML8_ORDMBOMITEMREVISION T5 on T4.puid=T5.puid %s +ML_TCMPROCESSINSERTSQL=INSERT INTO ML_TCMPROCESS VALUES(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\') +ML_TCMPROCESSUPDATESQL=UPDATE ML_TCMPROCESS SET MSGID = \'%s\',BUSID = \'%s\',DTSEND = \'%s\',PLNNR = \'%s\',DATUV = \'%s\',VERWE = \'%s\',STATU = \'%s\',VORNR = \'%s\',STEUS = \'%s\',ARBPL = \'%s\',LTXA1 = \'%s\',BMSCH = \'%s\',VGW01 = \'%s\',VGW02 = \'%s\',VGW03 = \'%s\',VGW04 = \'%s\',KZ = \'%s\',STATUS = \'%s\',MESSAGE = \'%s\',TYPE = \'%s\',GROUPNAME = \'%s\',VGW05 = \'%s\' WHERE MATNR = \'%s\' AND WERKS = \'%s\' AND PLNAL = \'%s\' +ML_TCMPROCESSSELECTSQL=SELECT * FROM ML_TCMPROCESS WHERE MATNR = \'%s\' AND WERKS = \'%s\' AND PLNAL = \'%s\' +ML_TCMPROCESSSELECTSQL2=SELECT * FROM ML_TCMPROCESS WHERE MATNR = \'%s\' AND WERKS = \'%s\' +ML_TCMPRODUCTREVINSERTSQL=INSERT INTO ML_TCMPRODUCTREV VALUES(\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\') +ML_TCMPRODUCTREVUPDATEPLNNRSQL=UPDATE ML_TCMPRODUCTREV SET PLNNR = \'%s\' WHERE MATNR = \'%s\' AND WERKS = \'%s\' AND ALNAL = \'%s\' +ML_TCMPRODUCTREVUPDATESQL=UPDATE ML_TCMPRODUCTREV SET MSGID = \'%s\',BUSID = \'%s\',DTSEND = \'%s\',VERID = \'%s\',TEXT1 = \'%s\',ADATU = \'%s\',BDATU = \'%s\',STLAN = \'%s\',PLNNR = \'%s\',ALNAL = \'%s\',MDV01 = \'%s\',ALORT = \'%s\',ELPRO = \'%s\',STATUS = \'%s\',MESSAGE = \'%s\',STLAL = \'%s\' WHERE MATNR = \'%s\' AND WERKS = \'%s\' AND ALNAL = \'%s\' AND VERID = \'%s\' +ML_TCMPRODUCTREVSELECTSQL=SELECT * FROM ML_TCMPRODUCTREV WHERE MATNR = \'%s\' AND WERKS = \'%s\' AND ALNAL = \'%s\' AND VERID = \'%s\' +ML_TCMPRODUCTREVSELECTSQL2=SELECT * FROM ML_TCMPRODUCTREV WHERE MATNR = \'%s\' AND WERKS = \'%s\' + +ML_GETITEMID_ITEMTYPESQL=SELECT * FROM(SELECT T1.pitem_id,T2.pobject_name,T2.pobject_type,T3.psymbol,T5.pml8_Specifications,T5.pml8_StdDesc FROM PITEM T1 INNER JOIN (SELECT * FROM(SELECT a1.ritems_tagu,a1.puid FROM PITEMREVISION a1 INNER join PRELEASE_STATUS_LIST b on a1.puid=b.puid GROUP BY a1.ritems_tagu,a1.puid) aa) T4 ON T1.puid = T4.ritems_tagu LEFT JOIN PWORKSPACEOBJECT T2 ON T1.puid = T2.puid LEFT JOIN PUNITOFMEASURE T3 ON T1.ruom_tagu = T3.puid INNER JOIN PML8_RAWMATERIALREVISION T5 ON T4.puid = T5.puid UNION SELECT T1.pitem_id,T2.pobject_name,T2.pobject_type,T3.psymbol,T5.pml8_Specifications,T5.pml8_StdDesc FROM PITEM T1 INNER JOIN (SELECT * FROM(SELECT a1.ritems_tagu,a1.puid FROM PITEMREVISION a1 INNER join PRELEASE_STATUS_LIST b on a1.puid=b.puid GROUP BY a1.ritems_tagu,a1.puid) aa) T4 ON T1.puid = T4.ritems_tagu LEFT JOIN PWORKSPACEOBJECT T2 ON T1.puid = T2.puid LEFT JOIN PUNITOFMEASURE T3 ON T1.ruom_tagu = T3.puid INNER JOIN PML8_PARTREVISION T5 ON T4.puid = T5.puid) T WHERE %s +ML_GETITEMID_ITEMNAMESQL=SELECT * FROM(SELECT T1.pitem_id,T2.pobject_name,T2.pobject_type,T3.psymbol FROM PITEM T1 LEFT JOIN PWORKSPACEOBJECT T2 ON T1.puid = T2.puid LEFT JOIN PUNITOFMEASURE T3 ON T1.ruom_tagu = T3.puid) T WHERE %s AND (pobject_type = 'ML8_Refrigerator' OR pobject_type = 'ML8_Washing' OR pobject_type = 'ML8_Cold' OR pobject_type = 'ML8_Others') + +ML_TCMPROCESDELETESQL=DELETE FROM ML_TCMPROCESS WHERE MATNR = \'%s\' AND WERKS = \'%s\' +ML_WEBSERVICE_LOGINSERTSQL=INSERT INTO ML_WEBSERVICE_LOG VALUES (\'%s\',\'%s\',\'%s\',\'%s\') \ No newline at end of file diff --git a/com.connor.ml.tcm/sqlconn.properties b/com.connor.ml.tcm/sqlconn.properties new file mode 100644 index 0000000..01410a5 --- /dev/null +++ b/com.connor.ml.tcm/sqlconn.properties @@ -0,0 +1,9 @@ +DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +Connection=jdbc:sqlserver://10.18.1.100:1433; DatabaseName=TC +User=infodba +Password=Plm_8023 + +#DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +#Connection=jdbc:sqlserver://10.18.1.105:1433; DatabaseName=TC +#User=infodba +#Password=Plm_8023 \ No newline at end of file diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/exportExcel/TCUtil.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/exportExcel/TCUtil.java new file mode 100644 index 0000000..679073c --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/exportExcel/TCUtil.java @@ -0,0 +1,59 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Toolkit; +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Vector; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +@SuppressWarnings("deprecation") +public class TCUtil { + public static final int MINWIDTH = 1280; + public static final int MINHEIGHT = 768; + + + public static void setByPass(TCSession session, boolean val) { + try { + TCUserService userservice = session.getUserService(); + userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[] { "" }); + System.out.println(val ? "Open Bypass" : "Close Bypass"); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/DbPool.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/DbPool.java new file mode 100644 index 0000000..b24ea66 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/DbPool.java @@ -0,0 +1,246 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import java.io.InputStream; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.Properties; + +public class DbPool { + + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + private static DbPool instance = null; + + public static synchronized Connection getConnection() { + if (instance == null) { + instance = new DbPool(); + } + return instance._getConnection(); + } + + private Connection _getConnection() { + try { + String sDBDriver = null; + String sConnection = null; + String sUser = null; + String sPassword = null; + Properties p = new Properties(); + InputStream is = getClass().getResourceAsStream( + "/sqlconn.properties"); + p.load(is); + sDBDriver = p.getProperty("DBDriver", "1"); + sConnection = p.getProperty("Connection", "jdbc:sqlserver://10.18.1.100:1433; DatabaseName=TC"); + sUser = p.getProperty("User", ""); + sPassword = p.getProperty("Password", ""); + + if (sDBDriver == null || sConnection == null || sUser == null + || sPassword == null) { + + System.out.println("请检查数据库首选项是否配置正确"); + + } + + Class.forName(sDBDriver); + connection = DriverManager.getConnection(sConnection, sUser, + sPassword); + return connection; + } catch (Exception se) { + System.out.println(se); + } + return null; + } + + public final static ResultSet read(String sql, Object[] argments) throws SQLException { + return DbPool.rs = DbPool.getPs(argments, sql).executeQuery(); + } + /** + * 得到Statement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) throws SQLException { + return getPs(sql, argments); + } + /** + * 得到Statement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) throws SQLException { + DbPool.ps = DbPool.connection.prepareStatement(sql); + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + DbPool.ps.setObject(i + 1, argments[i]); + } + } + return DbPool.ps; + } + /** + * 查询 + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + public static void executeUpdateSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + //System.out.println("sql===" + sql); + int i = st.executeUpdate(sql); + } catch (SQLException e) { + System.out.println(e.getMessage()); + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + // connection.close(); + } + + } + + public static void executeDeleteSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + //System.out.println("sql===" + sql); + st.executeUpdate(sql); + connection.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + connection.close(); + } + + } + /** + * 增加 + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + /** + * 修改(增删改最终都要调用此方法,此处进行异常处理,关闭除Connection以为的对象) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + i = DbPool.getPs(argments, sql).executeUpdate(); + DbPool.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(DbPool.rs, DbPool.ps); + } + return i; + } + public static ResultSet executeSelectSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + //System.out.println("sql===" + sql); + rs = st.executeQuery(sql); + // conn.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } + return rs; + + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(DbPool.rs, DbPool.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(DbPool.rs, DbPool.ps, DbPool.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SAPConn.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SAPConn.java new file mode 100644 index 0000000..f36f59c --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SAPConn.java @@ -0,0 +1,90 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.Properties; + +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoDestinationManager; +import com.sap.conn.jco.JCoException; +import com.sap.conn.jco.ext.DestinationDataProvider; +import com.teamcenter.rac.util.MessageBox; + +public class SAPConn { + private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL"; + + static { + Properties connectProperties = new Properties(); + + connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, + "10.3.1.71"); + connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00"); + connectProperties + .setProperty(DestinationDataProvider.JCO_CLIENT, "800"); + connectProperties.setProperty(DestinationDataProvider.JCO_USER, + "MLSCP"); + connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, + "ml654321"); + connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "zh"); + connectProperties.setProperty( + DestinationDataProvider.JCO_POOL_CAPACITY, "3"); + connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, + "10"); + +// connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, +// "10.3.1.224"); +// connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "01"); +// connectProperties +// .setProperty(DestinationDataProvider.JCO_CLIENT, "800"); +// connectProperties.setProperty(DestinationDataProvider.JCO_USER, +// "MLSCP"); +// connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, +// "654321"); +// connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "zh"); +// connectProperties.setProperty( +// DestinationDataProvider.JCO_POOL_CAPACITY, "3"); +// connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, +// "10"); + + createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties); + + } + + private static void createDataFile(String name, String suffix, + Properties properties) { + File cfg = new File(name + "." + suffix); + if (cfg.exists()) { + cfg.deleteOnExit(); + } + try { + FileOutputStream fos = new FileOutputStream(cfg, false); + properties.store(fos, "for tests only !"); + fos.close(); + } catch (Exception e) { + //log.error("Create Data file fault, error msg: " + e.toString()); + throw new RuntimeException("Unable to create the destination file " + + cfg.getName(), e); + } + } + + /** + * 获取sap连接 + * + * @return SAP连接对象 + */ + public static JCoDestination connect() { + JCoDestination destination = null; + try { + destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED); + if(destination==null){ + MessageBox.post("sap连接不上","错误",MessageBox.ERROR); + } + } catch (JCoException e) { + MessageBox.post("sap连接不上","错误",MessageBox.ERROR); +// log.error("Connect SAP fault, error msg: " + e.toString()); + } + return destination; + } + + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SelectDialog.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SelectDialog.java new file mode 100644 index 0000000..a00d819 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SelectDialog.java @@ -0,0 +1,84 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; + +import javax.swing.JButton; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class SelectDialog extends AbstractAIFDialog{ + + private TCSession session; + private List duocCompList; + public SelectDialog(TCSession session,List duocCompList) { + // TODO Auto-generated constructor stub + this.session = session; + this.duocCompList=duocCompList; +// this.item=item; + //this.bop = bop; + + init(); + } + + private void init() { + + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(300, 200)); + + this.setTitle("选择传递方式"); + + JButton button1 = new JButton("单层传递"); + JButton button2 = new JButton("多层传递"); + + button1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + Thread t=new Thread(new Runnable(){ + public void run(){ + + SendBomSapDialog dialog = new SendBomSapDialog(session,duocCompList,false); + } + }); + t.start(); + } + }); + button2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + // TODO Auto-generated method stub + Thread t=new Thread(new Runnable(){ + public void run(){ + + SendBomSapDialog dialog = new SendBomSapDialog(session,duocCompList,true); + } + }); + t.start(); + } + }); + + this.add("1.1.left.top", button1); + this.add("2.1.left.top", button2); + + this.setVisible(true); + this.centerToScreen(); + this.pack(); + this.setResizable(false); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); + + + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomOperation.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomOperation.java new file mode 100644 index 0000000..5b2b5a3 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomOperation.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class SendBomOperation extends AbstractAIFOperation{ + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomSapDialog.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomSapDialog.java new file mode 100644 index 0000000..c8e2db9 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomSapDialog.java @@ -0,0 +1,1073 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.apache.commons.collections4.map.HashedMap; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.lov.LOVComboBox; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.soa.client.model.LovValue; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +import cn.net.connor.ml.plm.exportExcel.TCUtil; + +public class SendBomSapDialog extends AbstractAIFDialog{ + + private TCSession session; + private TCComponentItem item; + private String itemId; + private String objectName; + private TCComponentType mycomponenttype;// LOV类型 + private TCComponentListOfValuesType myComponentListOfValuesType; // 取得LOV对象 + private TCComponentListOfValues Arraylistofvalues[];// LOV默认数组 + private TCComponentListOfValues ML8_BOMPurpose_LOV;// 关重件/重要件 + private TCComponentListOfValues ML8_Factory_LOV;// 自制/外购 + private TCComponentListOfValues ML8_SortString_LOV;// 图幅 + private String ml8_Factory; + private boolean flag; + private TCComponentItemRevision revisionSe; + private List dancCompList; +// private String itemId; + + +// bl_level_starting_1 +// private String itemId; + public SendBomSapDialog(TCSession session, List dancCompList,boolean flag) { + // TODO Auto-generated constructor stub + this.session = session; + //this.bop = bop; + this.dancCompList = dancCompList; + this.flag=flag; +// this.item=item; + try { + this.item = dancCompList.get(0); + itemId = this.item.getStringProperty("item_id"); + objectName = this.item.getStringProperty("object_name"); + ml8_Factory = this.item.getLatestItemRevision().getPropertyDisplayableValue("ml8_Factory"); + redlov(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + String tempDir = System.getenv("TEMP") + File.separator + UUID.randomUUID(); + + file = new File(tempDir); + if (!file.isDirectory()) { + file.mkdirs(); + } + getRefs(file); + getRefs2(); + + + init(); + } + private String validdate; + private File file; + private File fmsFile; + private void getRefs2() { + // TODO Auto-generated method stub + + validdate = session.getPreferenceService().getStringValue("ML_StartDateofValidity"); //SF6_HJGYGCQD_Excel + + } + private void getRefs(File absRoot) { + // TODO Auto-generated method stub + + String prefValue = session.getPreferenceService().getStringValue("ML_MRP"); //SF6_HJGYGCQD_Excel + try { + TCComponent stringToComponent = session.stringToComponent(prefValue); + if(stringToComponent !=null && stringToComponent instanceof TCComponentDataset) { + + TCComponentDataset dateset = (TCComponentDataset) stringToComponent; + + String[] fileNames = dateset.getFileNames(""); + if (fileNames.length == 0) { + return; + } else { + fmsFile = dateset.getFile("", fileNames[0], absRoot.getAbsolutePath()); + } +// dateset.getFile("IMAN_specification", fileNames[0], absRoot.getAbsolutePath()); + + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + String[] prefValues = session.getPreferenceService().getStringValues("ML_BOMSendSapProperty"); //SF6_HJGYGCQD_Excel + for(String pref:prefValues) { + if(pref.contains("-")) { + typePropertyType.put(pref.split("-")[0],pref.split("-")[1]); + } + } + + } + private Map changeLevels = new HashMap<>(); + Map typePropertyType = new HashedMap(); + private void redlov() throws TCException { + // TODO Auto-generated method stub +// ML8_SortString_LOV //排序 +// +// ML8_Factory_LOV //工厂 +// +// ML8_BOMPurpose_LOV //bom用途 + mycomponenttype = session.getTypeComponent("ListOfValues"); + if (mycomponenttype instanceof TCComponentListOfValuesType) { + myComponentListOfValuesType = (TCComponentListOfValuesType) mycomponenttype; + Arraylistofvalues = myComponentListOfValuesType + .find("ML8_BOMPurpose_LOV"); + ML8_BOMPurpose_LOV = Arraylistofvalues[0]; + Arraylistofvalues = myComponentListOfValuesType + .find("ML8_Factory_LOV"); + ML8_Factory_LOV = Arraylistofvalues[0]; + List values = ML8_Factory_LOV.getListOfValues().getValues(); + for (LovValue lovValue : values) { + changeLevels.put(lovValue.getDisplayValue(),(String) lovValue.getValue()); + } + Arraylistofvalues = myComponentListOfValuesType + .find("ML8_SortString_LOV"); + ML8_SortString_LOV = Arraylistofvalues[0]; + } + } + JTextField materialText; + JTextField materialDescText; + JTextField bomQTYText; + JTextField sapBomTypeText; + LOVComboBox factoryComb; + LOVComboBox bomUseComb; + LOVComboBox sortStrText; + private Map facMrpToSort = new HashMap(); + private Map facMrpToFact = new HashMap(); + private List facList = new ArrayList(); + private Map facMrpSortList = new HashMap(); +// private List mrpList = new ArrayList(); + private void init() { + + + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(450, 500)); + + JPanel btnPanel1 = new JPanel(); + JLabel drawingtype = new JLabel("物料编码:"); + + materialText = new JTextField(); + materialText.setText(itemId); + btnPanel1.add("1.1.left.top", drawingtype); + btnPanel1.add("1.2.left.top", materialText); + + JPanel btnPanel2 = new JPanel(); + JLabel drawingtype2 = new JLabel("物料描述:"); + + materialDescText = new JTextField(); + materialDescText.setText(objectName); + btnPanel2.add("1.1.left.top", drawingtype2); + btnPanel2.add("1.2.left.top", materialDescText); + + JPanel btnPanel3 = new JPanel(); + JLabel drawingtype3 = new JLabel("BOM基本数量:"); + + bomQTYText = new JTextField(); + bomQTYText.setText("1000"); + btnPanel3.add("1.1.left.top", drawingtype3); + btnPanel3.add("1.2.left.top", bomQTYText); + + JPanel btnPanel4 = new JPanel(); + JLabel drawingtype4 = new JLabel("BOM用途:"); + + bomUseComb = new LOVComboBox(); + utils.dymanicLov(session, ML8_BOMPurpose_LOV, bomUseComb); + bomUseComb.setText("1"); + btnPanel4.add("1.1.left.top", drawingtype4); + btnPanel4.add("1.2.left.top", bomUseComb); + + + JPanel btnPanel5 = new JPanel(); + JLabel drawingtype5 = new JLabel("SAPBOM版本:"); + + sapBomTypeText = new JTextField(); + sapBomTypeText.setText("01"); + btnPanel5.add("1.1.left.top", drawingtype5); + btnPanel5.add("1.2.left.top", sapBomTypeText); + + JPanel btnPanel6 = new JPanel(); + JLabel drawingtype6 = new JLabel("工厂:"); + + factoryComb = new LOVComboBox(ML8_Factory_LOV,""); + System.out.println("----ml8_Factory----"+ml8_Factory); + factoryComb.setText(ml8_Factory); +// factoryComb.setSelectedItem(factoryComb); + btnPanel6.add("1.1.left.top", drawingtype6); + btnPanel6.add("1.2.left.top", factoryComb); + + + JPanel btnPanel7 = new JPanel(); + JLabel drawingtype7 = new JLabel("排序字符串:"); + + sortStrText = new LOVComboBox(); + utils.dymanicLov(session, ML8_SortString_LOV, sortStrText); +// bomQTYText.setText("01"); + btnPanel7.add("1.1.left.top", drawingtype7); + btnPanel7.add("1.2.left.top", sortStrText); + + JPanel btnPanel8 = new JPanel(); + JLabel drawingtype8 = new JLabel("起始生效日期:"); + + JTextField startDateText = new JTextField(); + startDateText.setText(validdate); +// bomQTYText.setText("01"); + btnPanel8.add("1.1.left.top", drawingtype8); + btnPanel8.add("1.2.left.top", startDateText); + + JPanel btnPanel9 = new JPanel(); + JButton jButton1=new JButton("确定"); + JButton jButton2=new JButton("取消"); + btnPanel9.add("1.1.left.top", jButton1); + jButton2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + jButton1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("----start----"); + TCUtil.setByPass(session, true); + //char parameters[100000] = "";//写入到文件的值 +// parameters.append( "getBomPropertys}}"); + try { + String work = ""; + String parentMrp = ""; + try { + if(fmsFile!=null) { + FileInputStream in = new FileInputStream(fmsFile); + XSSFWorkbook oldwbWorkbook = new XSSFWorkbook(in); + XSSFSheet sheetAt = oldwbWorkbook.getSheetAt(0); + String selectedString = factoryComb.getSelectedString(); + if(changeLevels.containsKey(selectedString.trim())) { + selectedString = changeLevels.get(selectedString.trim()); + work = selectedString; + }else { + work = selectedString; + System.out.println(changeLevels.toString()); + } + parentMrp = utils.sapConnectDisop(itemId, work); + System.out.println(selectedString + "parentMrp ====>"+parentMrp); +// String ml8_MRP = "IZ5"; +// Map facMrpMap = new HashedMap(); + + int physicalNumberOfRows = sheetAt.getPhysicalNumberOfRows(); + + for(int t = 0;t" + "work"+work); + for(int t=0;t bomLines = new ArrayList(); + ArrayList a0Lines = new ArrayList(); + TCComponentItem tcComponentItem = dancCompList.get(t); + try { + + TCComponentItemRevision topRevision = null; + + TCComponent[] revs = tcComponentItem.getReferenceListProperty("revision_list"); + for(int i = 0;i"); + System.out.println(parentJSON.size() +"parentJSON =====>"); + for(int ind = 0;ind arrayList = null; + if(!isJGFB) { + TCComponentItemRevision topRevision = null; + TCComponentItem item2 = itemRevision.getItem(); + TCComponent[] revs = item2.getReferenceListProperty("revision_list"); + for(int i = 0;i(); + TCComponentBOMWindowType bopWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bopWindow = bopWindowType.create(null); + System.out.println("topRevision uid ==> "+topRevision.getUid()+topRevision.getType()); + TCComponentBOMLine topBopline = bopWindow.setWindowTopLine(item2, topRevision , null, null); + AIFComponentContext[] children = topBopline.getChildren(); + for(AIFComponentContext context2:children) { + TCComponentBOMLine component2 = (TCComponentBOMLine)context2.getComponent(); + arrayList.add(component2); +// this.bomLines.add(component2); + } + bopWindow.close(); + itemRevision = topRevision; + }else { + arrayList = childJSON.get(ind); + } + + String ml8_ProcessingMode = itemRevision.getStringProperty("ml8_ProcessingMode"); + String ml8_AddTrade = itemRevision.getStringProperty("ml8_AddTrade"); + String item_id = itemRevision.getStringProperty("item_id"); + String mrp = utils.sapConnectDisop(item_id, work); + String childWork = work; + String sortstr = sortStrText.getSelectedString(); + if(facMrpToSort.containsKey(work+";"+mrp)) { + sortstr = facMrpToSort.get(work+";"+mrp); + }else { + System.out.println(work+";"+mrp+"fac"); + } + if((ml8_ProcessingMode.equals("外协外购") && ml8_AddTrade.equals("是"))) { +// String factory = itemRevision.getStringProperty("ml8_Factory"); + + if(work.equals("I100")) { + childWork = work; + sortstr = sortStrText.getSelectedString(); + }else if(work.equals("I060")) { + childWork = "I010"; + sortstr = "1234"; + }else if (work.equals("I080")) { + sortstr = "78"; + childWork = "I080"; + } + boolean succ = setJSONByItems(pbomLine.getItem(),arrayList,"01",sortstr,childWork); + if(succ) { +// ml8_BOMSendERP + itemRevision.setStringProperty("ml8_BOMSendERP", "成功"); + }else { + itemRevision.setStringProperty("ml8_BOMSendERP", "失败"); + } +// if(!setJSONByItems) + + }else { + boolean succ = setJSONByItems(pbomLine.getItem(),arrayList,"01",sortstr,childWork); + if(succ) { +// ml8_BOMSendERP + itemRevision.setStringProperty("ml8_BOMSendERP", "成功"); + }else { + itemRevision.setStringProperty("ml8_BOMSendERP", "失败"); + } + } + itemRevision.setStringProperty("ml8_MRP", mrp); + if(facMrpToFact.containsKey(work+";"+mrp)) { + + String moreFact = facMrpToFact.get(work+";"+mrp); + if(!moreFact.equals("")) { +// String mrpMore = utils.sapConnectDisop(item_id, moreFact); + if(facMrpToSort.containsKey(moreFact+";"+mrp)) { + sortstr = facMrpToSort.get(moreFact+";"+mrp); + }else { + System.out.println(moreFact+";"+mrp); + } + childWork = moreFact; + if((ml8_ProcessingMode.equals("外协外购") && ml8_AddTrade.equals("是"))) { + if(moreFact.equals("I100")) { + childWork = work; + sortStrText.getSelectedString(); + }else if(moreFact.equals("I060")) { + childWork = "I010"; + sortstr = "1234"; + }else if (moreFact.equals("I080")) { + sortstr = "78"; + childWork = "I080"; + } + boolean succ = setJSONByItems(pbomLine.getItem(),arrayList,"01",sortstr,childWork); + if(succ) { +// ml8_BOMSendERP + itemRevision.setStringProperty("ml8_BOMSendERP", "成功"); + }else { + itemRevision.setStringProperty("ml8_BOMSendERP", "失败"); + } + }else { + boolean succ = setJSONByItems(pbomLine.getItem(),arrayList,"01",sortstr,childWork); + if(succ) { +// ml8_BOMSendERP + itemRevision.setStringProperty("ml8_BOMSendERP", "成功"); + }else { + itemRevision.setStringProperty("ml8_BOMSendERP", "失败"); + } + } + } + + } +// for(int i=0;i"+parameters); + parameters = setJSONByItems(parameters,tcComponentItem,isFirst,bomLines,"01",sortStrText.getSelectedString()); + isFirst = false; + }else { + for(int j=0;j0) { + bomLines.remove(bomLines.size()-1); + } + bomLines.add(a0Lines.get(j)); + parameters = setJSONByItems(parameters,tcComponentItem,isFirst,bomLines,alternative,sortStrText.getSelectedString()); + Integer valueOf = Integer.valueOf(alternative); + valueOf = valueOf +1; + alternative = String.format("%02d", valueOf); + + isFirst = false; + } + } + } + + +// SendBomOperation operation = new SendBomOperation(); +// session.queueOperation(operation); + parameters.append( "]"); + String paramStr = parameters.toString(); + boolean sapConnectBom = utils.sapConnectBom(paramStr); + try { + if(sapConnectBom && revisionSe!=null) { +// ml8_BOMSendERP + revisionSe.setStringProperty("ml8_BOMSendERP", "成功"); + }else { + revisionSe.setStringProperty("ml8_BOMSendERP", "失败"); + } + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + +// if(sapConnectBom) { +//// topRevision +// revisionSe.setStringProperty("", paramStr); +// } + System.out.println(facList.toString()); + System.out.println(facMrpSortList.toString()); +// if(sortList.size() == facList.size()) { + for(int i=0;i bomLines,String alternative,String sort) { + // TODO Auto-generated method stub +// StringBuffer parameters = new StringBuffer(); + if(isFirst) { + parameters.append( "{"); + }else { + parameters.append( ",{"); + } + + String item_id = ""; + String objectName = ""; + try { + item_id = item.getStringProperty("item_id"); + objectName = item.getStringProperty("object_name"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + parameters.append( "\"matnr\":\""); + parameters.append( item_id ); //materialText.getText() + parameters.append( "\","); + parameters.append( "\"werks\":\""); + String selectedString = factoryComb.getSelectedString(); + if(changeLevels.containsKey(selectedString.trim())) { + selectedString = changeLevels.get(selectedString.trim()); + } + parameters.append( selectedString); + parameters.append( "\","); + parameters.append( "\"bomusage\":\""); + parameters.append( "1"); + parameters.append( "\","); + parameters.append( "\"alternative\":\""); + //parameters.append( lineCode); + parameters.append( alternative); + parameters.append( "\","); + parameters.append( "\"validdate\":\""); + parameters.append( validdate ); + parameters.append( "\","); + parameters.append( "\"description\":\""); + parameters.append( objectName); + parameters.append( "\","); + parameters.append( "\"basequan\":\""); + parameters.append( "1000"); + parameters.append( "\","); + + parameters.append( "\"itemdetail\":["); + //获取子件 + boolean isstart = true; + if(bomLines.size()==0) { + MessageBox.post("没有符合条件的bomline","提示",2); + } + + for(TCComponentBOMLine bomLine:bomLines) { +// for (String prop : typePropertyType.keySet()) { +// String string = typePropertyType.get(prop); +// + try { + if (isstart) + { + parameters.append( "{"); + isstart = false; + } + else + { + parameters.append( ",{"); + } + String type = bomLine.getStringProperty("fnd0bl_line_object_type"); + if(typePropertyType.containsKey(type)) { + + String string = typePropertyType.get(type); + String[] split = string.split(","); + for(int t=0;t< split.length ;t++) { + String[] prop = split[t].split("="); + parameters.append( "\""); + parameters.append( prop[1]); + parameters.append( "\""); + parameters.append( ":"); + String value1 = ""; + String value = utils.TCGetPropertyValue(bomLine,"Bomline",prop[0],value1); + if (prop[1].equals("itemtext1")) + { + if (value == null || value.equals("") || value.equals("Eac") || value.equals("Each.") || value.equals("每个") ) + { + value = "ea"; + } + }else if (prop[1].equals( "sortstring")) + { + value = sort; + } + else if (prop[1].equals( "component")) + { + if( prop[1].contains("-")) { + String[] split2 = prop[1].split("-"); + value = split2[0]; + } + + } + else if (prop[1].equals( "compqty") && !value.equals("")) + { + //BOM关系中子项数量*SAP BOM基本数量 + double bomNum = Double.valueOf(value); + double bomBase = 1000; + double sum = bomNum*bomBase; +// char * sumChar = new char[20]; +// sprintf(sumChar, "%.3f", sum); + DecimalFormat df = new DecimalFormat("0.000"); + //cout << "bomNum【" << bomNum << "】,bomBaseNum【" << bomBaseNum << "】,bomBase【" << bomBase << "】,sum【" << sum << "】,sumChar【" << sumChar << "】\n" << endl; + //printf("bomNum【%d】,bomBaseNum【%s】,bomBase:【%d】,sum:【%d】,sumChar:【%s】\n", bomNum, bomBaseNum,bomBase, sum, sumChar); + value = df.format(sum); + }else if (prop[1].equals("itemno") ) + { + //需要*10后,格式化为4位长度后进行传递 + if(!value.equals("")) { + Integer valueOf = Integer.valueOf(value)*10; + String newName = String.format("%04d", valueOf); + String substring = newName.substring(0,4); + value = substring; + } + + } + parameters.append( "\""); + parameters.append( value); + parameters.append( "\""); + if(t < split.length-1 ) { + parameters.append( ","); + } + + } + parameters.append( "}"); + } + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } +// } + } +// getBomLineProperty(BomLine, typePropertyType, basequan, (char*)result3.c_str(), parameters); + parameters.append( "]"); + parameters.append( "}"); + + + return parameters; + } + protected boolean setJSONByItems(TCComponentItem item, ArrayList bomLines,String alternative,String sort,String work) { + // TODO Auto-generated method stub + StringBuffer parameters = new StringBuffer(); +// if(isFirst) { + parameters.append( "["); + parameters.append( "{"); +// }else { +// parameters.append( ",{"); +// } + + String item_id = ""; + String objectName = ""; + try { + item_id = item.getStringProperty("item_id"); + objectName = item.getStringProperty("object_name"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + parameters.append( "\"matnr\":\""); + parameters.append( item_id ); //materialText.getText() + parameters.append( "\","); + parameters.append( "\"werks\":\""); +// String selectedString = factoryComb.getSelectedString(); +// if(changeLevels.containsKey(selectedString.trim())) { +// selectedString = changeLevels.get(selectedString.trim()); +// } + parameters.append( work); + parameters.append( "\","); + parameters.append( "\"bomusage\":\""); + parameters.append( "1"); + parameters.append( "\","); + parameters.append( "\"alternative\":\""); + //parameters.append( lineCode); + parameters.append( alternative); + parameters.append( "\","); + parameters.append( "\"validdate\":\""); + parameters.append( validdate ); + parameters.append( "\","); + parameters.append( "\"description\":\""); + parameters.append( objectName); + parameters.append( "\","); + parameters.append( "\"basequan\":\""); + parameters.append( "1000"); + parameters.append( "\","); + + parameters.append( "\"itemdetail\":["); + //获取子件 + boolean isstart = true; + if(bomLines.size()==0) { + MessageBox.post("没有符合条件的bomline","提示",2); + } + + for(TCComponentBOMLine bomLine:bomLines) { +// for (String prop : typePropertyType.keySet()) { +// String string = typePropertyType.get(prop); +// + try { + if (isstart) + { + parameters.append( "{"); + isstart = false; + } + else + { + parameters.append( ",{"); + } + String type = bomLine.getItemRevision().getType(); + if(typePropertyType.containsKey(type)) { + + String string = typePropertyType.get(type); + String[] split = string.split(","); + for(int t=0;t< split.length ;t++) { + String[] prop = split[t].split("="); + parameters.append( "\""); + parameters.append( prop[1]); + parameters.append( "\""); + parameters.append( ":"); + String value1 = ""; + String value = utils.TCGetPropertyValue(bomLine,"Bomline",prop[0],value1); + if (prop[1].equals("itemtext1")) + { + if (value == null || value.equals("") || value.equals("Eac") || value.equals("Each.") || value.equals("每个") ) + { + value = "ea"; + } + }else if (prop[1].equals( "sortstring")) + { + value = sort; + } + else if (prop[1].equals( "component")) + { + if( prop[1].contains("-")) { + String[] split2 = prop[1].split("-"); + value = split2[0]; + } + + } + else if (prop[1].equals( "compqty") && !value.equals("")) + { + //BOM关系中子项数量*SAP BOM基本数量 + double bomNum = Double.valueOf(value); + double bomBase = 1000; + double sum = bomNum*bomBase; +// char * sumChar = new char[20]; +// sprintf(sumChar, "%.3f", sum); + DecimalFormat df = new DecimalFormat("0.000"); + //cout << "bomNum【" << bomNum << "】,bomBaseNum【" << bomBaseNum << "】,bomBase【" << bomBase << "】,sum【" << sum << "】,sumChar【" << sumChar << "】\n" << endl; + //printf("bomNum【%d】,bomBaseNum【%s】,bomBase:【%d】,sum:【%d】,sumChar:【%s】\n", bomNum, bomBaseNum,bomBase, sum, sumChar); + value = df.format(sum); + }else if (prop[1].equals("itemno") ) + { + //需要*10后,格式化为4位长度后进行传递 + if(!value.equals("")) { + Integer valueOf = Integer.valueOf(value)*10; + String newName = String.format("%04d", valueOf); + String substring = newName.substring(0,4); + value = substring; + } + + } + parameters.append( "\""); + parameters.append( value); + parameters.append( "\""); + if(t < split.length-1 ) { + parameters.append( ","); + } + + } + parameters.append( "}"); + }else { + System.out.println("type == >"+type); + } + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } +// } + } +// getBomLineProperty(BomLine, typePropertyType, basequan, (char*)result3.c_str(), parameters); + parameters.append( "]"); + parameters.append( "}"); + parameters.append( "]"); + String paramStr = parameters.toString(); + boolean sapConnectBom = utils.sapConnectBom(paramStr); + return sapConnectBom; + } + private static String getCellValue(XSSFCell cell) { + // TODO Auto-generated method stub +// int cellType = cell.getCellType(); + if(cell==null) { + return ""; + } + cell.setCellType(CellType.STRING); + String stringCellValue = cell.getStringCellValue(); + + return stringCellValue; + + } + ArrayList parentJSON=new ArrayList(); + ArrayList> childJSON=new ArrayList>(); + protected void getAllBoms(AIFComponentContext[] children) { + // TODO Auto-generated method stub + + for(AIFComponentContext context : children) { + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + try { + TCComponentItemRevision itemRevision = component.getItemRevision(); + String ml8_ProcessingMode = itemRevision.getStringProperty("ml8_ProcessingMode"); + String ml8_AddTrade = itemRevision.getStringProperty("ml8_AddTrade"); + if(ml8_ProcessingMode!=null && ml8_AddTrade!=null) { + if((ml8_ProcessingMode.equals("自制"))|| (ml8_ProcessingMode.equals("外协外购") && ml8_AddTrade.equals("是"))) { +// System.out.println("--------"+"获取子件"); + AIFComponentContext[] children2 = component.getChildren(); + ArrayList bomLines =new ArrayList(); + for(AIFComponentContext context2:children2) { + TCComponentBOMLine component2 = (TCComponentBOMLine)context2.getComponent(); + bomLines.add(component2); +// this.bomLines.add(component2); + } + +// listMap.put(component, bomLines); + getAllBoms(children2); + if(bomLines.size()>0) { + parentJSON.add(component); + childJSON.add(bomLines); + } + + } + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomSapHandler.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomSapHandler.java new file mode 100644 index 0000000..0ffb137 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendBomSapHandler.java @@ -0,0 +1,116 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SendBomSapHandler extends AbstractHandler { + +// private TCComponentItem item; + private List dancCompList = new ArrayList(); + private List duocCompList = new ArrayList(); + private TCSession session; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + + + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + +// item = null; + if(targetComponents.length==0) { + MessageBox.post("请选择至少一个对象","提示",2); + } + dancCompList.clear(); + duocCompList.clear(); + for(int t = 0; t0) { + Thread t=new Thread(new Runnable(){ + public void run(){ + + SendBomSapDialog dialog = new SendBomSapDialog(session,dancCompList,false); + } + }); + t.start(); + }else if(duocCompList.size()>0) { + Thread t=new Thread(new Runnable(){ + public void run(){ + + SelectDialog dialog = new SelectDialog(session,duocCompList); + } + }); + t.start(); + } + + + + return null; + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapBomBean.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapBomBean.java new file mode 100644 index 0000000..891864e --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapBomBean.java @@ -0,0 +1,76 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import java.util.List; + +public class SendSapBomBean { + private String matnr; + private String werks; + private String bomusage; + private String alternative; + private String validdate; + private String description; + private String basequan = "1000"; + private String flag; + private String result; + private List itemdetail; + public String getMatnr() { + return matnr; + } + public void setMatnr(String matnr) { + this.matnr = matnr; + } + public String getWerks() { + return werks; + } + public void setWerks(String werks) { + this.werks = werks; + } + public String getBomusage() { + return bomusage; + } + public void setBomusage(String bomusage) { + this.bomusage = bomusage; + } + public String getAlternative() { + return alternative; + } + public void setAlternative(String alternative) { + this.alternative = alternative; + } + public String getValiddate() { + return validdate; + } + public void setValiddate(String validdate) { + this.validdate = validdate; + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + public String getBasequan() { + return basequan; + } + public void setBasequan(String basequan) { + this.basequan = basequan; + } + public List getItemdetail() { + return itemdetail; + } + public void setItemdetail(List itemdetail) { + this.itemdetail = itemdetail; + } + public String getFlag() { + return flag; + } + public void setFlag(String flag) { + this.flag = flag; + } + public String getResult() { + return result; + } + public void setResult(String result) { + this.result = result; + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapBomChildBean.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapBomChildBean.java new file mode 100644 index 0000000..b184d6c --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapBomChildBean.java @@ -0,0 +1,116 @@ +package cn.net.connor.ml.plm.sendBomSap; + +public class SendSapBomChildBean { + private String itemno; + private String itemcateg = "L"; + private String component; + private String compqty; + private String itemtext1; + private String itemtext2; + private String sortstring; + private String zzmaktx1; + private String zzbz; + private String zzbz2; + private String zzbz3; + private String zzbz4; + private String zzbz5; + private String zzbz6; + private String message; + private String flag; + public String getItemno() { + return itemno; + } + public void setItemno(String itemno) { + this.itemno = itemno; + } + public String getItemcateg() { + return itemcateg; + } + public void setItemcateg(String itemcateg) { + this.itemcateg = itemcateg; + } + public String getComponent() { + return component; + } + public void setComponent(String component) { + this.component = component; + } + public String getCompqty() { + return compqty; + } + public void setCompqty(String compqty) { + this.compqty = compqty; + } + public String getItemtext1() { + return itemtext1; + } + public void setItemtext1(String itemtext1) { + this.itemtext1 = itemtext1; + } + public String getItemtext2() { + return itemtext2; + } + public void setItemtext2(String itemtext2) { + this.itemtext2 = itemtext2; + } + public String getSortstring() { + return sortstring; + } + public void setSortstring(String sortstring) { + this.sortstring = sortstring; + } + public String getZzmaktx1() { + return zzmaktx1; + } + public void setZzmaktx1(String zzmaktx1) { + this.zzmaktx1 = zzmaktx1; + } + public String getZzbz() { + return zzbz; + } + public void setZzbz(String zzbz) { + this.zzbz = zzbz; + } + public String getZzbz2() { + return zzbz2; + } + public void setZzbz2(String zzbz2) { + this.zzbz2 = zzbz2; + } + public String getZzbz3() { + return zzbz3; + } + public void setZzbz3(String zzbz3) { + this.zzbz3 = zzbz3; + } + public String getZzbz4() { + return zzbz4; + } + public void setZzbz4(String zzbz4) { + this.zzbz4 = zzbz4; + } + public String getZzbz5() { + return zzbz5; + } + public void setZzbz5(String zzbz5) { + this.zzbz5 = zzbz5; + } + public String getZzbz6() { + return zzbz6; + } + public void setZzbz6(String zzbz6) { + this.zzbz6 = zzbz6; + } + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + public String getFlag() { + return flag; + } + public void setFlag(String flag) { + this.flag = flag; + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapDisopBean.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapDisopBean.java new file mode 100644 index 0000000..1c9efa1 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/SendSapDisopBean.java @@ -0,0 +1,41 @@ +package cn.net.connor.ml.plm.sendBomSap; + +public class SendSapDisopBean { + private String dispo; + private String beskz; + private String sobsl; + private String retcode; + private String retmsg; + public String getDispo() { + return dispo; + } + public void setDispo(String dispo) { + this.dispo = dispo; + } + public String getBeskz() { + return beskz; + } + public void setBeskz(String beskz) { + this.beskz = beskz; + } + public String getSobsl() { + return sobsl; + } + public void setSobsl(String sobsl) { + this.sobsl = sobsl; + } + public String getRetcode() { + return retcode; + } + public void setRetcode(String retcode) { + this.retcode = retcode; + } + public String getRetmsg() { + return retmsg; + } + public void setRetmsg(String retmsg) { + this.retmsg = retmsg; + } + + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/utils.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/utils.java new file mode 100644 index 0000000..477ea47 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/sendBomSap/utils.java @@ -0,0 +1,252 @@ +package cn.net.connor.ml.plm.sendBomSap; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import com.alibaba.fastjson.JSON; +//import com.connor.ml.bean.SendSapBomBean; +//import com.connor.ml.bean.SendSapBomChildBean; +//import com.connor.ml.bean.SendSapDisopBean; +//import com.connor.ml.util.SAPConn; +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoFunction; +import com.sap.conn.jco.JCoParameterList; +import com.sap.conn.jco.JCoRepository; +import com.teamcenter.rac.common.lov.LOVComboBox; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; +//import com.yujianbo.main.main; + +public class utils { + + public static void main(String[] args) { + String value = "12345"; + Integer valueOf = Integer.valueOf(value)*10; + String newName = String.format("%04d", valueOf); + String substring = newName.substring(0,4); + System.out.println(substring); + } + + public static void dymanicLov(TCSession session,TCComponentListOfValues lov,LOVComboBox lovComboBox) { +// System.out.println("动态lovName=" + lovName); + + LOVService lovService = LOVService.getService(session); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = ""; // lov的后台值 + filter.order = 1; + filter.numberToReturn = 10000; + filter.maxResults = 10000; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); +// LOVSearchResults + System.out.println("动态lov数量" + result.lovValues.length); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + String disval = ""; + String xsVal = ""; + String key1 = "r9_WLZ";// 显示值第一列 + for(String key : map.keySet()) { + lovComboBox.addItem(map.get(key)[0]); +// System.out.println(""); + } + } + } + public static String TCGetPropertyValue(TCComponentBOMLine bomLine,String type,String propertyName,String propertyValue) throws TCException + { + //判断是否包含.号 + if (propertyName.contains(".")) + { + //根据等号拆分条件和值 +// char ** itemPropertyChar = new char *[64]; +// //分割字符串 +// split(propertyName, ".", itemPropertyChar, &itemPropertyCount); + + String[] split = propertyName.split("\\."); + String itemAddress = split[0]; +// char * itemAddress = itemPropertyChar[0]; + + if (type.equals("Bomline")) + { +// tag_t revisions = NULLTAG; + TCComponent item=null; +// AOM_ask_value_tag(item, "bl_line_object", &revisions); + //传进来的是对象 + if (itemAddress.equals("item")) + { +// ITEM_ask_item_of_rev(revisions, &item); + item = bomLine.getItem(); + } + else if (itemAddress.equals("rev")) + { + item = bomLine.getItemRevision(); + } + else if (itemAddress.equals("revMaster")) + { + TCComponentItemRevision revision= bomLine.getItemRevision(); + TCComponent revMaster = revision.getRelatedComponent("IMAN_master_form_rev"); + if(revMaster!=null) { + item=revMaster; + } + }else { + item=bomLine; + } + //判断拆分出的数量是否大于2 + if (split.length > 2) + { + //遍历查找关系对象 + for (int i = 1; i < split.length - 1; i++) + { +// item.get +// AOM_ask_value_tag(item, itemPropertyChar[i], &item); + } + } + if (item == null) + { + propertyValue = ""; + } + else + { + try { + propertyValue = item.getStringProperty(split[split.length-1]); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + } + else + { + propertyValue = propertyName; + } + + return propertyValue; + } + public static String sapConnectDisop(String matnr,String werks) { + try { + String bapiFunctionName = "ZMLPLM_MM_F0006"; + JCoDestination destination = SAPConn.connect(); + JCoRepository repository = destination.getRepository(); // JCoFunction是一个接口,代表SAP系统的函数库 + JCoFunction function = repository.getFunction(bapiFunctionName); // 从这个函数模板获得该SAP函数的对象 + JCoParameterList input = function.getImportParameterList(); // 获得函数的import参数列表 +// input.getva + input.setValue("MATNR", matnr); + input.setValue("WERKS", werks); + function.execute(destination); + JCoParameterList output = function.getExportParameterList(); // 获得Export变量列表。 + String ml8_MRP = output.getString("DISPO"); + String ml8_Purc = output.getString("BESKZ"); + String ml8_Speci = output.getString("SOBSL"); + + return ml8_MRP; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return ""; + } + public static boolean sapConnectBom(String proStr) { + try { + String json = proStr; +// json = json.substring(1, json.length() - 1); + System.out.println("send ===>"+json); + insertLog("SDsapConnectBom", json, "POST"); + String bapiFunctionName = "ZMLPLM_MM_F0004"; + JCoDestination destination = SAPConn.connect(); + JCoRepository repository = destination.getRepository(); // JCoFunction是一个接口,代表SAP系统的函数库 + JCoFunction function = repository.getFunction(bapiFunctionName); // 从这个函数模板获得该SAP函数的对象 + JCoParameterList input = function.getImportParameterList(); // 获得函数的import参数列表 + input.setValue("IN", json); + function.execute(destination); + JCoParameterList output = function.getExportParameterList(); // 获得Export变量列表。 + String value = output.getString("OUT"); + + List stu = JSON.parseArray(value, SendSapBomBean.class); + // 报错错误信息 + System.out.println("sapConnectBom"+ value+"RESULT"); + insertLog("SDsapConnectBom", value, "RESULT"); + StringBuffer stringBuffer = new StringBuffer(); + for (SendSapBomBean sendSapBomBean : stu) { + + if (sendSapBomBean.getFlag().equals("E")) { + stringBuffer.append(sendSapBomBean.getMatnr()); + stringBuffer.append(":"); + stringBuffer.append(sendSapBomBean.getResult()); + stringBuffer.append("\r"); + System.out.println("error"); + return false; + } + List sendSapBomChildBeans = sendSapBomBean.getItemdetail(); + if (sendSapBomChildBeans != null && sendSapBomChildBeans.size() > 0) { + for (int i = 0; i < sendSapBomChildBeans.size(); i++) { + if (sendSapBomChildBeans.get(i).getFlag().equals("E")) { + stringBuffer.append(sendSapBomChildBeans.get(i).getComponent()); + stringBuffer.append(":"); + stringBuffer.append(sendSapBomChildBeans.get(i).getMessage()); + stringBuffer.append("\r"); + } + } + } + } + if (stringBuffer.length() > 1) { + System.out.println(stringBuffer.toString()); + } + // E失败,S成功 + + return true; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return true; + } + public static void insertLog(String type, String json, String value) { + InputStream input = null; + try { + input = new BufferedInputStream(utils.class.getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String insertSql = String.format(pro.getProperty("ML_WEBSERVICE_LOGINSERTSQL"), type, json, + sdf.format(new Date()), value); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + DbPool.freeAll(); + } + } + + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KAction.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KAction.java new file mode 100644 index 0000000..030ee39 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KAction.java @@ -0,0 +1,37 @@ +package cn.net.connor.ml.plm.tcm; + +import java.lang.reflect.Constructor; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.util.MessageBox; + + +public class KAction extends AbstractAIFAction { + + + KAction(AbstractAIFUIApplication app, String string) { + super(app,string); + } + + @Override + public void run() { + try { + int ind = actionName.indexOf('#'); + String action=actionName; + String actionData=""; + if(ind>0) { + action=actionName.substring(0,ind); + actionData=actionName.substring(ind+1); + } + Class c = Class.forName(action); + Constructor constructor = c.getConstructor(AbstractAIFApplication.class, String.class,String.class); + KCommand command = (KCommand) constructor.newInstance(this.application, action, actionData); + command.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e.toString(),KLocale.getString("error"),MessageBox.ERROR); + } + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KCommand.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KCommand.java new file mode 100644 index 0000000..6f97d29 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.ml.plm.tcm; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; + +public abstract class KCommand extends AbstractAIFCommand { + + protected AbstractAIFApplication app; + protected String actionInfo; + + public KCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + this.app = app; + this.actionInfo = actionInfo; + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KHandler.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KHandler.java new file mode 100644 index 0000000..d8e60c6 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KHandler.java @@ -0,0 +1,24 @@ +package cn.net.connor.ml.plm.tcm; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +/** + * Add following config to MANIFEST.MF + * Eclipse-RegisterBuddy: k.util + * @author Administrator + * + */ +public class KHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + new Thread(new KAction(app,arg0.getCommand().getId())).start(); + return null; + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KLocale.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KLocale.java new file mode 100644 index 0000000..55e178a --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KLocale.java @@ -0,0 +1,22 @@ +package cn.net.connor.ml.plm.tcm; + +import com.teamcenter.rac.util.Registry; + + +public class KLocale { + + public static final Registry reg = Registry.getRegistry(KLocale.class); + + public static String getString(String title) { + if (isEmpty(title)) { + return ""; + } else { + String res = reg.getString(title); + return isEmpty(res) ? title : res; + } + } + + private static boolean isEmpty(String title) { + return title == null || "".equals(title.trim()); + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KOperation.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KOperation.java new file mode 100644 index 0000000..38688ce --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KOperation.java @@ -0,0 +1,54 @@ +package cn.net.connor.ml.plm.tcm; + +import java.awt.Dimension; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; + +//import cn.net.connor.ml.plm.util.ProgressBar; + +/* + * do not call executeOperation yourself + * use session.performOperation + */ +public abstract class KOperation extends AbstractAIFOperation { + + protected AbstractAIFApplication app; + protected TCSession session; + public String messageLabel; + + public KOperation(AbstractAIFApplication app, String opName, String messageLabel) { + super(opName, true); + this.app = app; + this.session = (TCSession) app.getSession(); + this.messageLabel = messageLabel;// 进度条信息 + setSession(session); + } + + public abstract boolean init() throws Exception; + + public abstract void execute() throws Exception; + + @Override + public void executeOperation() { + ProgressBar pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true); + try { + pb.showDialog(); + pb.setText(messageLabel); + setStatus(KLocale.getString("initop.STATUS")); + if (!init()) { + pb.disposeDialog(); + return; + } + setStatus(KLocale.getString("exeop.STATUS")); + pb.setText(messageLabel); + execute(); + pb.disposeDialog(); + } catch (Exception e) { + pb.disposeDialog(); + KUtil.error(getCurrentDesktop(), "发生异常:\n" + e); + e.printStackTrace(); + } + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KOperation2.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KOperation2.java new file mode 100644 index 0000000..aec425b --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KOperation2.java @@ -0,0 +1,53 @@ +package cn.net.connor.ml.plm.tcm; + +import java.awt.Dimension; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCSession; + +//import cn.net.connor.ml.plm.util.ProgressBar; + +/* + * do not call executeOperation yourself + * use session.performOperation + */ +public abstract class KOperation2 extends AbstractAIFOperation { + + protected AbstractAIFApplication app; + protected TCSession session; + protected ProgressBar pb; + + public KOperation2(AbstractAIFApplication app, String opName) { + super(opName, true); + this.app = app; + this.session = (TCSession) app.getSession(); + setSession(session); + } + + public abstract boolean init() throws Exception; + + public abstract void execute() throws Exception; + + @Override + public void executeOperation() { + pb = new ProgressBar(getCurrentDesktop(), new Dimension(250, 50), true); + try { + pb.showDialog(); + setStatus(KLocale.getString("initop.STATUS")); + if (!init()) { + pb.disposeDialog(); + return; + } + setStatus(KLocale.getString("exeop.STATUS")); + execute(); + KUtil.setByPass(false); + pb.disposeDialog(); + } catch (Exception e) { + pb.disposeDialog(); + KUtil.setByPass(false); + KUtil.error(getCurrentDesktop(), "发生异常:\n" + e); + e.printStackTrace(); + } + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KUtil.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KUtil.java new file mode 100644 index 0000000..9f7bba4 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/KUtil.java @@ -0,0 +1,1991 @@ +package cn.net.connor.ml.plm.tcm; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.Window; +import java.io.BufferedWriter; +import java.io.EOFException; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.net.URI; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Shell; + +import com.teamcenter.rac.aif.commands.open.OpenCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupMember; +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.TCComponentManager; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentScheduleDeliverable; +import com.teamcenter.rac.kernel.TCComponentTCCalendar; +import com.teamcenter.rac.kernel.TCComponentTaskDeliverable; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.schedule.calendar.TCCalendar; +import com.teamcenter.rac.schedule.componentutils.CalendarHelper; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.rac.util.log.TcLogger; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2006_03.DataManagement.Relationship; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedInfo; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedOutput; +import com.teamcenter.services.rac.core._2007_01.DataManagement.WhereReferencedResponse; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; +import com.teamcenter.soa.client.model.LovValue; +import com.teamcenter.soa.client.model.ServiceData; + +@SuppressWarnings("deprecation") +public class KUtil { + + public static final TCSession session; + public static final TCTextService textService; + public static final Registry REG = Registry.getRegistry(KUtil.class); + public static final ZoneId zoneId = ZoneId.systemDefault(); + public static final Registry reg = Registry.getRegistry(KUtil.class); + + public static String getRegString(String title) { + String res = reg.getString(title); + if (KUtil.isEmpty(res)) { + return title; + } + return res; + } + + static { + session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + textService = session.getTextService(); + } + + public static void printLogFile() { + System.out.println("Log File: " + TcLogger.getRecursionDepth()); + } + + public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) { + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + if (value instanceof Double) { + tcProperty.setDoubleValue((double) value); + } else { + tcProperty.setDoubleValue(Double.parseDouble(value.toString())); + } + break; + case TCProperty.PROP_int: + if (value instanceof Integer) { + tcProperty.setDoubleValue((int) value); + } else { + tcProperty.setDoubleValue(Integer.parseInt(value.toString())); + } + break; + case TCProperty.PROP_string: + tcProperty.setStringValue(value.toString()); + break; + case TCProperty.PROP_date: + if (value instanceof Date) { + tcProperty.setDateValue((Date) value); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + tcProperty.setDateValue(sdf.parse(value.toString())); + } + break; + default: + break; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static Object getTCPropertyValue(TCComponent item, String propertyName) { + Object result = ""; + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + if (tcProperty == null) { + System.out.println("未获取属性:" + propertyName); + return result; + } + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + result = tcProperty.getDoubleValue(); + break; + case TCProperty.PROP_int: + result = tcProperty.getIntValue(); + break; + case TCProperty.PROP_string: + result = tcProperty.getStringValue(); + break; + case TCProperty.PROP_date: + result = tcProperty.getDateValue(); + break; + default: + break; + } + } catch (TCException e) { + e.printStackTrace(); + } + return result; + } + + public static String getCellValue(Cell c) { + if (c == null) { + return ""; + } + String value = ""; + if (c.getCellType() == CellType.NUMERIC.getCode()) { + DecimalFormat df = new DecimalFormat("0"); + String whatYourWant = df.format(c.getNumericCellValue()); + return whatYourWant; + } + switch (c.getCellType()) { + case HSSFCell.CELL_TYPE_NUMERIC:// 数字 + value = (c.getNumericCellValue() + "").split("\\.")[0]; + break; + case HSSFCell.CELL_TYPE_STRING:// 字符串 + value = c.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_BOOLEAN:// boolean + value = c.getBooleanCellValue() + ""; + break; + case HSSFCell.CELL_TYPE_FORMULA:// 公式 + value = c.getCellFormula() + ""; + break; + case HSSFCell.CELL_TYPE_BLANK:// 空值 + value = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + value = "非法字符"; + break; + default: + value = "未知类型"; + break; + } + return value; + } + + /** + * 用来得到真实行数 + * @param sheet + * @param flag 需要写进数据库的Excel单元格列索引,多列用逗号隔开 比如Excel有5列单元格,其中4列 + * 需要入库,第2列不需要入库,这里flag就传 [0,2,3,4] + * @return + * @throws Exception + * + */ + public static int findRealRows(Sheet sheet, int... flag) throws Exception { + int row_real = 0; + int rows = sheet.getPhysicalNumberOfRows();// 此处物理行数统计有错误, + int size = flag.length; + try { + + for (int i = 1; i < rows; i++) { + Row row = sheet.getRow(i); + int total = 0; + ArrayList blank = new ArrayList(); + int type = -1; + String s = null; + for (int j : flag) { + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + type = row.getCell(j).getCellType(); + row.getCell(j).setCellType(1); + } + + if (row.getCell(j) == null || row.getCell(j).getStringCellValue().matches("^\\s+$") || row.getCell(j).getCellType() > 2) { + total++; + + if (!(row.getCell(j) == null) && row.getCell(j).getCellType() < 2) { + row.getCell(j).setCellType(type); + } + blank.add(j); + + } + } + System.out.println(s + "我"); + // 如果4列都是空说明就该返回 + if (total == flag.length) { + + return row_real; + } else if (total == 0) { + row_real++; + + } else { + String h = ""; + for (Integer b : blank) { + + h = h + "第" + (b + 1) + "列" + " "; + } + throw new Exception("第" + (i + 1) + "行" + h + "不能为空"); + } + + } + } catch (NullPointerException e) { + throw new Exception("excel格式异常,请检查excel格式有无数据缺失,无效数据行!"); + } + return row_real; + } + + public static Workbook getWorkbook(File file) throws Exception { + Workbook workbook = null; + FileInputStream in = new FileInputStream(file); + if (file.getName().endsWith("xlsx")) { + System.out.println("读取模板:" + file.getName()); + try { + workbook = WorkbookFactory.create(in); + } catch (EOFException e) { + e.printStackTrace(); + } +// workbook = new XSSFWorkbook(in); + } else { + System.out.println("格式错误"); + } + in.close(); + return workbook; + } + + public static void removeEnd(StringBuilder sb, int len) { + if (sb == null || len <= 0) { + return; + } + if (sb.length() >= len) { + sb.setLength(sb.length() - len); + } + } + + public static TCComponent[] getComponentsByItemType(TCComponent comp, String type, String relation) throws TCException { + TCComponent[] comps1 = comp.getRelatedComponents(relation); + if (comps1 == null || comps1.length < 1) { + return null; + } + ArrayList list = new ArrayList(); + for (TCComponent comp1 : comps1) { + if (comp1.getType().equals(type)) { + list.add(comp1); + } + } + return list.toArray(new TCComponent[] {}); + } + + public static TCComponentContextList objectsInProject(String type, String projId) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static TCComponentContextList objectsInProject(String type, String projId, String name) throws Exception { + if (KUtil.isEmpty(type) || KUtil.isEmpty(projId) || KUtil.isEmpty(name)) { + return null; + } + String queryName = "Objects in Projects"; + String[] keys = new String[] { KUtil.getText("Name"), KUtil.getText("Type"), KUtil.getText("ProjectID") }; + String[] vals = new String[] { name, type, projId }; + return KUtil.query(KUtil.session, queryName, keys, vals); + } + + public static boolean checkGMPrivilegeFromPref(String prefName) throws Exception { + boolean validityCanEdit = false; + String validRoles = KUtil.getPrefVal(KUtil.session, prefName); + System.out.println(">> Check GroupMember Priv: " + validRoles); + if (!KUtil.isEmpty(validRoles)) { + List groups = new ArrayList(); + List roles = new ArrayList(); + String[] split = validRoles.split(":"); + for (String string : split) { + if (string.startsWith("G.")) { + groups.add(string.substring(2)); + } else if (string.startsWith("R.")) { + roles.add(string.substring(2)); + } + } + TCComponentUser currentUser = KUtil.session.getUser(); + System.out.println(">> Current User: " + currentUser); + TCComponentGroupMember[] gms = currentUser.getGroupMembers(); + System.out.println(">> Current GroupMembers: " + Arrays.toString(gms)); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + TCComponentGroup g = gm.getGroup(); + TCComponentRole r = gm.getRole(); + String gName = g.getGroupName(); + String rName = r.getRoleName(); + System.out.println((i + 1) + ". " + gName + " - " + rName); + if (groups.contains(gName) && roles.contains(rName)) { + validityCanEdit = true; + // break; + } + } + } + return validityCanEdit; + } + + public static boolean compare(String str1, String str2) { + if (str1 == null) { + str1 = ""; + } + if (str2 == null) { + str2 = ""; + } + return str1.equals(str2); + } + + public static boolean compare(Object str1, Object str2) { + if (str1 == null) { + return str2 == null; + } + return str1.equals(str2); + } + + public static TCComponentItem createItem(TCComponentItemType itemType, String itemName) throws Exception { + if (itemType == null) { + return null; + } + String id = itemType.getNewID(); + String rev = itemType.getNewRev(null); + return itemType.create(id, rev, itemType.getName(), itemName, "", null); + } + + public static void setByPass(boolean val) { + try { + TCUserService userservice = session.getUserService(); + userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[] { "" }); + System.out.println(val ? "Open Bypass" : "Close Bypass"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static TCComponentItem createItemBySOA(String itemTypeName, String revTypeName, String revMasterTypeName, String itemId, String revId, + String name, Map stringProps, Map dateProps) throws Exception { + if (KUtil.isEmpty(itemTypeName) || KUtil.isEmpty(revTypeName) || KUtil.isEmpty(revMasterTypeName)) { + return null; + } + CreateInput revMasterInput = new CreateInput(); + revMasterInput.boName = revMasterTypeName; + if (stringProps != null) { + revMasterInput.stringProps = stringProps; + } + if (dateProps != null) { + revMasterInput.dateProps = dateProps; + } + CreateInput revInput = new CreateInput(); + revInput.boName = revTypeName; + Map revPropMap = new HashMap<>(); + if (!KUtil.isEmpty(revId)) { + revPropMap.put("item_revision_id", revId); + } + revInput.stringProps = revPropMap; + Map revMasterInfoMap = new HashMap<>(); + revMasterInfoMap.put("IMAN_master_form_rev", new CreateInput[] { revMasterInput }); + revInput.compoundCreateInput = revMasterInfoMap; + // create rev + CreateInput itemInput = new CreateInput(); + itemInput.boName = itemTypeName; + Map itemPropMap = new HashMap<>(); + if (!KUtil.isEmpty(itemId)) { + itemPropMap.put("item_id", itemId); + } + if (!KUtil.isEmpty(name)) { + itemPropMap.put("object_name", name); + } + itemInput.stringProps = itemPropMap; + Map revInfoMap = new HashMap<>(); + revInfoMap.put("revision", new CreateInput[] { revInput }); + itemInput.compoundCreateInput = revInfoMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateItem"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentItem) { + return (TCComponentItem) s; + } + } + } + return null; + } + + public static TCComponentFolder createFolderBySOA(String folderTypeName, String folderName) throws Exception { + if (KUtil.isEmpty(folderTypeName)) { + return null; + } + CreateInput itemInput = new CreateInput(); + itemInput.boName = folderTypeName; + Map itemPropMap = new HashMap<>(); + itemPropMap.put("object_name", folderName); + itemInput.stringProps = itemPropMap; + // create info + CreateIn cI = new CreateIn(); + cI.clientId = "CreateFolder"; + cI.data = itemInput; + // service + DataManagementService service = DataManagementService.getService(session); + // create + CreateResponse resp = service.createObjects(new CreateIn[] { cI }); + throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + if (cOs.length > 0) { + for (TCComponent s : cOs[0].objects) { + if (s instanceof TCComponentFolder) { + return (TCComponentFolder) s; + } + } + } + return null; + } + + public static void throwServiceDataError(ServiceData serviceData) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg); + } + } + // System.out.println(errInfo.toString()); + throw new Exception(errInfo.toString()); + } + } + + public static void throwServiceDataError(ServiceData serviceData, String defaultErrorMsg) throws Exception { + if (serviceData.sizeOfPartialErrors() > 0) { + StringBuilder errInfo = new StringBuilder(); + for (int i = 0; i < serviceData.sizeOfPartialErrors(); i++) { + for (String msg : serviceData.getPartialError(i).getMessages()) { + errInfo.append(msg + "\n"); + } + } + // System.out.println(errInfo.toString()); + if (KUtil.isEmpty(errInfo.toString())) { + throw new Exception(defaultErrorMsg); + } + throw new Exception(errInfo.toString()); + } + } + + public static Date localDateToDate(LocalDate localDate) { + if (localDate == null) { + return null; + } + ZonedDateTime zdt = localDate.atStartOfDay(zoneId); + Date date = Date.from(zdt.toInstant()); + return date; + } + + public static LocalDate dateToLocalDate(Date date) { + if (date == null) { + return null; + } + Instant instant = date.toInstant(); + LocalDate localDate = instant.atZone(zoneId).toLocalDate(); + return localDate; + } + + public static TCComponent stringToComponent(String uid) throws Exception { + if (KUtil.isEmpty(uid)) { + return null; + } + return session.stringToComponent(uid); + } + + public static String getText(String str) throws Exception { + if (KUtil.isEmpty(str)) { + return str; + } + String res = textService.getTextValue(str); + if (!KUtil.isEmpty(res)) { + return res; + } + return str; + } + + public static void sendTo(TCComponent comp, String perspectiveId) { + if (comp == null) { + return; + } + if (KUtil.isEmpty(perspectiveId)) { + perspectiveId = "com.teamcenter.rac.ui.perspectives.navigatorPerspective"; + } + com.teamcenter.rac.common.Activator.getDefault().openPerspective(perspectiveId); + com.teamcenter.rac.common.Activator.getDefault().openComponents(perspectiveId, new TCComponent[] { comp }); + } + + public static void open(TCComponent comp) { + if (comp == null) { + return; + } + if (comp instanceof TCComponentScheduleDeliverable) { + System.out.println(">> Open Schedule Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("deliverable_inst"); + System.out.println(">> Open Schedule Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } else if (comp instanceof TCComponentTaskDeliverable) { + System.out.println(">> Open Task Deliverable: " + comp); + try { + comp = comp.getReferenceProperty("fnd0DeliverableInstance"); + System.out.println(">> Open Task Deliverable Inst: " + comp); + if (comp == null) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + try { + Registry localRegistry = Registry.getRegistry("com.teamcenter.rac.commands.open.open"); + OpenCommand localOpenCommand = (OpenCommand) localRegistry.newInstanceForEx("openCommand", + new Object[] { AIFUtility.getActiveDesktop(), comp }); + localOpenCommand.executeModeless(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static JButton getImageBtn(String iconName) { + ImageIcon icon = new ImageIcon(KUtil.class.getResource("/icons/" + iconName)); + JButton btn = new JButton(icon); + btn.setPreferredSize(new Dimension(26, 26)); + btn.setContentAreaFilled(true); + btn.setFocusPainted(false); + btn.setBorderPainted(true); + // btn.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + return btn; + } + + public static void info(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.INFORMATION); + } + + public static void warn(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.WARNING); + } + + public static void error(Window dialog, String msg) { + MessageBox.post(dialog, msg, "", MessageBox.ERROR); + } + + public static void error(Window dialog, String msg, String title) { + MessageBox.post(dialog, msg, title, MessageBox.ERROR); + } + + public static void showScrollDialog(Window dialog, String text, String title) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + JOptionPane.showMessageDialog(dialog, scrollPane, title, JOptionPane.INFORMATION_MESSAGE); + } + + public static void showScrollDialogWithExport(Window dialog, String text, String title, String exportFileName) { + if (dialog == null) { + dialog = UIUtilities.getCurrentModalDialog(); + } + JTextArea textArea = new JTextArea(text); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + textArea.setLineWrap(true); + textArea.setWrapStyleWord(true); + scrollPane.setPreferredSize(new Dimension(500, 300)); + String yesOption = KLocale.getString("ok"); + String exportOption = KLocale.getString("export"); + int op = JOptionPane.showOptionDialog(dialog, scrollPane, title, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, + new String[] { yesOption, exportOption }, yesOption); + if (op == 1) { + System.out.println("Export"); + File saveFile = KUtil.chooseSaveFile(dialog, exportFileName, "txt"); + if (saveFile != null) { + try { + BufferedWriter writer = new BufferedWriter(new FileWriter(saveFile, false)); + writer.write(text); + writer.flush(); + writer.close(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(dialog, e); + } + } + } + } + + public static void errorSWT(Shell shell, String message, String title) { + showDialog(shell, message, title, SWT.ICON_ERROR); + } + + public static void showDialog(Shell shell, String message, String title, int type) { + org.eclipse.swt.widgets.MessageBox dialog = new org.eclipse.swt.widgets.MessageBox(shell, SWT.OK | type); + dialog.setText(title); + dialog.setMessage(message); + dialog.open(); + } + + public static String[] getPrefVals(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValues(prefName); + } + + public static String getPrefVal(TCSession session, String prefName) throws Exception { + if (KUtil.isEmpty(prefName)) { + return null; + } + return session.getPreferenceService().getStringValue(prefName); + } + + public static String getReg(Registry reg, String name) { + String val = reg.getString(name); + // System.out.println("Read REG: " + name + " = " + val); + return val; + } + + public static String getReg(String name) { + return getReg(REG, name); + } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { + newRow(panel, comp, s, width, 0); + } + + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.weightx = weightx; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void newRow(JDialog panel, Component comp, GridBagConstraints s, int width) { + s.weightx = 0; + s.gridwidth = width; + s.gridx = 0; + s.gridy++; + panel.add(comp, s); + } + + public static void addCol(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + s.gridx++; + s.gridwidth = width; + s.weightx = weightx; + panel.add(comp, s); + } + + public static TCComponentDataset getDataset(TCComponent rev, String dsType, String dsName, String rel) throws Exception { + if (rev == null || KUtil.isEmpty(dsName)) { + return null; + } + rev.refresh(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.toString().equals(dsName)) { + return (TCComponentDataset) c; + } + } + return null; + } + + public static List getDatasets(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add((TCComponentDataset) c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel, String dsNamePrefix) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").startsWith(dsNamePrefix)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponentsContainsStr(TCComponent rev, String dsType, String rel, String dsNameSubStr) throws Exception { + if (rev == null) { + return null; + } + if (dsNameSubStr == null) { + dsNameSubStr = ""; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType) && c.getProperty("object_name").contains(dsNameSubStr)) { + res.add(c); + } + } + return res; + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add(c); + } + } + return res; + } + + public static TCComponentFolder getChildFolder(TCComponentFolder folder, String cFolderName) throws Exception { + if (folder == null || cFolderName == null) { + return null; + } + AIFComponentContext[] cc = folder.getChildren(); + int len = KUtil.getLen(cc); + for (int i = 0; i < len; i++) { + InterfaceAIFComponent c = cc[i].getComponent(); + if ((c instanceof TCComponentFolder) && cFolderName.equals(c.getProperty("object_name"))) { + return (TCComponentFolder) c; + } + } + return null; + } + + public static TCComponentDataset uploadFile(TCSession session, TCComponent rev, File newFile, String dsName, String dsTypeName, String refName, + String rel) throws Exception { + TCComponentDataset ds = getDataset(rev, dsTypeName, dsName, rel); + if (ds == null) { + TCComponentDatasetType dsType = (TCComponentDatasetType) session.getTypeComponent(dsTypeName); + ds = dsType.create(dsName, "", dsTypeName); + if (rev != null) { + rev.add(rel, ds); + rev.refresh(); + } + } + setDsFile(ds, refName, newFile); + return ds; + } + + public static void setDsFile(TCComponentDataset ds, String refName, File newFile) throws Exception { + if (ds.isCheckedOut()) { + throw new Exception(String.format(KLocale.getString("uploadfilewhencheckout.ERROR1"), ds.toString())); + } + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static void setDsFile2(TCComponentDataset ds, String refName, File newFile) throws Exception { + String[] refs = new String[] { refName }; + String[] files = new String[] { newFile.getAbsolutePath() }; + ds.setFiles(files, refs); + // ds.save(); + ds.refresh(); + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + public static int inArray(int target, int[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target == arr[i]) { + return i; + } + } + return -1; + } + + public static boolean inArray(String str, String arr, String splitter) { + if (KUtil.isEmpty(arr) || KUtil.isEmpty(splitter)) { + return false; + } + if (KUtil.isEmpty(str)) { + return true; + } + return inArray(str, arr.split(splitter)) >= 0; + } + + public static int inArray(String target, String[] arr) { + int len = arr == null ? 0 : arr.length; + for (int i = 0; i < len; i++) { + if (target.equals(arr[i])) { + return i; + } + } + return -1; + } + + public static int getNextColNumber(int currentIndex, int[] skipColIndex, int cols) { + int res = currentIndex; + for (int i = 0; i < cols; i++) { + res++; + if (inArray(res, skipColIndex) >= 0) { + i--; + } + } + return res; + } + + public static List> groupList(List originList, int maxCount, int gap, E gapFiller) { + List> res = new ArrayList>(); + int cnt = originList == null ? 0 : originList.size(); + List list = new ArrayList(); + for (int i = 0; i < cnt; i++) { + list.add(originList.get(i)); + if (i != cnt - 1) {// add gap + for (int j = 0; j < gap; j++) { + list.add(gapFiller); + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List> groupListWithGapAdded(List list, int maxCount, E gapFiller) { + List> res = new ArrayList>(); + int cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List cList = new ArrayList(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + E item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static List>> groupList(List> originList, int maxCount, int gap, Map gapFiller, + String gapKey) { + List>> res = new ArrayList>>(); + int cnt = originList == null ? 0 : originList.size(); + List> list = new ArrayList>(); + boolean addGap = false; + for (int i = 0; i < cnt; i++) { + Map item = originList.get(i); + list.add(item); + if (i != cnt - 1) {// add gap + Map nextItem = originList.get(i + 1); + addGap = KUtil.isEmpty(gapKey) || (nextItem != null && nextItem.containsKey(gapKey)); + for (int j = 0; j < gap; j++) { + if (addGap) { + list.add(gapFiller); + } + } + } + } + cnt = list == null ? 0 : list.size(); + if (maxCount <= 0) { + maxCount = cnt; + } + int pageCounter = 0; + List> cList = new ArrayList>(); + res.add(cList); + for (int i = 0; i < cnt; i++) { + if (pageCounter == maxCount) { + cList = new ArrayList<>(); + res.add(cList); + pageCounter = 0; + } + if (cList != null) { + Map item = list.get(i); + if (cList.size() == 0 && item == gapFiller) { + continue; + } + cList.add(list.get(i)); + pageCounter++; + } + } + list.clear(); + list = null; + return res; + } + + public static File getFileFromDataset(TCSession session, String dsType, String uid, String prefName) throws Exception { + TCComponent comp = null; + try { + comp = session.stringToComponent(uid); + } catch (Exception e) { + e.printStackTrace(); + } + if (comp == null) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + String type = comp.getType(); + System.out.println("Dataset: " + comp + "|Type: " + type); + if (!dsType.equals(type)) { + throw new Exception(String.format(KLocale.getString("dsuidinpref.ERROR1"), prefName)); + } + TCComponentDataset tDataset = (TCComponentDataset) comp; + return getDatasetFile(tDataset); + } + + public static File getDatasetFile(TCComponentDataset dataset) throws Exception { + File[] files = dataset.getFiles("", System.getenv("TEMP")); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static File getDatasetFile(File dir, TCComponentDataset dataset) throws Exception { + if (dir == null || !dir.isDirectory()) { + throw new Exception("Directory not found."); + } + File[] files = dataset.getFiles("", dir.getAbsolutePath()); + if (files == null || files.length == 0) { + throw new Exception(String.format(KLocale.getString("norefindataset.ERROR1"), dataset.toString())); + } + System.out.println(">> Download file (" + files.length + "): " + files[0].getAbsolutePath()); + return files[0]; + } + + public static String[] getStringArrayProp(TCComponentForm form, String propName) throws Exception { + if (form == null) { + return null; + } + TCProperty prop = form.getFormTCProperty(propName); + if (prop == null) { + throw new java.lang.Exception(String.format(KLocale.getString("nopropintype.ERROR2"), form.getDisplayType(), propName)); + } + return prop.getStringArrayValue(); + } + + public static File chooseDirectory(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static boolean addReleaseStatus(TCSession session, String uid, String status) throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[2]; + obj[0] = uid; + obj[1] = status; + Object res = userservice.call("K_add_release_status", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + /** + * 设置只读属性的值 + * @param session + * @param propName + * @param propValue + * @param comp + * @return + * @throws Exception + */ + public static boolean setPropValue(TCSession session, String propName, String propValue, TCComponent comp) throws Exception { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[3]; + obj[0] = propName; + obj[1] = propValue; + obj[2] = comp; + Object res = userservice.call("Connor_Set_Prop_Value", obj); + if (res != null && res.toString().equalsIgnoreCase("true")) { + return true; + } + return false; + } + + public static File chooseFile(Component parent) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + int state = fileChooser.showOpenDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + FileNameExtensionFilter filter = new FileNameExtensionFilter("*.xlsx", "xlsx"); + fileChooser.setFileFilter(filter); + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File chooseSaveFile(Component parent, String defaultFile, String ext) { + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(new File(deskPath)); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + if (!KUtil.isEmpty(ext)) { + FileNameExtensionFilter filter = new FileNameExtensionFilter("*." + ext, ext); + fileChooser.setFileFilter(filter); + } + fileChooser.setSelectedFile(new File(defaultFile)); + int state = fileChooser.showSaveDialog(parent); + if (state == 1) { + return null; + } + return fileChooser.getSelectedFile(); + } + + public static File getNewFile(File folder, String fileName, String ext) { + File file = new File(folder.getAbsolutePath() + "\\" + fileName + "." + ext); + int index = 1; + while (file.exists()) { + file = new File(folder.getAbsolutePath() + "\\" + fileName + "(" + (index++) + ")." + ext); + } + return file; + } + + public static String getDateStr(Date date, String format) { + String res = ""; + try { + SimpleDateFormat sdf = new SimpleDateFormat(format); + res = sdf.format(date); + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentContextList query(TCSession session, String queryName, Map fields) throws Exception { + String[] keys = fields.keySet().toArray(new String[] {}); + String[] vals = fields.values().toArray(new String[] {}); + return query(session, queryName, keys, vals); + } + + public static TCComponentContextList query(TCSession session, String queryName, String[] keys, String[] vals) throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.getExecuteResultsList(keys, vals); + } + + public static TCComponent[] query2(TCSession session, String queryName, String[] keys, String[] vals) throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new Exception(String.format(KLocale.getString("querynotexist.ERROR1"), queryName)); + } + queryType.clearCache(); + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + + public static TCComponentContextList combineContext(TCSession session, TCComponentQuery query, TCComponentContextList... contexts) + throws Exception { + Class c = TCComponentContextList.class; + Field f1 = c.getDeclaredField("m_compUids"); + f1.setAccessible(true); + List compUids = new ArrayList<>(); + for (TCComponentContextList cc : contexts) { + String[] u1 = (String[]) f1.get(cc); + System.out.println(Arrays.toString(u1)); + compUids.addAll(Arrays.asList(u1)); + } + Constructor constructor = c.getDeclaredConstructor(TCComponentManager.class, TCComponent.class, String[].class, String[].class, + String.class); + constructor.setAccessible(true); + TCComponentContextList res = (TCComponentContextList) constructor.newInstance(new TCComponentManager(session), query, + compUids.toArray(new String[] {}), null, ""); + return res; + } + + public static int getLen(Object[] arr) { + return arr == null ? 0 : arr.length; + } + + public static String getValueInArray(String[] arr, int index) { + int len = arr == null ? 0 : arr.length; + if (index >= len) { + return ""; + } + return arr[index]; + } + + public static String getValueInArray(String arrStr, int index, String splitter) { + if (KUtil.isEmpty(arrStr)) { + return ""; + } + String[] split = arrStr.split(splitter, -1); + int len = getLen(split); + if (len > index && index >= 0) { + return split[index]; + } + return ""; + } + + public static String getTypeNames(TCSession session, Object[] types) { + int len = types == null ? 0 : types.length; + if (len == 0) { + return ""; + } + String[] names = new String[len]; + for (int i = 0; i < len; i++) { + try { + if ("TC_Project".equals(types[i].toString())) { + names[i] = KLocale.getString("project"); + } else { + names[i] = session.getTypeComponent(types[i].toString()).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + if (names[i] == null) { + names[i] = types[i].toString(); + } + } + return Arrays.toString(names); + } + + public static String getTypeName(TCSession session, String type) { + if (KUtil.isEmpty(type)) { + return ""; + } + try { + if ("TC_Project".equals(type)) { + return KLocale.getString("project"); + } else { + return session.getTypeComponent(type).getDisplayTypeName(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return type; + } + + public static boolean isReleased(TCComponent comp) throws Exception { + TCComponent[] status = comp.getReferenceListProperty("release_status_list"); + if (status == null || status.length == 0) { + return false; + } + return true; + } + + public static TCComponentUser getUserFromStr(String str) throws Exception { + System.out.println("Search User: " + str); + if (KUtil.isEmpty(str)) { + return null; + } + int ind1 = str.lastIndexOf('('); + int ind2 = str.lastIndexOf(')'); + TCComponentUser user = null; + if (ind1 > 0 && ind2 > ind1) { + String userId = str.substring(ind1 + 1, ind2); + if (KUtil.isEmpty(userId)) { + System.out.println("No Id between '(' and ')'"); + user = null; + } else { + user = queryUserById(userId); + } + } else { + user = queryUserById(str); + if (user == null) { + user = queryUserByName(str); + } + } + return user; + } + + public static TCComponentUser queryUserById(String userId) throws Exception { + System.out.println("Search User By Id: " + userId); + if (KUtil.isEmpty(userId)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("UserId") }; + String[] vals = new String[] { userId }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyid.ERROR1"), userId)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponentUser queryUserByName(String userName) throws Exception { + System.out.println("Search User By Name: " + userName); + if (KUtil.isEmpty(userName)) { + return null; + } + String queryName = "Admin - Employee Information"; + String[] keys = new String[] { KUtil.getText("PersonName") }; + String[] vals = new String[] { userName }; + TCComponentContextList res = KUtil.query(KUtil.session, queryName, keys, vals); + if (res.getListCount() == 0) { + return null; + } + if (res.getListCount() > 1) { + throw new Exception(String.format(KLocale.getString("multiuserbyname.ERROR1"), userName)); + } + return (TCComponentUser) res.get(0).getComponent(); + } + + public static TCComponent[] getGroupMember(List privMembers) throws Exception { + if (privMembers == null) { + return null; + } + List res = new ArrayList<>(); + for (TCComponentUser user : privMembers) { + TCComponentGroupMember[] gms = user.getGroupMembers(); + int len = KUtil.getLen(gms); + for (int i = 0; i < len; i++) { + TCComponentGroupMember gm = gms[i]; + if (KUtil.isEmpty(gm.toString())) { + continue; + } + /* + * if(!gm.isActive()) { System.out.println("锟斤拷锟皆憋拷腔疃拷锟?"+gm); continue; } + */ + if (!res.contains(gm)) { + System.out.println("Add Group Member: " + gm); + res.add(gm); + } else { + System.out.println("Added: " + gm); + } + } + } + return res.toArray(new TCComponent[] {}); + } + + public static int compareWBS(String wbsCode, String wbsCode2) { + if (KUtil.isEmpty(wbsCode) && KUtil.isEmpty(wbsCode2)) { + return 0; + } + if (KUtil.isEmpty(wbsCode)) { + return -1; + } + if (KUtil.isEmpty(wbsCode2)) { + return 1; + } + String[] a = wbsCode.split("\\."); + String[] b = wbsCode2.split("\\."); + int lenA = a.length; + int lenB = b.length; + for (int i = 0; i < lenA && i < lenB; i++) { + String aa = a[i]; + String bb = b[i]; + int ai = 0; + int bi = 0; + try { + ai = Integer.parseInt(aa); + bi = Integer.parseInt(bb); + } catch (Exception e) { + e.printStackTrace(); + } + if (ai != bi) { + return ai - bi; + } + } + return lenA - lenB; + } + + public static TCComponentListOfValues getLov(String lovName) { + TCComponentListOfValuesType lovType; + try { + lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if (lov.length > 0) + return lov[0]; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + public static String[] getDynamicLOV(String s) { + TCComponentListOfValues lov = null; + List lovDisplayValueList = new ArrayList<>(); + lovDisplayValueList.add(""); + List lovValueList = new ArrayList<>(); + lov = TCComponentListOfValuesType.findLOVByName(s); + try { + if ("Fnd0ListOfValuesDynamic".equals(lov.getProperty("lov_type"))) { + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = "object_name"; + filter.order = 1; + filter.numberToReturn = 100; + filter.maxResults = 100; + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + StringBuffer sb = new StringBuffer(); + sb.append(">>"); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; + + for (String key : map.keySet()) { + sb.append("UID:" + row.uid + ",key:" + key + ",value:" + map.get(key)[0]); + sb.append("\n"); + + lovDisplayValueList.add(map.get(key)[0]); + lovValueList.add(realmap.get(key)[0]); + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return lovDisplayValueList.toArray(new String[lovDisplayValueList.size()]); + } + + public static String getLovValue(TCComponentListOfValues lov, String str) throws Exception { + return getLovValue(lov, str, true); + } + + public static String getLovValue(TCComponentListOfValues lov, String str, boolean translate) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + if (translate) { + String prefName = "LOV_TRANS_" + lov.getStringProperty(TCComponentListOfValues.PROP_LOV_NAME); + String[] prefVals = KUtil.getPrefVals(KUtil.session, prefName); + int len = KUtil.getLen(prefVals); + for (int i = 0; i < len; i++) { + String pref = prefVals[i]; + int ind = pref.indexOf('='); + if (ind > 0) { + String realVal = pref.substring(0, ind); + String disVal = pref.substring(ind + 1); + if (str.equals(realVal) || str.equals(disVal)) { + return realVal; + } + } + } + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return str; + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return realValue; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static String getLovDisplayableValue(TCComponentListOfValues lov, String str) throws Exception { + if (lov == null || KUtil.isEmpty(str)) { + return str; + } + ListOfValuesInfo info = lov.getListOfValues(); + if (info == null) { + return str; + } + List v = info.getValues(); + int size = v == null ? 0 : v.size(); + for (int i = 0; i < size; i++) { + LovValue vv = v.get(i); + String realValue = vv.getValue() == null ? "" : vv.getValue().toString(); + if (str.equals(realValue)) { + return vv.getDisplayValue(); + } + String disValue = vv.getDisplayValue(); + if (str.equals(disValue)) { + return str; + } + } + throw new Exception(String.format(KLocale.getString("valuenotinlov.ERROR2"), lov.toString(), str)); + } + + public static void openFile(File file) { + try { + if (file != null && file.exists()) { + Runtime.getRuntime().exec("cmd /c start /b call \"" + file.getAbsolutePath() + "\""); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(e); + } + } + + public static void importDataset(TCComponent parent, String rel, File f, String dsType, String refName) throws Exception { + if (f == null || !f.exists() || KUtil.isEmpty(dsType) || KUtil.isEmpty(refName)) { + return; + } + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent(dsType); + TCComponentDataset dataset = datasetType.create(f.getName(), "", dsType); + String paths[] = { f.getAbsolutePath() }; + String refs[] = { refName }; + dataset.setFiles(paths, refs); + if (parent != null && !KUtil.isEmpty(rel)) { + parent.add(rel, dataset); + } + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, Map itemMasterPropMap, + Map revPropMap, Map revMasterPropMap) throws Exception { + initPropMap(propConfig, value, itemPropMap, itemMasterPropMap, revPropMap, revMasterPropMap, null); + } + + public static void initPropMap(String propConfig, String value, Map itemPropMap, Map itemMasterPropMap, + Map revPropMap, Map revMasterPropMap, Map bomlinePropMap) throws Exception { + if (KUtil.isEmpty(propConfig)) { + return; + } + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + return; + } + Map target; + if ("ITEM".equals(propFrom)) { + target = itemPropMap; + System.out.println(">> ITEM PROP: " + propName + " = " + value); + } else if ("REV".equals(propFrom)) { + System.out.println(">> REV PROP: " + propName + " = " + value); + target = revPropMap; + } else if ("ITEMMASTER".equals(propFrom)) { + System.out.println(">> ITEMMASTER PROP: " + propName + " = " + value); + target = itemMasterPropMap; + } else if ("REVMASTER".equals(propFrom)) { + System.out.println(">> REVMASTER PROP: " + propName + " = " + value); + target = revMasterPropMap; + } else if ("BOMLINE".equals(propFrom)) { + System.out.println(">> BOMLINE PROP: " + propName + " = " + value); + target = bomlinePropMap; + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + if (target == null) { + return; + } + target.put(propName, value); + } + + public static String getMarkedPropValue(String config, Map markedComponents) throws Exception { + return getMarkedPropValue(config, markedComponents, null); + } + + public static String getMarkedPropValue(String config, Map markedComponents, + Map> relatedComponents) throws Exception { + if (markedComponents == null || KUtil.isEmpty(config)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = config.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String defaultValue = ""; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) >= 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.getLen(split) >= 3) { + defaultValue = split[2].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + if (propConfig.contains("\\n")) { + propConfig = propConfig.replace("\\n", "\n"); + } + res.append(propConfig); + continue; + } + if (!markedComponents.containsKey(propFrom)) { + if (propFrom.startsWith("T")) { + return ""; + } + continue; + } + TCComponent comp = markedComponents.get(propFrom); + // 检查表格属性 属性位置.表格属性名称-表格行属性名称[-连接符] + int ind = propName.indexOf('-'); + if (ind > 0) { + String tableProp = propName.substring(0, ind).trim(); + String tableRowProp = propName.substring(ind + 1).trim(); + if (!KUtil.isEmpty(tableProp) && !KUtil.isEmpty(tableRowProp)) { + TCProperty prop = comp.getTCProperty(tableProp.trim()); + if (prop == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), comp.getType(), propName)); + } + String rowSplitter = "#ROW#"; + ind = tableRowProp.indexOf('-'); + if (ind > 0) { + rowSplitter = tableRowProp.substring(ind + 1); + tableRowProp = tableRowProp.substring(0, ind); + } + TCComponent[] tableRows = prop.getReferenceValueArray(); + int rowCnt = KUtil.getLen(tableRows); + String[] value = new String[rowCnt]; + for (int j = 0; j < rowCnt; j++) { + value[j] = tableRows[j].getPropertyDisplayableValue(tableRowProp); + } + res.append(String.join(rowSplitter, value)); + } + continue; + } + TCProperty prop = comp.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), comp.getType(), propName)); + } + String value = prop.getDisplayableValue(); + if ("NAME".equalsIgnoreCase(defaultValue)) { + value = prop.getPropertyDisplayName(); + } else if (value == null || "".equals(value)) { + value = defaultValue; + } + res.append(value); + } + return res.toString(); + } + + public static TCComponent getLatestComponent(List comps) { + int size = comps == null ? 0 : comps.size(); + if (size == 0) { + return null; + } + if (size == 1) { + return comps.get(0); + } + TCComponent res = comps.get(0); + try { + Date maxDate = res.getDateProperty("creation_date"); + for (int i = 1; i < size; i++) { + TCComponent temp = comps.get(i); + Date tempDate = temp.getDateProperty("creation_date"); + if (tempDate.after(maxDate)) { + maxDate = tempDate; + res = temp; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public static TCComponentType[] getComponentTypes(String itemTypeName) throws Exception { + TCComponentItemType itemType = null; + try { + itemType = (TCComponentItemType) session.getTypeComponent(itemTypeName); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName)); + } + TCComponentItemRevisionType revType = itemType.getItemRevisionType(); + if (revType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Revision")); + } + TCComponentType itemMasterType = null; + try { + itemMasterType = session.getTypeComponent(itemTypeName + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (itemMasterType == null) { + try { + itemMasterType = session.getTypeComponent(itemTypeName + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (itemMasterType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), itemTypeName + "Master")); + } + TCComponentType revMasterType = null; + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + "Master"); + } catch (Exception e) { + e.printStackTrace(); + } + if (revMasterType == null) { + try { + revMasterType = session.getTypeComponent(revType.getTypeName() + " Master"); + } catch (Exception e) { + e.printStackTrace(); + } + } + if (revMasterType == null) { + throw new Exception(String.format(KLocale.getString("typenotfound.ERROR1"), revType.getTypeName() + "Master")); + } + return new TCComponentType[] { itemType, revType, itemMasterType, revMasterType }; + } + + public static String getPropertyDisplayName(TCComponentType type, String propName) throws Exception { + if (type == null || KUtil.isEmpty(propName)) { + return propName; + } + TCPropertyDescriptor desc = type.getPropDesc(propName); + if (desc == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), type.getDisplayTypeName(), propName)); + } + return desc.getDisplayName(); + } + + public static String getConfigPropValue(TCComponentItemRevision rev, String propConfigStr) throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getStringValue()); + } + return res.toString(); + } + + public static String getConfigPropDisplayableValue(TCComponentItemRevision rev, String propConfigStr) throws Exception { + if (rev == null || KUtil.isEmpty(propConfigStr)) { + return ""; + } + StringBuilder res = new StringBuilder(); + String[] propConfigSplit = propConfigStr.split("\\+"); + int len = KUtil.getLen(propConfigSplit); + for (int i = 0; i < len; i++) { + String propConfig = propConfigSplit[i]; + String propFrom = null, propName = null; + String[] split = propConfig.split("\\."); + if (KUtil.getLen(split) == 2) { + propFrom = split[0].trim().toUpperCase(); + propName = split[1].trim(); + } + if (KUtil.isEmpty(propFrom) || KUtil.isEmpty(propName)) { + res.append(propConfig); + continue; + } + TCComponent target; + if ("ITEM".equals(propFrom)) { + target = rev.getItem(); + } else if ("REV".equals(propFrom)) { + target = rev; + } else if ("ITEMMASTER".equals(propFrom)) { + target = rev.getItem().getRelatedComponent("IMAN_master_form"); + } else if ("REVMASTER".equals(propFrom)) { + target = rev.getRelatedComponent("IMAN_master_form_rev"); + } else { + throw new Exception(String.format(KLocale.getString("proplocationnotdefined.ERROR1"), propFrom)); + } + TCProperty prop = target.getTCProperty(propName.trim()); + if (prop == null) { + throw new Exception(String.format(KLocale.getString("propnotdefinedintype.ERROR2"), target.getType(), propName)); + } + res.append(prop.getDisplayableValue()); + } + return res.toString(); + } + + public static void removeAllParents(DataManagementService dm, TCComponent comp) throws Exception { + comp.refresh(); + System.out.println("Remove from parent: " + comp); + WhereReferencedResponse refResp = dm.whereReferenced(new TCComponent[] { comp }, 1); + KUtil.throwServiceDataError(refResp.serviceData); + int len = KUtil.getLen(refResp.output); + List datas = new ArrayList(); + for (int i = 0; i < len; i++) { + WhereReferencedOutput ref = refResp.output[i]; + int cnt = KUtil.getLen(ref.info); + for (int j = 0; j < cnt; j++) { + WhereReferencedInfo info = ref.info[j]; + Relationship data = new Relationship(); + data.primaryObject = info.referencer; + data.secondaryObject = comp; + data.relationType = info.relation; + System.out.println(">> " + info.relation + " | " + info.referencer); + datas.add(data); + } + } + ServiceData resp = dm.deleteRelations(datas.toArray(new Relationship[] {})); + KUtil.throwServiceDataError(resp); + } + + public static TCComponent newTableRow(DataManagementService dmService, String type, Map rowStringProps, + Map rowDateProps) throws Exception { + CreateIn rowIn = new CreateIn(); + CreateInput rowInput = new CreateInput(); + rowInput.boName = type; + if (rowStringProps != null) { + rowInput.stringProps = rowStringProps; + } + if (rowDateProps != null) { + rowInput.dateProps = rowDateProps; + } + rowIn.data = rowInput; + CreateResponse res = dmService.createObjects(new CreateIn[] { rowIn }); + KUtil.throwServiceDataError(res.serviceData); + if (res.serviceData.sizeOfCreatedObjects() > 0) { + return res.serviceData.getCreatedObject(0); + } + return null; + } + + public static Date addDay(Date day, int cnt) { + if (day == null) { + return null; + } + Calendar c = Calendar.getInstance(); + c.setTime(day); + c.add(Calendar.DATE, cnt); + return c.getTime(); + } + + public static Date calTime(TCCalendar calendar, Date date, int minutes) { + if (calendar == null || date == null) { + return null; + } + int diff = minutes > 0 ? 1 : -1; + if (minutes < 0) { + minutes = -minutes; + } + Calendar c = Calendar.getInstance(); + c.setTime(date); + int counter = 0; + while (counter < minutes) { + counter += calendar.getMinutesOnDay(c); + c.add(Calendar.DATE, diff); + } + return c.getTime(); + } + + public static int getMinutesBetween(TCCalendar calendar, Date start, Date end) { + if (calendar == null || start == null || end == null) { + return 0; + } + Calendar c = Calendar.getInstance(); + c.setTime(start); + int res = 0; + while (c.getTime().before(end)) { + res += calendar.getMinutesOnDay(c); + // System.out.println(calendar.getMinutesOnDay(c)+" > "+c.getTime()); + c.add(Calendar.DATE, 1); + } + return res; + } + + public static TCComponentTCCalendar getScheduleCalendar(TCComponentSchedule schedule) throws Exception { + if (schedule == null) { + return null; + } + return CalendarHelper.getScheduleCalendar(schedule, session); + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/ProgressBar.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/ProgressBar.java new file mode 100644 index 0000000..86501c3 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/ProgressBar.java @@ -0,0 +1,130 @@ +package cn.net.connor.ml.plm.tcm; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.KeyStroke; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; + +@SuppressWarnings("serial") +public class ProgressBar extends AbstractAIFDialog { + + private JLabel messageLabel; + + private JProgressBar progressBar; + + private boolean showBar = false; + + public ProgressBar(AIFDesktop aifDesktop, Dimension dim, boolean showBar) { + super(aifDesktop, false); + this.showBar = showBar; + initUI(dim); + } + + public ProgressBar(AbstractAIFDialog pd, Dimension dimension) { + super(pd, false); + initUI(dimension); + } + + public ProgressBar(Dimension dim, boolean showBar) { + super(false); + this.showBar = showBar; + initUI(dim); + } + + public ProgressBar(AbstractAIFDialog pd, Dimension dimension, boolean showBar) { + super(pd, false); + this.showBar = showBar; + initUI(dimension); + } + + private void initUI(Dimension dim) { + this.setLayout(new BorderLayout(0, 0)); + this.setUndecorated(true); + JPanel main = new JPanel(new GridBagLayout()); + GridBagConstraints s = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 5, 2, 5), 0, 0); + main.setBackground(new Color(53, 53, 53)); + if (dim != null) { + this.setPreferredSize(dim); + } else { + this.setPreferredSize(new Dimension(200, 40)); + } + messageLabel = new JLabel(" "); + messageLabel.setForeground(Color.white); + progressBar = new JProgressBar(); + progressBar.setForeground(Color.black); + main.add(messageLabel, s); + s.gridy++; + s.insets = new Insets(0, 5, 2, 5); + if (showBar) { + main.add(progressBar, s); + } + this.add(BorderLayout.CENTER, main); + KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); + this.getRootPane().registerKeyboardAction(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); + MouseAdapter ma = new MouseAdapter() { + private Point pressPoint = new Point(); + + @Override + public void mousePressed(MouseEvent e) { + pressPoint = e.getPoint(); + } + + @Override + public void mouseReleased(MouseEvent e) { + pressPoint = new Point(); + } + + @Override + public void mouseDragged(MouseEvent e) { + Rectangle r = ProgressBar.this.getBounds(); + setLocation(r.x + (e.getX() - pressPoint.x), r.y + (e.getY() - pressPoint.y)); + } + }; + this.addMouseListener(ma); + this.addMouseMotionListener(ma); + } + + public void setText(String message) { + // System.out.println(message); + messageLabel.setText(message); + } + + public void setText(String txt, int percent) { + setText(txt); + if (percent > progressBar.getMaximum()) { + percent = progressBar.getMaximum(); + } + progressBar.setValue(percent); + } + + public void cancel() { + disposeDialog(); + } + + public void startProgress() { + showDialog(); + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/TCM01Command.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/TCM01Command.java new file mode 100644 index 0000000..faed05c --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/TCM01Command.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.tcm; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +//import cn.net.connor.ml.plm.KCommand; + +public class TCM01Command extends KCommand { + + public TCM01Command(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new TCM01Operation(app, "批量替换订单零部件")); + } +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/TCM01Operation.java b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/TCM01Operation.java new file mode 100644 index 0000000..b3efa8b --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/TCM01Operation.java @@ -0,0 +1,242 @@ +package cn.net.connor.ml.plm.tcm; + +import java.util.ArrayList; +import java.util.HashMap; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +//import cn.net.connor.ml.plm.KOperation2; +//import cn.net.connor.ml.plm.KUtil; + +public class TCM01Operation extends KOperation2 { + + private TCComponentBOMLine target; + private TCComponentItemType tccomponentitemtype; + private ArrayList> list; + private HashMap map; + + public TCM01Operation(AbstractAIFApplication app, String opName) { + super(app, opName); + target = (TCComponentBOMLine) app.getTargetComponent(); + try { + tccomponentitemtype = (TCComponentItemType) (session.getTypeComponent("ML8_Part")); + } catch (TCException e) { + e.printStackTrace(); + } + list = new ArrayList>(); + map = new HashMap(); + } + private TCComponentItemRevision targetRev; + @Override + public boolean init() throws Exception { + pb.setText("初始化检查中..."); + if (target == null || !target.getType().equals("Mfg0BvrPlantBOP")) { + KUtil.info(getCurrentDesktop(), "请在制造工艺规划器中选择具体工艺!"); + return false; + } + pb.setText("开始遍历对象..."); + + targetRev = target.getItemRevision(); + System.out.println(targetRev.getStringProperty("object_string")); + findOrdItem(target); + + if (list.size() == 0) { + KUtil.info(getCurrentDesktop(), "当前工艺下没有找到合适的零部件!"); + return false; + } + return true; + } +// private TCComponent mbom ; + @SuppressWarnings("deprecation") + private void findOrdItem(TCComponentBOMLine pline) throws TCException { + + + //获取订单BOM版本上的物料号和ERP班组编码 + TCComponent mbom=null; + AIFComponentContext[] alines = pline.getChildren(); + if (alines == null || alines.length == 0) { + return; + } + for (AIFComponentContext aline : alines) { + TCComponentBOMLine line = (TCComponentBOMLine) aline.getComponent(); + TCComponent rev = line.getRelatedComponent("bl_line_object"); + String type = rev.getType(); + if (type.equals("ML8_OrdItemRevision")) { + String id = rev.getProperty("ml8_MaterialNo"); + if (id.equals("")) { + System.out.println("对象[" + rev.getProperty("object_string") + "]的ml8_MaterialNo属性为空!"); + continue; + } + TCComponentItem item=null; + mbom=findMbom(targetRev,id); + if(mbom!=null) { + TCComponentItemRevision revision=(TCComponentItemRevision)mbom; + item=revision.getItem(); + }else { + item = tccomponentitemtype.find(id); + if (item == null) { + System.out.println("对象[" + rev.getProperty("object_string") + "]的ml8_MaterialNo属性" + id + "没有找到对象!"); + continue; + } + } + + ArrayList tclist = new ArrayList<>(); + tclist.add(pline);// 订单零部件的父级BOMLine + tclist.add(line);// 订单零部件BOMLine + tclist.add(item);// 零部件对象 + list.add(tclist); + String bl_quantity = line.getProperty("bl_quantity");// 数量 + String bl_occ_type = line.getProperty("bl_occ_type");// 事例类型 + map.put(id, bl_quantity + ";" + bl_occ_type); + } else { + // 当BOMLine类型不是[订单零部件版本]时对其遍历 + findOrdItem(line); + } + } + return; + } + + private TCComponent findMbom(TCComponent rev, String materialNoId) throws TCException { + System.out.println("rec"+rev.getStringProperty("object_string")); + TCComponent mbom=null; + TCComponentItemRevision itemRevision =(TCComponentItemRevision) rev.getRelatedComponent("IMAN_METarget"); + // TODO Auto-generated method stub + String materialNo = itemRevision.getStringProperty("ml8_MaterialNo"); + System.out.println("ml8_MaterialNo"+materialNo); + String productID = itemRevision.getStringProperty("ml8_ProductID"); + String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + //根据物料号获取对象 + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem item1 = itemType.find(productID); + if(item1 == null) + { +// MessageBox.post("通过产品代码【"+productID+"】未找到产品对象!", "错误", MessageBox.ERROR); + return null; + } + System.out.println("ml8_ERPCode"+ERPCode+"materialNo"+materialNoId); + //根据EBOM获取对应的MBOM节点 + TCComponent[] mboms = item1.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); + if(mboms.length <= 0) + { +// MessageBox.post("EBOM下未找到对应的MBOM对象!", "错误", MessageBox.ERROR); + return null; + } + TCComponent mbomTarget = null; + for (int i = 0; i < mboms.length; i++) { + //取ERP班组号相同的MBOM 匹配id + System.out.println("mbom产品对象"+((TCComponentItem)mboms[i]).getLatestItemRevision().getStringProperty("item_id")); + TCComponentItemRevision revision=((TCComponentItem)mboms[i]).getLatestItemRevision(); + TCComponent[] psChildren = revision.getReferenceListProperty("ps_children"); + String stringProperty = revision.getStringProperty("ml8_ERPCode"); + if(revision.getStringProperty("item_id").contains(materialNoId) && revision.getStringProperty("item_id").contains("-")) { + mbom=revision; + mbomTarget=((TCComponentItem)mboms[i]).getLatestItemRevision(); + } + + + for(TCComponent component:psChildren) { + String item_id=component.getStringProperty("item_id"); + if(item_id.contains(materialNoId) && item_id.contains("-")) + { + mbomTarget=((TCComponentItem)mboms[i]).getLatestItemRevision(); + mbom = component; + System.out.println("mbom"+component.getStringProperty("item_id")); + } + } + + + } + if(mbom == null) + { +// MessageBox.post("没有找到对应的MBOM!", "错误", MessageBox.ERROR); + return null; + } + return mbom; + } + + @Override + public void execute() throws Exception { + pb.setText("开始替换订单零部件..."); + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + KUtil.setByPass(true); + try { + for (ArrayList aList : list) { + TCComponentBOMLine pline = (TCComponentBOMLine) aList.get(0); + TCComponentBOMLine cline = (TCComponentBOMLine) aList.get(1); + TCComponentItem item = (TCComponentItem) aList.get(2); + // + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine newLine = view.setWindowTopLine(item, item.getLatestItemRevision(), null, null);// 把版本变成bomline + pline.lock(); + pline.remove("", cline); + pline.add(newLine, false); + pline.save(); + pline.unlock(); + pline.refresh(); + view.save(); + view.close(); + } + + if (map.size() > 0) { + pb.setText("开始修改零部件数量..."); + System.out.println("开始修改零部件数量..."); + changeLine(target); + } + + target.getCachedWindow().save(); + target.getCachedWindow().refresh(); + target.window().save(); + target.window().refresh(); + + KUtil.info(getCurrentDesktop(), "替换完成!"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + } + + // 修改数量 事例类型 + private void changeLine(TCComponentBOMLine pline) throws Exception { + System.out.println("子件数量:" + pline.getChildrenCount()); + AIFComponentContext[] alines = pline.getChildren(); + + if (alines == null || alines.length == 0) { + return; + } + for (AIFComponentContext aline : alines) { + TCComponentBOMLine line = (TCComponentBOMLine) aline.getComponent(); + String id = line.getRelatedComponent("bl_line_object").getProperty("item_id"); + System.out.println("changeLine id=" + id); +// String id = line.getProperty("bl_rev_awp0Item_item_id"); + if (map.containsKey(id)) { + String[] values = map.get(id).split(";"); + line.lock(); + line.setProperty("bl_quantity", values[0]); + line.setProperty("bl_occ_type", values[1]); + line.save(); + line.unlock(); + line.refresh(); + } + changeLine(line); + } + return; + } + +} diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/k_locale.properties b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/k_locale.properties new file mode 100644 index 0000000..ac8931f --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/k_locale.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=Project +dsuidinpref.ERROR1=Error dataset uid set in preference\: %s +valuenotinlov.ERROR2=LOV "%s" does not contain value\: %s +writedata=Write Data +querynotexist.ERROR1=Query not exist\: %s +dialoginit.ERROR=Init Error +preferror.ERROR1=Preference error\: %s +norefindataset.ERROR1=Download file from dataset "%s" failed. No ref file. +cancel=Cancel +exeop.STATUS=Execute... +initop.STATUS=Checking Data... +noflowkey.ERROR=Missing key for flow number. +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=Property is not defined in type "%s"\: %s. +getflowno.ERROR1=Error getting new flow number for key\: %s +formsave.ERRORTITLE=Error Saving Data +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=Title row in sheet does not have any relation info. +selectProject=Select Project +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=Can't find title row in excel sheet. +loadCompFromUid.Error2=Error loading component "%s", UID \= "%s". +uploadfilewhencheckout.ERROR1=Dataset "%s" is checked out. Upload file failed. +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=No Data in File\: %s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=Error +mergefile=Merge File... +index=Index +forminit.ERRORTITLE=Error Loading Rendering +ok=OK +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=Find multiple users by id\: %s +preparedata=Prepare Data +dbconn.ERROR=Connect to database failed. +typenotfound.ERROR1=Type not found\: %s +filenotexist.ERROR1=File not exist\: %s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=Read Data +clearcache=Clear Cache +exportsuccess.INFO=Export Complete. +uploadfile=Upload File +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=Folder not exist\: %s +info=Info +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=Find multiple users by name\: %s +exportopenfile.INFO=Export complete. Open file? +prefnotconfiged.ERROR1=Prefernce not found\: %s +export=Export diff --git a/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/k_locale_zh_CN.properties b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/k_locale_zh_CN.properties new file mode 100644 index 0000000..902d489 --- /dev/null +++ b/com.connor.ml.tcm/src/cn/net/connor/ml/plm/tcm/k_locale_zh_CN.properties @@ -0,0 +1,58 @@ +# +#Thu Jan 21 10:28:16 CST 2021 +createscheduledeliverable.ERROR2=\u4E3A [%s] \u521B\u5EFA\u65F6\u95F4\u8868\u4EA4\u4ED8\u7269 [%s] \u5931\u8D25 +project=\u9879\u76EE +dsuidinpref.ERROR1=\u8BF7\u68C0\u67E5\u9996\u9009\u9879<%s>\uFF0C\u901A\u8FC7\u914D\u7F6EUID\u672A\u627E\u5230\u6570\u636E\u96C6 +valuenotinlov.ERROR2=LOV "%s" \u4E2D\u672A\u5B9A\u4E49\u6570\u503C\uFF1A%s +writedata=\u5199\u5165\u6570\u636E +querynotexist.ERROR1=\u67E5\u8BE2\u4E0D\u5B58\u5728\uFF1A%s +dialoginit.ERROR=\u521D\u59CB\u5316\u5F02\u5E38 +preferror.ERROR1=\u9996\u9009\u9879\u914D\u7F6E\u9519\u8BEF\uFF1A%s +norefindataset.ERROR1=\u4ECE\u6570\u636E\u96C6\u201C%s\u201D\u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25\uFF0C\u6CA1\u6709\u627E\u5230\u5F15\u7528\u6587\u4EF6\u3002 +cancel=\u53D6\u6D88 +exeop.STATUS=\u6B63\u5728\u6267\u884C... +initop.STATUS=\u68C0\u67E5\u6570\u636E... +noflowkey.ERROR=\u6D41\u6C34\u7801\u952E\u503C\u4E0D\u53EF\u4E3A\u7A7A +wordfield_pagecount.NAME=\u9875\u6570 +nopropintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u4E0D\u5B58\u5728\u5C5E\u6027\uFF1A%s +getflowno.ERROR1=\u83B7\u53D6\u6D41\u6C34\u7801\u5931\u8D25\uFF1A%s +formsave.ERRORTITLE=\u4FDD\u5B58\u6570\u636E\u51FA\u9519 +wordfield_pageno.NAME=\u9875\u7801 +wordfield_totalpagenominus1.NAME=\u603B\u9875\u7801\u51CF\u4E00 +wordfield_totalpagecount.NAME=\u603B\u9875\u6570 +exceltitlenorelateinfo.ERROR=\u6807\u9898\u884C\u6CA1\u6709\u89E3\u6790\u5230\u6620\u5C04\u5185\u5BB9 +selectProject=\u9009\u62E9\u9879\u76EE +proplocationnotdefined.ERROR1=\u672A\u77E5\u5C5E\u6027\u4F4D\u7F6E\u201C%s\u201D\uFF0C\u8BF7\u68C0\u67E5\u914D\u7F6E +excelnotitle.ERROR=\u672A\u627E\u5230\u5DE5\u4F5C\u8868\u4E2D\u7684\u6807\u9898\u884C +loadCompFromUid.Error2=\u52A0\u8F7D\u5BF9\u8C61\u201C%s\u201D\u5931\u8D25\uFF0CUID\=\u201C%s\u201D\u3002 +uploadfilewhencheckout.ERROR1=\u6570\u636E\u96C6\u201C%s\u201D\u5DF2\u7B7E\u51FA\uFF0C\u4E0A\u4F20\u6587\u4EF6\u5931\u8D25\u3002\u8BF7\u7B7E\u5165\u540E\u518D\u8FDB\u884C\u64CD\u4F5C\u3002 +wordfield_totalactualpagecountminus1.NAME=\u603B\u5B9E\u9645\u9875\u6570\u51CF\u4E00 +nodatainfile.ERROR1=\u6587\u4EF6\u4E2D\u6CA1\u6709\u6570\u636E\uFF1A%s +noexportdata.ERROR=\u6CA1\u6709\u6570\u636E\u53EF\u4EE5\u5BFC\u51FA +notscheduleadmin.INFO=\u53EA\u6709\u534F\u8C03\u8005\u624D\u80FD\u64CD\u4F5C +error=\u9519\u8BEF +mergefile=\u5408\u5E76\u6587\u4EF6 +index=\u5E8F\u53F7 +forminit.ERRORTITLE=\u521D\u59CB\u5316\u754C\u9762\u5F02\u5E38 +ok=\u786E\u5B9A +wordfield_totalactualpagecount.NAME=\u603B\u5B9E\u9645\u9875\u6570 +requireprop.INFO1=\u8BF7\u586B\u5199\u5C5E\u6027\uFF1A%s +functionnotavailable.INFO=\u6B64\u5BF9\u8C61\u4E0D\u53EF\u4F7F\u7528\u6B64\u529F\u80FD +multiuserbyid.ERROR1=\u901A\u8FC7id\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +preparedata=\u51C6\u5907\u6570\u636E +dbconn.ERROR=\u8FDE\u63A5\u6570\u636E\u5E93\u5931\u8D25\u3002 +typenotfound.ERROR1=\u672A\u627E\u5230\u7C7B\u578B\uFF1A%s +filenotexist.ERROR1=\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A%s +wordfield_totalpagecountminus1.NAME=\u603B\u9875\u6570\u51CF\u4E00 +readdata=\u8BFB\u53D6\u6570\u636E +clearcache=\u6E05\u7406\u7F13\u5B58 +exportsuccess.INFO=\u5BFC\u51FA\u5B8C\u6210 +uploadfile=\u4E0A\u4F20\u6587\u4EF6 +propnotdefinedintype.ERROR2=\u5BF9\u8C61\u7C7B\u578B\u201C%s\u201D\u672A\u5B9A\u4E49\u5C5E\u6027\uFF1A%s +foldernotexist.ERROR1=\u6587\u4EF6\u5939\u4E0D\u5B58\u5728\uFF1A%s +info=\u63D0\u793A +wordfield_totalpageno.NAME=\u603B\u9875\u7801 +multiuserbyname.ERROR1=\u901A\u8FC7\u59D3\u540D\u67E5\u8BE2\u5230\u591A\u4E2A\u7528\u6237\uFF1A%s +exportopenfile.INFO=\u5BFC\u51FA\u5B8C\u6210\uFF0C\u6253\u5F00\u6587\u4EF6\uFF1F +prefnotconfiged.ERROR1=\u672A\u914D\u7F6E\u9996\u9009\u9879\uFF1A%s +export=\u5BFC\u51FA diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/Activator.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/Activator.java new file mode 100644 index 0000000..dc74305 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/Activator.java @@ -0,0 +1,44 @@ +package com.connor.ml.tcm; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.connor.ml"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/AssignItemID/AutoAssignItemIDPropertyBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/AssignItemID/AutoAssignItemIDPropertyBean.java new file mode 100644 index 0000000..553ad95 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/AssignItemID/AutoAssignItemIDPropertyBean.java @@ -0,0 +1,1123 @@ +package com.connor.ml.tcm.AssignItemID; + +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.newitem.NamingRulesHelper; +import com.teamcenter.rac.common.lov.view.controls.LOVDisplayer; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCQueryClause; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.controls.SWTComboBox; +import com.teamcenter.rac.viewer.stylesheet.beans.AbstractAutoAssignBean; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2013_05.DataManagement; + +public class AutoAssignItemIDPropertyBean + extends AbstractAutoAssignBean +{ + private static final Logger logger = Logger.getLogger(AutoAssignItemIDPropertyBean.class); + + public AutoAssignItemIDPropertyBean(FormToolkit paramFormToolkit, Composite paramComposite, boolean paramBoolean, Map paramMap) + { + super(paramFormToolkit, paramComposite, paramBoolean, paramMap); + } + + protected boolean canUserEditAfterAssignment() + { + return false; + } + + public void load(TCPropertyDescriptor tcpropertydescriptor) + throws Exception + { + logger.info("进入Load..."); + this.m_propBean.setProperty(getProperty()); + this.m_propBean.beanLabel = this.beanLabel; + this.descriptor = tcpropertydescriptor; + com.teamcenter.soa.client.model.NamingRule namingrule = this.descriptor.getNamingRule(); + logger.info("tcpropertydescriptor.isEnabled():" + tcpropertydescriptor.isEnabled()); + if (!tcpropertydescriptor.isEnabled()) { + this.m_assignButton.setEnabled(false); + } + if (namingrule == null) + { + logger.info("没有命名规则"); + createControlWhenNoNamingRuleIsAttached(tcpropertydescriptor, this.m_namingPatternComboBox, this.m_assignButton); + this.m_assignButton.addSelectionListener(new IC_GenerateIDButtonSelectionAdapter(tcpropertydescriptor, null)); + } + else + { + logger.info("有命名规则"); + createControlForPropertyWhichHaveNamingRuleAttached(tcpropertydescriptor); + } + this.m_propBean.load(tcpropertydescriptor); + logger.info("离开Load..."); + } + + protected void createControlWhenNoNamingRuleIsAttached(TCPropertyDescriptor tcpropertydescriptor, SWTComboBox swtcombobox, Button button) + { + setLayout(2); + swtcombobox.dispose(); + button.setData("RCAF_ID", tcpropertydescriptor.getName()); + } + + private void createControlForPropertyWhichHaveNamingRuleAttached(TCPropertyDescriptor tcpropertydescriptor) + { + String[] as = getNamingRulePatternsWithCounters(tcpropertydescriptor); + String s = getPreferredNamingRulePattern(tcpropertydescriptor); + if ((as != null) && (as.length > 0)) + { + this.m_validationNeeded = true; + setupWidgets(tcpropertydescriptor, as, s); + } + else + { + setLayout(1); + this.m_validationNeeded = true; + this.m_namingPatternComboBox.dispose(); + this.m_assignButton.dispose(); + } + } + + private void setupWidgets(TCPropertyDescriptor paramTCPropertyDescriptor, String[] paramArrayOfString, String paramString) + { + String[] arrayOfString; + int j = (arrayOfString = paramArrayOfString).length; + for (int i = 0; i < j; i++) + { + String str = arrayOfString[i]; + this.m_namingPatternComboBox.addItem(str); + } + this.m_namingPatternComboBox.setAutoCompleteSuggestive(false); + if ((paramString != null) && (paramString.length() > 0)) { + this.m_namingPatternComboBox.setSelectedItem(paramString); + } else { + this.m_namingPatternComboBox.setSelectedIndex(0); + } + this.m_assignButton.setData("RCAF_ID", paramTCPropertyDescriptor.getName()); + this.m_assignButton.addSelectionListener(new IC_GenerateIDButtonSelectionAdapter(paramTCPropertyDescriptor, this.m_namingPatternComboBox)); + } + + private String[] getNamingRulePatternsWithCounters(TCPropertyDescriptor tcpropertydescriptor) + { + DataManagementService datamanagementservice = DataManagementService.getService(getSession()); + com.teamcenter.services.rac.core._2008_06.DataManagement.GetNRPatternsWithCountersResponse getnrpatternswithcountersresponse = null; + com.teamcenter.services.rac.core._2008_06.DataManagement.NRAttachInfo[] anrattachinfo = new com.teamcenter.services.rac.core._2008_06.DataManagement.NRAttachInfo[1]; + anrattachinfo[0] = new com.teamcenter.services.rac.core._2008_06.DataManagement.NRAttachInfo(); + anrattachinfo[0].propName = getProperty(); + anrattachinfo[0].typeName = getOwningTypeName(tcpropertydescriptor); + getnrpatternswithcountersresponse = datamanagementservice.getNRPatternsWithCounters(anrattachinfo); + com.teamcenter.services.rac.core._2008_06.DataManagement.PatternsWithCounters[] apatternswithcounters = getnrpatternswithcountersresponse.patterns; + return apatternswithcounters[0].patternStrings; + } + + private String getPreferredNamingRulePattern(TCPropertyDescriptor tcpropertydescriptor) + { + String s = tcpropertydescriptor.getTypeComponent().getOwningType().toString(); + String s1 = (s != null) && (!s.isEmpty()) ? s : tcpropertydescriptor.getTypeComponent().toString(); + String[] as = { tcpropertydescriptor.getName() }; + String[] as1 = { s1 }; + com.teamcenter.rac.commands.newitem.NamingRule[] anamingrule = NamingRulesHelper.getInstance().getNamingRules(getSession(), as1, as); + return anamingrule[0].getPreferredPattern(); + } + + private class IC_GenerateIDButtonSelectionAdapter + extends SelectionAdapter + { + private TCPropertyDescriptor m_propDesc; + private SWTComboBox m_comboBox; + private Button m_sourceObject; + private String owningType; + + public IC_GenerateIDButtonSelectionAdapter(TCPropertyDescriptor tcpropertydescriptor, SWTComboBox swtcombobox) + { + this.m_propDesc = tcpropertydescriptor; + this.m_propDesc = tcpropertydescriptor; + this.m_comboBox = swtcombobox; + AutoAssignItemIDPropertyBean.logger.info("进入IC_GenerateIDButtonSelectionAdapter..."); + } + + public void widgetSelected(SelectionEvent selectionevent) + { + AutoAssignItemIDPropertyBean.logger.info("进入指派。。。"); + if ((selectionevent.getSource() instanceof Button)) { + this.m_sourceObject = ((Button)selectionevent.getSource()); + } + AutoAssignItemIDPropertyBean.this.m_validationNeeded = false; + final TCSession session = AutoAssignItemIDPropertyBean.this.getSession(); + + TCComponentType tccomponenttype = this.m_propDesc.getTypeComponent(); + this.owningType = tccomponenttype.getOwningType(); + String owningDisplayType = tccomponenttype.getType(); + AutoAssignItemIDPropertyBean.logger.info("owningType:" + this.owningType + ",owningDisplayType:" + owningDisplayType); + if (this.owningType.isEmpty()) { + this.owningType = tccomponenttype.getTypeName(); + } + if (("ML8_StdOperation".equals(this.owningType))) + { + AutoAssignItemIDPropertyBean.logger.info("标准工序类型对象指派"); + AutoAssignItemIDPropertyBean.this.setStdOperationIdText(this.owningType); + } + else if(("ML8_DifOperation".equals(this.owningType))) + { + AutoAssignItemIDPropertyBean.logger.info("差异化工序类型对象指派"); + AutoAssignItemIDPropertyBean.this.setDifOperationIdText(this.owningType); + } + else if(("ML8_SpecOp".equals(this.owningType))) + { + AutoAssignItemIDPropertyBean.logger.info("专项工序类型对象指派"); + AutoAssignItemIDPropertyBean.this.setSpecOpIdText(this.owningType); + } + else + { + AutoAssignItemIDPropertyBean.logger.info("其他类型调用OOTB指派"); + final String pattern = this.m_comboBox == null ? null : (String)this.m_comboBox.getSelectedItem(); + if (this.m_comboBox != null) { + AutoAssignItemIDPropertyBean.logger.info("(String) m_comboBox.getSelectedItem():" + (String)this.m_comboBox.getSelectedItem()); + } + AbstractAIFOperation abstractaifoperation = new AbstractAIFOperation() + { + public void executeOperation() + throws Exception + { + String s = "sourceObject"; + String s1 = "AutoAssignRAC"; + String s2 = "CONTEXT"; + String s3 = AutoAssignItemIDPropertyBean.IC_GenerateIDButtonSelectionAdapter.this.m_propDesc.getName(); + TCComponentType tccomponenttype = AutoAssignItemIDPropertyBean.IC_GenerateIDButtonSelectionAdapter.this.m_propDesc.getTypeComponent(); + String s4 = tccomponenttype.getOwningType(); + AutoAssignItemIDPropertyBean.logger.info("getOwningType:" + s4 + ",s3:" + s3); + if (s4.isEmpty()) { + s4 = tccomponenttype.getTypeName(); + } + int i = AutoAssignItemIDPropertyBean.IC_GenerateIDButtonSelectionAdapter.this.m_propDesc.getTypeComponent().getOperationType().getOperationCode(); + DataManagementService datamanagementservice = DataManagementService.getService(session); + DataManagement.GenerateNextValuesIn generatenextvaluesin = new DataManagement.GenerateNextValuesIn(); + generatenextvaluesin.clientId = s1; + if (i == TCComponentType.OPERATION.EDIT_OPERATION.getOperationCode()) { + i = TCComponentType.OPERATION.CREATE_OPERATION.getOperationCode(); + } + generatenextvaluesin.operationType = i; + generatenextvaluesin.businessObjectName = s4; + Object obj = AutoAssignItemIDPropertyBean.this.getViewer().getData(s2); + if ((obj != null) && ((obj instanceof TCComponent))) + { + String s5 = ((TCComponent)obj).getUid().toString(); + generatenextvaluesin.additionalInputParams.put(s, s5); + } + if (pattern != null) { + generatenextvaluesin.propertyNameWithSelectedPattern.put(s3, pattern); + } else { + generatenextvaluesin.propertyNameWithSelectedPattern.put(s3, ""); + } + DataManagement.GenerateNextValuesIn[] ageneratenextvaluesin = { generatenextvaluesin }; + DataManagement.GenerateNextValuesResponse generatenextvaluesresponse = datamanagementservice + .generateNextValues(ageneratenextvaluesin); + SoaUtil.handlePartialErrors(generatenextvaluesresponse.data, null, null, false); + DataManagement.GeneratedValue generatedvalue = + (DataManagement.GeneratedValue)generatenextvaluesresponse.generatedValues[0].generatedValues.get(s3); + if (generatedvalue != null) + { + AutoAssignItemIDPropertyBean.this.updatePrimaryControlValue(generatedvalue.nextValue); + if (!generatedvalue.isModifiable) { + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + if (AutoAssignItemIDPropertyBean.IC_GenerateIDButtonSelectionAdapter.this.m_sourceObject != null) { + AutoAssignItemIDPropertyBean.IC_GenerateIDButtonSelectionAdapter.this.m_sourceObject.setEnabled(false); + } + if (AutoAssignItemIDPropertyBean.IC_GenerateIDButtonSelectionAdapter.this.m_comboBox != null) { + AutoAssignItemIDPropertyBean.IC_GenerateIDButtonSelectionAdapter.this.m_comboBox.setEnabled(false); + } + ((Text)AutoAssignItemIDPropertyBean.this.m_propBean.getControl()).setEditable(false); + } + }); + } + } + } + }; + AutoAssignItemIDPropertyBean.this.getSession().queueOperation(abstractaifoperation); + } + AutoAssignItemIDPropertyBean.logger.info("56"); + } + } + + private void setSpecOpIdText(String owningType) + { + Text idText = null; + Text ml8_SpecOpNumber = null; + Text ml8_SpecOpPeriod = null; + LOVDisplayer ml8_SpecOpCode = null; + HashMap mapLabelText = new HashMap(16); + + Composite compositeTop = this.m_propBean.getControl().getParent().getParent().getParent(); + Control[] children0 = compositeTop.getChildren(); + for (int c1 = 0; c1 < children0.length; c1++) { + if ((children0[c1] instanceof Composite)) + { + Control[] childChildren = ((Composite)children0[c1]).getChildren(); + for (int c2 = 0; c2 < childChildren.length; c2++) { + if ((childChildren[c2] instanceof Composite)) + { + Control[] childChildren2 = ((Composite)childChildren[c2]).getChildren(); + for (int c3 = 0; c3 < childChildren2.length; c3++) { + if ((childChildren2[c3] instanceof Label)) + { + Label labelId = (Label)childChildren2[c3]; + String labelTextId = labelId.getText(); + if (("item_id:".equals(labelTextId)) || ("ID:".equals(labelTextId))) { + if ((childChildren[(c2 + 1)] instanceof Composite)) + { + Composite childComposite = (Composite)childChildren[(c2 + 1)]; + Control[] controlChild = childComposite.getChildren(); + for (int k = 0; k < controlChild.length; k++) { + if ((controlChild[k] instanceof Text)) { + idText = (Text)controlChild[k]; + } + } + } + } + else if (("ml8_SpecOpPeriod:".equals(labelTextId)) || ("specOpPeriod:".equals(labelTextId)) || ("专项类型:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof Text)) + { + ml8_SpecOpPeriod = (Text)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_SpecOpPeriod", ml8_SpecOpPeriod.getText()); + } + } + else if (("ml8_SpecOpCode:".equals(labelTextId)) || ("specOpCode:".equals(labelTextId)) || ("专项工序代号:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_SpecOpCode = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_SpecOpCode", ml8_SpecOpCode.getSelectedValue().toString()); + } + } + else if (("ml8_SpecOpNumber:".equals(labelTextId)) || ("specOpNumber:".equals(labelTextId)) || ("工序序列号:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof Text)) + { + ml8_SpecOpNumber = (Text)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_SpecOpNumber", ml8_SpecOpNumber.getText()); + } + } + } + } + } + } + } + } + if ((ml8_SpecOpPeriod == null) || ml8_SpecOpPeriod.getText() == null || ml8_SpecOpPeriod.getText().isEmpty()) + { + MessageBox.post("专项类型不能为空!", "错误", MessageBox.ERROR); + return; + } + if ((ml8_SpecOpCode == null) || (ml8_SpecOpCode.getSelectedValue().equals(""))) + { + MessageBox.post("专项工序代号不能为空!", "错误", MessageBox.ERROR); + return; + } + try { + String stdOpNumber = ""; + if(ml8_SpecOpNumber == null || ml8_SpecOpNumber.getText() == null || ml8_SpecOpNumber.getText().isEmpty()) + { + //获取选中的工艺对象 + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + TCComponentBOMLine meprocessBOMLine = (TCComponentBOMLine)comp; +// if(!meprocessBOMLine.getItem().getStringProperty("object_type").equals("ML8_SpecProcess")) +// { +// MessageBox.post("请在结构管理器或制造工艺规划器中选中工艺对象!", "错误", MessageBox.ERROR); +// return; +// } + //获取子BOM + if(meprocessBOMLine.hasChildren()) + { + AIFComponentContext[] childBomLines = meprocessBOMLine.getChildren(); +// TCComponentBOMLine childBomLine = (TCComponentBOMLine)childBomLines[childBomLines.length - 1].getComponent(); +// //获取最下级工序的工序编号 +// String childStdOpNumber = childBomLine.getItem().getStringProperty("ml8_SpecOpNumber"); +// if(childStdOpNumber == null || childStdOpNumber.isEmpty()) +// { +// MessageBox.post("工艺下最后一个工序的工序编号为空!", "错误", MessageBox.ERROR); +// return; +// } + String childStdOpNumber = ""; + for (int i = 0; i < childBomLines.length; i++) { + TCComponentBOMLine childBomLine = (TCComponentBOMLine)childBomLines[i].getComponent(); + //获取对象类型 + String stringProperty = childBomLine.getItem().getStringProperty("object_type"); + if(stringProperty.compareTo("ML8_StdOperation") == 0 || stringProperty.compareTo("ML8_SpecOp")==0) + { + if(childBomLine.getItem().getType().equals("ML8_StdOperation")){ + childStdOpNumber = childBomLine.getItem().getStringProperty("ml8_StdOpNumber"); + }else if(childBomLine.getItem().getType().equals("ML8_SpecOp")){ + childStdOpNumber = childBomLine.getItem().getStringProperty("ml8_SpecOpNumber"); + } + } + } + System.out.println("childStdOpNumber " + childStdOpNumber); + if(childStdOpNumber.isEmpty()) + { + stdOpNumber = "010"; + }else { + stdOpNumber = getStdOpNumber(childStdOpNumber, 10); + } + + ml8_SpecOpNumber.setText(stdOpNumber); + } + else + { + System.out.println("hasChildren == false stdOpNumber = 010"); + stdOpNumber = "010"; + ml8_SpecOpNumber.setText(stdOpNumber); + } + } + else + { + stdOpNumber = ml8_SpecOpNumber.getText(); + } + + String newItemID = getGyRuleID(getSession(), String.format("%s-%s-%s", mapLabelText.get("ml8_SpecOpPeriod"),mapLabelText.get("ml8_SpecOpCode"),stdOpNumber)); + + idText.setText(newItemID); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + private void setDifOperationIdText(String owningType) + { + Text idText = null; + Text ml8_StdOpNumber = null; + LOVDisplayer ml8_StdOpType = null; + LOVDisplayer ml8_StdOpPeriod = null; + LOVDisplayer ml8_ProductType = null; + LOVDisplayer ml8_MaterialType = null; + HashMap mapLabelText = new HashMap(16); + Composite compositeTop = this.m_propBean.getControl().getParent().getParent().getParent(); + Control[] children0 = compositeTop.getChildren(); + for (int c1 = 0; c1 < children0.length; c1++) { + if ((children0[c1] instanceof Composite)) + { + Control[] childChildren = ((Composite)children0[c1]).getChildren(); + for (int c2 = 0; c2 < childChildren.length; c2++) { + if ((childChildren[c2] instanceof Composite)) + { + Control[] childChildren2 = ((Composite)childChildren[c2]).getChildren(); + for (int c3 = 0; c3 < childChildren2.length; c3++) { + if ((childChildren2[c3] instanceof Label)) + { + Label labelId = (Label)childChildren2[c3]; + String labelTextId = labelId.getText(); + if (("item_id:".equals(labelTextId)) || ("ID:".equals(labelTextId))) { + if ((childChildren[(c2 + 1)] instanceof Composite)) + { + Composite childComposite = (Composite)childChildren[(c2 + 1)]; + Control[] controlChild = childComposite.getChildren(); + for (int k = 0; k < controlChild.length; k++) { + if ((controlChild[k] instanceof Text)) { + idText = (Text)controlChild[k]; + } + } + } + } + else if (("ml8_StdOpType:".equals(labelTextId)) || ("stdOpType:".equals(labelTextId)) || ("工序类型:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_StdOpType = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_StdOpType", ml8_StdOpType.getSelectedValue().toString()); + } + } + else if (("ml8_StdOpPeriod:".equals(labelTextId)) || ("stdOpPeriod:".equals(labelTextId)) || ("工序段类型:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_StdOpPeriod = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_StdOpPeriod", ml8_StdOpPeriod.getSelectedValue().toString()); + } + } + else if (("ml8_ProductType:".equals(labelTextId)) || ("productType:".equals(labelTextId)) || ("产品类型:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_ProductType = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_ProductType", ml8_ProductType.getSelectedValue().toString()); + } + } + else if (("ml8_MaterialType:".equals(labelTextId)) || ("materialType:".equals(labelTextId)) || ("材料:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_MaterialType = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_MaterialType", ml8_MaterialType.getSelectedValue().toString()); + } + } + else if (("ml8_StdOpNumber:".equals(labelTextId)) || ("stdOpNumber:".equals(labelTextId)) || ("工序序列号:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof Text)) + { + ml8_StdOpNumber = (Text)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_StdOpNumber", ml8_StdOpNumber.getText()); + } + } + } +// else if ((childChildren2[c3] instanceof Composite)) +// { +// Control[] childChildren3 = ((Composite)childChildren2[c3]).getChildren(); +// for (int c4 = 0; c4 < childChildren3.length; c4++) { +// if ((childChildren3[c4] instanceof Composite)) +// { +// Control[] childChildren4 = ((Composite)childChildren3[c4]).getChildren(); +// for (int c5 = 0; c5 < childChildren4.length; c5++) { +// if ((childChildren4[c5] instanceof Label)) +// { +// Label label = (Label)childChildren4[c5]; +// String labelText = label.getText(); +// if (("ml8_StdOpType:".equals(labelText)) || ("stdOpType:".equals(labelText)) || ("工序类型".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_StdOpType = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_StdOpType", ml8_StdOpType.getSelectedValue().toString()); +// } +// } +// else if (("ml8_StdOpPeriod:".equals(labelText)) || ("stdOpPeriod:".equals(labelText)) || ("工序段类型".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_StdOpPeriod = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_StdOpPeriod", ml8_StdOpPeriod.getSelectedValue().toString()); +// } +// } +// else if (("ml8_ProductType:".equals(labelText)) || ("productType:".equals(labelText)) || ("产品类型".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_ProductType = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_ProductType", ml8_ProductType.getSelectedValue().toString()); +// } +// } +// else if (("ml8_MaterialType:".equals(labelText)) || ("materialType:".equals(labelText)) || ("材料".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_MaterialType = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_MaterialType", ml8_MaterialType.getSelectedValue().toString()); +// } +// } +// else if (("ml8_StdOpNumber:".equals(labelText)) || ("stdOpNumber:".equals(labelText)) || ("工序序列号".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof Text)) +// { +// ml8_StdOpNumber = (Text)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_StdOpNumber", ml8_StdOpNumber.getText()); +// } +// } +// } +// } +// } +// } +// } + } + } + } + } + } + if ((ml8_StdOpType == null) || (ml8_StdOpType.getSelectedValue().equals(""))) + { + MessageBox.post("工序类型不能为空!", "错误", MessageBox.ERROR); + return; + } + if ((ml8_StdOpPeriod == null) || (ml8_StdOpPeriod.getSelectedValue().equals(""))) + { + MessageBox.post("工序段类型不能为空!", "错误", MessageBox.ERROR); + return; + } + if ((ml8_ProductType == null) || (ml8_ProductType.getSelectedValue().equals(""))) + { + MessageBox.post("产品类型不能为空!", "错误", MessageBox.ERROR); + return; + } +// if ((ml8_MaterialType == null) || (ml8_MaterialType.getSelectedValue().equals(""))) +// { +// MessageBox.post("材料不能为空!", "错误", MessageBox.ERROR); +// return; +// } + if(ml8_StdOpNumber == null || ml8_StdOpNumber.getText() == null || ml8_StdOpNumber.getText().isEmpty()) + { + MessageBox.post("工序序列号不能为空!", "错误", MessageBox.ERROR); + return; + } + try { + String stdOpNumber = ""; + if(ml8_StdOpNumber == null || ml8_StdOpNumber.getText() == null || ml8_StdOpNumber.getText().isEmpty()) + { + //获取选中的工艺对象 + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + TCComponentBOMLine meprocessBOMLine = (TCComponentBOMLine)comp; +// if(!meprocessBOMLine.getItem().getStringProperty("object_type").equals("ML8_DifProcess")) +// { +// MessageBox.post("请在结构管理器或制造工艺规划器中选中工艺对象!", "错误", MessageBox.ERROR); +// return; +// } + stdOpNumber = "010"; + ml8_StdOpNumber.setText(stdOpNumber); + //获取子BOM + if(meprocessBOMLine.hasChildren()) + { + AIFComponentContext[] childBomLines = meprocessBOMLine.getChildren(); + for (int i = childBomLines.length-1; i >= 0; i--) { + TCComponentBOMLine childBomLine = (TCComponentBOMLine)childBomLines[i].getComponent(); +// if(childBomLine.getItem().getStringProperty("object_type").compareTo(owningType) == 0) +// { + //获取最下级工序的工序编号 + String childStdOpNumber = childBomLine.getItem().getStringProperty("ml8_StdOpNumber"); + stdOpNumber = getStdOpNumber(childStdOpNumber, 10); + ml8_StdOpNumber.setText(stdOpNumber); +// } + } + } + } + else + { + stdOpNumber = ml8_StdOpNumber.getText(); + } + + String newItemID = getGyRuleID(getSession(), String.format("%s-%s%s%s-%s", mapLabelText.get("ml8_StdOpType"),mapLabelText.get("ml8_StdOpPeriod"),mapLabelText.get("ml8_ProductType"),mapLabelText.get("ml8_MaterialType"),stdOpNumber)); + + idText.setText(newItemID); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + private void setStdOperationIdText(String owningType) + { + Text idText = null; + Text ml8_StdOpNumber = null; + LOVDisplayer ml8_StdOpType = null; + LOVDisplayer ml8_StdOpPeriod = null; + LOVDisplayer ml8_ProductType = null; + LOVDisplayer ml8_MaterialType = null; + HashMap mapLabelText = new HashMap(16); + + Composite compositeTop = this.m_propBean.getControl().getParent().getParent().getParent(); + Control[] children0 = compositeTop.getChildren(); + for (int c1 = 0; c1 < children0.length; c1++) { + if ((children0[c1] instanceof Composite)) + { + Control[] childChildren = ((Composite)children0[c1]).getChildren(); + for (int c2 = 0; c2 < childChildren.length; c2++) { + if ((childChildren[c2] instanceof Composite)) + { + Control[] childChildren2 = ((Composite)childChildren[c2]).getChildren(); + for (int c3 = 0; c3 < childChildren2.length; c3++) { + if ((childChildren2[c3] instanceof Label)) + { + Label labelId = (Label)childChildren2[c3]; + String labelTextId = labelId.getText(); + if (("item_id:".equals(labelTextId)) || ("ID:".equals(labelTextId))) { + if ((childChildren[(c2 + 1)] instanceof Composite)) + { + Composite childComposite = (Composite)childChildren[(c2 + 1)]; + Control[] controlChild = childComposite.getChildren(); + for (int k = 0; k < controlChild.length; k++) { + if ((controlChild[k] instanceof Text)) { + idText = (Text)controlChild[k]; + } + } + } + } + else if (("ml8_StdOpType:".equals(labelTextId)) || ("stdOpType:".equals(labelTextId)) || ("工序类型:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_StdOpType = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_StdOpType", ml8_StdOpType.getSelectedValue().toString()); + } + } + else if (("ml8_StdOpPeriod:".equals(labelTextId)) || ("stdOpPeriod:".equals(labelTextId)) || ("工序段类型:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_StdOpPeriod = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_StdOpPeriod", ml8_StdOpPeriod.getSelectedValue().toString()); + } + } + else if (("ml8_ProductType:".equals(labelTextId)) || ("productType:".equals(labelTextId)) || ("产品类型:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_ProductType = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_ProductType", ml8_ProductType.getSelectedValue().toString()); + } + } + else if (("ml8_MaterialType:".equals(labelTextId)) || ("materialType:".equals(labelTextId)) || ("材料:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof LOVDisplayer)) + { + ml8_MaterialType = (LOVDisplayer)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_MaterialType", ml8_MaterialType.getSelectedValue().toString()); + } + } + else if (("ml8_StdOpNumber:".equals(labelTextId)) || ("stdOpNumber:".equals(labelTextId)) || ("工序序列号:".equals(labelTextId))) + { + if ((childChildren[(c2 + 1)] instanceof Text)) + { + ml8_StdOpNumber = (Text)childChildren[(c2 + 1)]; + mapLabelText.put("ml8_StdOpNumber", ml8_StdOpNumber.getText()); + } + } + } +// else if ((childChildren2[c3] instanceof Composite)) +// { +// Control[] childChildren3 = ((Composite)childChildren2[c3]).getChildren(); +// for (int c4 = 0; c4 < childChildren3.length; c4++) { +// if ((childChildren3[c4] instanceof Composite)) +// { +// Control[] childChildren4 = ((Composite)childChildren3[c4]).getChildren(); +// for (int c5 = 0; c5 < childChildren4.length; c5++) { +// if ((childChildren4[c5] instanceof Label)) +// { +// Label label = (Label)childChildren4[c5]; +// String labelText = label.getText(); +// if (("ml8_StdOpType:".equals(labelText)) || ("stdOpType:".equals(labelText)) || ("工序类型".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_StdOpType = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_StdOpType", ml8_StdOpType.getSelectedValue().toString()); +// } +// } +// else if (("ml8_StdOpPeriod:".equals(labelText)) || ("stdOpPeriod:".equals(labelText)) || ("工序段类型".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_StdOpPeriod = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_StdOpPeriod", ml8_StdOpPeriod.getSelectedValue().toString()); +// } +// } +// else if (("ml8_ProductType:".equals(labelText)) || ("productType:".equals(labelText)) || ("产品类型".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_ProductType = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_ProductType", ml8_ProductType.getSelectedValue().toString()); +// } +// } +// else if (("ml8_MaterialType:".equals(labelText)) || ("materialType:".equals(labelText)) || ("材料".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof LOVDisplayer)) +// { +// ml8_MaterialType = (LOVDisplayer)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_MaterialType", ml8_MaterialType.getSelectedValue().toString()); +// } +// } +// else if (("ml8_StdOpNumber:".equals(labelText)) || ("stdOpNumber:".equals(labelText)) || ("工序序列号".equals(labelText))) +// { +// if ((childChildren3[(c4 + 1)] instanceof Text)) +// { +// ml8_StdOpNumber = (Text)childChildren3[(c4 + 1)]; +// mapLabelText.put("ml8_StdOpNumber", ml8_StdOpNumber.getText()); +// } +// } +// } +// } +// } +// } +// } + } + } + } + } + } + if ((ml8_StdOpType == null) || (ml8_StdOpType.getSelectedValue().equals(""))) + { + MessageBox.post("工序类型不能为空!", "错误", MessageBox.ERROR); + return; + } + if ((ml8_StdOpPeriod == null) || (ml8_StdOpPeriod.getSelectedValue().equals(""))) + { + MessageBox.post("工序段类型不能为空!", "错误", MessageBox.ERROR); + return; + } + if ((ml8_ProductType == null) || (ml8_ProductType.getSelectedValue().equals(""))) + { + MessageBox.post("产品类型不能为空!", "错误", MessageBox.ERROR); + return; + } +// if ((ml8_MaterialType == null) || (ml8_MaterialType.getSelectedValue().equals(""))) +// { +// MessageBox.post("材料不能为空!", "错误", MessageBox.ERROR); +// return; +// } + try { + String stdOpNumber = ""; + if(ml8_StdOpNumber == null || ml8_StdOpNumber.getText() == null || ml8_StdOpNumber.getText().isEmpty()) + { + //获取选中的工艺对象 + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent comp = app.getTargetComponent(); + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + TCComponentBOMLine meprocessBOMLine = (TCComponentBOMLine)comp; +// if(!meprocessBOMLine.getItem().getStringProperty("object_type").equals("ML8_StdProcess")) +// { +// MessageBox.post("请在结构管理器或制造工艺规划器中选中工艺对象!", "错误", MessageBox.ERROR); +// return; +// } + //获取子BOM + if(meprocessBOMLine.hasChildren()) + { + AIFComponentContext[] childBomLines = meprocessBOMLine.getChildren(); + String childStdOpNumber = ""; + for (int i = 0; i < childBomLines.length; i++) { + TCComponentBOMLine childBomLine = (TCComponentBOMLine)childBomLines[i].getComponent(); + //获取对象类型 + String stringProperty = childBomLine.getItem().getStringProperty("object_type"); + if(stringProperty.compareTo("ML8_StdOperation") == 0 || stringProperty.compareTo("ML8_SpecOp")==0) + { + if(childBomLine.getItem().getType().equals("ML8_StdOperation")){ + childStdOpNumber = childBomLine.getItem().getStringProperty("ml8_StdOpNumber"); + }else if(childBomLine.getItem().getType().equals("ML8_SpecOp")){ + childStdOpNumber = childBomLine.getItem().getStringProperty("ml8_SpecOpNumber"); + } + // + } + } + //TCComponentBOMLine childBomLine = (TCComponentBOMLine)childBomLines[childBomLines.length - 1].getComponent(); + //获取最下级工序的工序编号 + //String childStdOpNumber = childBomLine.getItem().getStringProperty("ml8_StdOpNumber"); + System.out.println("ML8_SpecOp childStdOpNumber :"+childStdOpNumber); + if(childStdOpNumber ==null || childStdOpNumber.isEmpty()) + { + stdOpNumber = "010"; + ml8_StdOpNumber.setText(stdOpNumber); + } + else + { + stdOpNumber = getStdOpNumber(childStdOpNumber, 10); + ml8_StdOpNumber.setText(stdOpNumber); + } + } + else + { + stdOpNumber = "010"; + ml8_StdOpNumber.setText(stdOpNumber); + } + } + else + { + stdOpNumber = ml8_StdOpNumber.getText(); + } + + String newItemID = getGyRuleID(getSession(), String.format("%s-%s%s%s-%s", mapLabelText.get("ml8_StdOpType"),mapLabelText.get("ml8_StdOpPeriod"),mapLabelText.get("ml8_ProductType"),mapLabelText.get("ml8_MaterialType"),stdOpNumber)); + + idText.setText(newItemID); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } +// TCSession session = getSession(); +// TCComponent[] tcComponentForm = queryWithUserEntryName(session, "afdsgfd", new String[] { "Type" }, new String[] { "A2_coderule" }); +// if ((tcComponentForm == null) || (tcComponentForm.length == 0)) +// { +// MessageBox.post("sdfsdgsfg", "jhgkjh", 4); +// return; +// } + + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000000"); + String newID = oldItemID + "-000001"; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "-" + df.format(i); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + + + public static String getStdOpNumber( String itemID,int num) { + DecimalFormat df = new DecimalFormat("000"); + String newID = "010"; + // String idTemp = + try { + int i = 10; + while (itemID.compareTo(newID) != 0) { + i = i+1; + newID = df.format(i); + } + newID = df.format(i+num); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + private void sortTCComponentByProperty(List listTcComponentData, final String propertyName, final boolean ascendingSort) + { + Collections.sort(listTcComponentData, new Comparator() + { + public int compare(TCComponent t1, TCComponent t2) + { + String propertyValue1 = AutoAssignItemIDPropertyBean.this.getTCComponentPropertyValue(t1, propertyName); + String propertyValue2 = AutoAssignItemIDPropertyBean.this.getTCComponentPropertyValue(t2, propertyName); + int result = propertyValue1.compareTo(propertyValue2); + if (result < 0) + { + if (ascendingSort) { + return -1; + } + return 1; + } + if (result > 0) + { + if (ascendingSort) { + return 1; + } + return -1; + } + return 0; + } + + @Override + public int compare(Object o1, Object o2) { + // TODO Auto-generated method stub + if(o1 instanceof TCComponent && o2 instanceof TCComponent) + { + String propertyValue1 = AutoAssignItemIDPropertyBean.this.getTCComponentPropertyValue((TCComponent)o1, propertyName); + String propertyValue2 = AutoAssignItemIDPropertyBean.this.getTCComponentPropertyValue((TCComponent)o2, propertyName); + int result = propertyValue1.compareTo(propertyValue2); + if (result < 0) + { + if (ascendingSort) { + return -1; + } + return 1; + } + if (result > 0) + { + if (ascendingSort) { + return 1; + } + return -1; + } + } + return 0; + } + }); + } + + private String getTCComponentPropertyValue(TCComponent tcComponent, String propertyName) + { + String propertyValue = ""; + TCProperty tcproperty = null; + try + { + tcproperty = tcComponent.getTCProperty(propertyName); + } + catch (TCException e) + { + e.printStackTrace(); + } + if (tcproperty != null) + { + int type = tcproperty.getPropertyType(); + if (type == 2) + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = tcproperty.getDateValue(); + if (date != null) + { + String strDate = sdf.format(date); + propertyValue = strDate; + } + } + else if (type == 6) + { + boolean b = tcproperty.getBoolValue(); + if ("true".equals(String.valueOf(b))) { + propertyValue = "是"; + } else if ("false".equals(String.valueOf(b))) { + propertyValue = "否"; + } + } + else if (type == 8) + { + if (tcproperty.getDisplayableValue() == null) { + propertyValue = ""; + } else { + propertyValue = tcproperty.getDisplayableValue(); + } + } + else if (type == 9) + { + TCComponent component = tcproperty.getReferenceValue(); + if (component == null) { + propertyValue = ""; + } else { + propertyValue = component.toString(); + } + } + else if (type == 13) + { + TCComponent component = null; + try + { + component = tcComponent.getRelatedComponent(propertyName); + } + catch (TCException e) + { + e.printStackTrace(); + } + if (component == null) { + propertyValue = ""; + } else { + propertyValue = component.toString(); + } + } + else + { + try + { + if (tcComponent.getProperty(propertyName) == null) { + propertyValue = ""; + } else { + propertyValue = tcComponent.getProperty(propertyName); + } + } + catch (TCException e) + { + e.printStackTrace(); + } + } + } + return propertyValue; + } + + private String addPrefixWith0(int number) + { + String pix = "0"; + StringBuilder strNumber = new StringBuilder(); + if ((number >= 0) && (number < 10)) { + strNumber.append(pix).append(pix).append(String.valueOf(number)); + } else if ((10 <= number) && (number < 100)) { + strNumber.append(pix).append(String.valueOf(number)); + } + return strNumber.toString(); + } + + public TCComponent[] queryWithUserEntryName(TCSession session, String queryName, String[] keys, String[] values) + { + TCComponent[] component = (TCComponent[])null; + try + { + TCComponentQueryType queryType = (TCComponentQueryType)session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery)queryType.find(queryName); + TCQueryClause[] queryClauses = query.describe(); + + String[] userEntryNameDisplays = new String[keys.length]; + int count = queryClauses.length; + for (int k = 0; k < keys.length; k++) { + for (int i = 0; i < count; i++) { + if (keys[k].equals(queryClauses[i].getUserEntryName())) + { + userEntryNameDisplays[k] = queryClauses[i].getUserEntryNameDisplay(); + break; + } + } + } + TCComponentContextList tcComponentContextList = query.getExecuteResultsList(userEntryNameDisplays, values); + component = tcComponentContextList.toTCComponentArray(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + return component; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/AssignProductName/AssignPropertyTextField.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/AssignProductName/AssignPropertyTextField.java new file mode 100644 index 0000000..b2040c0 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/AssignProductName/AssignPropertyTextField.java @@ -0,0 +1,423 @@ +package com.connor.ml.tcm.AssignProductName; + +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.stylesheet.PropertyTextField; +import java.awt.Color; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +import org.apache.log4j.Level; +import org.apache.log4j.Logger; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.TCConstants; +import com.teamcenter.rac.common.TCUtilities; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.stylesheet.InterfaceBufferedPropertyComponent; +import com.teamcenter.rac.stylesheet.InterfacePropertyComponent; +import com.teamcenter.rac.util.FilterDocument; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.Utilities; +import com.teamcenter.rac.util.iButton; +import com.teamcenter.rac.util.iTextField; +import com.teamcenter.rac.util.log.Debug; + +public class AssignPropertyTextField extends PropertyTextField{ + + + public static final Logger logger; + public String property; + public boolean mandatory; + public boolean modifiable; + public TCPropertyDescriptor descriptor; + public boolean savable; + public Object originalValue; + public KeyListener syncTooltipWithValueListener; + public static Color bkgrdColor; + public static Color foregrdColor; + private Registry registry; + private TCSession session; + static + { + logger = Logger.getLogger(AssignPropertyTextField.class); + if(!logger.isDebugEnabled() && Debug.isOn("stylesheet,form,property,properties")) + logger.setLevel(Level.DEBUG); + } + public AssignPropertyTextField() throws TCException{ + super(); + setValue();//自定义方法:获取选中项目的代号,并setText,形如:setText("属性值"); + setRequired(true); + savable= false; + registry = Registry.getRegistry(PropertyTextField.class); + mandatory = false; + modifiable = true; + mandatory = false; + setOpaque(false); + Registry registry = Registry.getRegistry(this); + bkgrdColor = AbstractRendering.getReadOnlyBackgroundColor(registry); + foregrdColor = AbstractRendering.getReadOnlyForegroundColor(registry); + syncTooltipWithValueListener = new KeyAdapter() { + + public void keyReleased(KeyEvent keyevent) + { + String s = getText(); + setToolTipText(getWrappedToolTip(s)); + } + }; + } + public void setValue() throws TCException { + String productCode = null;//产品 + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp == null) { + MessageBox.post("请选中项目执行创建!!", "错误", MessageBox.ERROR); + }else { + String targetType = targetComp.getType(); + System.out.println("选中对象的类型 targetType = "+targetType); + } + if (targetComp instanceof TCComponentProject) { + System.out.println("当前选中对象是project!"); + //获取产品代号 + TCComponentProject product =(TCComponentProject)targetComp; + //产品代号 + productCode = product.getStringProperty("ml8_ProductCode"); + if (productCode != null) { + System.out.println("设置产品代号:"+productCode); + setText(productCode); + }else { + System.out.println("获取产品代号失败!请检查ml8_ProductCode字段。"); + } + + } + } + + @Override + public TCProperty saveProperty(TCComponent tccomponent) throws Exception { + // TODO Auto-generatsavePropertyed method stub + String value = getText(); + System.out.println("saveProperty(TCComponent="+value); + if(value == null || "".equals(value)){ + MessageBox.post("必填", "错误", MessageBox.ERROR); + return null; + } + TCProperty tcproperty = getPropertyToSave(tccomponent); + if(savable) + return tcproperty; + else + return null; + } + + public void load(TCComponentType tccomponenttype) + throws Exception{ + System.out.println("load(TCComponentType"); + if(tccomponenttype != null) + { + TCPropertyDescriptor tcpropertydescriptor = tccomponenttype.getPropertyDescriptor(property); + load(tcpropertydescriptor); + } + } + + public void load(TCPropertyDescriptor tcpropertydescriptor) + throws Exception + { + System.out.println("load(TCPropertyDescriptor"); + descriptor = tcpropertydescriptor; + setEditable(tcpropertydescriptor.isEnabled() && modifiable); + if(tcpropertydescriptor.isRequired()) + setMandatory(true); + if(!tcpropertydescriptor.isDisplayable()) + setVisible(false); + addKeyListener(syncTooltipWithValueListener); + } + + public void load(TCComponent tccomponent) + throws Exception + { + System.out.println("load(TCComponent tccomponent)"); + if(property != null) + { + TCProperty tcproperty = tccomponent.getTCProperty(property); + if(tcproperty != null) + load(tcproperty); + else + logger.debug((new StringBuilder("Unable to get property! comp=")).append(tccomponent).append(" property=").append(property).toString()); + } + } + public void load(TCProperty tcproperty) + throws Exception + { + System.out.println("load(TCProperty tcproperty)"); + property = tcproperty.getPropertyName(); + if(property == null) + return; + TCComponent tccomponent = tcproperty.getTCComponent(); + if(descriptor == null) + { + TCPropertyDescriptor tcpropertydescriptor = tccomponent.getTypeComponent().getPropertyDescriptor(property); + load(tcpropertydescriptor); + } + if(!descriptor.isDisplayable()) + return; + if(isEnabled() && !tcproperty.isEnabled()) + setEditable(false); + int i = tcproperty.getPropertyType(); + int j = descriptor.getMaxStringLength(); + if(j <= 0) + j = i != 8 ? TCConstants.getDefaultMaxNameSize(tccomponent.getSession()) : -1; + if(logger.isDebugEnabled()) + logger.debug((new StringBuilder("PropertyTextField:load propName=")).append(property).append(" propValue=").append(tcproperty.toString()).append(" type=").append(i).append(" maxLen=").append(j).toString()); + FilterDocument filterdocument = new FilterDocument(); + switch(i) + { + case 1: // '\001' + filterdocument.setLength(1); + break; + + case 3: // '\003' + case 4: // '\004' + filterdocument.setAcceptedChars("0123456789.eE"); + filterdocument.setNegativeAccepted(true); + break; + + case 5: // '\005' + filterdocument.setAcceptedChars("9876543210"); + filterdocument.setNegativeAccepted(true); + break; + + case 7: // '\007' + filterdocument.setAcceptedChars("1023456789"); + filterdocument.setNegativeAccepted(true); + break; + + case 8: // '\b' + filterdocument.setLength(j); + break; + } + + if(isEditable()) + { + filterdocument.setEncodeName(TCSession.getServerEncodingName(tccomponent.getSession())); + setDocument(filterdocument); + } + if(tcproperty.getNullVerdict()) + { + setText(""); + originalValue = null; + } else + { + setText(tcproperty.toString()); + setToolTipText(getWrappedToolTip(tcproperty.toString())); + originalValue = tcproperty.getPropertyData(); + } + int k = getColumns(); + if(k == 10) + { + int l = getText().length(); + byte byte0 = 32; + int i1 = tcproperty.toString().getBytes().length; + if(i1 > l) + l = i1; + if(k < l) + setColumns(l >= byte0 ? ((int) (byte0)) : l); + } + } + + @Override + public TCProperty saveProperty(TCProperty tcproperty) throws Exception { + // TODO Auto-generated method stub + String value = getText(); + System.out.println("saveProperty(TCProperty="+value+"-"+property); + if(value == null || "".equals(value)){ + MessageBox.post("属性["+property+"]必填", "错误", MessageBox.WARNING); + return null; + } + TCProperty tcproperty1 = getPropertyToSave(tcproperty); + if(savable) + return tcproperty1; + else + return null; + } + + @Override + public Object getEditableValue() { + // TODO Auto-generated method stub + return getText(); + } + + public String getValue() + { + System.out.println("getValue"); + return getText(); + } + + @Override + public String getProperty() { + // TODO Auto-generated method stub + return property; + } + + @Override + public boolean isMandatory() { + // TODO Auto-generated method stub + return mandatory; + } + + @Override + public boolean isPropertyModified(TCComponent tccomponent) throws Exception { + // TODO Auto-generated method stub + if(property != null) + { + TCProperty tcproperty = tccomponent.getTCProperty(property); + return isPropertyModified(tcproperty); + } else + { + return false; + } + } + + @Override + public boolean isPropertyModified(TCProperty tcproperty) throws Exception { + savable = false; + String s = getText(); + // System.out.println("isPropertyModified"); + + if(s == null || "".equals(s)){ + // MessageBox.post("必填", "错误", MessageBox.ERROR); + return true; + } + + + if(!tcproperty.isEnabled() || !modifiable) + { + return savable; + } else + { + String as[] = registry.getStringArray("booleanCharacter.YES"); + savable = TCUtilities.comparePropertyValue(s, originalValue, tcproperty, as); + return savable; + } + } + + + @Override + public void save(TCComponent tccomponent) throws Exception { + // TODO Auto-generated method stub + String value = getText(); + System.out.println("save(TCComponent="+value); + if(value == null || "".equals(value)){ + MessageBox.post("save(TCComponent必填", "错误", MessageBox.ERROR); + return; + } + TCProperty tcproperty = getPropertyToSave(tccomponent); + if(savable) + tccomponent.setTCProperty(tcproperty); + } + + @Override + public void save(TCProperty tcproperty) throws Exception { + // TODO Auto-generated method stub + String value = getText(); + System.out.println("save(TCProperty="+value); + if(value == null || "".equals(value)){ + MessageBox.post("save(TCProperty必填", "错误", MessageBox.ERROR); + return; + } + TCProperty tcproperty1 = getPropertyToSave(tcproperty); + if(savable && tcproperty1 != null) + tcproperty1.getTCComponent().setTCProperty(tcproperty); + } + + @Override + public void setMandatory(boolean flag) { + // TODO Auto-generated method stub + mandatory = flag; + } + + @Override + public void setModifiable(boolean flag) { + // TODO Auto-generated method stub + modifiable = flag; + setEditable(modifiable); + } + + @Override + public void setProperty(String s) { + System.out.println("222"); + // TODO Auto-generated method stub + property = s; + } + + @Override + public void setUIFValue(Object obj) { + // TODO Auto-generated method stub + if(obj != null) + setText(obj.toString()); + else + setText(""); + } + + private String getWrappedToolTip(String s) + { + if(s == null || s.length() <= 0) + return null; + int i = registry.getInt("wrapToolTipPosition", 80); + StringBuilder stringbuilder = new StringBuilder(); + if(s != null && s.length() > i) + { + for(int j = 0; j < s.length(); j += i) + if(j + i < s.length()) + stringbuilder.append((new StringBuilder(String.valueOf(s.substring(j, j + i)))).append("\n").toString()); + else + stringbuilder.append(s.substring(j)); + + } else + { + stringbuilder = stringbuilder.append(s); + } + return Utilities.getToolTipHTML(stringbuilder.toString(), 0); + } + private boolean isSetPropValueNULL(TCSession tcsession) + { + TCPreferenceService tcpreferenceservice = tcsession.getPreferenceService(); + Boolean boolean1 = tcpreferenceservice.getLogicalValue("FORM_text_field_shown_NULL"); + return boolean1 != null && boolean1.booleanValue(); + } + @Override + public TCProperty getPropertyToSave(TCComponent arg0) throws Exception { + // TODO Auto-generated method stub + + System.out.println("getPropertyToSave(TCComponent arg0)"); + String s = getText(); + if(s == null || "".equals(s)){ + MessageBox.post("必填", "错误", MessageBox.ERROR); + return null; + } + + return super.getPropertyToSave(arg0); + } + @Override + public TCProperty getPropertyToSave(TCProperty arg0) throws Exception { + // TODO Auto-generated method stub + + System.out.println("getPropertyToSave(TCProperty arg0)"); + String s = getText(); + if(s == null || "".equals(s)){ + MessageBox.post("必填", "错误", MessageBox.ERROR); + return null; + } + return super.getPropertyToSave(arg0); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ChangeBomViewHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ChangeBomViewHandler.java new file mode 100644 index 0000000..c546c63 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ChangeBomViewHandler.java @@ -0,0 +1,55 @@ +package com.connor.ml.tcm.ChangeBomView; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.context.MessageContext; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ChangeBomViewHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + // TODO Auto-generated method stub + // 获取当前系统活动 + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + // 获取tc当前选择的操作 + InterfaceAIFComponent target = app.getTargetComponent(); + if (target instanceof TCComponentBOMLine) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) target; + try { + if ("ML8_OrdMBOMItem".equals(bomLine.getItem().getStringProperty("object_type"))) { + TCComponentBOMLine topBOMLine = bomLine.window().getTopBOMLine(); + if (bomLine.getProperty("object_string") == topBOMLine.getProperty("object_string")) { + TCSession session = bomLine.getSession(); + ChangeBomViewOpertion changeBomViewOpertion = new ChangeBomViewOpertion(session, bomLine); + session.queueOperation(changeBomViewOpertion); + } else { + MessageBox.post("请选中顶层BOM行,再执行操作!!!", "提示", MessageBox.INFORMATION); + return null; + } + } else { + MessageBox.post("请选择订单BOM行", "提示", MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + + e.printStackTrace(); + } + }else { + MessageBox.post("请选中BOM版本,再执行操作!!!", "提示", MessageBox.INFORMATION); + } + return null; + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ChangeBomViewOpertion.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ChangeBomViewOpertion.java new file mode 100644 index 0000000..504a76d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ChangeBomViewOpertion.java @@ -0,0 +1,247 @@ +package com.connor.ml.tcm.ChangeBomView; + +import java.awt.BorderLayout; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.List; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +import org.json.*; + +import com.spire.ms.System.Collections.ArrayList; +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AIFTransferable; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFOperation; +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import edu.emory.mathcs.backport.java.util.Arrays; + +public class ChangeBomViewOpertion extends AbstractAIFOperation{ + private TCSession session; + private TCComponentBOMLine bomLine; + private DefaultMutableTreeNode selectedNode; + private JTable table = new JTable(); + private String[] titile = {"89码","数量","订单号","物料描述","名称","工厂","产线","ERP班组编码","ID","所有者","创建日期","父级","默认度量单位","零组件类型","零组件发布状态"}; + + public ChangeBomViewOpertion(TCSession session, TCComponentBOMLine bomLine) { + // TODO Auto-generated constructor stub + this.session = session; + this.bomLine = bomLine; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + //获取当前选中bom版本下的json文件 + String getjson = getjson(); + if(getjson == null) { + MessageBox.post("当前选中对象不包含JOSN数据", "提示", MessageBox.INFORMATION); + return; + } + //开始构建窗口 + JFrame jFrame = new JFrame(); + // 设置窗口标题 + jFrame.setTitle("BOM视图"); + //获取表格数据 + JSONObject json = new JSONObject(getjson); + List> tableValue = getTableValue(json); + // 创建表格 + // 创建表格模型 + DefaultTableModel tableModel = new DefaultTableModel(titile, 0); + // 将数据添加到表格模型中 + for (List rowValue : tableValue) { + tableModel.addRow(rowValue.toArray()); + } + // 将表格模型设置为表格的模型 + table.setModel(tableModel); + + // 创建复制按钮 + JButton confirmButton = new JButton("复制"); + confirmButton.addActionListener(e -> { + try { + String id = table.getValueAt(table.getSelectedRow(), 0).toString(); + //设置查询的条件 + String[] keys = new String[] {"零组件 ID"}; + //设置查询的id值 + String[] values = new String[] {id}; + //调用查询的方法 + List comps = queryObject("零组件...",keys,values); + //获取到查询的零组件 + TCComponent component = comps.get(0); + if(component instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem)component; + AIFClipboard cutBoard = AIFPortal.getClipboard(); + AIFTransferable aIFTransferable = new AIFTransferable(item.getLatestItemRevision()); + cutBoard.setContents(aIFTransferable, null); + MessageBox.post("对象已复制到剪切板", "提示", MessageBox.INFORMATION); + } + + } catch (TCException e2) { + e2.printStackTrace(); + // TODO: handle exception + } + }); + // 创建取消按钮 + JButton cancelButton = new JButton("取消"); + cancelButton.addActionListener(e -> { + jFrame.dispose(); + }); + + // 创建底部面板,用于放置按钮 + JPanel bottomPanel = new JPanel(); + bottomPanel.add(confirmButton); + bottomPanel.add(cancelButton); + // 将中间面板和底部面板添加到窗口中 + jFrame.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER); + jFrame.getContentPane().add(bottomPanel, BorderLayout.SOUTH); + + // 设置窗口大小,并设置窗口关闭时的操作 + jFrame.setSize(1800, 1000); + jFrame.setDefaultCloseOperation(2); + jFrame.setLocationRelativeTo(null); + jFrame.setAlwaysOnTop(true); + jFrame.setVisible(true); + } + + + public List queryObject(String queryName, String[] keys, String[] values) { + TCComponent[] components = null; + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + MessageBox.post("没有找到查询:" + queryName, "错误", MessageBox.ERROR); + return null; + } + components = query.execute(keys, values); + } catch (TCException e) { + e.printStackTrace(); + } + if (components != null && components.length > 0) { + List compList = Arrays.asList(components); + return compList; + } else { + return null; + } + } + + public String getjson() throws TCException { + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + TCComponent[] referenceListProperty = itemRevision.getReferenceListProperty("IMAN_specification"); + System.out.println("规范长度为:"+referenceListProperty.length); + for(TCComponent component : referenceListProperty) { + System.out.println("类型为:"+component.getStringProperty("object_type")); + if("Text".equalsIgnoreCase(component.getProperty("object_type"))||"文本".equals(component.getProperty("object_type"))) { + System.out.println("名字为:"+component.getStringProperty("object_name")); + if("bomJson".equals(component.getStringProperty("object_name"))) { + System.out.println("包含"); + //获取文本中的JSON,转换成虚拟BOM对象 + System.out.println("获取数据集"); + TCComponentDataset dataset = (TCComponentDataset)component; + System.out.println("获取数据集文件"); + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + System.out.println("获取文件地址"); + File file = tcFiles[0].getFile(System.getProperty("java.io.tmpdir")); + String path = file.getPath(); + System.out.println("文件地址:"+path); + String jsonStr = ""; + try { + FileReader fileReader = new FileReader(path); + Reader reader = new InputStreamReader(new FileInputStream(path),"GBK"); + int ch = 0; + StringBuffer sb = new StringBuffer(); + while ((ch = reader.read()) != -1) { + sb.append((char) ch); + } + fileReader.close(); + jsonStr = sb.toString(); + System.out.println(jsonStr); + return jsonStr; + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + } + } + return null; + } + private List> getTableValue(JSONObject json) { + JSONArray childItems = json.getJSONArray("childItems"); + List> tableValueList = new ArrayList(); + for (int i = 0; i < childItems.length(); i++) { + JSONObject childItem = childItems.getJSONObject(i); + String materialNo = (String) childItem.get("ml8_MaterialNo"); + //设置查询的条件 + String[] keys = new String[] {"零组件 ID"}; + //设置查询的id值 + String[] values = new String[] {materialNo}; + //调用查询的方法 + List comps = queryObject("零组件...",keys,values); + if(comps == null) { + continue; + } + //获取到查询的零组件 + TCComponent component = comps.get(0); + if(component instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem)component; + TCComponentBOMWindowType winType = null; + TCComponentBOMWindow view = null; + TCComponentBOMLine line = null; + try { + winType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + view = winType.create(null); + line = view.setWindowTopLine(item, item.getLatestItemRevision(), null, null); + List rowList = new ArrayList(); + rowList.add(line.getItemRevision().getProperty("item_id")); + rowList.add(childItem.getInt("bl_quantity")+""); + rowList.add(json.getString("ml8_ProdOrderNo")); + rowList.add(line.getItemRevision().getProperty("object_desc")); + rowList.add(line.getItemRevision().getProperty("object_name")); + rowList.add(line.getProperty("bl_ML8_PartRevision_ml8_Factory")); + rowList.add(line.getProperty("bl_ML8_PartRevision_ml8_Line")); + rowList.add(line.getProperty("bl_ML8_PartRevision_ml8_ERPCode")); + rowList.add(line.getProperty("bl_rev_awp0Item_item_id")); + rowList.add(line.getProperty("awb0RevisionOwningUser")); + rowList.add(line.getItemRevision().getProperty("creation_date")); + rowList.add(bomLine.getProperty("bl_line_name")); + rowList.add(line.getProperty("bl_item_uom_tag")); + rowList.add(line.getProperty("bl_item_object_type")); + rowList.add(line.getProperty("bl_rev_release_statuses")); + tableValueList.add(rowList); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + return tableValueList; + } +} + diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/MainFrame.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/MainFrame.java new file mode 100644 index 0000000..810d76d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/MainFrame.java @@ -0,0 +1,57 @@ +package com.connor.ml.tcm.ChangeBomView; + +import java.awt.BorderLayout; +import javax.swing.*; +import javax.swing.tree.DefaultMutableTreeNode; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +public class MainFrame extends JFrame { + + private DefaultMutableTreeNode selectedNode; + + public MainFrame(DefaultMutableTreeTableNode rootNode) { + // 设置窗口标题 + setTitle("BOM视图"); + // 创建树组件 + JTree tree = new JTree(rootNode); + // 创建确定按钮 + JButton confirmButton = new JButton("确定"); + confirmButton.addActionListener(e -> { + // 获取选中的节点 + Object selectedObject = tree.getSelectionPath().getLastPathComponent(); + if (selectedObject instanceof DefaultMutableTreeNode) { + selectedNode = (DefaultMutableTreeNode) selectedObject; + // 关闭窗口 + dispose(); + } + }); + // 创建取消按钮 + JButton cancelButton = new JButton("取消"); + cancelButton.addActionListener(e -> { + // 设置选中节点为null + selectedNode = null; + // 关闭窗口 + dispose(); + }); + // 创建中间面板,用于放置树组件 + JPanel centerPanel = new JPanel(); + centerPanel.add(new JScrollPane(tree)); + // 创建底部面板,用于放置按钮 + JPanel bottomPanel = new JPanel(); + bottomPanel.add(confirmButton); + bottomPanel.add(cancelButton); + // 将中间面板和底部面板添加到窗口中 + getContentPane().add(centerPanel); + getContentPane().add(bottomPanel, BorderLayout.SOUTH); + + // 设置窗口大小,并设置窗口关闭时的操作 + setSize(400, 400); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + } + + public DefaultMutableTreeNode getSelectedNode() { + return selectedNode; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/MaterialNoTreeNode.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/MaterialNoTreeNode.java new file mode 100644 index 0000000..8cd1fe0 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/MaterialNoTreeNode.java @@ -0,0 +1,54 @@ +package com.connor.ml.tcm.ChangeBomView; + +import javax.swing.tree.DefaultMutableTreeNode; + +public class MaterialNoTreeNode extends DefaultMutableTreeNode { + private String materialNo; + private String objectName; + private String blQuantity; + private String ml8_Units; + + public String getBlQuantity() { + return blQuantity; + } + + public void setBlQuantity(String blQuantity) { + this.blQuantity = blQuantity; + } + + public MaterialNoTreeNode(String materialNo, String objectName,String blQuantity,String ml8_Units) { + this.materialNo = materialNo; + this.objectName = objectName; + this.blQuantity = blQuantity; + this.ml8_Units = ml8_Units; + } + + public String getMl8_Units() { + return ml8_Units; + } + + public void setMl8_Units(String ml8_Units) { + this.ml8_Units = ml8_Units; + } + + public String getMaterialNo() { + return materialNo; + } + + + public String getObjectName() { + return objectName; + } + + public void setObjectName(String objectName) { + this.objectName = objectName; + } + + public void setMaterialNo(String materialNo) { + this.materialNo = materialNo; + } + + public String toString() { + return objectName; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ObjectNameTreeNode.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ObjectNameTreeNode.java new file mode 100644 index 0000000..34c1dfd --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/ObjectNameTreeNode.java @@ -0,0 +1,53 @@ +package com.connor.ml.tcm.ChangeBomView; + +import javax.swing.tree.DefaultMutableTreeNode; + +class ObjectNameTreeNode extends DefaultMutableTreeNode { + private String objectName; + private String prodOrderNo; + private String factory; + private String ml8_ERPCode; + + public ObjectNameTreeNode(String objectName,String prodOrderNo,String factory,String ml8_ERPCode) { + this.objectName = objectName; + this.prodOrderNo = prodOrderNo; + this.factory = factory; + this.ml8_ERPCode = ml8_ERPCode; + } + + public String getMl8_ERPCode() { + return ml8_ERPCode; + } + + public void setMl8_ERPCode(String ml8_ERPCode) { + this.ml8_ERPCode = ml8_ERPCode; + } + + public String getFactory() { + return factory; + } + + public void setFactory(String factory) { + this.factory = factory; + } + + public String getObjectName() { + return objectName; + } + + public void setObjectName(String objectName) { + this.objectName = objectName; + } + + public String getProdOrderNo() { + return prodOrderNo; + } + + public void setProdOrderNo(String prodOrderNo) { + this.prodOrderNo = prodOrderNo; + } + + public String toString() { + return objectName; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/test.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/test.java new file mode 100644 index 0000000..2887ad1 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ChangeBomView/test.java @@ -0,0 +1,100 @@ +package com.connor.ml.tcm.ChangeBomView; + +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.tree.*; +import javax.swing.table.*; +import java.awt.*; +import java.awt.event.*; +import org.json.*; + +public class test extends JFrame { + private JTree tree; + private JTable table; + private DefaultMutableTreeNode selectedNode; + + public test(JSONObject json) { + setTitle("BOM视图"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLayout(new BorderLayout()); + + DefaultMutableTreeNode rootNode = createTreeNodes(json); + tree = new JTree(rootNode); + tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); + tree.addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + selectedNode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + updateTable(); + } + }); + + JScrollPane treeScrollPane = new JScrollPane(tree); + add(treeScrollPane, BorderLayout.CENTER); + + table = new JTable(); + JScrollPane tableScrollPane = new JScrollPane(table); + add(tableScrollPane, BorderLayout.SOUTH); + + pack(); + setVisible(true); + } + + private void updateTable() { + if (selectedNode != null) { + DefaultTableModel tableModel = new DefaultTableModel(); + table.setModel(tableModel); + + tableModel.addColumn("属性"); + tableModel.addColumn("值"); + + if (selectedNode instanceof MaterialNoTreeNode) { + MaterialNoTreeNode node = (MaterialNoTreeNode) selectedNode; + tableModel.addRow(new Object[]{"ml8_MaterialNo", node.getMaterialNo()}); + tableModel.addRow(new Object[]{"object_name", node.getObjectName()}); + } + } + } + + private DefaultMutableTreeNode createTreeNodes(JSONObject json) { + DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(json.getString("object_name")); + + JSONArray childItems = json.getJSONArray("childItems"); + for (int i = 0; i < childItems.length(); i++) { + JSONObject childItem = childItems.getJSONObject(i); + String materialNo = childItem.getString("ml8_MaterialNo"); + String objectName = childItem.getString("object_name"); + DefaultMutableTreeNode childNode = new MaterialNoTreeNode(materialNo, objectName); + rootNode.add(childNode); + } + + return rootNode; + } + + private class MaterialNoTreeNode extends DefaultMutableTreeNode { + private String materialNo; + private String objectName; + + public MaterialNoTreeNode(String materialNo, String objectName) { + this.materialNo = materialNo; + this.objectName = objectName; + } + + public String getMaterialNo() { + return materialNo; + } + + public String getObjectName() { + return objectName; + } + } + + public static void main(String[] args) { + String jsonStr = "{\"ml8_ProductID\":\"ML9027460\",\"ml8_MaterialNo\":\"ML9027460\",\"object_name\":\"冷藏冷冻箱BCD-406WUP9B星河银\",\"ml8_ProdPlanNo\":\"P230610143\",\"ml8_BatchNo\":\"\",\"ml8_Factory\":\"I060\",\"ml8_ERPCode\":\"L\",\"ml8_ProdOrderNo\":\"1007689401\",\"bl_quantity\":1.000,\"childItems\":[{\"ml8_MaterialNo\":\"890306094\",\"object_name\":\"电源线_Q/MLKT-138A/G1.BE7G.Z9\",\"bl_quantity\":1.000,\"ml8_Units\":\"EA\"},{\"ml8_MaterialNo\":\"890241824\",\"object_name\":\"冷冻室门(B1103)_B18190.24\",\"bl_quantity\":1.000,\"ml8_Units\":\"EA\"}]}"; + JSONObject json = new JSONObject(jsonStr); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new test(json); + } + }); + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructCommand.java new file mode 100644 index 0000000..9e6a277 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructCommand.java @@ -0,0 +1,121 @@ +package com.connor.ml.tcm.CreateMBOM; + +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class MbomConstructCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private TCComponentBOMLine bomLine = null; + + public MbomConstructCommand(AbstractAIFApplication app, TCSession session) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //获取选中的对象 + InterfaceAIFComponent comp = app.getTargetComponent(); + + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + bomLine = (TCComponentBOMLine) comp; +// TCComponentBOMLine parent = bomLine.parent(); +// if(parent != null) +// { +// if(parent.parent() != null) +// { +// MessageBox.post("请选第一层和第二层BOMLine对象!", "错误", MessageBox.ERROR); +// return; +// } +// } +// +// if(parent == null) +// { +// parent = bomLine; +// } +// TCComponent rev = parent.getRelatedComponent("mfg0realRevision"); + // fnd0StartedWorkflowTasks +// TCComponent[] tasks = rev.getRelatedComponents("fnd0StartedWorkflowTasks"); +// if (tasks == null || tasks.length == 0) { +// MessageBox.post("父节点检查不通过!", "错误", MessageBox.ERROR); +// return; +// } +// String task_name = MethodUtil.getPreferenceValue("Meling_task_name"); +// boolean flag = false; +// String user_name = ""; +// for (TCComponent task : tasks) { +// String name = task.getProperty("fnd0AliasTaskName"); +// if (task_name.contains(name)) { +// flag = true; +// TCComponent[] users = task.getRelatedComponents("valid_signoffs"); +// if (users == null || users.length == 0) { +// MessageBox.post("认可人为空!", "错误", MessageBox.ERROR); +// return; +// } +// user_name = users[0].getRelatedComponent("fnd0Performer").getProperty("user_id"); +// } +// } +// if (!flag) { +// MessageBox.post("节点名称不匹配!", "错误", MessageBox.ERROR); +// return; +// } +// +// String userName = session.getUser().getProperty("user_id"); +// if (!userName.equals(user_name)) { +// MessageBox.post("认可人与当前登录用户不匹配!", "错误", MessageBox.ERROR); +// return; +// } + + //判断选中的对象类型是否为原辅材料 + TCComponentItem item = bomLine.getItem(); + + String itemType = item.getStringProperty("object_type"); + //获取允许下挂原材料的对象类型 + String[] itemTypes = MethodUtil.getPreferenceValues("ML_HaveMBOM_ItemType"); + boolean isHave = false; + for (int i = 0; i < itemTypes.length; i++) { + if(itemTypes[i].equals(itemType)) + { + isHave = true; + break; + } + } + if(!isHave) + { + MessageBox.post(itemType+"下不能搭建原辅材料!", "错误", MessageBox.ERROR); + return; + } +// if(item.getStringProperty("object_type").equals("ML8_RawMaterial")) +// { +// MessageBox.post("原辅材料下不能搭建原辅材料!", "错误", MessageBox.ERROR); +// return; +// } + + new Thread() { + @Override + public void run() { + MbomConstructDialog dialog = new MbomConstructDialog( + app, session,bomLine); + } + }.start(); + + super.executeModal(); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructDialog.java new file mode 100644 index 0000000..e266d79 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructDialog.java @@ -0,0 +1,585 @@ +package com.connor.ml.tcm.CreateMBOM; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MethodUtil; +import com.connor.ml.tcm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class MbomConstructDialog extends JFrame implements +ActionListener { + private AbstractAIFApplication app; + private TCSession session; + private TCComponentBOMLine bomLine; + private ArrayList> dataValue = new ArrayList>();//获取的数据 + private Object[][] values; + //private String[] queryName;//查询条件 + //private String[] queryValue;//值 + + private String[] columns = new String[] {"ID","名称","数量","单位","规格型号","标准描述"}; + + //系统界面 + private JPanel queryPanel; + private JLabel itemIdLabel; + private JTextField itemIdTextField; + private JLabel itemNameLabel; + private JTextField itemNameTextField; + private JLabel itemDescLabel; + private JTextField itemDescTextField; + private JButton queryButton; + private JButton deletePartButton; + + private JTable mainTable; + + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + + public MbomConstructDialog(AbstractAIFApplication app, TCSession session, TCComponentBOMLine bomLine) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = session; + this.bomLine = bomLine; + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("查询原辅材料"); + this.setPreferredSize(new Dimension(600,500)); + + this.queryPanel = new JPanel(new PropertyLayout()); + this.itemIdLabel = new JLabel("ID"); + this.itemIdLabel.setPreferredSize(new Dimension(50,25)); + this.itemIdTextField = new JTextField(); + this.itemIdTextField.setPreferredSize(new Dimension(300,25)); + this.itemNameLabel = new JLabel("名称"); + this.itemNameLabel.setPreferredSize(new Dimension(50,25)); + this.itemNameTextField = new JTextField(); + this.itemNameTextField.setPreferredSize(new Dimension(300,25)); + this.itemDescLabel = new JLabel("标准描述"); + this.itemDescLabel.setPreferredSize(new Dimension(50,25)); + this.itemDescTextField = new JTextField(); + this.itemDescTextField.setPreferredSize(new Dimension(300,25)); + this.queryButton = new JButton("查询"); + this.queryButton.setPreferredSize(new Dimension(300,25)); + this.deletePartButton = new JButton("去除零组件"); + this.deletePartButton.setPreferredSize(new Dimension(100,25)); + + this.queryPanel.add("1.1.left.top",this.itemIdLabel); + this.queryPanel.add("1.2.left.top",this.itemIdTextField); + this.queryPanel.add("2.1.left.top",this.itemNameLabel); + this.queryPanel.add("2.2.left.top",this.itemNameTextField); + this.queryPanel.add("3.1.left.top",this.itemDescLabel); + this.queryPanel.add("3.2.left.top",this.itemDescTextField); + this.queryPanel.add("4.1.left.top",this.deletePartButton); + this.queryPanel.add("4.2.left.top",this.queryButton); + + this.mainTable = getjTable(mainTable, null, columns, values); + + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("确定"); + this.celButton = new JButton("取消"); + + this.rootPanel.add(this.okButton); + this.rootPanel.add(this.celButton); + + // 添加按钮监听 + this.createActionEvent(); + this.add(queryPanel, BorderLayout.NORTH); + this.add(new JScrollPane(this.mainTable), BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + + + } + + // 添加监听 + public void createActionEvent() { + this.queryButton.addActionListener(this); + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.deletePartButton.addActionListener(this); + } + + /*** + * Jtable通用方法 + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(30); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames); + } + return tableModel; + } + + public String setQuery() + { + String selectSql = " 1=1"; + //List queryNameList=new ArrayList(); + //List queryValueList=new ArrayList(); + + //queryNameList.add("类型"); + //queryValueList.add("ML8_RawMaterial"); + + if(this.itemIdTextField.getText() != null && !this.itemIdTextField.getText().isEmpty()) + { + selectSql = " pitem_id LIKE '%"+this.itemIdTextField.getText()+"%'"; + //queryNameList.add("零组件 ID"); + //queryValueList.add("*" + this.itemIdTextField.getText() + "*"); + } + if(this.itemDescTextField.getText() != null && !this.itemDescTextField.getText().isEmpty()) + { + selectSql = " pml8_StdDesc LIKE '%"+this.itemDescTextField.getText()+"%'"; + //queryNameList.add("零组件 ID"); + //queryValueList.add("*" + this.itemIdTextField.getText() + "*"); + } + + if(this.itemNameTextField.getText() != null && !this.itemNameTextField.getText().isEmpty()) + { + if(selectSql.equals(" 1=1")) + { + selectSql = " pobject_name LIKE '%"+this.itemNameTextField.getText()+"%'"; + } + else + { + selectSql = selectSql + " AND pobject_name KILE '%"+this.itemNameTextField.getText()+"%'"; + } + //queryNameList.add("名称"); + //queryValueList.add("*" + this.itemNameTextField.getText() + "*"); + } + +// if(queryNameList.size() == 0){ +// this.queryName=new String[]{"ID"}; +// this.queryValue=new String[]{"*"}; +// } +// else{ +// this.queryName=new String[queryNameList.size()]; +// this.queryValue=new String[queryValueList.size()]; +// for (int i = 0; i < queryNameList.size(); i++) { +// this.queryName[i]=queryNameList.get(i); +// this.queryValue[i]=queryValueList.get(i); +// } +// } + return selectSql; + } + + //获取所有查询到的对象 + public List getItem(String[] queryName,String[] queryValue) + { + List components=new ArrayList(); + // 获取查询 + try { + TCComponentQueryType queryType = (TCComponentQueryType) session + .getTypeComponent("ImanQuery"); + //获取产品统计查询 + TCComponentQuery cptjQuery=(TCComponentQuery)queryType.find("零组件..."); + if(cptjQuery==null){ + MessageBox.post("未找到零组件...查询!", "错误", ERROR); + return null; + } + + + TCComponent[] cptjComponents = cptjQuery.execute(queryName, queryValue); + for (TCComponent tcComponent : cptjComponents) { + components.add(tcComponent); + } + return components; + } catch (TCException e) { + MessageBox.post("查询对象出错!请联系系统管理员!", "错误", MessageBox.ERROR); + e.printStackTrace(); + } + return null; + } + //获取所需要的数据 + public void getCellValue(String whereSql) + { + //errSb=new StringBuffer();//用来保存错误的数据 + InputStream input = null; + ResultSet rs = null; + try { + + input = new BufferedInputStream(getClass().getResourceAsStream( + "/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String selectSql = String.format(pro.getProperty("ML_GETITEMID_ITEMTYPESQL"),whereSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + + if(rs != null) + { + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + while(rs.next()) + { + ArrayList cellValue=new ArrayList(); + String itemId = rs.getString("pitem_id"); + cellValue.add(itemId); + cellValue.add(rs.getString("pobject_name")); + cellValue.add(""); + cellValue.add(rs.getString("psymbol")); + cellValue.add(rs.getString("pml8_Specifications")); + cellValue.add(rs.getString("pml8_StdDesc")); +// //获取规格型号 +// TCComponentItemRevision itemRevision = MethodUtil.getLastItemRevision(itemType.find(itemId)); +// cellValue.add(itemRevision.getStringProperty("ml8_Specifications")); +// String desc = itemRevision.getStringProperty("ml8_StdDesc"); +// cellValue.add(desc); +// if(this.itemDescTextField.getText() != null && !this.itemDescTextField.getText().isEmpty()) { +// if(desc.indexOf(this.itemDescTextField.getText()) < 0) +// { +// continue; +// } +// } + this.dataValue.add(cellValue); + } + } + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } + } + public void addData(Object[][] cellData2) { + DefaultTableModel tableModel = (DefaultTableModel) this.mainTable + .getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter(this.getTableModel(null, this.columns, cellData2)); + this.mainTable.setRowSorter(sorter); + for (int i = 0; i < cellData2.length; i++) { + tableModel.addRow(cellData2[i]); + } + // 表格数据不可修改 + this.mainTable.setEnabled(true); + // 更新表格 + this.mainTable.invalidate(); + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + try { + //将选中对象添加到选中的BOMLine中 + int[] rows = this.mainTable.getSelectedRows(); + if (this.mainTable.isEditing()) + { + this.mainTable.getCellEditor().stopCellEditing(); + } + List itemList = new ArrayList(); + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + for (int i = 0; i < rows.length; i++) { + String itemId = this.mainTable.getValueAt(rows[i], 0).toString(); + String num = this.mainTable.getValueAt(rows[i], 2).toString(); + String unit = this.mainTable.getValueAt(rows[i], 3) == null ? "ea" : this.mainTable.getValueAt(rows[i], 3).toString(); + if(num.isEmpty()) + { + MessageBox.post("数量不允许为空。对象:"+itemId, "错误", MessageBox.ERROR); + return; + } + if(unit.compareTo("ea") == 0 && num.indexOf(".")>=0) + { + MessageBox.post("单位是ea的对象属性不能为小数。对象:"+itemId, "错误", MessageBox.ERROR); + return; + } + itemList.add(MethodUtil.getLastItemRevision(itemType.find(itemId))); + } +// MethodUtil.openByPass(session); + //重新搭建BOM + this.recreateBom(itemList, false); + + this.bomLine.lock(); + //设置BOM行属性 + for (int i = 0; i < rows.length; i++) { + String itemId = this.mainTable.getValueAt(rows[i], 0).toString(); + String num = this.mainTable.getValueAt(rows[i], 2) == null ? "": this.mainTable.getValueAt(rows[i], 2).toString(); + + for (int j = 0; j < this.bomLine.getChildren().length; j++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) this.bomLine.getChildren()[j].getComponent(); + + boolean canWrite = this.session.getTCAccessControlService().checkPrivilege(bomLine, "WRITE"); + System.out.println(">> write: " + canWrite); + if(!canWrite) { + MessageBox.post("没有修改权限","提示",2); + return; + } + if(itemId.equals(bomLine.getStringProperty("bl_item_item_id"))) + { + String uom = ""; + try { + uom = bomLine.getPropertyDisplayableValue("bl_uom"); + } catch (NotLoadedException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + System.out.println("单位:++++++++++++++++"+uom); + //获取数量 + String quantity = bomLine.getStringProperty("bl_quantity"); + if(quantity == null || quantity.isEmpty()) + { + if(uom.equals("每个")) + { + bomLine.setStringProperty("bl_quantity", num); + } + else + { + if(num != null && !num.isEmpty()) + { + Double bomNum = Double.parseDouble(num); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + } + } + else + { + if(num != null && !num.isEmpty()) + { + if(uom.equals("每个")) + { + Integer bomNum = Integer.parseInt(quantity) + Integer.parseInt(num); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + else + { + Double bomNum = Double.parseDouble(quantity) + Double.parseDouble(num); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } +// if(quantity.indexOf(".") > 0 || num.indexOf(".") > 0) +// { +// Double bomNum = Double.parseDouble(quantity) + Double.parseDouble(num); +// bomLine.setStringProperty("bl_quantity", bomNum.toString()); +// } +// else +// { +// Integer bomNum = Integer.parseInt(quantity) + Integer.parseInt(num); +// bomLine.setStringProperty("bl_quantity", bomNum.toString()); +// } + } + else + { + if(uom.equals("每个")) + { + Integer bomNum = Integer.parseInt(quantity) + 1; + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + else + { + Double bomNum = Double.parseDouble(quantity) + 1; + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } +// if(quantity.indexOf(".") > 0) +// { +// Double bomNum = Double.parseDouble(quantity) + 1; +// bomLine.setStringProperty("bl_quantity", bomNum.toString()); +// } +// else +// { +// Integer bomNum = Integer.parseInt(quantity) + 1; +// bomLine.setStringProperty("bl_quantity", bomNum.toString()); +// } + } + } + bomLine.setStringProperty("ML8_MBOM", "MBOM"); + } + } + } + this.bomLine.save(); + this.bomLine.unlock(); + this.bomLine.refresh(); + if(this.bomLine.getBOMView() != null) + { + this.bomLine.getBOMView().save(); + this.bomLine.getBOMView().refresh(); + } + this.bomLine.getCachedWindow().save(); + this.bomLine.getCachedWindow().refresh(); +// MethodUtil.closeByPass(session); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + else if(source.equals(this.queryButton)) + { + //查询获取数据 + ProgressBarThread thread = new ProgressBarThread("查询对象", + "查询对象..."); + thread.start(); + this.dataValue.clear(); + String selectSql = this.setQuery(); + selectSql = selectSql+ " AND (pobject_type = 'ML8_RawMaterial' OR pobject_type = 'ML8_Part')"; + //List components = getItem(queryName, queryValue); + this.getCellValue(selectSql); + //根据查询获取对象 + this.values=new String[this.dataValue.size()][]; + for (int i = 0; i < this.dataValue.size(); i++) { + this.values[i]=new String[this.dataValue.get(i).size()]; + for (int j = 0; j < this.dataValue.get(i).size(); j++) { + this.values[i][j]=this.dataValue.get(i).get(j); + } + } + //更新表格 + this.addData(values); + thread.setBool(true); + } + else if(source.equals(this.deletePartButton)) + { + //查询获取数据 + ProgressBarThread thread = new ProgressBarThread("去除零组件查询对象", + "去除零组件查询对象..."); + thread.start(); + this.dataValue.clear(); + String selectSql = this.setQuery(); + selectSql = selectSql+ " AND pobject_type = 'ML8_RawMaterial'"; + //List components = getItem(queryName, queryValue); + this.getCellValue(selectSql); + //根据查询获取对象 + this.values=new String[this.dataValue.size()][]; + for (int i = 0; i < this.dataValue.size(); i++) { + this.values[i]=new String[this.dataValue.get(i).size()]; + for (int j = 0; j < this.dataValue.get(i).size(); j++) { + this.values[i][j]=this.dataValue.get(i).get(j); + } + } + //更新表格 + this.addData(values); + thread.setBool(true); + } + else if(source.equals(this.celButton)) + { + this.dispose(); + } + + } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom( + List itemList, boolean isDelete) + throws TCException { + try { + TCComponentBOMLine topline = this.bomLine; + + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItemRevision n_itemRevision : itemList) { + if(n_itemRevision != null) + { + boolean isHave = false; + if(!isDelete) + { + for (AIFComponentContext children : topline.getChildren()) { + if(n_itemRevision.getStringProperty("item_id").compareTo(children.getComponent().getProperty("bl_item_item_id")) == 0) + { + isHave = true; + } + } + } + if(!isHave) + { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + +// //设置BOMLine数量 +// AIFComponentContext[] childrens = topline.getChildren(); +// TCComponentBOMLine bomLine = (TCComponentBOMLine) childrens[childrens.length -1].getComponent(); +// bomLine.lock(); +// bomLine.setIntProperty("bl_quantity", 3); +// bomLine.save(); +// bomLine.unlock(); +// bomLine.refresh(); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if(topline.getBOMView() != null) + { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructHandler.java new file mode 100644 index 0000000..b514f66 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructHandler.java @@ -0,0 +1,28 @@ +package com.connor.ml.tcm.CreateMBOM; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class MbomConstructHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + MbomConstructCommand command = new MbomConstructCommand(app,session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructOperation.java new file mode 100644 index 0000000..959e6f3 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateMBOM/MbomConstructOperation.java @@ -0,0 +1,13 @@ +package com.connor.ml.tcm.CreateMBOM; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class MbomConstructOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateTimeSheet/CreateScheduleHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateTimeSheet/CreateScheduleHandler.java new file mode 100644 index 0000000..f7feb9a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/CreateTimeSheet/CreateScheduleHandler.java @@ -0,0 +1,120 @@ +package com.connor.ml.tcm.CreateTimeSheet; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.schedule.commands.newschedule.NewScheduleHandler; +import com.teamcenter.rac.schedule.plugin.Activator; +import com.teamcenter.rac.schedule.project.sharedUtils.TimeZoneCalUtil; +import com.teamcenter.rac.schedule.wizardpages.SchedulePageModel; +import com.teamcenter.rac.ui.commands.handlers.NewBOHandler; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import java.text.MessageFormat; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.*; + +public class CreateScheduleHandler extends NewBOHandler { + + private TCSession session; + + private static SchedulePageModel scheduleModel = null; + private final Registry textRegistry = Registry + .getRegistry("com.teamcenter.rac.schedule.schedule"); + + + + public CreateScheduleHandler() { + } + + public static SchedulePageModel getScheduleModel() { + if (scheduleModel == null) + scheduleModel = new SchedulePageModel(); + return scheduleModel; + } + + public Object execute(ExecutionEvent executionevent) throws ExecutionException { + + + String productCode = null;//产品 + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + session = (TCSession) app.getSession(); + InterfaceAIFComponent targetComp = app.getTargetComponent(); + if (targetComp == null) { + MessageBox.post("请选中项目执行创建!!", "错误", MessageBox.ERROR); + return null; + }else { + String targetType = targetComp.getType(); + System.out.println("选中对象的类型 targetType = "+targetType); + } + + if (targetComp instanceof TCComponentProject) { + System.out.println("当前选中对象是project!"); + //获取产品代号 +// TCComponentProject product =(TCComponentProject)targetComp; +// try { +// if (product != null) { +// //产品代号 +// productCode = product.getStringProperty("ml8_ProductCode"); +// System.out.println("获取到产品代号:"+productCode); +// } +// } catch (TCException e) { +// // TODO 自动生成的 catch 块 +// e.printStackTrace(); +// } + + scheduleModel = null; + wizardId = "com.teamcenter.rac.schedule.commands.newschedule.GenericScheduleWizard"; + TCSession tcsession = (TCSession) Activator.getDefault() + .getSessionService().getDefaultSession(); + TCPreferenceService tcpreferenceservice = tcsession + .getPreferenceService(); + String s = tcpreferenceservice.getString(4, "SiteTimeZone", "null"); + IWorkbench iworkbench = PlatformUI.getWorkbench(); + IWorkbenchWindow iworkbenchwindow = iworkbench + .getActiveWorkbenchWindow(); + Shell shell = iworkbenchwindow.getShell(); + if ("null".equals(s) || s == null) { + MessageDialog.openInformation(shell, + textRegistry.getString("tzNotSet.TITLE"), + textRegistry.getString("tzNotSet.MSG")); + return Boolean.valueOf(false); + } + if (!TimeZoneCalUtil.testTimeZoneID(s)) { + String s1 = textRegistry.getString("tzInvalid.MSG"); + s1 = MessageFormat.format(s1, new Object[] { s }); + MessageDialog.openInformation(shell, + textRegistry.getString("tzInvalid.TITLE"), s1); + return Boolean.valueOf(false); + } else { + return super.execute(executionevent); + } + }else { + MessageBox.post("请在【我的项目】视图中,选择项目创建!", "提示", MessageBox.INFORMATION); + return null; + } + } + + + + /** + * + */ + public String getWizardTitle() { + Registry registry = Registry.getRegistry(NewScheduleHandler.class); + registry.setString("object_name", "123"); +// return registry.getString("dialog.TITLE"); + return registry.getString("dialog.TITLE"); + } + + + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01.7z b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01.7z new file mode 100644 index 0000000..8895456 Binary files /dev/null and b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01.7z differ diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/ChangeItemIdDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/ChangeItemIdDialog.java new file mode 100644 index 0000000..c18c7e3 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/ChangeItemIdDialog.java @@ -0,0 +1,114 @@ +package com.connor.ml.tcm.ML_01; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.bean.ComboBoxItemBean; +import com.connor.ml.tcm.bean.NodeBean; +import com.connor.ml.tcm.util.JAutoCompleteComboBox; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ChangeItemIdDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private InterfaceAIFComponent comp; + private NodeBean nodeBean; + + private JPanel titlePanel; + private JLabel titleLabel; + + private JLabel lineLabel; + private JTextField lineComBox; + + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + + + public ChangeItemIdDialog(NodeBean nodeBean) { + // TODO Auto-generated constructor stub + //super(false); + this.nodeBean = nodeBean; + init(); + showDialog(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("更改ID"); + this.setPreferredSize(new Dimension(350, 180)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("更改ID"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + JPanel panel = new JPanel(); + panel.add(this.titlePanel, BorderLayout.NORTH); + + this.lineLabel = new JLabel("选择产线:"); + this.lineLabel.setPreferredSize(new Dimension(80, 30)); + + this.lineComBox = new JTextField(nodeBean.getMbomId()); + this.lineComBox.setPreferredSize(new Dimension(150, 30)); + + JPanel topPanel = new JPanel(new FlowLayout()); + topPanel.add(lineLabel); + topPanel.add(lineComBox); + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("确认"); + this.celButton = new JButton("取消"); + + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.NORTH); + this.add(topPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + // 添加监听 + public void createActionEvent() { + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + try { + nodeBean.setMbomId(this.lineComBox.getText()); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + else + { + this.dispose(); + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomCommand.java new file mode 100644 index 0000000..e089350 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomCommand.java @@ -0,0 +1,1060 @@ +package com.connor.ml.tcm.ML_01; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.TreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; +import com.connor.ml.tcm.util.MethodUtil; +import com.microsoft.schemas.office.excel.STObjectType.Enum; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.exceptions.NotLoadedException; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +public class EbomTransitionToMbomCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine bomLine = null; + private String lineId; + private String factory; + private DefaultMutableTreeTableNode node = null; + private SelectLineDialog selectLineDialog; + private TCComponentItemRevision topItemRevision = null; + private List factoryLineList = new ArrayList(); + private boolean flag; + private Map lineEroCodeMap=new HashMap(); + + public EbomTransitionToMbomCommand(String lineId,String factory, InterfaceAIFComponent comp, TCSession session, + SelectLineDialog selectLineDialog,Map lineEroCodeMap) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + this.lineId = lineId; + this.factory = factory; + this.selectLineDialog = selectLineDialog; + this.lineEroCodeMap=lineEroCodeMap; + } + + public EbomTransitionToMbomCommand(String lineId,String factory, InterfaceAIFComponent comp, TCSession session,Map lineEroCodeMap,boolean flag) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + this.lineId = lineId; + this.factory = factory; + this.lineEroCodeMap=lineEroCodeMap; + this.flag=flag; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + // 获取选中的对象 + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + //TCComponentBOMLine bomLine = null; + + if(comp instanceof TCComponentBOMLine) + { + bomLine = (TCComponentBOMLine) comp; + } + else if(comp instanceof TCComponentItem) + { + TCComponentItem item = (TCComponentItem) comp; + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, itemRevision, null, null); + + bomLine = topline; + } + else if(comp instanceof TCComponentItemRevision) + { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + + TCComponentBOMLine topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + bomLine = topline; + + } + if(bomLine == null) + { + return; + } + +// if (!(comp instanceof TCComponentBOMLine)) { +// MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); +// return; +// } +// bomLine = (TCComponentBOMLine) comp; + + if (bomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) { + MessageBox.post("选中对象的替代项目组为A0!", "错误", MessageBox.ERROR); + return; + } + + // 判断对象类型 + TCComponentItem item = bomLine.getItem(); + System.out.println(item.getType()); + + //获取首选项中的工厂和产线 + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringValues("ML_MBOM_ExtendLine"); + for (int i = 0; i < values.length; i++) { + if(values[i].indexOf("-") > 0) + { + String[] lineValues = values[i].split("-"); + if (lineValues[0].indexOf("|") > 0) + { + String[] factoryLineValues = lineValues[0].split("\\|"); + factoryLineList.add(factoryLineValues[0] + "-" + factoryLineValues[1]); + } + } + } + // 判断所选对象的产线是否为空 + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + String bomItemLine = itemRevision.getStringProperty("ml8_Line"); + try { + if (bomItemLine == null || bomItemLine.isEmpty()) { + if (!item.getType().equals("ML8_Refrigerator") && !item.getType().equals("ML8_Part") && !item.getType().equals("ML8_Cold")) { + MessageBox.post("请选中冰箱柜、商冷或零部件对象!", "错误", MessageBox.ERROR); + return; + } + boolean isPart = false; + if (!item.getType().equals("ML8_Part")) { + isPart = true; + } + node = this.getBomPropertyToNode(session, bomLine, isPart); + } else { + if (!item.getType().equals("ML8_Refrigerator") && !item.getType().equals("ML8_Part") && !item.getType().equals("ML8_Cold")) { + MessageBox.post("请选中冰箱柜、商冷或零部件对象!", "错误", MessageBox.ERROR); + return; + } + // 判断产线是否相同 + if (bomItemLine.compareTo(lineId) == 0) { + MessageBox.post("请选择其他产线扩产线!", "错误", MessageBox.ERROR); + return; + } + boolean isPart = false; + if (!item.getType().equals("ML8_Part")) { + isPart = true; + } + node = this.getBomExtendPropertyToNode(session, bomLine, isPart); + } + } catch (Exception e) { + // TODO: handle exception + MessageBox.post(e.getMessage(), "错误", MessageBox.ERROR); + return; + } + if (node == null) { + MessageBox.post("获取转换MBOM信息失败!", "错误", MessageBox.ERROR); + return; + } + +// + + new Thread() { + @Override + public void run() { + if (selectLineDialog == null) { + TCComponentItemType itemType; + try { + MethodUtil.openByPass(session); + try { + itemType = (TCComponentItemType) session.getTypeComponent("Item"); + System.out.println("开始转MBOM"); + adaptiveVariants("", "", (DefaultMutableTreeTableNode) (node.getChildAt(0)), itemType); + if (topItemRevision != null) { + topItemRevision.refresh(); + TCComponent[] targets = new TCComponent[] { topItemRevision, itemRevision }; + int[] types = new int[] { 1, 1 }; + if(topItemRevision.getStringProperty("item_id").equals(itemRevision.getStringProperty("item_id"))) + { + targets = new TCComponent[] { topItemRevision }; + types = new int[] { 1 }; + } + try + { + MethodUtil.CreateProcess(session, targets, types, "000-扩线体MBOM传递ERP"); + } + catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + MethodUtil.closeByPass(session); + } + + if(flag) { + MessageBox.post("扩产线完成!", "完成", MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + EbomTransitionToMbomDialog dialog = new EbomTransitionToMbomDialog(lineId,factory, comp, session, node, + selectLineDialog,lineEroCodeMap); + } + } + }.start(); + super.executeModal(); + } + + TCComponentBOMLine resultTopline = null; + + /** + * 重新搭建BOM + * + * @param topItem + * @throws TCException + */ + private void adaptiveVariants(String lineCode, String erpCode, DefaultMutableTreeTableNode tableNode, + TCComponentItemType itemType) throws TCException { + NodeBean childBean = (NodeBean) tableNode.getUserObject(); + TCComponentItem topItem = itemType.find(childBean.getMbomId()); + if (topItem == null) { + System.out.println("topItem = null"); + TCComponentItemRevision itemRevision = childBean.getItem().getLatestItemRevision(); + //另存对象 + topItem = itemRevision.saveAsItem(childBean.getMbomId(), "A"); + + TCComponentItemRevision topItemRevision2=null; +// topItem = itemRevision.saveAsItem(childBean.getMbomId(), "A"); + if (lineCode.isEmpty() && erpCode.isEmpty()) { + topItemRevision2 = topItem.getLatestItemRevision(); + } + TCComponent[] relatedComps = itemRevision.getRelatedComponents("TC_Primary_Design_Representation"); + if(topItemRevision2!=null) { + for (int i = 0; i < relatedComps.length; i++) { + topItemRevision2.add("TC_Primary_Design_Representation", relatedComps[i]); + } + } + // 获取EBOM ID + String ebomId = itemRevision.getStringProperty("item_id"); + String mbomId = childBean.getMbomId(); + String lineCodeString = ""; + String factoryString = ""; + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + if (mbomId.indexOf("-") > 0) { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode(lineCodeString,factoryString); + if (result.indexOf("=") > 0) { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + TCComponentItem ebom = itemType.find(ebomId); + // 将另存的对象放在EBOM的ML8_RelatedMBOM关系下 + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + topItem.refresh(); + topItem.getLatestItemRevision().refresh(); + // 设置属性 + System.out.println("对象:"+topItem.getLatestItemRevision().getStringProperty("object_string")); + System.out.println("设置属性:ml8_LineCode:"+lineCode); + System.out.println("设置属性:ml8_ERPCode:"+erpCode); + System.out.println("设置属性:ml8_Line:"+lineCodeString); + System.out.println("设置属性:ml8_Factory:"+this.factory); + topItem.getLatestItemRevision().setStringProperty("ml8_LineCode", lineCode); + topItem.getLatestItemRevision().setStringProperty("ml8_ERPCode", erpCode); + topItem.getLatestItemRevision().setStringProperty("ml8_Line", lineCodeString); + topItem.getLatestItemRevision().setStringProperty("ml8_Factory", this.factory); + TreeTableNode parent = tableNode.getParent(); + if(parent != null) { + // 获取EBOM ID + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + TCComponent[] relatedMBOMs = ebom.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); + boolean isHave = false; + for (int j = 0; j < relatedMBOMs.length; j++) { + if(relatedMBOMs[j].getUid().equals(topItem.getUid())) + { + isHave = true; + break; + } + } + if(!isHave) + { + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + } + } + } + else + { + TCComponentItemRevision itemRevision = childBean.getItem().getLatestItemRevision(); + // 获取EBOM ID + String ebomId = itemRevision.getStringProperty("item_id"); + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + TCComponentItem ebom = itemType.find(ebomId); + + TCComponent[] relatedMBOMs = ebom.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); + boolean isHave = false; + if(relatedMBOMs != null) + { + for (int i = 0; i < relatedMBOMs.length; i++) { + if(relatedMBOMs[i].getUid().equals(topItem.getUid())) + { + isHave = true; + break; + } + } + if(!isHave) + { + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + } + } + + } + ArrayList itemList = new ArrayList(); + Map itemNumMap = new HashMap(); + Map itemTeamMap = new HashMap(); + for (int i = 0; i < tableNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i); + NodeBean childNodeBean = (NodeBean) childNode.getUserObject(); + + adaptiveVariants(lineCode, erpCode, childNode, itemType); + + TCComponentItem item = itemType.find(childNodeBean.getMbomId()); + if (item == null) { + topItem = childNodeBean.getItem().getLatestItemRevision().saveAsItem(childNodeBean.getMbomId(), "A"); + TCComponent[] relatedComps = childNodeBean.getItem().getLatestItemRevision().getRelatedComponents("TC_Primary_Design_Representation"); + for (int j = 0; j < relatedComps.length; j++) { + topItem.getLatestItemRevision().add("TC_Primary_Design_Representation", relatedComps[i]); + } + // 获取EBOM ID + String mbomId = childNodeBean.getMbomId(); + String lineCodeString = ""; + String factoryString=""; + if (mbomId.indexOf("-") > 0) { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode(lineCodeString,factoryString); + if (result.indexOf("=") > 0) { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + // 将另存的对象放在EBOM的ML8_RelatedMBOM关系下 + childNodeBean.getItem().getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + topItem.refresh(); + topItem.getLatestItemRevision().refresh(); + System.out.println("对象:"+topItem.getLatestItemRevision().getStringProperty("object_string")); + System.out.println("设置属性:ml8_LineCode:"+lineCode); + System.out.println("设置属性:ml8_ERPCode:"+erpCode); + System.out.println("设置属性:ml8_Line:"+lineCodeString); + System.out.println("设置属性:ml8_Factory:"+this.factory); + // 设置属性 + topItem.getLatestItemRevision().setStringProperty("ml8_LineCode", lineCode); + topItem.getLatestItemRevision().setStringProperty("ml8_ERPCode", erpCode); + topItem.getLatestItemRevision().setStringProperty("ml8_Line", lineCodeString); + topItem.getLatestItemRevision().setStringProperty("ml8_Factory", this.factory); + } + else + { + TCComponentItemRevision itemRevision = childBean.getItem().getLatestItemRevision(); + // 获取EBOM ID + String ebomId = itemRevision.getStringProperty("item_id"); + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + TCComponentItem ebom = itemType.find(ebomId); + + TCComponent[] relatedMBOMs = ebom.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); + boolean isHave = false; + for (int j = 0; j < relatedMBOMs.length; j++) { + if(relatedMBOMs[j].getUid().equals(topItem.getUid())) + { + isHave = true; + break; + } + } + if(!isHave) + { + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + } + } + itemList.add(topItem.getLatestItemRevision()); + itemNumMap.put(childBean.getMbomId(), childBean.getNum()); + itemTeamMap.put(childBean.getMbomId(), childBean.getProjectTeam()); + } + if(topItem != null && lineCode.isEmpty() && erpCode.isEmpty()) + { + topItemRevision = topItem.getLatestItemRevision(); + } + if (topItem != null && itemList.size() > 0) { + topItemRevision = topItem.getLatestItemRevision(); + resultTopline = null; + this.recreateBom(topItem.getLatestItemRevision(), itemList, true); + if (resultTopline != null) { + resultTopline.lock(); + // 设置BOM行属性 + for (int j = 0; j < resultTopline.getChildren().length; j++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent(); + if (itemTeamMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { + + String team = itemTeamMap.get(bomLine.getStringProperty("bl_item_item_id")); + if (team != null) { + bomLine.setStringProperty("ML8_ProjectTeam", team); + } + } + if (itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { + String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id")); + if (quantity == null || quantity.isEmpty() || quantity.equals("0")) { + String uom = ""; + try { + uom = bomLine.getPropertyDisplayableValue("bl_uom"); + } catch (NotLoadedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("单位:++++++++++++++++" + uom); + if (uom.equals("每个")) { + continue; + } + quantity = "1.00"; + } + System.out.println("数量:++++++++++++++++" + quantity); + if (quantity.indexOf(".") > 0) { + Double bomNum = Double.parseDouble(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } else { + Integer bomNum = Integer.parseInt(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + // bomLine.setStringProperty("bl_quantity", + // itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"))); + } + } + resultTopline.save(); + resultTopline.unlock(); + resultTopline.refresh(); + if (resultTopline.getBOMView() != null) { + resultTopline.getBOMView().save(); + resultTopline.getBOMView().refresh(); + } + } + } + } + + private String getLineCode(String lineId, String factoryString) throws TCException { + String result = ""; +// +// String keyString=factoryString+"line"+lineId; +// +// if(lineEroCodeMap.containsKey(keyString)) { +// result=lineEroCodeMap.get(keyString); +// } + TCClassificationService classificationService = session.getClassificationService(); + ICSSearchResult[] results = classificationService.searchICOs("组计数器字典", null, 0); + String line = ""; + String classFactory = ""; + String lineCode = ""; + String erpCode = ""; + for (int i = 0; i < results.length; i++) { + String icoUID = results[i].getIcoUid(); + TCComponentICO ico = (TCComponentICO) session.stringToComponent(icoUID); + ico.getClassifiedObject(); + ICSProperty[] icsProps = ico.getICSProperties(true); + + ICSPropertyDescription[] icsDs = ico.getICSPropertyDescriptors(); + + for (ICSPropertyDescription icsD : icsDs) { +// if (icsD.getName().compareTo("产线") == 0) { +// continue; +// } + String value = ""; + for (ICSProperty icsProperty : icsProps) { + if (icsProperty.getId() == icsD.getId()) { + value = icsProperty.getValue(); + } + } + if (icsD.getName().compareTo("产线") == 0) { + line = value; + } + if (icsD.getName().compareTo("工厂") == 0) { + classFactory = value; + } + if (icsD.getName().compareTo("产线代码") == 0) { + lineCode = value; + } + if (icsD.getName().compareTo("ERP班组编码") == 0) { + erpCode = value; + } + } + if(line.equals(lineId) && classFactory.equals(factoryString)) + { + break; + } + } + result = lineCode + "=" + erpCode; +// System.out.println(); + return result; + } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev, ArrayList itemRevisionlists, + boolean isDelete) throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null); + resultTopline = topline; + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e) { + // TODO: handle exception + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e2) { + // TODO: handle exception + } + e.printStackTrace(); + } + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if (n_itemRevision != null) { + boolean isHave = false; + if (!isDelete) { + for (AIFComponentContext children : topline.getChildren()) { + if (n_itemRevision.getStringProperty("item_id") + .compareTo(children.getComponent().getProperty("bl_child_id")) == 0) { + isHave = true; + } + } + } + if (!isHave) { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if (topline.getBOMView() != null) { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } + + /** + * 扩展获取BOM属性 + * + * @throws TCException + */ + public DefaultMutableTreeTableNode getBomExtendPropertyToNode(TCSession session, TCComponentBOMLine topBomLine, + boolean isPart) throws TCException { + // TODO Auto-generated method stub + + NodeBean nodeBean = new NodeBean(); + + // String ss = subline.getStringProperty("bl_indented_title"); + // 对象ID + nodeBean.setEbom("顶层"); + nodeBean.setRefreshStatus(""); + nodeBean.setProjectTeam(""); + nodeBean.setNum(""); + nodeBean.setMbomId(""); + nodeBean.setMbomName(""); + nodeBean.setIsHave(""); + DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); + // 获取BOM + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + getBomExtendPropertysToNode(itemType, topBomLine, rootNode, "", isPart); + return rootNode; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + + /** + * 获取BOM扩展信息 + * + * @param bomLine + * @param bomPropertyList + * @param parentID + * @throws Exception + */ + public void getBomExtendPropertysToNode(TCComponentItemType itemType, TCComponentBOMLine bomLine, + DefaultMutableTreeTableNode rootNode, String parentID, boolean isPart) throws Exception { + try { + TCComponentItemRevision itemRevision = bomLine.getItem().getLatestItemRevision(); + // 获取发布状态 + TCProperty refreshStatusProperty = itemRevision.getTCProperty("release_status_list"); + TCComponent[] refreshStatus = refreshStatusProperty.getReferenceValueArray(); + TCProperty processProperty = itemRevision.getTCProperty("process_stage_list"); + TCComponent[] processStage = processProperty.getReferenceValueArray(); + + NodeBean nodeBean = new NodeBean(); + + // 设置发布状态 + if (refreshStatus.length > 0) { + StringBuffer stringBuffer = new StringBuffer(""); + // 添加发布状态 + for (int i = 0; i < refreshStatus.length; i++) { + stringBuffer.append(refreshStatus[i] == null ? "" : refreshStatus[i].toString()); + if (i < refreshStatus.length - 1) { + stringBuffer.append(","); + } + } +// System.out.println("对象:"+itemRevision.getStringProperty("item_id")+"发布状态:" + stringBuffer); +// if (stringBuffer.toString().indexOf("发布") < 0 && !parentID.isEmpty()) { +// throw new Exception("当前EBOM子节点未发布,无法生成MBOM!"); +// // MessageBox.post("当前EBOM子节点未发布,无法生成MBOM!", "错误", MessageBox.ERROR); +// // return; +// } + nodeBean.setRefreshStatus(stringBuffer.toString()); + }else { + nodeBean.setRefreshStatus(""); + } +// else if (processStage.length > 0 && !parentID.isEmpty()) { +// throw new Exception("当前EBOM子节点未发布,无法生成MBOM!"); +// // nodeBean.setRefreshStatus("流程中"); +// } else if (!parentID.isEmpty()) { +// throw new Exception("当前EBOM子节点未发布,无法生成MBOM!"); +// // nodeBean.setRefreshStatus(""); +// } + + nodeBean.setEbom(bomLine.getStringProperty("bl_item_object_string")); + nodeBean.setProjectTeam(bomLine.getStringProperty("ML8_ProjectTeam")); + nodeBean.setNum(bomLine.getStringProperty("bl_quantity")); + String newItemId = bomLine.getStringProperty("bl_item_item_id"); + + String itemId = bomLine.getStringProperty("bl_item_item_id"); + if (!bomLine.getItem().getStringProperty("object_type").equals("ML8_RawMaterial")) { + if (itemId.indexOf("-") > 0) { + itemId = itemId.split("-")[0]; + newItemId = itemId + "-" + factory + "-" + lineId; + } + else + { + newItemId = itemId; + } + //newItemId = itemId + "-" + lineId; + } + //itemId.indexOf("-") > 0 && + + + if (bomLine.getChildrenCount() <= 0 && !parentID.isEmpty()) { + newItemId = itemId; + } + if (!parentID.isEmpty()) { + //判断是否包含首选项中的那些工厂和产线 + System.out.println("bomLine"+bomLine.getStringProperty("bl_item_item_id")); + String factoryLine = getFactoryLine(itemType,itemId,bomLine.getStringProperty("bl_item_item_id"),bomLine.getStringProperty("bl_ML8_PartRevision_ML8_RelatedMBOM")); + if(!factoryLine.isEmpty()) + { + newItemId = factoryLine; + } + } + nodeBean.setMbomId(newItemId); + nodeBean.setMbomName(bomLine.getStringProperty("bl_item_object_name")); + nodeBean.setItem(itemRevision.getItem()); + TCComponentItem item = itemType.find(newItemId); + if (item != null) { + if (parentID.isEmpty()) { + // MessageBox.post("请选择其他产线生成MBOM!", "错误", MessageBox.ERROR); + // return; + } + nodeBean.setIsHave("存在"); + } else { + nodeBean.setIsHave("不存在"); + + if(this.bomLine.getStringProperty("bl_item_item_id").indexOf("-") > 0 && bomLine.getStringProperty("bl_item_item_id").indexOf("-") < 0) + { + nodeBean.setMbomId(bomLine.getStringProperty("bl_item_item_id")); + nodeBean.setIsHave("存在"); + } + + if(this.bomLine.getStringProperty("bl_item_item_id").indexOf("-") < 0 && !parentID.isEmpty()) + { + nodeBean.setMbomId(bomLine.getStringProperty("bl_item_item_id")); + nodeBean.setIsHave("存在"); + } + } + + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean); + rootNode.add(node); + + if(!nodeBean.getIsHave().equals("存在")) + { + if (bomLine.getChildren().length > 0 && !bomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) { + AIFComponentContext aif[] = bomLine.getChildren(); + for (int i = 0; i < aif.length; i++) { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i].getComponent(); + getBomExtendPropertysToNode(itemType, subline, node, bomLine.getStringProperty("bl_item_item_id"), + isPart); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + } + + private String getFactoryLine(TCComponentItemType itemType,String itemId,String bomLineItem,String mBOM) throws TCException + { + String result = ""; + TCComponentItem item = itemType.find(bomLineItem); + + String[] facLine = mBOM.split(","); + //加工方式 + String processingMode = item.getLatestItemRevision().getStringProperty("ml8_ProcessingMode"); + //是否加贸 + String addTrade = item.getLatestItemRevision().getStringProperty("ml8_AddTrade"); +// if(processingMode.equals("自制")) +// { +// result = newItemIdMap.get("I"); +// } +// else + System.out.println(mBOM); +// if(addTrade.equals("是") && processingMode.equals("外协外购")) +// { +// for(String string:facLine) { +// if(string.contains("-Z")) { +// System.out.println("-z"); +// result=string; +// } +// } +//// result = newItemIdMap.get("Z"); +// }else { +// +// for(String string:facLine) { +// if(string.contains(factory)) { +// result=string; +// } +// } +// } + + +// result.trim(); +// String sameResult = ""; +// Map newItemIdMap = new HashMap(); + List newItemIdList=new ArrayList(); +// + boolean isMbom=false; + for (String factoryLine : factoryLineList) { + String newItemId = itemId + "-" + factoryLine; +// System.out.println("newItemId:" + newItemId); + TCComponentItem item22 = itemType.find(newItemId); + + if(bomLineItem.contains(factoryLine)) { + isMbom=true; + } + for(String string:facLine) { + if(item22 != null && string.contains(newItemId)) { + newItemIdList.add(string); + } + } + +// for(int i=0;i<) +// if (item22 != null && newItemId.equals()) { +// +// //break; +// } + } + + if(newItemIdList.size()==1) { + result=newItemIdList.get(0); + }else if(newItemIdList.size()>1){ + if(addTrade.equals("是") && processingMode.equals("外协外购")) + { + for(String string:newItemIdList) { + if(string.contains("-Z")) { + System.out.println("-z"); + result=string; + } + } +// result = newItemIdMap.get("Z"); + }else { + + for(String string:newItemIdList) { + if(string.contains(factory)) { + result=string; + } + } + } + } + + if(newItemIdList.size()==0) { + if(bomLineItem.contains("-")) { + result=itemId+"-"+factory+"-"+lineId+"-111"; + } +// for(String string:facLine) { +// if(string.contains(factory+"-"+lineId)) { +// result=string; +// } +// } + } + int lastIndexOf = result.lastIndexOf("-"); + if(lastIndexOf>0) { + String substring = result.substring(0, lastIndexOf); + +// System.out.println(substring); + result=substring; + } + + if(isMbom) { + System.out.println("取自己"); + result=bomLineItem; + } + + result=result.trim(); +// +// if(newItemIdMap.keySet().size() == 2) +// { +// TCComponentItem item = itemType.find(bomLineItem); +// +// //加工方式 +// String processingMode = item.getLatestItemRevision().getStringProperty("ml8_ProcessingMode"); +// //是否加贸 +// String addTrade = item.getLatestItemRevision().getStringProperty("ml8_AddTrade"); +//// if(processingMode.equals("自制")) +//// { +//// result = newItemIdMap.get("I"); +//// } +//// else +// if(addTrade.equals("是") && processingMode.equals("外协外购")) +// { +// result = newItemIdMap.get("Z"); +// }else { +// result=itemId + "-" + factory + "-" + lineId; +// } +// +// } +// +// if(result.isEmpty()) +// { +// result = itemId + "-" + factory + "-" + lineId; +// TCComponentItem item = itemType.find(result); +// if (item == null) { +// result = ""; +// } +// } + return result; + } + + /** + * 获取BOM属性 + * + * @throws Exception + */ + public DefaultMutableTreeTableNode getBomPropertyToNode(TCSession session, TCComponentBOMLine topBomLine, + boolean isPart) throws Exception { + // TODO Auto-generated method stub + + NodeBean nodeBean = new NodeBean(); + + // String ss = subline.getStringProperty("bl_indented_title"); + // 对象ID + nodeBean.setEbom("顶层"); + nodeBean.setRefreshStatus(""); + nodeBean.setProjectTeam(""); + nodeBean.setNum(""); + nodeBean.setMbomId(""); + nodeBean.setMbomName(""); + nodeBean.setIsHave(""); + DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); + // 获取BOM + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + getBomPropertysToNode(itemType, topBomLine, rootNode, "", isPart); + return rootNode; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + // return null; + } + + /** + * 获取BOM信息 + * + * @param bomLine + * @param bomPropertyList + * @param parentID + * @throws Exception + */ + public void getBomPropertysToNode(TCComponentItemType itemType, TCComponentBOMLine bomLine, + DefaultMutableTreeTableNode rootNode, String parentID, boolean isPart) throws Exception { + try { + + TCComponentItemRevision itemRevision = bomLine.getItem().getLatestItemRevision(); + // 获取发布状态 + TCProperty refreshStatusProperty = itemRevision.getTCProperty("release_status_list"); + TCComponent[] refreshStatus = refreshStatusProperty.getReferenceValueArray(); + TCProperty processProperty = itemRevision.getTCProperty("process_stage_list"); + TCComponent[] processStage = processProperty.getReferenceValueArray(); + + NodeBean nodeBean = new NodeBean(); + + // 设置发布状态 + if (refreshStatus.length > 0) { + StringBuffer stringBuffer = new StringBuffer(""); + // 添加发布状态 + for (int i = 0; i < refreshStatus.length; i++) { + stringBuffer.append(refreshStatus[i] == null ? "" : refreshStatus[i].toString()); + if (i < refreshStatus.length - 1) { + stringBuffer.append(","); + } + } + System.out.println("对象:"+itemRevision.getStringProperty("item_id")+"发布状态:" + stringBuffer); +// if (stringBuffer.toString().indexOf("发布") < 0 && !parentID.isEmpty()) { +// throw new Exception("当前EBOM子节点未发布,无法生成MBOM!"); +// // MessageBox.post("当前EBOM子节点未发布,无法生成MBOM!", "错误", MessageBox.ERROR); +// // return; +// } + nodeBean.setRefreshStatus(stringBuffer.toString()); + } + else { + nodeBean.setRefreshStatus(""); + } +// else if (processStage.length > 0 && !parentID.isEmpty()) { +// throw new Exception("当前EBOM子节点未发布,无法生成MBOM!"); +// // nodeBean.setRefreshStatus("流程中"); +// } else if (!parentID.isEmpty()) { +// throw new Exception("当前EBOM子节点未发布,无法生成MBOM!"); +// // nodeBean.setRefreshStatus(""); +// } + + nodeBean.setEbom(bomLine.getStringProperty("bl_item_object_string")); + nodeBean.setProjectTeam(bomLine.getStringProperty("ML8_ProjectTeam")); + nodeBean.setNum(bomLine.getStringProperty("bl_quantity")); + String itemId = bomLine.getStringProperty("bl_item_item_id"); + if (itemId.indexOf("-") > 0) { + itemId = itemId.split("-")[0]; + } + String newItemId = itemId + "-" + factory + "-" + lineId; + //String newItemId = itemId + "-" + lineId; + if ((!parentID.isEmpty() && isPart && bomLine.getChildrenCount() <= 0) + || bomLine.getItem().getStringProperty("object_type").equals("ML8_RawMaterial")) { + newItemId = itemId; + } + //itemId.indexOf("-") > 0 && + + + if (bomLine.getChildrenCount() <= 0 && !parentID.isEmpty()) { + newItemId = itemId; + } + System.out.println("!parentID.isEmpty()"+!parentID.isEmpty()); + if (!parentID.isEmpty()) { + //判断是否包含首选项中的那些工厂和产线 +// System.out.println("bomLine"+bomLine.getStringProperty("bl_item_item_id")); + String factoryLine = getFactoryLine(itemType,itemId,bomLine.getStringProperty("bl_item_item_id"),bomLine.getStringProperty("bl_ML8_PartRevision_ML8_RelatedMBOM")); + if(!factoryLine.isEmpty()) + { + newItemId = factoryLine; + } + } + nodeBean.setMbomId(newItemId); + nodeBean.setMbomName(bomLine.getStringProperty("bl_item_object_name")); + nodeBean.setItem(itemRevision.getItem()); + TCComponentItem item = itemType.find(newItemId); + if (item != null) { + if (parentID.isEmpty()) { + // throw new Exception("请选择其他产线生成MBOM!"); +// MessageBox.post("请选择其他产线生成MBOM!", "错误", MessageBox.ERROR); +// return; + } + nodeBean.setIsHave("存在"); + } else { + nodeBean.setIsHave("不存在"); + if(!parentID.isEmpty() && !isPart) + { + nodeBean.setMbomId(itemId); + nodeBean.setIsHave("存在"); + } + if(this.bomLine.getStringProperty("bl_item_item_id").indexOf("-") > 0 && bomLine.getStringProperty("bl_item_item_id").indexOf("-") < 0) + { + nodeBean.setMbomId(itemId); + nodeBean.setIsHave("存在"); + } + + if(this.bomLine.getStringProperty("bl_item_item_id").indexOf("-") < 0 && !parentID.isEmpty()) + { + nodeBean.setMbomId(itemId); + nodeBean.setIsHave("存在"); + } + } + + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean); + rootNode.add(node); + if(!nodeBean.getIsHave().equals("存在")) + { + if (bomLine.getChildren().length > 0 && !bomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) { + AIFComponentContext aif[] = bomLine.getChildren(); + for (int i = 0; i < aif.length; i++) { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i].getComponent(); + + getBomPropertysToNode(itemType, subline, node, bomLine.getStringProperty("bl_item_item_id"), + isPart); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomDialog.java new file mode 100644 index 0000000..ca74b01 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomDialog.java @@ -0,0 +1,553 @@ +package com.connor.ml.tcm.ML_01; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.TreePath; + +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; +import com.connor.ml.tcm.util.Adapter; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class EbomTransitionToMbomDialog extends AbstractAIFDialog implements ActionListener, MouseListener { + + private TCSession session; + private InterfaceAIFComponent comp; + + private String lineId; + private String factory; + private List isNotEditableRow = new ArrayList(); + private DefaultMutableTreeTableNode node; + private SelectLineDialog selectLineDialog; + + private String[] header = new String[] { "EBOM对象", "发布状态", "替代项目组", "数量", "MBOM对象ID","MBOM对象名称","是否存在" }; + + private JPanel titlePanel; + private JLabel titleLabel; + private JTreeTable table; + private JTreeTableModel map; + + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + private JButton refreshButton; + + private Map lineEroCodeMap=new HashMap(); + + public EbomTransitionToMbomDialog(String lineId,String factory,InterfaceAIFComponent comp, + TCSession session, DefaultMutableTreeTableNode node,SelectLineDialog selectLineDialog,Map lineEroCodeMap) { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.node = node; + this.lineId = lineId; + this.factory = factory; + this.selectLineDialog = selectLineDialog; + + this.lineEroCodeMap=lineEroCodeMap; + + init(); + } + + public EbomTransitionToMbomDialog(TCSession session2, Object factory2, SelectLineDialog selectLineDialog2, + DefaultMutableTreeTableNode node2, String bomItemLine, TCComponentItemRevision itemRevision, boolean flag) { + // TODO Auto-generated constructor stub + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("EBOM转MBOM"); + this.setPreferredSize(new Dimension(800, 600)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("EBOM转MBOM"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + JPanel panel = new JPanel(); + panel.add(this.titlePanel, BorderLayout.NORTH); + + this.table = getJTreeTable(null, null, header, null); + this.table.addMouseListener(this); + + Adapter adapter = new Adapter(table); + + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("确认"); + this.celButton = new JButton("取消"); + this.refreshButton = new JButton("刷新"); + + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + this.rootPanel.add(refreshButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(panel, BorderLayout.NORTH); + this.add(new JScrollPane(this.table), BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + + // 添加监听 + public void createActionEvent() { + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.refreshButton.addActionListener(this); + // this.celValueButton.addActionListener(this); + } + + // Jtable通用方法 + public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames, + Object[][] values) { + int simpleLen = 100; + int totleLen = 1500; + if (partsTable == null) { + this.map = new JTreeTableModel(this.node); + this.map.setIsNotEditableRow(this.isNotEditableRow); + // map.setColumnIdentifiers(titleNames); + + partsTable = new JTreeTable(map); + partsTable.setIsNotEditableRow(this.isNotEditableRow); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(30); + partsTable.expandAll(); // 展开全部节点 + // 隐藏列 +// partsTable.HiddenCell(0); + + partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // 设置第一列宽度 + partsTable.getColumnModel().getColumn(1).setPreferredWidth(100); // 设置第二列宽度 + partsTable.getColumnModel().getColumn(2).setPreferredWidth(80); // 设置第三列宽度 + + partsTable.setHighlighters(HighlighterFactory.createSimpleStriping()); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + EbomTransitionToMbomOperation operation=new EbomTransitionToMbomOperation(session,this,this.selectLineDialog,node,factory,lineEroCodeMap); + session.queueOperation(operation); +// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); +// this.adaptiveVariants("","",(DefaultMutableTreeTableNode) (this.node.getChildAt(0)), itemType); +// this.dispose(); +// this.selectLineDialog.dispose(); +// checkFactoryAndLine(resultTopline); +// MessageBox.post("转换成功!"+sbString, "成功", MessageBox.INFORMATION); + } else if (source.equals(this.refreshButton)) { + this.dispose(); + try { + EbomTransitionToMbomCommand command = new EbomTransitionToMbomCommand(lineId,factory,comp, session,this.selectLineDialog,lineEroCodeMap); + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } else { + this.dispose(); + } + } + + TCComponentBOMLine resultTopline = null; + private String sbString=""; + /** + * 检验生成的mbom的子列的工厂与产线结构 + * @param topLine + * @return + * @throws TCException + */ + private String checkFactoryAndLine(TCComponentBOMLine topLine) throws TCException { + if(resultTopline==null) { + System.out.println("未找到mbom首行"); + return ""; + } + TCComponentItemRevision topRev = resultTopline.getItemRevision(); + String ml8_Factory = topRev.getStringProperty("ml8_Factory"); + String ml8_Line = topRev.getStringProperty("ml8_Line"); + System.out.println("首行工厂属性:"+ml8_Factory+",产线属性:"+ml8_Line); +// StringBuffer sb = new StringBuffer(""); + for(int i =0;i0) { + checkFactoryAndLine(childLine); + } + + } + + return ""; + } + +// /** +// * 重新搭建BOM +// * +// * @param topItem +// * @throws TCException +// */ +// private void adaptiveVariants(String lineCode,String erpCode,DefaultMutableTreeTableNode tableNode, TCComponentItemType itemType) +// throws TCException { +// NodeBean childBean = (NodeBean) tableNode.getUserObject(); +// TCComponentItem topItem = itemType.find(childBean.getMbomId()); +// if(topItem == null) +// { +// TCComponentItemRevision itemRevision = childBean.getItem().getLatestItemRevision(); +// //另存对象 +// topItem = itemRevision.saveAsItem(childBean.getMbomId(), "A"); +// //获取EBOM ID +// String ebomId = itemRevision.getStringProperty("item_id"); +// String mbomId = childBean.getMbomId(); +// String lineCodeString = ""; String factoryString = ""; +// if(ebomId.indexOf("-") > 0) +// { +// ebomId = ebomId.split("-")[0]; +// } +// if(mbomId.indexOf("-") > 0) +// { +// lineCodeString = mbomId.split("-")[2];factoryString = mbomId.split("-")[1]; +// } +// String result = getLineCode(lineCodeString,factoryString); +// if(result.indexOf("=") > 0) +// { +// lineCode = result.split("=")[0]; +// erpCode = result.split("=")[1]; +// } +// TCComponentItem ebom = itemType.find(ebomId); +// //将另存的对象放在EBOM的ML8_RelatedMBOM关系下 +// ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); +// //设置属性 +// topItem.getLatestItemRevision().setStringProperty("ml8_LineCode", lineCode); +// topItem.getLatestItemRevision().setStringProperty("ml8_ERPCode", erpCode); +// topItem.getLatestItemRevision().setStringProperty("ml8_Line", lineCodeString); +// topItem.getLatestItemRevision().setStringProperty("ml8_Factory", this.factory); +// } +// ArrayList itemList = new ArrayList(); +// Map itemNumMap = new HashMap(); +// Map itemTeamMap = new HashMap(); +// for (int i = 0; i < tableNode.getChildCount(); i++) { +// DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i); +// NodeBean childNodeBean = (NodeBean) childNode.getUserObject(); +// +// adaptiveVariants(lineCode,erpCode,childNode, itemType); +// +// TCComponentItem item = itemType.find(childNodeBean.getMbomId()); +// if(item == null) +// { +// topItem = childNodeBean.getItem().getLatestItemRevision().saveAsItem(childNodeBean.getMbomId(), "A"); +// //获取EBOM ID +// String mbomId = childNodeBean.getMbomId(); +// String lineCodeString = ""; String factoryString = ""; +// if(mbomId.indexOf("-") > 0) +// { +// lineCodeString = mbomId.split("-")[2]; +// factoryString = mbomId.split("-")[1]; +// } +// String result = getLineCode(lineCodeString,factoryString); +// if(result.indexOf("=") > 0) +// { +// lineCode = result.split("=")[0]; +// erpCode = result.split("=")[1]; +// } +// //将另存的对象放在EBOM的ML8_RelatedMBOM关系下 +// childNodeBean.getItem().getLatestItemRevision().add("ML8_RelatedMBOM", topItem); +// //设置属性 +// topItem.getLatestItemRevision().setStringProperty("ml8_LineCode", lineCode); +// topItem.getLatestItemRevision().setStringProperty("ml8_ERPCode", erpCode); +// topItem.getLatestItemRevision().setStringProperty("ml8_Line", lineCodeString); +// topItem.getLatestItemRevision().setStringProperty("ml8_Factory", this.factory); +// } +// itemList.add(item.getLatestItemRevision()); +// itemNumMap.put(childNodeBean.getMbomId(), childNodeBean.getNum()); +// itemTeamMap.put(childNodeBean.getMbomId(), childNodeBean.getProjectTeam()); +// } +// if (topItem != null && itemList.size() > 0) { +// resultTopline = null; +// this.recreateBom(topItem.getLatestItemRevision(), itemList, true); +// if (resultTopline != null) { +// resultTopline.lock(); +// // 设置BOM行属性 +// for (int j = 0; j < resultTopline.getChildren().length; j++) { +// TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent(); +// if (itemTeamMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { +// +// String team = itemTeamMap.get(bomLine.getStringProperty("bl_item_item_id")); +// if(team != null) +// { +// bomLine.setStringProperty("ML8_ProjectTeam", team); +// } +// } +// if (itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { +// String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id")); +// if (quantity == null || quantity.isEmpty() || quantity.equals("0")) { +// String uom = ""; +// try { +// uom = bomLine.getPropertyDisplayableValue("bl_uom"); +// } catch (NotLoadedException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// System.out.println("单位:++++++++++++++++" + uom); +// if (uom.equals("每个")) { +// continue; +// } +// quantity = "1.00"; +// } +// System.out.println("数量:++++++++++++++++" + quantity); +// if (quantity.indexOf(".") > 0) { +// Double bomNum = Double.parseDouble(quantity); +// bomLine.setStringProperty("bl_quantity", bomNum.toString()); +// } else { +// Integer bomNum = Integer.parseInt(quantity); +// bomLine.setStringProperty("bl_quantity", bomNum.toString()); +// } +// // bomLine.setStringProperty("bl_quantity", +// // itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"))); +// } +// } +// resultTopline.save(); +// resultTopline.unlock(); +// resultTopline.refresh(); +// if (resultTopline.getBOMView() != null) { +// resultTopline.getBOMView().save(); +// resultTopline.getBOMView().refresh(); +// } +// //发送到结构管理器 +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.pse.PSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.pse.PSEPerspective", +// new InterfaceAIFComponent[] { resultTopline.getItem() }); +// } +// } +// } +// +// private String getLineCode(String lineId, String factoryString) throws TCException +// { +// String result = ""; +// //通过产线获取分类库的产线代码和ERP班组编码 +// TCClassificationService classificationService = session +// .getClassificationService(); +// ICSSearchResult[] results = classificationService.searchICOs( +// "组计数器字典", null, 0); +// String line = "";String classFactory = ""; +// String lineCode = ""; +// String erpCode = ""; +// for (int i = 0; i < results.length ; i++) { +// String icoUID = results[i].getIcoUid(); +// TCComponentICO ico = (TCComponentICO) session +// .stringToComponent(icoUID); +// ico.getClassifiedObject(); +// ICSProperty[] icsProps = ico.getICSProperties(true); +// +// ICSPropertyDescription[] icsDs = ico +// .getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +//// if (icsD.getName().compareTo("产线") == 0) { +//// continue; +//// } +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// if (icsD.getName().compareTo("工厂") == 0) { +// classFactory = value; +// } +// if (icsD.getName().compareTo("产线") == 0) { +// line = value; +// } +// if (icsD.getName().compareTo("产线代码") == 0) { +// lineCode = value; +// } +// if (icsD.getName().compareTo("ERP班组编码") == 0) { +// erpCode = value; +// } +// } +// if(line.equals(lineId) && classFactory.equals(factoryString)) +// { +// break; +// } +// } +// result = lineCode + "=" + erpCode; +// return result; +// } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev, ArrayList itemRevisionlists, + boolean isDelete) throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null); + resultTopline = topline; + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e) { + // TODO: handle exception + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e2) { + // TODO: handle exception + } + e.printStackTrace(); + } + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if (n_itemRevision != null) { + boolean isHave = false; + if (!isDelete) { + for (AIFComponentContext children : topline.getChildren()) { + if (n_itemRevision.getStringProperty("item_id") + .compareTo(children.getComponent().getProperty("bl_child_id")) == 0) { + isHave = true; + } + } + } + if (!isHave) { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if (topline.getBOMView() != null) { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + if (e.getClickCount() == 2) {// 获得选中列 + int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); + + TreePath treePath = table.getPathForLocation(e.getX(), e.getY()); + if (treePath != null) { + DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent(); + NodeBean nodeBean = (NodeBean) node.getUserObject(); + ChangeItemIdDialog changeItemIdDialog = new ChangeItemIdDialog(nodeBean); + + } + } + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomHandler.java new file mode 100644 index 0000000..9c7ec4d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomHandler.java @@ -0,0 +1,240 @@ +package com.connor.ml.tcm.ML_01; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.swing.tree.TreePath; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.pse.common.BOMLineNode; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.psebase.common.AbstractViewableTreeTable; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + + +public class EbomTransitionToMbomHandler extends AbstractHandler { + private Map lineEroCodeMap=new HashMap(); + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + MethodUtil.openByPass(session); + InterfaceAIFComponent[] comps = app.getTargetComponents(); + +// SelectLineDialog dialog = new SelectLineDialog( +// app.getTargetComponent(), session); + + List bomLineList = new ArrayList(); + + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + for (int i = 0; i < comps.length; i++) { + InterfaceAIFComponent comp = comps[i]; + + TCComponentBOMLine bomLine = null; + + if(comp instanceof TCComponentBOMLine) + { + bomLine = (TCComponentBOMLine) comp; + } + else if(comp instanceof TCComponentItem) + { + TCComponentItem item = (TCComponentItem) comp; + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, itemRevision, null, null); + + bomLine = topline; + } + else if(comp instanceof TCComponentItemRevision) + { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + + TCComponentBOMLine topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + bomLine = topline; + + } + if(bomLine == null) + { + continue; + } + + if(bomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) + { + MessageBox.post("选中对象的替代项目组为A0!", "错误", MessageBox.ERROR); + continue; + } + + //判断对象类型 + TCComponentItem item = bomLine.getItem(); + TCComponentItemRevision _rev = bomLine.getItemRevision(); + TCComponent[] status = _rev.getRelatedComponents("release_status_list"); + boolean statu_flag = true; + for (int j = 0; j < status.length; j++) { + String statu_name = status[j].getStringProperty("object_name"); + if("ML8_JGFB".equals(statu_name)) { + statu_flag = false; + break; + } + } + if(statu_flag) { + MessageBox.post("当前对象未结构发布,无法生成MBOM!", "错误", MessageBox.ERROR); + return null; + } + System.out.println(item.getType()); + + if(!item.getType().equals("ML8_Refrigerator") && !item.getType().equals("ML8_Part") && !item.getType().equals("ML8_Cold")) + { + MessageBox.post("请选中冰箱柜、商冷或零部件对象!", "错误", MessageBox.ERROR); + continue; + } + + bomLineList.add(bomLine); + + } + + + +// AbstractBOMLineViewerApplication bomapp = (AbstractBOMLineViewerApplication) AIFUtility +// .getCurrentApplication(); +// AbstractViewableTreeTable m_tree = null; +// // 获取BOM树 +// if (m_tree == null) { +// m_tree = bomapp.getAbstractViewableTreeTable(); +// } else { +// m_tree = bomapp.getAbstractViewableTreeTable(); +// +// } +// m_tree.clearSelection(); +// //4为起始行,10为截止行 +// m_tree.setRowSelectionInterval(4, 10); + //m_tree.setSelectionPaths(new TreePath[] {}); + System.out.println("bypass=="+session.hasBypass()); +// new Thread() { +// @Override +// public void run() { + try { + for (int ii = 0; ii < bomLineList.size(); ii++) { + TCComponentBOMLine bomLine = bomLineList.get(ii); + TCComponentItem item = bomLine.getItem(); + + String itemId = item.getStringProperty("item_id"); + System.out.println(itemId); + //String itemType = item.getLatestItemRevision().getStringProperty("object_type"); + //if (itemType.equals("ML8_RefrigeratorRevision")) + //{ + String processingMode = item.getLatestItemRevision().getStringProperty("ml8_ProcessingMode"); + String addTrade = item.getLatestItemRevision().getStringProperty("ml8_AddTrade"); + if(processingMode.equals("外协外购") && addTrade.equals("否")) + { + MessageBox.post("外协外购&非加贸的零件无法生成MBOM!", "错误 ", MessageBox.ERROR); +// return; + break; + } + //} + + //获取工厂 + String factory = item.getLatestItemRevision().getStringProperty("ml8_Factory"); + if(itemId.indexOf("-") > 0) + { + //获取产线 + String line = itemId.split("-")[2]; + String value = factory+"|"+line; + //获取要扩的产线 + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringValues("ML_MBOM_ExtendLine"); + boolean isHave = false; + + for (int i = 0; i < values.length; i++) { + if(values[i].indexOf("-") > 0) + { +// System.out.println("values[i]:"+values[i]); + String[] lineValues = values[i].split("-"); +// System.out.println("lineValues[0]:"+lineValues[0]); + if(value.compareTo(lineValues[0]) == 0) + { + String lineCode = lineValues[1]; + String[] lineCodes = new String[] {lineCode}; + if(lineCode.indexOf(",") > 0) + { + lineCodes = lineCode.split(","); + } + isHave = true; + for (int j = 0; j < lineCodes.length; j++) { + System.out.println("lineCodes[j]:" + lineCodes[j]); + boolean flag=false; + if(j == lineCodes.length-1) { + flag=true; + } + EbomTransitionToMbomCommand command = new EbomTransitionToMbomCommand(lineCodes[j],factory,item ,session,lineEroCodeMap,flag); + command.executeModal(); + } +// MessageBox.post("扩产线完成!", "完成", MessageBox.INFORMATION); + } + } + } + + if(!isHave) + { + SelectLineDialog dialog = new SelectLineDialog( + app.getTargetComponent(), session,lineEroCodeMap); + } + } + else + { + SelectLineDialog dialog = new SelectLineDialog( + app.getTargetComponent(), session,lineEroCodeMap); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } +// } +// }.start(); + //EbomTransitionToMbomCommand command = new EbomTransitionToMbomCommand(app.getTargetComponent(),session); + //command.executeModal(); +// MethodUtil.closeByPass(session); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + try { + MethodUtil.openByPass(session); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return null; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomOperation.java new file mode 100644 index 0000000..eb65fdf --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/EbomTransitionToMbomOperation.java @@ -0,0 +1,488 @@ +package com.connor.ml.tcm.ML_01; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class EbomTransitionToMbomOperation extends AbstractAIFOperation { + private TCSession session; + private EbomTransitionToMbomDialog ebomTransitionToMbomDialog; + private SelectLineDialog selectLineDialog; + private DefaultMutableTreeTableNode node; + private String factory; + + private Map lineEroCodeMap=new HashMap(); + public EbomTransitionToMbomOperation(TCSession session, EbomTransitionToMbomDialog ebomTransitionToMbomDialog, + SelectLineDialog selectLineDialog, DefaultMutableTreeTableNode node,String factory,Map lineEroCodeMap) { + // TODO Auto-generated constructor stub + this.session=session; + this.ebomTransitionToMbomDialog=ebomTransitionToMbomDialog; + this.selectLineDialog=selectLineDialog; + this.node=node; + this.factory=factory; + this.lineEroCodeMap=lineEroCodeMap; + + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + +// Map> eroCodeFactoryMap=new HashMap>(); + //根据产线获取分类中的ERP班组编码 + System.out.println("开始组计数器字典"); + TCClassificationService classificationService = session + .getClassificationService(); + ICSSearchResult[] results = classificationService.searchICOs( + "组计数器字典", null, 0); + for (int j = 0; j < results.length ; j++) { + String ERPCode = ""; + String line = ""; + + String groupNo = ""; + String lineName = ""; +// String classERPCode = ""; + String classFactory = ""; + String icoUID = results[j].getIcoUid(); + TCComponentICO ico = (TCComponentICO) session + .stringToComponent(icoUID); + ico.getClassifiedObject(); + ICSProperty[] icsProps = ico.getICSProperties(true); + + ICSPropertyDescription[] icsDs = ico + .getICSPropertyDescriptors(); + + for (ICSPropertyDescription icsD : icsDs) { + String value = ""; + for (ICSProperty icsProperty : icsProps) { + if (icsProperty.getId() == icsD.getId()) { + value = icsProperty.getValue(); + } + } + if (icsD.getName().compareTo("ERP班组编码") == 0) { + ERPCode = value; + } + if (icsD.getName().compareTo("产线") == 0) { + line = value; + } + if (icsD.getName().compareTo("产线代码") == 0) { + lineName = value; + } + if (icsD.getName().compareTo("工厂") == 0) { + classFactory = value; + } + } + String keyString=classFactory+"line"+line; + System.out.println(keyString + "result"+lineName + "=" + ERPCode); + if(!lineEroCodeMap.containsKey(keyString)) { + lineEroCodeMap.put(keyString, lineName + "=" + ERPCode); + } + } + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + System.out.println("开始adaptiveVariants"); + adaptiveVariants("","",(DefaultMutableTreeTableNode) (this.node.getChildAt(0)), itemType); + System.out.println("结束adaptiveVariants"); + + if(resultTopline==null) { + System.out.println("未找到mbom首行"); + return; + } + + TCComponentItemRevision topRev = resultTopline.getItemRevision(); + ml8_Factory = topRev.getStringProperty("ml8_Factory"); + ml8_Line = topRev.getStringProperty("ml8_Line"); + System.out.println("首行工厂属性:"+ml8_Factory+",产线属性:"+ml8_Line); + + String checkResult = checkFactoryAndLine(resultTopline); +// if(resultTopline != null) { +// +// } + MessageBox.post("转换成功!"+checkResult, "成功", MessageBox.INFORMATION); + this.ebomTransitionToMbomDialog.dispose(); + this.selectLineDialog.dispose(); + + + + } + + private String ml8_Factory; + + private String ml8_Line; + + private String checkFactoryAndLine(TCComponentBOMLine topLine) throws TCException { + + + StringBuffer sb = new StringBuffer(""); + for(int i =0;i0) { + sb.append(checkFactoryAndLine(childLine)); + } + + } + + return sb.toString(); + } + + private String getLineCode1(String lineId, String factoryString, Map lineEroCodeMap) throws TCException + { + String result = ""; + + + if(lineEroCodeMap.containsKey(factoryString+"line"+lineId)) { + result = lineEroCodeMap.get(factoryString+"line"+lineId); + } + System.out.println(factoryString+"line"+lineId+"result"+result); +// //通过产线获取分类库的产线代码和ERP班组编码 +// TCClassificationService classificationService = session +// .getClassificationService(); +// ICSSearchResult[] results = classificationService.searchICOs( +// "组计数器字典", null, 0); +// String line = "";String classFactory = ""; +// String lineCode = ""; +// String erpCode = ""; +// for (int i = 0; i < results.length ; i++) { +// String icoUID = results[i].getIcoUid(); +// TCComponentICO ico = (TCComponentICO) session +// .stringToComponent(icoUID); +// ico.getClassifiedObject(); +// ICSProperty[] icsProps = ico.getICSProperties(true); +// +// ICSPropertyDescription[] icsDs = ico +// .getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +//// if (icsD.getName().compareTo("产线") == 0) { +//// continue; +//// } +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// if (icsD.getName().compareTo("工厂") == 0) { +// classFactory = value; +// } +// if (icsD.getName().compareTo("产线") == 0) { +// line = value; +// } +// if (icsD.getName().compareTo("产线代码") == 0) { +// lineCode = value; +// } +// if (icsD.getName().compareTo("ERP班组编码") == 0) { +// erpCode = value; +// } +// } +// if(line.equals(lineId) && classFactory.equals(factoryString)) +// { +// break; +// } +// } +// result = lineCode + "=" + erpCode; + return result; + } + private void adaptiveVariants(String lineCode,String erpCode,DefaultMutableTreeTableNode tableNode, TCComponentItemType itemType) + throws TCException { +// TCComponentAuditReport + + NodeBean childBean = (NodeBean) tableNode.getUserObject(); + TCComponentItem topItem = itemType.find(childBean.getMbomId()); + if(topItem == null) + { + System.out.println("topItem = null"); + TCComponentItemRevision itemRevision = childBean.getItem().getLatestItemRevision(); + //另存对象 + topItem = itemRevision.saveAsItem(childBean.getMbomId(), "A"); + + TCComponentItemRevision topItemRevision2=null; +// topItem = itemRevision.saveAsItem(childBean.getMbomId(), "A"); + if (lineCode.isEmpty() && erpCode.isEmpty()) { + topItemRevision2 = topItem.getLatestItemRevision(); + } + TCComponent[] relatedComps = itemRevision.getRelatedComponents("TC_Primary_Design_Representation"); + if(topItemRevision2!=null) { + for (int i = 0; i < relatedComps.length; i++) { + topItemRevision2.add("TC_Primary_Design_Representation", relatedComps[i]); + } + } + +// TCComponent[] relatedComps = itemRevision.getRelatedComponents("TC_Primary_Design_Representation"); +// for (int i = 0; i < relatedComps.length; i++) { +// topItemRevision.add("TC_Primary_Design_Representation", relatedComps[i]); +// } + //获取EBOM ID + String ebomId = itemRevision.getStringProperty("item_id"); + String mbomId = childBean.getMbomId(); + String lineCodeString = ""; String factoryString = ""; + if(ebomId.indexOf("-") > 0) + { + ebomId = ebomId.split("-")[0]; + } + if(mbomId.indexOf("-") > 0) + { + lineCodeString = mbomId.split("-")[2];factoryString = mbomId.split("-")[1]; + } + String result = getLineCode1(lineCodeString,factoryString,lineEroCodeMap); +// System.out.println(result); + if(result.indexOf("=") > 0) + { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + TCComponentItem ebom = itemType.find(ebomId); + //将另存的对象放在EBOM的ML8_RelatedMBOM关系下 + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + //设置属性 + TCComponentItemRevision topLasteRev = topItem.getLatestItemRevision(); + topLasteRev.setStringProperty("ml8_LineCode", lineCode); + topLasteRev.setStringProperty("ml8_ERPCode", erpCode); + topLasteRev.setStringProperty("ml8_Line", lineCodeString); + topLasteRev.setStringProperty("ml8_Factory", this.factory); + + System.out.println("topItem = null setPro"); + } + System.out.println("将另存的对象放在EBOM的ML8_RelatedMBOM关系下"); + ArrayList itemList = new ArrayList(); + Map> itemNumMap = new HashMap>(); + Map itemTeamMap = new HashMap(); + for (int i = 0; i < tableNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i); + NodeBean childNodeBean = (NodeBean) childNode.getUserObject(); + + adaptiveVariants(lineCode,erpCode,childNode, itemType); + + TCComponentItem item = itemType.find(childNodeBean.getMbomId()); + if(item == null) + { + topItem = childNodeBean.getItem().getLatestItemRevision().saveAsItem(childNodeBean.getMbomId(), "A"); + //获取EBOM ID + String mbomId = childNodeBean.getMbomId(); + String lineCodeString = ""; String factoryString = ""; + if(mbomId.indexOf("-") > 0) + { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode1(lineCodeString,factoryString,lineEroCodeMap); + if(result.indexOf("=") > 0) + { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + //将另存的对象放在EBOM的ML8_RelatedMBOM关系下 + childNodeBean.getItem().getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + //设置属性 + TCComponentItemRevision itemRev=topItem.getLatestItemRevision(); + itemRev.setStringProperty("ml8_LineCode", lineCode); + itemRev.setStringProperty("ml8_ERPCode", erpCode); + itemRev.setStringProperty("ml8_Line", lineCodeString); + itemRev.setStringProperty("ml8_Factory", this.factory); + }else { + String mbomId = childNodeBean.getMbomId(); + String lineCodeString = ""; String factoryString = ""; + if(mbomId.indexOf("-") > 0) + { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode1(lineCodeString,factoryString,lineEroCodeMap); + if(result.indexOf("=") > 0) + { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + TCComponentItemRevision itemRev=topItem.getLatestItemRevision(); + itemRev.setStringProperty("ml8_LineCode", lineCode); + itemRev.setStringProperty("ml8_ERPCode", erpCode); + itemRev.setStringProperty("ml8_Line", lineCodeString); + itemRev.setStringProperty("ml8_Factory", this.factory); + } + itemList.add(item.getLatestItemRevision()); + + if(itemNumMap.containsKey(childNodeBean.getMbomId())) { + List listNum = itemNumMap.get(childNodeBean.getMbomId()); + listNum.add(childNodeBean.getNum()); + itemNumMap.put(childNodeBean.getMbomId(), listNum); + }else { + List listNum=new ArrayList(); + listNum.add(childNodeBean.getNum()); + itemNumMap.put(childNodeBean.getMbomId(), listNum); + } + itemTeamMap.put(childNodeBean.getMbomId(), childNodeBean.getProjectTeam()); + } + System.out.println(""); + if (topItem != null && itemList.size() > 0) { + resultTopline = null; + System.out.println("开始recreateBom"); + this.recreateBom(topItem.getLatestItemRevision(), itemList, true); + System.out.println("结束recreateBom"); + if (resultTopline != null) { + resultTopline.lock(); + // 设置BOM行属性 + AIFComponentContext[] children = resultTopline.getChildren(); + System.out.println("child size"+children.length); + for (int j = 0; j < children.length; j++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) children[j].getComponent(); + if (itemTeamMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { + + String team = itemTeamMap.get(bomLine.getStringProperty("bl_item_item_id")); + if(team != null) + { + bomLine.setStringProperty("ML8_ProjectTeam", team); + } + } + if (itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { + List list = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id")); + + if(list.size()==0) { + continue; + } + + String quantity = list.get(0); + list.remove(0); + if (quantity == null || quantity.isEmpty() || quantity.equals("0")) { + String uom = ""; + try { + uom = bomLine.getPropertyDisplayableValue("bl_uom"); + } catch (NotLoadedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("单位:++++++++++++++++" + uom); + if (uom.equals("每个")) { + continue; + } + quantity = "1.00"; + } + System.out.println("数量:++++++++++++++++" + quantity); + if (quantity.indexOf(".") > 0) { + Double bomNum = Double.parseDouble(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } else { + Integer bomNum = Integer.parseInt(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + // bomLine.setStringProperty("bl_quantity", + // itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"))); + } + } + resultTopline.save(); + resultTopline.unlock(); + resultTopline.refresh(); + if (resultTopline.getBOMView() != null) { + resultTopline.getBOMView().save(); + resultTopline.getBOMView().refresh(); + } + //发送到结构管理器 + System.out.println("发送到结构管理器"); + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.pse.PSEPerspective"); + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.pse.PSEPerspective", + new InterfaceAIFComponent[] { resultTopline.getItem() }); + + System.out.println("结束发送到结构管理器"); + } + } + } + + TCComponentBOMLine resultTopline = null; + public void recreateBom(TCComponentItemRevision topItemRev, ArrayList itemRevisionlists, + boolean isDelete) throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null); + resultTopline = topline; + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e) { + // TODO: handle exception + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e2) { + // TODO: handle exception + } + e.printStackTrace(); + } + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if (n_itemRevision != null) { + boolean isHave = false; + if (!isDelete) { + for (AIFComponentContext children : topline.getChildren()) { + if (n_itemRevision.getStringProperty("item_id") + .compareTo(children.getComponent().getProperty("bl_child_id")) == 0) { + isHave = true; + } + } + } + if (!isHave) { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if (topline.getBOMView() != null) { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/JTreeTable.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/JTreeTable.java new file mode 100644 index 0000000..0a4174f --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/JTreeTable.java @@ -0,0 +1,85 @@ +package com.connor.ml.tcm.ML_01; + +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.jdesktop.swingx.JXTreeTable; + +public class JTreeTable extends JXTreeTable { + + + private List isNotEditableRow; + //CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + public JTreeTable(JTreeTableModel testTreeTableModel) { + // TODO Auto-generated constructor stub + super(testTreeTableModel); + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + return true;//super.isCellEditable(arg0, arg1); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + // TODO Auto-generated method stub + //if(isNotEditableRow.contains(row) && column == 2) + + + return cellEditor; + //return super.getCellEditor(row, column); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + if(this.getValueAt(row, 2) != null && (this.getValueAt(row, 2).toString().equals("0") || this.getValueAt(row, 2).toString().equals("1")) && column == 2) + { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/JTreeTableModel.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/JTreeTableModel.java new file mode 100644 index 0000000..45c2a69 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/JTreeTableModel.java @@ -0,0 +1,116 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.ML_01; + +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; + +/** + * + * @author vearn + */ +public class JTreeTableModel extends DefaultTreeTableModel { + + private String[] _names = { "EBOM对象", "发布状态", "替代项目组", "数量", "MBOM对象ID","MBOM对象名称","是否存在"}; + + + private List isNotEditableRow; + + + + public JTreeTableModel(TreeTableNode node) { + super(node); + } + + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + /** + * 列的数量 + */ + @Override + public int getColumnCount() { + return _names.length; + } + + /** + * 表头显示的内容 + */ + @Override + public String getColumnName(int column) { + return _names[column]; + } + + /** + * 返回在单元格中显示的Object + */ + @Override + public Object getValueAt(Object node, int column) { + Object value = null; + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node; + Object o = mutableNode.getUserObject(); + if (o != null && o instanceof NodeBean) { + NodeBean bean = (NodeBean) o; + switch (column) { + case 0: + value = bean.getEbom(); + break; + case 1: + value = bean.getRefreshStatus(); + break; + case 2: + value = bean.getProjectTeam(); + break; + case 3: + value = bean.getNum(); + break; + case 4: + value = bean.getMbomId(); + break; + case 5: + value = bean.getMbomName(); + break; + case 6: + value = bean.getIsHave(); + break; + } + } + } + return value; + } + + /** + * 设置所有单元格都不能编辑 + * + * @param the node (i.e. row) for which editing is to be determined + * @param the column for which editing is to be determined + * @return false + */ + @Override + public boolean isCellEditable(Object node, int column) { + //if(column == 5) + //{ + return true; + //} + //else + //{ + // return false; + //} + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/OperationNew.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/OperationNew.java new file mode 100644 index 0000000..184e90c --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/OperationNew.java @@ -0,0 +1,517 @@ +package com.connor.ml.tcm.ML_01; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.TreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.exceptions.NotLoadedException; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + +public class OperationNew extends AbstractAIFOperation { + + private TCSession session; + private DefaultMutableTreeTableNode node; + private String factory; + private TCComponentItemRevision topItemRevision = null; + private boolean flag; + TCComponentBOMLine resultTopline = null; + private TCComponentItemRevision itemRevision; + public OperationNew(TCSession session, EbomTransitionToMbomDialog ebomTransitionToMbomDialog, + SelectLineDialog selectLineDialog, DefaultMutableTreeTableNode node,String factory,TCComponentItemRevision itemRevision,boolean flag) { + // TODO Auto-generated constructor stub + this.session=session; +// this.ebomTransitionToMbomDialog=ebomTransitionToMbomDialog; +// this.selectLineDialog=selectLineDialog; + this.node=node; + this.factory=factory; + this.itemRevision=itemRevision; + this.flag=flag; +// this.lineEroCodeMap=lineEroCodeMap; + } + + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + TCComponentItemType itemType; + try { +// MethodUtil.openByPass(session); + itemType = (TCComponentItemType) session.getTypeComponent("Item"); + System.out.println("开始转MBOM"); + adaptiveVariants("", "", (DefaultMutableTreeTableNode) (node.getChildAt(0)), itemType); + if (topItemRevision != null) { + topItemRevision.refresh(); + TCComponent[] targets = new TCComponent[] { topItemRevision, itemRevision }; + int[] types = new int[] { 1, 1 }; + if(topItemRevision.getStringProperty("item_id").equals(itemRevision.getStringProperty("item_id"))) + { + targets = new TCComponent[] { topItemRevision }; + types = new int[] { 1 }; + } + try + { + System.out.println("000-扩线体MBOM传递ERP"); + MethodUtil.CreateProcess(session, targets, types, "000-扩线体MBOM传递ERP"); + } + catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } +// MethodUtil.closeByPass(session); + + if(flag) { + MessageBox.post("扩产线完成!", "完成", MessageBox.INFORMATION); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + private void adaptiveVariants(String lineCode, String erpCode, DefaultMutableTreeTableNode tableNode, + TCComponentItemType itemType) throws TCException { + NodeBean childBean = (NodeBean) tableNode.getUserObject(); + TCComponentItem topItem = itemType.find(childBean.getMbomId()); + MethodUtil.openByPass(session); + try { + if (topItem == null) { + TCComponentItemRevision itemRevision = childBean.getItem().getLatestItemRevision(); + // 另存对象 + topItem = itemRevision.saveAsItem(childBean.getMbomId(), "A"); + if (lineCode.isEmpty() && erpCode.isEmpty()) { + topItemRevision = topItem.getLatestItemRevision(); + } + TCComponent[] relatedComps = itemRevision.getRelatedComponents("TC_Primary_Design_Representation"); + for (int i = 0; i < relatedComps.length; i++) { + topItemRevision.add("TC_Primary_Design_Representation", relatedComps[i]); + } + // 获取EBOM ID + String ebomId = itemRevision.getStringProperty("item_id"); + String mbomId = childBean.getMbomId(); + String lineCodeString = ""; + String factoryString = ""; + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + if (mbomId.indexOf("-") > 0) { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode(lineCodeString,factoryString); + if (result.indexOf("=") > 0) { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + TCComponentItem ebom = itemType.find(ebomId); + // 将另存的对象放在EBOM的ML8_RelatedMBOM关系下 + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + topItem.refresh(); + topItem.getLatestItemRevision().refresh(); + // 设置属性 + System.out.println("对象:"+topItem.getLatestItemRevision().getStringProperty("object_string")); + System.out.println("设置属性:ml8_LineCode:"+lineCode); + System.out.println("设置属性:ml8_ERPCode:"+erpCode); + System.out.println("设置属性:ml8_Line:"+lineCodeString); + System.out.println("设置属性:ml8_Factory:"+this.factory); + topItem.getLatestItemRevision().setStringProperty("ml8_LineCode", lineCode); + topItem.getLatestItemRevision().setStringProperty("ml8_ERPCode", erpCode); + topItem.getLatestItemRevision().setStringProperty("ml8_Line", lineCodeString); + topItem.getLatestItemRevision().setStringProperty("ml8_Factory", this.factory); + TreeTableNode parent = tableNode.getParent(); + if(parent != null) { + // 获取EBOM ID + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + TCComponent[] relatedMBOMs = ebom.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); + boolean isHave = false; + for (int j = 0; j < relatedMBOMs.length; j++) { + if(relatedMBOMs[j].getUid().equals(topItem.getUid())) + { + isHave = true; + break; + } + } + if(!isHave) + { + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + } + } + } + else + { + TCComponentItemRevision itemRevision = topItem.getLatestItemRevision(); + String mbomId = childBean.getMbomId(); + String lineCodeString = ""; + String factoryString=""; + if (mbomId.indexOf("-") > 0) { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode(lineCodeString,factoryString); + if (result.indexOf("=") > 0) { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + System.out.println("对象:"+topItem.getLatestItemRevision().getStringProperty("object_string")); + System.out.println("设置属性:ml8_LineCode:"+lineCode); + System.out.println("设置属性:ml8_ERPCode:"+erpCode); + System.out.println("设置属性:ml8_Line:"+lineCodeString); + System.out.println("设置属性:ml8_Factory:"+this.factory); + itemRevision.setStringProperty("ml8_LineCode", lineCode); + itemRevision.setStringProperty("ml8_ERPCode", erpCode); + itemRevision.setStringProperty("ml8_Line", lineCodeString); + itemRevision.setStringProperty("ml8_Factory", this.factory); + // 获取EBOM ID + String ebomId = itemRevision.getStringProperty("item_id"); + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + TCComponentItem ebom = itemType.find(ebomId); + + TCComponent[] relatedMBOMs = ebom.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); + boolean isHave = false; + if(relatedMBOMs != null) + { + for (int i = 0; i < relatedMBOMs.length; i++) { + if(relatedMBOMs[i].getUid().equals(topItem.getUid())) + { + isHave = true; + break; + } + } + if(!isHave) + { + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + } + } + + } + + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + MethodUtil.closeByPass(session); + } + ArrayList itemList = new ArrayList(); + Map itemNumMap = new HashMap(); + Map itemTeamMap = new HashMap(); + System.out.println("childCount"+ tableNode.getChildCount()); + for (int i = 0; i < tableNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i); + NodeBean childNodeBean = (NodeBean) childNode.getUserObject(); + + System.out.println("child"+lineCode+"lineCode"+erpCode); + adaptiveVariants(lineCode, erpCode, childNode, itemType); + MethodUtil.openByPass(session); + try { + TCComponentItem item = itemType.find(childNodeBean.getMbomId()); + if (item == null) { + topItem = childNodeBean.getItem().getLatestItemRevision().saveAsItem(childNodeBean.getMbomId(), "A"); + TCComponent[] relatedComps = childNodeBean.getItem().getLatestItemRevision().getRelatedComponents("TC_Primary_Design_Representation"); + for (int j = 0; j < relatedComps.length; j++) { + topItem.getLatestItemRevision().add("TC_Primary_Design_Representation", relatedComps[i]); + } + // 获取EBOM ID + String mbomId = childNodeBean.getMbomId(); + String lineCodeString = ""; + String factoryString=""; + if (mbomId.indexOf("-") > 0) { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode(lineCodeString,factoryString); + if (result.indexOf("=") > 0) { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + // 将另存的对象放在EBOM的ML8_RelatedMBOM关系下 + childNodeBean.getItem().getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + topItem.refresh(); + topItem.getLatestItemRevision().refresh(); + System.out.println("对象:"+topItem.getLatestItemRevision().getStringProperty("object_string")); + System.out.println("设置属性:ml8_LineCode:"+lineCode); + System.out.println("设置属性:ml8_ERPCode:"+erpCode); + System.out.println("设置属性:ml8_Line:"+lineCodeString); + System.out.println("设置属性:ml8_Factory:"+this.factory); + // 设置属性 + TCComponentItemRevision latestItemRevision = topItem.getLatestItemRevision(); + latestItemRevision.setStringProperty("ml8_LineCode", lineCode); + latestItemRevision.setStringProperty("ml8_ERPCode", erpCode); + latestItemRevision.setStringProperty("ml8_Line", lineCodeString); + latestItemRevision.setStringProperty("ml8_Factory", this.factory); + } + else + { + TCComponentItemRevision itemRevision = topItem.getLatestItemRevision(); + String mbomId = childNodeBean.getMbomId(); + String lineCodeString = ""; + String factoryString=""; + if (mbomId.indexOf("-") > 0) { + lineCodeString = mbomId.split("-")[2]; + factoryString = mbomId.split("-")[1]; + } + String result = getLineCode(lineCodeString,factoryString); + if (result.indexOf("=") > 0) { + lineCode = result.split("=")[0]; + erpCode = result.split("=")[1]; + } + System.out.println("对象:"+topItem.getLatestItemRevision().getStringProperty("object_string")); + System.out.println("设置属性:ml8_LineCode:"+lineCode); + System.out.println("设置属性:ml8_ERPCode:"+erpCode); + System.out.println("设置属性:ml8_Line:"+lineCodeString); + System.out.println("设置属性:ml8_Factory:"+this.factory); + itemRevision.setStringProperty("ml8_LineCode", lineCode); + itemRevision.setStringProperty("ml8_ERPCode", erpCode); + itemRevision.setStringProperty("ml8_Line", lineCodeString); + itemRevision.setStringProperty("ml8_Factory", this.factory); + // 获取EBOM ID + String ebomId = itemRevision.getStringProperty("item_id"); + if (ebomId.indexOf("-") > 0) { + ebomId = ebomId.split("-")[0]; + } + TCComponentItem ebom = itemType.find(ebomId); + + TCComponent[] relatedMBOMs = ebom.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); + boolean isHave = false; + for (int j = 0; j < relatedMBOMs.length; j++) { + if(relatedMBOMs[j].getUid().equals(topItem.getUid())) + { + isHave = true; + break; + } + } + if(!isHave) + { + ebom.getLatestItemRevision().add("ML8_RelatedMBOM", topItem); + } + } + + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + MethodUtil.closeByPass(session); + } + itemList.add(topItem.getLatestItemRevision()); + itemNumMap.put(childBean.getMbomId(), childBean.getNum()); + itemTeamMap.put(childBean.getMbomId(), childBean.getProjectTeam()); + } + if(topItem != null && lineCode.isEmpty() && erpCode.isEmpty()) + { + topItemRevision = topItem.getLatestItemRevision(); + } + MethodUtil.openByPass(session); + try { + if (topItem != null && itemList.size() > 0) { + topItemRevision = topItem.getLatestItemRevision(); + resultTopline = null; + System.out.println("recreateBom"); + this.recreateBom(topItem.getLatestItemRevision(), itemList, true); + if (resultTopline != null) { + resultTopline.lock(); + // 设置BOM行属性 + for (int j = 0; j < resultTopline.getChildren().length; j++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent(); + if (itemTeamMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { + + String team = itemTeamMap.get(bomLine.getStringProperty("bl_item_item_id")); + if (team != null) { + bomLine.setStringProperty("ML8_ProjectTeam", team); + } + } + if (itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) { + String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id")); + if (quantity == null || quantity.isEmpty() || quantity.equals("0")) { + String uom = ""; + try { + uom = bomLine.getPropertyDisplayableValue("bl_uom"); + } catch (NotLoadedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("单位:++++++++++++++++" + uom); + if (uom.equals("每个")) { + continue; + } + quantity = "1.00"; + } + System.out.println("数量:++++++++++++++++" + quantity); + if (quantity.indexOf(".") > 0) { + Double bomNum = Double.parseDouble(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } else { + Integer bomNum = Integer.parseInt(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + // bomLine.setStringProperty("bl_quantity", + // itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"))); + } + } + resultTopline.save(); + resultTopline.unlock(); + resultTopline.refresh(); + if (resultTopline.getBOMView() != null) { + resultTopline.getBOMView().save(); + resultTopline.getBOMView().refresh(); + } + } + } + + } catch (NumberFormatException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + MethodUtil.closeByPass(session); + } + } + + private String getLineCode(String lineId, String factoryString) throws TCException { + String result = ""; +// +// String keyString=factoryString+"line"+lineId; +// +// if(lineEroCodeMap.containsKey(keyString)) { +// result=lineEroCodeMap.get(keyString); +// } + TCClassificationService classificationService = session.getClassificationService(); + ICSSearchResult[] results = classificationService.searchICOs("组计数器字典", null, 0); + String line = ""; + String classFactory = ""; + String lineCode = ""; + String erpCode = ""; + for (int i = 0; i < results.length; i++) { + String icoUID = results[i].getIcoUid(); + TCComponentICO ico = (TCComponentICO) session.stringToComponent(icoUID); + ico.getClassifiedObject(); + ICSProperty[] icsProps = ico.getICSProperties(true); + + ICSPropertyDescription[] icsDs = ico.getICSPropertyDescriptors(); + + for (ICSPropertyDescription icsD : icsDs) { +// if (icsD.getName().compareTo("产线") == 0) { +// continue; +// } + String value = ""; + for (ICSProperty icsProperty : icsProps) { + if (icsProperty.getId() == icsD.getId()) { + value = icsProperty.getValue(); + } + } + if (icsD.getName().compareTo("产线") == 0) { + line = value; + } + if (icsD.getName().compareTo("工厂") == 0) { + classFactory = value; + } + if (icsD.getName().compareTo("产线代码") == 0) { + lineCode = value; + } + if (icsD.getName().compareTo("ERP班组编码") == 0) { + erpCode = value; + } + } + if(line.equals(lineId) && classFactory.equals(factoryString)) + { + break; + } + } + result = lineCode + "=" + erpCode; +// System.out.println(); + return result; + } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev, ArrayList itemRevisionlists, + boolean isDelete) throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null); + resultTopline = topline; + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e) { + // TODO: handle exception + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e2) { + // TODO: handle exception + } + e.printStackTrace(); + } + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if (n_itemRevision != null) { + boolean isHave = false; + if (!isDelete) { + for (AIFComponentContext children : topline.getChildren()) { + if (n_itemRevision.getStringProperty("item_id") + .compareTo(children.getComponent().getProperty("bl_child_id")) == 0) { + isHave = true; + } + } + } + if (!isHave) { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if (topline.getBOMView() != null) { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/SelectLineDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/SelectLineDialog.java new file mode 100644 index 0000000..c4d4937 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/SelectLineDialog.java @@ -0,0 +1,267 @@ +package com.connor.ml.tcm.ML_01; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.apache.commons.collections.map.HashedMap; +import org.apache.xalan.xsltc.compiler.util.StringStack; +import org.apache.xml.security.Init; + +import com.connor.ml.tcm.bean.ComboBoxItemBean; +import com.connor.ml.tcm.util.JAutoCompleteComboBox; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class SelectLineDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private InterfaceAIFComponent comp; + + private JPanel titlePanel; + private JLabel titleLabel; + + private JLabel lineLabel; + private JAutoCompleteComboBox lineComBox; + private JLabel factoryLabel; + private JAutoCompleteComboBox factoryComBox; + + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + + private Map> lineFactoryMap=new HashMap>(); + + private Map factoryMap=new HashMap(); + private Map lineMap=new HashMap(); + + private Map lineEroCodeMap=new HashMap(); + public SelectLineDialog(InterfaceAIFComponent comp, TCSession session, Map lineEroCodeMap) { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.lineEroCodeMap=lineEroCodeMap; + + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("选择产线"); + this.setPreferredSize(new Dimension(350, 180)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("选择产线"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + JPanel panel = new JPanel(); + panel.add(this.titlePanel, BorderLayout.NORTH); + + this.lineLabel = new JLabel("选择产线:"); + this.lineLabel.setPreferredSize(new Dimension(80, 30)); + + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringValues("ML_Factory_line"); + for(String value:values) { + String[] split = value.split("\\|"); + System.out.println(split[0]); + String[] split2 = split[0].split(":"); + String[] split3 = split[1].split(":"); + String factory=split2[0]; + factoryMap.put(factory, split[0]); + + String line=split3[0]; + lineMap.put(line, split3[1]); +// System.out.println(factory+split3[1]); +// for(String string:split) { +// String[] split2 = string.split(":"); +// String key=split2[0]; +// String keyValue=split2[0]; +// + if(lineFactoryMap.containsKey(factory)) { + lineFactoryMap.get(factory).add(line); + }else { + List list=new ArrayList(); + list.add(""); + list.add(line); + lineFactoryMap.put(factory, list); + } +// } + } + List list=new ArrayList(); + list.add(""); + for(Map.Entry> key:lineFactoryMap.entrySet()) { + String key2 = key.getKey(); + System.out.println(key2); + list.add(key2); + for(String string:key.getValue()) { + System.out.println(string); + } + } + this.lineComBox = new JAutoCompleteComboBox(new String[] {}); //ML8_LineLOV + + this.lineComBox.setPreferredSize(new Dimension(150, 30)); + + + this.factoryLabel = new JLabel("选择工厂:"); + this.factoryLabel.setPreferredSize(new Dimension(80, 30)); + + this.factoryComBox = new JAutoCompleteComboBox(list.toArray()); //MethodUtil.findLOVByName(session, "ML8_Factory_LOV") + this.factoryComBox.setPreferredSize(new Dimension(150, 30)); + + factoryComBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JComboBox source = (JComboBox) e.getSource(); + String provinces = (String) source.getSelectedItem(); + lineComBox.removeAllItems(); + if(lineFactoryMap.containsKey(provinces)) { + List lsit = lineFactoryMap.get(provinces); + Object[] array = lsit.toArray(); + for(Object object:array) { + lineComBox.addItem(object); + } + } + } + }); + + JPanel topPanel = new JPanel(new PropertyLayout()); + topPanel.add("1.1.left.top", factoryLabel); + topPanel.add("1.2.left.top", factoryComBox); + topPanel.add("2.1.left.top", lineLabel); + topPanel.add("2.2.left.top", lineComBox); + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("确认"); + this.celButton = new JButton("取消"); + + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.NORTH); + this.add(topPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + + // 添加监听 + public void createActionEvent() { + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + try { + // 获取选中的产线 + if (this.lineComBox.getSelectedItem() == null) { + MessageBox.post("请选择产线!", "错误", MessageBox.ERROR); + return; + } + String lineItem = (String) this.lineComBox.getSelectedItem(); + if (lineItem == null || lineItem.isEmpty()) { + MessageBox.post("请选择产线!", "错误", MessageBox.ERROR); + return; + } + + if(lineMap.containsKey(lineItem)) { + lineItem=lineMap.get(lineItem); + } + // 获取选中的产线 + if (this.factoryComBox.getSelectedItem() == null) { + MessageBox.post("请选择工厂!", "错误", MessageBox.ERROR); + return; + } + String factoryItem = (String) this.factoryComBox.getSelectedItem(); + if (factoryItem== null || factoryItem.isEmpty()) { + MessageBox.post("请选择工厂!", "错误", MessageBox.ERROR); + return; + } + String factoryVal=""; + if(factoryMap.containsKey(factoryItem)) { + String string = factoryMap.get(factoryItem); + if(string.contains("/")) { + String vals=string.split(":")[1]; + TCComponentItem item = null; + if(comp instanceof TCComponentBOMLine) + { + TCComponentBOMLine bomLine = (TCComponentBOMLine) comp; + item = bomLine.getItem(); + } + else if(comp instanceof TCComponentItem) + { + item = (TCComponentItem) comp; + } + else if(comp instanceof TCComponentItemRevision) + { + TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp; + item = itemRevision.getItem(); + } + //判断对象类型 + + System.out.println(item.getType()); + if(item.getType().equals("ML8_Part")) { + String addTrade = item.getLatestItemRevision().getStringProperty("ml8_AddTrade"); + String processingMode = item.getLatestItemRevision().getStringProperty("ml8_ProcessingMode"); + if(addTrade!=null && addTrade.equals("是") && processingMode!=null && processingMode.equals("外协外购")) + { + factoryVal=string.split(":")[1].split("/")[1]; + }else { + factoryVal=string.split(":")[1].split("/")[0]; + } + }else { + factoryVal=string.split(":")[1].split("/")[0]; + } + + }else { + factoryVal=string.split(":")[1]; + } + } + + System.out.println("工厂代号"+factoryVal+"产线代号"+lineItem); + EbomTransitionToMbomCommand command = new EbomTransitionToMbomCommand(lineItem, + factoryVal, comp, session, this,lineEroCodeMap); +// EbomTransitionToMbomCommand command = new EbomTransitionToMbomCommand(item.getKey(), "", comp, session, +// this); + command.executeModal(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } else { + this.dispose(); + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/TableCellCheckboxRenderer.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..98ce4db --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_01/TableCellCheckboxRenderer.java @@ -0,0 +1,71 @@ +package com.connor.ml.tcm.ML_01; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + //private TestTreeTableModel tableModel; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + + } + + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + + if(value != null) + { +// if(value.toString().equals("1")) +// { +// if(table.getColumnName(column).equals("改制") && hasFocus) +// { +// if(table.getValueAt(row, column + 1).toString().equals("1")) +// { +// table.setValueAt(0, row, column + 1); +// } +// } +// else if(table.getColumnName(column).equals("删除") && hasFocus) +// { +// if(table.getValueAt(row, column - 1).toString().equals("1")) +// { +// table.setValueAt(0, row, column - 1); +// } +// } +// } +// if(value.toString().equals("1")) +// { +// System.out.println(value.toString().equals("1") + "===="); +// } + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleCommand.java new file mode 100644 index 0000000..acf995d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleCommand.java @@ -0,0 +1,255 @@ +package com.connor.ml.tcm.ML_02; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.ml.tcm.util.ExcelUtil07; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ApprovedScaleCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine bomLine = null; + private List> dataList = new ArrayList>(); + + public ApprovedScaleCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + bomLine = (TCComponentBOMLine) comp; + + //判断对象类型是否是MBOM总节点对象ML8_Refrigerator + TCComponentItem item = bomLine.getItem(); + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + System.out.println(item.getType()); + + if(!item.getType().equals("ML8_Refrigerator")) + { + MessageBox.post("请选择MBOM总节点对象生成辅材核定定额表!", "错误", MessageBox.ERROR); + return; + } + //判断MBOM是否发布 + TCComponent[] releaseStatus = itemRevision.getReferenceListProperty("release_status_list"); + if(releaseStatus.length > 0) + { + MessageBox.post("MBOM已发布,无法生成辅材核定定额表!", "错误", MessageBox.ERROR); + return; + } + try { + //路径选择框 +// // 选择文件路径 +// JFileChooser fileChooser = new JFileChooser(); +// fileChooser.setFileSelectionMode(JFileChooser.SAVE_DIALOG | JFileChooser.DIRECTORIES_ONLY); +// fileChooser.setDialogTitle("选择文件夹"); +// fileChooser.setFileHidingEnabled(false); +// if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { +// File getPath = fileChooser.getSelectedFile(); + + //获取模板 + File modelFile = MethodUtil.getFile(session, "辅材核定定额表", "MSExcelX"); + if(modelFile == null) + { + MessageBox.post("从首选项ML_Doc_Teamplate中未找到对应模板文件!", "错误", MessageBox.ERROR); + return; + } + //获取要导出到Excel的数据 + getBomPropertysToNode(bomLine); + String itemId = itemRevision.getStringProperty("item_id"); + if(itemId.indexOf("-") > 0) + { + itemId = itemId.split("-")[0]; + } + String productCode = itemRevision.getStringProperty("ml8_ProductCode"); + String productType = itemRevision.getStringProperty("ml8_ProductType"); + String fileName = itemId+"["+productCode+"("+productType+")]"+"辅材核定定额表.xlsx"; + String outFilePath = System.getenv("TEMP") +"\\"+fileName; + writeExcel(bomLine, modelFile, outFilePath); + //将导出的Excel放在选中对象版本的规范关系下 + if (ExcelUtil07.getExcelToItem(session, itemRevision, + "IMAN_specification", "MSExcelX") != null) { + ExcelUtil07.changeDataSet( + ExcelUtil07.getExcelToDataset(session, itemRevision, "IMAN_specification", "MSExcelX"), + "excel", "MSExcelX", outFilePath); + new File(outFilePath).delete(); + } else { + ExcelUtil07.setExcelToItem(session, itemRevision, outFilePath, fileName, "IMAN_specification", + "MSExcelX", true); + new File(outFilePath).delete(); + } + MessageBox.post("辅材核定定额表已输出成功!", "成功", MessageBox.INFORMATION); + //} + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + public void getBomPropertysToNode(TCComponentBOMLine bomLine) throws TCException + { + AIFComponentContext aif[] = bomLine.getChildren(); + for (int i = 0; i < aif.length; i++) + { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + + TCComponentItem subItem = subline.getItem(); + TCComponentItemRevision subItemRevision = subItem.getLatestItemRevision(); + if(subItem.getType().equals("ML8_RawMaterial")) + { + List rowList = new ArrayList(); + rowList.add(bomLine.getItem().getLatestItemRevision().getStringProperty("object_name") + "工艺辅料"); + rowList.add(subItemRevision.getStringProperty("item_id")); + rowList.add(subItemRevision.getStringProperty("object_name")); + rowList.add(subItemRevision.getStringProperty("ml8_Specifications")); + rowList.add(subline.getStringProperty("bl_quantity")); + dataList.add(rowList); + } + else + { + getBomPropertysToNode(subline); + } + } + } + + /** + * 输出本部控制计划到EXCEL表格中 + * + * @param controlPlanBean 控制计划信息 + * @param input 模版文件流 + * @param outputFilePath 需要输出的全路径 + * @throws IOException + */ + public int writeExcel(TCComponentBOMLine bomLine, File file, String outFilePath) + throws Exception { + InputStream input = new FileInputStream(file); + TCComponentItemRevision itemRevision = bomLine.getItem().getLatestItemRevision(); + String itemId = itemRevision.getStringProperty("item_id"); + String productCode = itemRevision.getStringProperty("ml8_ProductCode"); + String productType = itemRevision.getStringProperty("ml8_ProductType"); + String portalBody = itemRevision.getStringProperty("ml8_PortalBody"); + String itemLine = itemRevision.getStringProperty("ml8_Line"); + FileOutputStream output = new FileOutputStream(new File(outFilePath)); + XSSFWorkbook wb = new XSSFWorkbook(input); + XSSFSheet sheet = wb.getSheetAt(0); + int startRow = 6; + //设置表头属性 + XSSFRow row1 = sheet.getRow(4); + ExcelUtil07.setCellValue(row1, 0, itemId); + ExcelUtil07.setCellValue(row1, 1, productCode); + ExcelUtil07.setCellValue(row1, 2, productType); + ExcelUtil07.setCellValue(row1, 3, portalBody); + ExcelUtil07.setCellValue(row1, 6, itemLine); + //相同的进行合并 + String meop = ""; + List> combineDatas = new ArrayList>(); + List combineData = new ArrayList(); + for (int i = 0; i < dataList.size(); i++) { + List rowList = dataList.get(i); + XSSFRow row = null; + Boolean isCreat = false; + if ((i + startRow) > sheet.getLastRowNum()) { + row = sheet.createRow(i + startRow); + isCreat = true; + } else { + row = sheet.getRow(i + startRow); + isCreat = false; + } + for (int cols = 0; cols < 6; cols++) { + XSSFCell cell = null; + if (isCreat) { + cell = row.createCell(cols); + } else { + cell = row.getCell(cols); + } + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 + if(cols == 0) + { + cell.setCellValue(i+1); + } + else + { + if(cols == 1) + { + if(!meop.isEmpty() && rowList.get(cols-1).compareTo(meop) == 0) + { + combineData.add(i + startRow); + } + else + { + combineData = new ArrayList(); + combineData.add(i + startRow); + combineDatas.add(combineData); + meop = rowList.get(cols-1); + } + } + cell.setCellValue(rowList.get(cols-1)); + } + } + } + for (int i = 0; i < combineDatas.size(); i++) { + if(combineDatas.get(i).size() <= 1) + { + continue; + } + ExcelUtil07.combine(sheet, combineDatas.get(i).toArray(new Integer[0]), new int[] {1}); + } +// if (map != null && map.size() != 0) { +// Iterator> it = map.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// List columnIndex = new ArrayList(); +// for (int i = 0; i < entry.getValue().length; i++) { +// if ((entry.getValue()[i] >= 18 && entry.getValue()[i] <= 20)) { +// continue; +// } else { +// columnIndex.add(entry.getValue()[i]); +// } +// } +// int[] column = new int[columnIndex.size()]; +// for (int i = 0; i < columnIndex.size(); i++) { +// column[i] = columnIndex.get(i); +// } +// if (column.length > 0) { +// combine(sheet, entry.getKey(), column); +// } +// } +// } + wb.write(output); + output.close(); + input.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + + return 0; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleHandler.java new file mode 100644 index 0000000..7d1ace0 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleHandler.java @@ -0,0 +1,39 @@ +package com.connor.ml.tcm.ML_02; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.ML_01.SelectLineDialog; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class ApprovedScaleHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + new Thread() { + @Override + public void run() { + ApprovedScaleCommand command = new ApprovedScaleCommand(app.getTargetComponent(),session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleOperation.java new file mode 100644 index 0000000..9e8a28e --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_02/ApprovedScaleOperation.java @@ -0,0 +1,13 @@ +package com.connor.ml.tcm.ML_02; + +import com.teamcenter.rac.aif.AbstractAIFOperation; + +public class ApprovedScaleOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryCommand.java new file mode 100644 index 0000000..3ddf5ea --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryCommand.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ML_03; + +import com.connor.ml.tcm.ML_01.EbomTransitionToMbomDialog; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class OrderBomQueryCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + + public OrderBomQueryCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + new Thread() { + @Override + public void run() { + OrderBomQueryDialog dialog = new OrderBomQueryDialog(comp, session); + } + }.start(); + super.executeModal(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryDialog.java new file mode 100644 index 0000000..49d30c2 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryDialog.java @@ -0,0 +1,395 @@ +package com.connor.ml.tcm.ML_03; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class OrderBomQueryDialog extends AbstractAIFDialog implements ActionListener { + + private InterfaceAIFComponent comp; + private TCSession session; + + private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm"); + + private JLabel startCreateDateLabel; + private DateButton startCreateDateButton; + private JLabel endCreateDateLabel; + private DateButton endCreateDateButton; + + private JLabel orderIdLabel; + private JTextField orderIdTextField; + private JLabel itemIdLabel; + private JTextField itemIdTextField; + private JLabel batchIdLabel; + private JTextField batchIdTextField; + private JLabel prodPlanLabel; + private JTextField prodPlanTextField; + private JLabel ERPCodeLabel; + private JTextField ERPCodeTextField; + + private JButton queryButton; + + private List> dataValueList = new ArrayList>(); + private JTable mainTable; + private String[] columnNames = new String[]{"序号","订单号","物料编号","物料名称","创建时间","批次号","生产计划号","订单对象"}; + + private String selectSql1; + private String selectSql2; + private String selectSql3; + + public OrderBomQueryDialog(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("订单BOM查询"); + this.setPreferredSize(new Dimension(700, 450)); + + this.startCreateDateLabel = new JLabel("创建时间:"); + this.startCreateDateLabel.setPreferredSize(new Dimension(70, 25)); + this.startCreateDateButton = new DateButton(simpleDateFormat); + this.startCreateDateButton.setText(""); + this.startCreateDateButton.setPreferredSize(new Dimension(150, 25)); + this.endCreateDateLabel = new JLabel("-"); + this.endCreateDateLabel.setPreferredSize(new Dimension(70, 25)); + this.endCreateDateButton = new DateButton(simpleDateFormat); + this.endCreateDateButton.setText(""); + this.endCreateDateButton.setPreferredSize(new Dimension(150, 25)); + + this.orderIdLabel = new JLabel("订单号:"); + this.orderIdLabel.setPreferredSize(new Dimension(70, 25)); + this.orderIdTextField = new JTextField(); + this.orderIdTextField.setPreferredSize(new Dimension(150, 25)); + this.itemIdLabel = new JLabel("物料号:"); + this.itemIdLabel.setPreferredSize(new Dimension(70, 25)); + this.itemIdTextField = new JTextField(); + this.itemIdTextField.setPreferredSize(new Dimension(150, 25)); + this.batchIdLabel = new JLabel("批次号:"); + this.batchIdLabel.setPreferredSize(new Dimension(70, 25)); + this.batchIdTextField = new JTextField(); + this.batchIdTextField.setPreferredSize(new Dimension(150, 25)); + this.prodPlanLabel = new JLabel("计划号:"); + this.prodPlanLabel.setPreferredSize(new Dimension(70, 25)); + this.prodPlanTextField = new JTextField(); + this.prodPlanTextField.setPreferredSize(new Dimension(150, 25)); + this.ERPCodeLabel = new JLabel("班组号:"); + this.ERPCodeLabel.setPreferredSize(new Dimension(70, 25)); + this.ERPCodeTextField = new JTextField(); + this.ERPCodeTextField.setPreferredSize(new Dimension(150, 25)); + + this.queryButton = new JButton("查询"); + this.queryButton.setPreferredSize(new Dimension(70, 25)); + + JPanel topPanel = new JPanel(new PropertyLayout()); + topPanel.add("1.1.left.top", this.startCreateDateLabel); + topPanel.add("1.2.left.top", this.startCreateDateButton); + topPanel.add("1.3.left.top", this.endCreateDateLabel); + topPanel.add("1.4.left.top", this.endCreateDateButton); + topPanel.add("2.1.left.top", this.orderIdLabel); + topPanel.add("2.2.left.top", this.orderIdTextField); + topPanel.add("2.3.left.top", this.itemIdLabel); + topPanel.add("2.4.left.top", this.itemIdTextField); + topPanel.add("3.1.left.top", this.batchIdLabel); + topPanel.add("3.2.left.top", this.batchIdTextField); + topPanel.add("3.3.left.top", this.prodPlanLabel); + topPanel.add("3.4.left.top", this.prodPlanTextField); + topPanel.add("4.1.left.top", this.ERPCodeLabel); + topPanel.add("4.2.left.top", this.ERPCodeTextField); + topPanel.add("4.3.left.top", this.queryButton); + + this.mainTable = this.getjTable(mainTable, null, columnNames, null); + this.mainTable.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + if(e.getClickCount() == 2) + { + //发送到制造工艺规划器 + int[] rows = mainTable.getSelectedRows(); + if(rows.length > 0) + { + try { + String itemId = mainTable.getValueAt(rows[0], 7).toString(); + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem item = itemType.find(itemId); + if (item == null) { + MessageBox.post("未找到对象!", "错误", MessageBox.ERROR); + return; + } + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.cme.mpp.MSEPerspective", + new InterfaceAIFComponent[] { item }); + + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + } + } + }); + +// JSplitPane splitPanePanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT); +// splitPanePanel.setOneTouchExpandable(true);// 让分割线显示出箭头 +// splitPanePanel.setContinuousLayout(true);// 操作箭头,重绘图形 +// splitPanePanel.setTopComponent(topPanel); +// splitPanePanel.setBottomComponent(new JScrollPane(this.mainTable)); + + // 添加按钮监听 + this.createActionEvent(); + this.add(topPanel, BorderLayout.NORTH); + this.add(new JScrollPane(this.mainTable), BorderLayout.CENTER); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + // 添加监听 + public void createActionEvent() { + this.queryButton.addActionListener(this); + } + /*** + * Jtable通用方法 + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public void addData(Object[][] cellData) { + DefaultTableModel tableModel = (DefaultTableModel) this.mainTable.getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter( + this.getTableModel(null, this.columnNames, cellData)); + this.mainTable.setRowSorter(sorter); + for (int i = 0; i < cellData.length; i++) { + tableModel.addRow(cellData[i]); + } + // 表格数据不可修改 + this.mainTable.setEnabled(true); + // 更新表格 + this.mainTable.invalidate(); + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + + return tableModel; + } + + public void setQuery() { + selectSql1 = " AND 1=1"; + selectSql2 = " AND 1=1"; + selectSql3 = " AND 1=1"; + + if (this.itemIdTextField.getText() != null && !this.itemIdTextField.getText().isEmpty()) { + selectSql3 = selectSql3 + " AND T5.pml8_MaterialNo LIKE '%" + this.itemIdTextField.getText() + "%'"; + } + if (this.startCreateDateButton.getText() != null && this.startCreateDateButton.getDate() != null + && !this.startCreateDateButton.getText().isEmpty()) { + selectSql2 = selectSql2 + " AND CONVERT(datetime, '" + simpleDateFormat.format(this.startCreateDateButton.getDate()) + + "') < T3.pcreation_date"; + } + + if (this.endCreateDateButton.getText() != null && this.endCreateDateButton.getDate() != null + && !this.endCreateDateButton.getText().isEmpty()) { + selectSql2 = selectSql2 + " AND CONVERT(datetime, '" + simpleDateFormat.format(this.endCreateDateButton.getDate()) + + "') > T3.pcreation_date"; + } + + if (this.orderIdTextField.getText() != null && !this.orderIdTextField.getText().isEmpty()) { + selectSql3 = selectSql1 + " AND T5.pml8_ProdOrderNo LIKE '%" + this.orderIdTextField.getText() + "%'"; + } + if (this.batchIdTextField.getText() != null && !this.batchIdTextField.getText().isEmpty()) { + selectSql3 = selectSql1 + " AND T5.pml8_BatchNo LIKE '%" + this.batchIdTextField.getText() + "%'"; + } + if (this.prodPlanTextField.getText() != null && !this.prodPlanTextField.getText().isEmpty()) { + selectSql3 = selectSql1 + " AND T5.pml8_ProdPlanNo LIKE '%" + this.prodPlanTextField.getText() + "%'"; + } + if (this.ERPCodeTextField.getText() != null && !this.ERPCodeTextField.getText().isEmpty()) { + selectSql3 = selectSql1 + " AND T5.pml8_ERPCode LIKE '%" + this.ERPCodeTextField.getText() + "%'"; + } + } + + // 获取所需要的数据 + public void getCellValue() { + // errSb=new StringBuffer();//用来保存错误的数据 + InputStream input = null; + ResultSet rs = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String selectSql = String.format(pro.getProperty("ML8_ORDMBOMITEMSELECTSQL"), selectSql1, selectSql2, + selectSql3); + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + + if (rs != null) { + while (rs.next()) { + ArrayList cellValue = new ArrayList(); + cellValue.add(rs.getString("pml8_ProdOrderNo")); + cellValue.add(rs.getString("pml8_MaterialNo")); + cellValue.add(rs.getString("pobject_name")); + cellValue.add(rs.getString("pcreation_date")); + cellValue.add(rs.getString("pml8_BatchNo")); + cellValue.add(rs.getString("pml8_ProdPlanNo")); + cellValue.add(rs.getString("pitem_id")); + this.dataValueList.add(cellValue); + } + } + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + DbPool.freeAll(); + } + } + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.queryButton)) { + try { + this.dataValueList.clear(); + // 获取查询条件. + this.setQuery(); + ProgressBarThread thread = new ProgressBarThread("查询对象", "查询对象..."); + thread.start(); + this.getCellValue(); + + String[][] values = new String[this.dataValueList.size()][]; + for (int i = 0; i < this.dataValueList.size(); i++) { + values[i] = new String[this.dataValueList.get(i).size()+1]; + for (int j = 0; j < this.dataValueList.get(i).size() + 1; j++) { + if(j == 0) + { + values[i][j] = Integer.toString(i + 1); + } + else + { + values[i][j] = this.dataValueList.get(i).get(j-1); + } + } + } + thread.setBool(true); + // 更新表格 + this.addData(values); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryHandler.java new file mode 100644 index 0000000..bc6d913 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_03/OrderBomQueryHandler.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ML_03; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class OrderBomQueryHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String id = AIFUtility.getCurrentPerspectiveDef().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + OrderBomQueryCommand command = new OrderBomQueryCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessCommand.java new file mode 100644 index 0000000..be8b01f --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessCommand.java @@ -0,0 +1,380 @@ +package com.connor.ml.tcm.ML_04; + +import java.util.ArrayList; +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateOrderProcessCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private DefaultMutableTreeTableNode node = null; +// private TCComponent mbom ; + + private TCComponent procLine ; + public CreateOrderProcessCommand(InterfaceAIFComponent comp, TCSession session) { + // Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + //判断是否为订单BOM版本对象 ML8_OrdMBOMItemRevision + TCComponentItemRevision itemRevision = null; + if(this.comp instanceof TCComponentItemRevision) + { + if(((TCComponentItemRevision) this.comp).getStringProperty("object_type").compareTo("ML8_OrdMBOMItemRevision") != 0) + { + MessageBox.post("请选中订单BOM版本对象!", "错误", MessageBox.ERROR); + return; + } + itemRevision = (TCComponentItemRevision) this.comp; + } + else if(this.comp instanceof TCComponentBOMLine) + { + itemRevision = ((TCComponentBOMLine) this.comp).getItemRevision(); + } + else + { + MessageBox.post("请选中订单BOM版本对象!", "错误", MessageBox.ERROR); + return; + } + //通过何处引用判断是否已包含订单工艺ML8_OrderProcess + AIFComponentContext[] tcComponentContexts = itemRevision.whereReferenced(); + for (int i = 0; i < tcComponentContexts.length; i++) { + if(tcComponentContexts[i].getComponent().getProperty("object_type").equals("ML8_OrderProcessRevision")) + { + MessageBox.post("选中订单BOM下已包含订单工艺!", "错误", MessageBox.ERROR); + return; + } + } + //获取订单BOM版本上的物料号和ERP班组编码 +// String materialNo = itemRevision.getStringProperty("ml8_MaterialNo"); +// System.out.println("ml8_MaterialNo"+materialNo); + String productID = itemRevision.getStringProperty("ml8_ProductID"); + String ml8_ProdOrderNo = itemRevision.getStringProperty("ml8_ProdOrderNo"); +// String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + //根据物料号获取对象 + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem[] is = itemType.findItems(productID);//).find(productID); + if(is==null || is.length==0) + { + MessageBox.post("通过产品代码【"+productID+"】未找到产品对象!", "错误", MessageBox.ERROR); + return; + } + TCComponentItem item = is[0]; +// System.out.println("ml8_ERPCode"+ERPCode); +// //根据EBOM获取对应的MBOM节点 +// TCComponent[] mboms = item.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); +// if(mboms.length <= 0) +// { +// MessageBox.post("EBOM下未找到对应的MBOM对象!", "错误", MessageBox.ERROR); +// return; +// } +// TCComponent mbomTarget = null; +// for (int i = 0; i < mboms.length; i++) { +// //取ERP班组号相同的MBOM 匹配id +// System.out.println("mbom产品对象"+((TCComponentItem)mboms[i]).getLatestItemRevision().getStringProperty("item_id")); +// TCComponentItemRevision revision=((TCComponentItem)mboms[i]).getLatestItemRevision(); +// TCComponent[] psChildren = revision.getReferenceListProperty("ps_children"); +// String stringProperty = revision.getStringProperty("ml8_ERPCode"); +// if(stringProperty.equals(ERPCode) ) { +// mbom=revision; +// mbomTarget=((TCComponentItem)mboms[i]).getLatestItemRevision(); +// } +// +// +// +// } +// if(mbom == null) +// { +// MessageBox.post("没有找到对应的MBOM!", "错误", MessageBox.ERROR); +// return; +// } + //根据EBOM获取对应的MBOM节点 +// TCComponent[] mboms = item.getLatestItemRevision().getReferenceListProperty("ML8_RelatedMBOM"); +// if(mboms.length <= 0) +// { +// MessageBox.post("EBOM下未找到对应的MBOM对象!", "错误", MessageBox.ERROR); +// return; +// } +// TCComponent mbom = null; +// for (int i = 0; i < mboms.length; i++) { +// //取ERP班组号相同的MBOM +// if(ERPCode.equals(((TCComponentItem)mboms[i]).getLatestItemRevision().getStringProperty("ml8_ERPCode"))) +// { +// mbom = mboms[i]; +// } +// } +// if(mbom == null) +// { +// MessageBox.post("EBOM下未找到ERP班组号为【"+ERPCode+"】的MBOM!", "错误", MessageBox.ERROR); +// return; +// } + + //获取工厂BOP + AIFComponentContext[] items = item.getLatestItemRevision().whereReferenced();//.getReferenceListProperty("IMAN_METarget"); + List bops = new ArrayList(); + for (int i = 0; i < items.length; i++) { + TCComponent itemComponent = (TCComponent) items[i].getComponent(); + System.out.println(itemComponent.getStringProperty("object_type")); + if(itemComponent.getStringProperty("object_type").compareTo("ML8_PlantBOPRevision") == 0 + || itemComponent.getStringProperty("object_type").compareTo("工厂BOP版本") == 0) + { + bops.add((TCComponent) items[i].getComponent()); + } + } + + if(bops == null || bops.size() <= 0) + { + MessageBox.post("未找到对应的工厂BOP!", "错误", MessageBox.ERROR); + return; + } +// TCComponent bop = bops.get(0); +// //获取BOM属性 + +// bops + node = new DefaultMutableTreeTableNode(); + for(TCComponent bop : bops) { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(((TCComponentItemRevision)bop).getItem(), ((TCComponentItemRevision)bop), null, null); + DefaultMutableTreeTableNode bomPropertyToNodeNew = this.getBomPropertyToNodeNew(session, topline,bop.getStringProperty("object_name")); + int childCount = bomPropertyToNodeNew.getChildCount(); + System.out.println(childCount); + node.add(bomPropertyToNodeNew); + } +// TCComponentItemRevision bop=(TCComponentItemRevision) this.comp; + + +// +// +// node = this.getBomPropertyToNode(session, topline,itemRevision.getStringProperty("object_name")); + new Thread() { + @Override + public void run() { + new CreateOrderProcessDialog(comp, session,node,procLine,ml8_ProdOrderNo); + } + }.start(); + super.executeModal(); + } + +// private void createOrderProcess() +// { +// // 创建订单工艺 +// try { +// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ML8_OrderProcess"); +// // 获取对象名称 +// NodeBean itemBean = (NodeBean) (this.node.getChildAt(0)).getUserObject(); +// TCComponentItem item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), +// "ML8_OrderProcess", itemBean.getMbomName(), "", null); +// +// // 获取第二层的对象 +// NodeBean childBean = (NodeBean) (this.node.getChildAt(0).getChildAt(0)).getUserObject(); +// +// TCComponentItem processItem = childBean.getItem(); +// +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); +// TCComponentBOMWindow bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null, null); +// +// +// TCComponentBOMWindow bomWindow2 = bomWindowType.create(null); +// TCComponentBOMLine childline = bomWindow2.setWindowTopLine(processItem, processItem.getLatestItemRevision(), null, null); +// // 搭建BOM +// ArrayList itemRevisionsList = new ArrayList(); +// itemRevisionsList.add(processItem.getLatestItemRevision()); +// +// PasteDuplicateOperation localPasteDuplicateOperation = new PasteDuplicateOperation( +// new TCComponent[] { childline }, +// new TCComponent[] { topline } ); +// this.session.queueOperation(localPasteDuplicateOperation); +// +// //bomWindow.close(); +// //bomWindow2.close(); +// +// // recreateBom(item.getLatestItemRevision(), itemRevisionsList, true); +// this.session.getUser().getNewStuffFolder().add("contents", item); +// +// TCComponentItemRevision itemRevision = null; +// if (this.comp instanceof TCComponentItemRevision) { +// itemRevision = (TCComponentItemRevision) this.comp; +// } else if (this.comp instanceof TCComponentBOMLine) { +// itemRevision = ((TCComponentBOMLine) this.comp).getItemRevision(); +// } +// +// // 将订单BOM以IMAN_METarget关系放置在工厂BOP下 +// item.getLatestItemRevision().add("IMAN_METarget", itemRevision); +// +// // 发送到制造工艺规划器 +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.cme.mpp.MSEPerspective", new InterfaceAIFComponent[] { item }); +// } catch (TCException e1) { +// // Auto-generated catch block +// e1.printStackTrace(); +// } +// } + + private DefaultMutableTreeTableNode getBomPropertyToNodeNew(TCSession session2, TCComponentBOMLine topline, + String stringProperty) throws TCException { + // Auto-generated method stub + HF04NodeBean nodeBean = new HF04NodeBean(); + + //String ss = subline.getStringProperty("bl_indented_title"); + //对象ID + nodeBean.setValue("顶层"); + nodeBean.setType(""); + nodeBean.setTemplate(topline.getItem().getStringProperty("")); + DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); + //获取BOM + AIFComponentContext[] children = topline.getChildren(); + HF04NodeBean nodeBean2 = new HF04NodeBean(); +// nodeBean2.setSelected("0"); + nodeBean2.setValue(topline.getItem().getStringProperty("item_id")); + nodeBean2.setTemplate(topline.getItem().getStringProperty("object_string")); + + DefaultMutableTreeTableNode rootNode2 = new DefaultMutableTreeTableNode(nodeBean2); + for(AIFComponentContext bop:children) { + HF04NodeBean nodeBean1 = new HF04NodeBean(); + TCComponentBOMLine component =(TCComponentBOMLine) bop.getComponent(); + nodeBean1.setSelected("0"); +// System.out.println(component.getItem().getStringProperty("item_id")); + nodeBean1.setValue(component.getItem().getStringProperty("item_id")); + nodeBean1.setTemplate(component.getItem().getStringProperty("object_string")); + DefaultMutableTreeTableNode rootNode1 = new DefaultMutableTreeTableNode(nodeBean1); + rootNode2.add(rootNode1); + } + rootNode.add(rootNode2); + return rootNode; + } + + /** + * 获取BOM属性 + * @throws Exception + */ +// public DefaultMutableTreeTableNode getBomPropertyToNode(TCSession session, List bops,String orderName) throws Exception { +// // Auto-generated method stub +// +// NodeBean nodeBean = new NodeBean(); +// +// //String ss = subline.getStringProperty("bl_indented_title"); +// //对象ID +// nodeBean.setEbom("顶层"); +// nodeBean.setRefreshStatus(""); +// nodeBean.setProjectTeam(""); +// nodeBean.setNum(""); +// nodeBean.setMbomId(""); +// nodeBean.setMbomName(""); +// nodeBean.setIsHave(""); +// DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); +// //获取BOM +// try { +// for (int i = 0; i < bops.size(); i++) { +// TCComponent bop = bops.get(i); +// +// //获取BOM属性 +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); +// TCComponentBOMWindow bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(((TCComponentItemRevision)bop).getItem(), ((TCComponentItemRevision)bop), null, null); +// +// +// getBomPropertysToNode(topline, rootNode, "",orderName); +// +// } +// return rootNode; +// } catch (Exception e) { +// // : handle exception +// e.printStackTrace(); +// throw new Exception(e.getMessage()); +// } +// //return null; +// } + + /** + * 获取BOM信息 + * @param bomLine + * @param bomPropertyList + * @param parentID + * @throws Exception + */ +// public void getBomPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID,String orderName) throws Exception +// { +// try { +// +//// if() +// +// NodeBean nodeBean = new NodeBean(); +// +// if(parentID.isEmpty()) +// { +// nodeBean.setMbomName(orderName+"工艺"); +// nodeBean.setMbomId(""); +// } +// else +// { +// nodeBean.setMbomName(bomLine.getStringProperty("bl_item_object_string")); +// String itemId = bomLine.getStringProperty("bl_item_item_id"); +// nodeBean.setMbomId(itemId); +// nodeBean.setItem(bomLine.getItem()); +// } +// +// DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean); +// rootNode.add(node); +// +// if(bomLine.getChildren().length > 0) +// { +// AIFComponentContext aif[] = bomLine.getChildren(); +// for (int i = 0; i < aif.length; i++) +// { +// TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] +// .getComponent(); +// +// TCComponentItemRevision rev = subline.getItemRevision(); +// +//// System.out.println(rev.getType()+ rev.getStringProperty("item_id")); +// if(rev.getType().equals("ML8_ProcLineRevision")) { +// String itemId = rev.getStringProperty("item_id"); +// if(mbom!=null) { +// AIFComponentContext[] whereReferenced = mbom.whereReferenced(); +// +// for (int t = 0; t < whereReferenced.length; t++) { +// TCComponent itemComponent = (TCComponent) whereReferenced[t].getComponent(); +// String stringProperty = itemComponent.getStringProperty("item_id"); +//// System.out.println("stringProperty"+stringProperty+itemId); +// if(itemId.equals(stringProperty)) { +// procLine=rev; +// getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id"),""); +// } +// } +// } +// }else { +// getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id"),""); +// } +// +// } +// } +// } catch (Exception e) { +// // Auto-generated catch block +// e.printStackTrace(); +// throw new Exception(e.getMessage()); +// } +// } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessDialog.java new file mode 100644 index 0000000..f7982a0 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessDialog.java @@ -0,0 +1,403 @@ +package com.connor.ml.tcm.ML_04; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.TreePath; + +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import com.connor.ml.tcm.cloneProcess.WebApiUtil; +import com.connor.ml.tcm.util.Adapter; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CreateOrderProcessDialog extends AbstractAIFDialog implements ActionListener { + + /** + * + */ + private static final long serialVersionUID = 1L; + private TCSession session; + private InterfaceAIFComponent comp; + + private List isNotEditableRow = new ArrayList(); + private DefaultMutableTreeTableNode node; + //private TCComponent bop; + + private String[] header = new String[] { "对象ID", "对象名称","选择派生" }; + + private JPanel titlePanel; + private JLabel titleLabel; + private JTreeTable table; + private JTreeTableModel map; + + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + private JButton refreshButton; + +// private TCComponent procLine; + private String ml8_ProdOrderNo; + public CreateOrderProcessDialog(InterfaceAIFComponent comp, TCSession session, DefaultMutableTreeTableNode node, + TCComponent procLine, String ml8_ProdOrderNo) { + // Auto-generated constructor stub + this.session = session; + this.comp = comp; + this.node = node; +// this.procLine=procLine; + this.ml8_ProdOrderNo=ml8_ProdOrderNo; + //this.bop = bop; + + + init(); + } + + private void init() { + // Auto-generated method stub + this.setTitle("生成订单工艺"); + this.setPreferredSize(new Dimension(800, 600)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("生成订单工艺"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + JPanel panel = new JPanel(); + panel.add(this.titlePanel, BorderLayout.NORTH); + + this.table = getJTreeTable(null, null, header, null); + + table.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent e) { + // Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent e) { + // Auto-generated method stub + int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); + + if(selectColumn != 1) + { + return; + } + + TreePath treePath = table.getPathForLocation(e.getX(),e.getY()); + if (treePath != null) { + DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent(); + HF04NodeBean nodeBean = (HF04NodeBean) node.getUserObject(); + System.out.println(node.toString()); + System.out.println("childCount=>"+node.getChildCount()); + if(nodeBean.getSelected().equals("1")) + { + nodeBean.setSelected("0"); + // 自动勾选下层 + } + else + { + nodeBean.setSelected("1"); + // 自动勾选下层 + } + + } + } + }); +// PasteDuplicateStructureInput + new Adapter(table); + + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("确认"); + this.celButton = new JButton("取消"); + this.refreshButton = new JButton("刷新"); + + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + this.rootPanel.add(refreshButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(panel, BorderLayout.NORTH); + this.add(new JScrollPane(this.table), BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); + this.showDialog(); + } + + // 添加监听 + public void createActionEvent() { + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.refreshButton.addActionListener(this); + // this.celValueButton.addActionListener(this); + } + + // Jtable通用方法 + public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames, + Object[][] values) { + int simpleLen = 100; + int totleLen = 1500; + if (partsTable == null) { + this.map = new JTreeTableModel(this.node); +// map.get + this.map.setIsNotEditableRow(this.isNotEditableRow); + // map.setColumnIdentifiers(titleNames); + + partsTable = new JTreeTable(map); + partsTable.setIsNotEditableRow(this.isNotEditableRow); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(30); + partsTable.expandAll(); // 展开全部节点 + // 隐藏列 +// partsTable.HiddenCell(0); + + partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // 设置第一列宽度 + partsTable.getColumnModel().getColumn(1).setPreferredWidth(100); // 设置第二列宽度 + + partsTable.setHighlighters(HighlighterFactory.createSimpleStriping()); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + @Override + public void actionPerformed(ActionEvent e) { + // Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + // 创建订单工艺 + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ML8_OrderProcess"); + // 获取对象名称 +// HF04NodeBean itemBean = (HF04NodeBean) (this.node.getChildAt(0)).getUserObject(); + TCComponentItem item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), + "ML8_OrderProcess", ml8_ProdOrderNo, "", null); + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); +// TCComponentBOMWindow bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null, null); + int t=0; + + for(int k = 0; k < this.node.getChildCount();k++) { +// TreeTableNode childAt = ; + +// this.node.getChildAt(i).getChildAt(0); + + for (int i = 0; i < this.node.getChildAt(k).getChildAt(0).getChildCount(); i++) { + + // 获取第二层的对象 + HF04NodeBean childBean = (HF04NodeBean) (this.node.getChildAt(k).getChildAt(0).getChildAt(i)).getUserObject(); + String selected = childBean.getSelected(); + if(selected.equals("1")) { + t=t+1; + } + } + } + + + if(t>1 || t==0) { + MessageBox.post("“请选择一条产线进行派生”","提示",2); + return; + } + + TCComponent[] childlines = new TCComponent[t]; + + TCComponentItemType itemType1 =(TCComponentItemType) session.getTypeComponent(item.getType()); + TCComponentItemRevision findRev = null; + for(int k = 0; k < this.node.getChildCount();k++) { + + for (int i = 0; i < this.node.getChildAt(k).getChildAt(0).getChildCount(); i++) { + + // 获取第二层的对象 + HF04NodeBean childBean = (HF04NodeBean) (this.node.getChildAt(k).getChildAt(0).getChildAt(i)).getUserObject(); + String selected = childBean.getSelected(); + if(selected.equals("1")) { + String processItem = childBean.getValue(); + TCComponentItem find = itemType1.findItems(processItem)[0]; + TCComponentBOMWindow bomWindow2 = bomWindowType.create(null); + TCComponentBOMLine childline = bomWindow2.setWindowTopLine(find, find.getLatestItemRevision(), null, null); + + childlines[0] = childline; + findRev = find.getLatestItemRevision(); + } + + // 搭建BOM + //ArrayList itemRevisionsList = new ArrayList(); + //itemRevisionsList.add(processItem.getLatestItemRevision()); + + } + } + TCPreferenceService service = session.getPreferenceService(); + String values = service.getStringValue("ML_CloneUrl"); + + String topLineUid = item.getLatestItemRevision().getUid(); + + String childUid = findRev.getUid(); + + TCComponentUser user = session.getUser(); + + String paramString = topLineUid+";"+childUid+";"+user.getUserId(); + WebApiUtil.httpSapRequest(values+"/connor/Clone/pasteOrders","POST", paramString,1); + +// StructureManagementService structureManagementService = StructureManagementService.getService(session); +// StructureManagement.PasteDuplicateStructureResponse pasteDuplicateStructureResponse = structureManagementService.pasteDuplicateStructure +// (childlines, new TCComponent[] { topline }, "Mfg0MEPlantBOP.Mfg0MEPlantBOP.PasteDuplicateTemplate", false); +// +// PasteDuplicateOperation localPasteDuplicateOperation = new PasteDuplicateOperation( +// childlines, new TCComponent[] { topline } ); +// this.session.queueOperation(localPasteDuplicateOperation); + + this.session.getUser().getNewStuffFolder().add("contents", item); + + TCComponentItemRevision itemRevision = null; + if (this.comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) this.comp; + } else if (this.comp instanceof TCComponentBOMLine) { + itemRevision = ((TCComponentBOMLine) this.comp).getItemRevision(); + } +// +// // 将订单BOM以IMAN_METarget关系放置在ML8_OrderProcess下 + item.getLatestItemRevision().add("IMAN_METarget", itemRevision); +// +// +// item.getLatestItemRevision().add("IMAN_specification", procLine); + // 发送到制造工艺规划器 + MessageBox.post("创建订单工艺完成","提示",2); +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.cme.mpp.MSEPerspective", new InterfaceAIFComponent[] { item }); + dispose(); + + } catch (TCException e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } else if (source.equals(this.refreshButton)) { + this.dispose(); + try { + CreateOrderProcessCommand command = new CreateOrderProcessCommand(comp, session); + command.executeModal(); + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } else { + this.dispose(); + } + } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev, ArrayList itemRevisionlists, + boolean isDelete) throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if (n_itemRevision != null) { + boolean isHave = false; + if (!isDelete) { + for (AIFComponentContext children : topline.getChildren()) { + if (n_itemRevision.getStringProperty("item_id") + .compareTo(children.getComponent().getProperty("bl_child_id")) == 0) { + isHave = true; + } + } + } + if (!isHave) { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.refresh(); + if (topline.getBOMView() != null) { + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // : handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.refresh(); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessHandler.java new file mode 100644 index 0000000..baa0125 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/CreateOrderProcessHandler.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ML_04; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class CreateOrderProcessHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // Auto-generated method stub +// String id = AIFUtility.getCurrentPerspectiveDef().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + CreateOrderProcessCommand command = new CreateOrderProcessCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/HF04NodeBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/HF04NodeBean.java new file mode 100644 index 0000000..66ebac9 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/HF04NodeBean.java @@ -0,0 +1,42 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.ML_04; + +/** + * + * @author vearn + */ +public class HF04NodeBean { + + private String selected;//选中 + private String value;//名称 + private String type;//类型 + private String template;//模板 + + public String getSelected() { + return selected; + } + public void setSelected(String selected) { + this.selected = selected; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public String getTemplate() { + return template; + } + public void setTemplate(String template) { + this.template = template; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/JTreeTable.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/JTreeTable.java new file mode 100644 index 0000000..481d126 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/JTreeTable.java @@ -0,0 +1,84 @@ +package com.connor.ml.tcm.ML_04; + +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.jdesktop.swingx.JXTreeTable; + +public class JTreeTable extends JXTreeTable { + + + private List isNotEditableRow; + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + public JTreeTable(JTreeTableModel testTreeTableModel) { + // TODO Auto-generated constructor stub + super(testTreeTableModel); + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + return true;//super.isCellEditable(arg0, arg1); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + // TODO Auto-generated method stub + //if(isNotEditableRow.contains(row) && column == 2) + + + return cellEditor; + //return super.getCellEditor(row, column); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + if(this.getValueAt(row, 1) != null && column == 1 && row!=0 ) + { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/JTreeTableModel.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/JTreeTableModel.java new file mode 100644 index 0000000..795ea3c --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/JTreeTableModel.java @@ -0,0 +1,103 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.ML_04; + +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; + + +/** + * + * @author vearn + */ +public class JTreeTableModel extends DefaultTreeTableModel { + + private String[] _names = { "对象ID", "选择派生","对象名称"}; + + + private List isNotEditableRow; + + + + public JTreeTableModel(TreeTableNode node) { + super(node); + } + + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + /** + * 列的数量 + */ + @Override + public int getColumnCount() { + return _names.length; + } + + /** + * 表头显示的内容 + */ + @Override + public String getColumnName(int column) { + return _names[column]; + } + + /** + * 返回在单元格中显示的Object + */ + @Override + public Object getValueAt(Object node, int column) { + Object value = null; + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node; + Object o = mutableNode.getUserObject(); + if (o != null && o instanceof HF04NodeBean) { + HF04NodeBean bean = (HF04NodeBean) o; + switch (column) { + case 0: + value = bean.getValue(); + break; + case 1: + value = bean.getSelected(); + break; + case 2: + value = bean.getTemplate(); + break; + } + } + } + return value; + } + + /** + * 设置所有单元格都不能编辑 + * + * @param the node (i.e. row) for which editing is to be determined + * @param the column for which editing is to be determined + * @return false + */ + @Override + public boolean isCellEditable(Object node, int column) { + //if(column == 5) + //{ + return true; + //} + //else + //{ + // return false; + //} + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/TableCellCheckboxRenderer.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..ebdac5e --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_04/TableCellCheckboxRenderer.java @@ -0,0 +1,50 @@ +package com.connor.ml.tcm.ML_04; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + //private TestTreeTableModel tableModel; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + + } + + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTable.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTable.java new file mode 100644 index 0000000..1f8ece5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTable.java @@ -0,0 +1,83 @@ +package com.connor.ml.tcm.ML_05; + +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.jdesktop.swingx.JXTreeTable; + +public class JTreeTable extends JXTreeTable { + + + private List isNotEditableRow; + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + public JTreeTable(JTreeTableModel testTreeTableModel) { + // TODO Auto-generated constructor stub + super(testTreeTableModel); + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + return true;//super.isCellEditable(arg0, arg1); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + // TODO Auto-generated method stub + //if(isNotEditableRow.contains(row) && column == 2) + + return cellEditor; + //return super.getCellEditor(row, column); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + if(this.getValueAt(row, 2) != null && (this.getValueAt(row, 2).toString().equals("0") || this.getValueAt(row, 2).toString().equals("1")) && column == 2) + { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTable2.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTable2.java new file mode 100644 index 0000000..4f38730 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTable2.java @@ -0,0 +1,85 @@ +package com.connor.ml.tcm.ML_05; + +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.jdesktop.swingx.JXTreeTable; + +public class JTreeTable2 extends JXTreeTable { + + + private List isNotEditableRow; + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + //CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + public JTreeTable2(JTreeTableModel2 testTreeTableModel) { + // TODO Auto-generated constructor stub + super(testTreeTableModel); + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + return true;//super.isCellEditable(arg0, arg1); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + // TODO Auto-generated method stub + //if(isNotEditableRow.contains(row) && column == 2) + + + return cellEditor; + //return super.getCellEditor(row, column); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + if(this.getValueAt(row, 1) != null && (this.getValueAt(row, 1).toString().equals("0") || this.getValueAt(row, 1).toString().equals("1")) && column == 1) + { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTableModel.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTableModel.java new file mode 100644 index 0000000..eac3f5c --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTableModel.java @@ -0,0 +1,104 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.ML_05; + +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; + +/** + * + * @author vearn + */ +public class JTreeTableModel extends DefaultTreeTableModel { + + private String[] _names = { "订单BOM", "物料编码", "是否不同" }; + + + private List isNotEditableRow; + + + + public JTreeTableModel(TreeTableNode node) { + super(node); + } + + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + /** + * 列的数量 + */ + @Override + public int getColumnCount() { + return _names.length; + } + + /** + * 表头显示的内容 + */ + @Override + public String getColumnName(int column) { + return _names[column]; + } + + /** + * 返回在单元格中显示的Object + */ + @Override + public Object getValueAt(Object node, int column) { + Object value = null; + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node; + Object o = mutableNode.getUserObject(); + if (o != null && o instanceof NodeBean) { + NodeBean bean = (NodeBean) o; + switch (column) { + case 0: + value = bean.getMbomName(); + break; + case 1: + value = bean.getMbomId(); + break; + case 2: + value = bean.getIsHave(); + break; + } + } + } + return value; + } + + /** + * 设置所有单元格都不能编辑 + * + * @param the node (i.e. row) for which editing is to be determined + * @param the column for which editing is to be determined + * @return false + */ + @Override + public boolean isCellEditable(Object node, int column) { + //if(column == 5) + //{ + return true; + //} + //else + //{ + // return false; + //} + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTableModel2.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTableModel2.java new file mode 100644 index 0000000..e8de971 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/JTreeTableModel2.java @@ -0,0 +1,101 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.ML_05; + +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; + +/** + * + * @author vearn + */ +public class JTreeTableModel2 extends DefaultTreeTableModel { + + private String[] _names = { "订单工艺", "是否不同" }; + + + private List isNotEditableRow; + + + + public JTreeTableModel2(TreeTableNode node) { + super(node); + } + + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + /** + * 列的数量 + */ + @Override + public int getColumnCount() { + return _names.length; + } + + /** + * 表头显示的内容 + */ + @Override + public String getColumnName(int column) { + return _names[column]; + } + + /** + * 返回在单元格中显示的Object + */ + @Override + public Object getValueAt(Object node, int column) { + Object value = null; + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node; + Object o = mutableNode.getUserObject(); + if (o != null && o instanceof NodeBean) { + NodeBean bean = (NodeBean) o; + switch (column) { + case 0: + value = bean.getMbomId(); + break; + case 1: + value = bean.getIsHave(); + break; + } + } + } + return value; + } + + /** + * 设置所有单元格都不能编辑 + * + * @param the node (i.e. row) for which editing is to be determined + * @param the column for which editing is to be determined + * @return false + */ + @Override + public boolean isCellEditable(Object node, int column) { + //if(column == 5) + //{ + return true; + //} + //else + //{ + // return false; + //} + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessCommand.java new file mode 100644 index 0000000..801c7c5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessCommand.java @@ -0,0 +1,186 @@ +package com.connor.ml.tcm.ML_05; + +import java.util.ArrayList; +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.ML_04.CreateOrderProcessDialog; +import com.connor.ml.tcm.bean.NodeBean; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class OrderBOMContrastProcessCommand extends AbstractAIFCommand { + private InterfaceAIFComponent comp[]; + private TCSession session; + private DefaultMutableTreeTableNode orderBomNode = null; + private List orderBomItem = new ArrayList(); + private DefaultMutableTreeTableNode orderProcessNode = null; + private List orderProcessItem = new ArrayList(); + + public OrderBOMContrastProcessCommand(InterfaceAIFComponent[] comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + + if(this.comp.length > 0) + { + //选订单工艺 + TCComponentBOMLine orderBomLine = (TCComponentBOMLine)this.comp[0]; + //获取版本制造目标下的订单BOM + TCComponent[] orderBoms = orderBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget"); + if(orderBoms.length > 0) + { + TCComponentItemRevision orderBomItemRevision = (TCComponentItemRevision) orderBoms[0]; + + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + TCComponentBOMLine orderProcessLine = bomWindow.setWindowTopLine(orderBomItemRevision.getItem(), orderBomItemRevision, null, null); + + this.orderBomNode = getBomPropertyToNode(session, orderProcessLine, null); + + this.orderProcessNode = getBomPropertyToNode(session, orderBomLine, null); + } + + new Thread() { + @Override + public void run() { + OrderBOMContrastProcessDialog dialog = new OrderBOMContrastProcessDialog(session,orderBomNode,orderProcessNode,orderBomItem,orderProcessItem); + } + }.start(); + + } + else + { + MessageBox.post("请选中订单工艺BOM对象!", "错误", MessageBox.ERROR); + } + + super.executeModal(); + } + + /** + * 获取BOM属性 + * @throws Exception + */ + public DefaultMutableTreeTableNode getBomPropertyToNode(TCSession session, TCComponentBOMLine topBomLine,String orderName) throws Exception { + // TODO Auto-generated method stub + + NodeBean nodeBean = new NodeBean(); + + //String ss = subline.getStringProperty("bl_indented_title"); + //对象ID + nodeBean.setEbom("顶层"); + nodeBean.setRefreshStatus(""); + nodeBean.setProjectTeam(""); + nodeBean.setNum(""); + nodeBean.setMbomId(""); + nodeBean.setMbomName(""); + nodeBean.setIsHave("0"); + DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); + //获取BOM + try { + getBomPropertysToNode(topBomLine, rootNode, "",orderName); + return rootNode; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + //return null; + } + + /** + * 获取BOM信息 + * @param bomLine + * @param bomPropertyList + * @param parentID + * @throws Exception + */ + public void getBomPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID,String orderName) throws Exception + { + try { + + if(bomLine.getItem().getStringProperty("object_type").compareTo("ML8_OrdItem") == 0) + { + NodeBean nodeBean = new NodeBean(); + nodeBean.setMbomName(bomLine.getStringProperty("bl_item_object_string")); + String itemId = bomLine.getItemRevision().getStringProperty("ml8_MaterialNo"); + orderBomItem.add(itemId); + nodeBean.setIsHave("0"); + nodeBean.setMbomId(itemId); + nodeBean.setItem(bomLine.getItem()); + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean); + rootNode.add(node); + if(bomLine.getChildren().length > 0) + { + AIFComponentContext aif[] = bomLine.getChildren(); + for (int i = 0; i < aif.length; i++) + { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + + getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id"),""); + } + } + } + else if(bomLine.getStringProperty("bl_occ_type").compareTo("MEConsumed") == 0) + { + NodeBean nodeBean = new NodeBean(); + //nodeBean.setMbomName(bomLine.getStringProperty("bl_item_object_string")); + String itemId = bomLine.getItemRevision().getStringProperty("item_id"); + if(itemId.indexOf("-") > 0) + { + itemId = itemId.split("-")[0]; + } + orderProcessItem.add(itemId); + nodeBean.setMbomId(itemId); + nodeBean.setIsHave("0"); + nodeBean.setItem(bomLine.getItem()); + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean); + rootNode.add(node); + if(bomLine.getChildren().length > 0) + { + AIFComponentContext aif[] = bomLine.getChildren(); + for (int i = 0; i < aif.length; i++) + { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + + getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id"),""); + } + } + } + else + { + if(bomLine.getChildren().length > 0) + { + AIFComponentContext aif[] = bomLine.getChildren(); + for (int i = 0; i < aif.length; i++) + { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + + getBomPropertysToNode(subline, rootNode,bomLine.getStringProperty("bl_item_item_id"),""); + } + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + throw new Exception(e.getMessage()); + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessDialog.java new file mode 100644 index 0000000..5695573 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessDialog.java @@ -0,0 +1,289 @@ +package com.connor.ml.tcm.ML_05; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; + +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; +import com.connor.ml.tcm.util.Adapter; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; + +public class OrderBOMContrastProcessDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + + private List isNotEditableRow = new ArrayList(); + private DefaultMutableTreeTableNode orderBomNode; + private DefaultMutableTreeTableNode orderProcessNode; + private List orderBomItem = new ArrayList(); + private List orderProcessItem = new ArrayList(); + + private String[] header = new String[] { "订单BOM", "物料编码", "是否不同" }; + private String[] header2 = new String[] { "订单工艺", "是否不同" }; + + private JPanel titlePanel; + private JLabel titleLabel; + private JTreeTable table; + private JTreeTableModel map; + private JTreeTable2 table2; + private JTreeTableModel2 map2; + + private JPanel rootPanel; + private JButton contrastButton; + private JButton nContrastButton; + + public OrderBOMContrastProcessDialog(TCSession session, DefaultMutableTreeTableNode orderBomNode, DefaultMutableTreeTableNode orderProcessNode,List orderBomItem,List orderProcessItem) { + // TODO Auto-generated constructor stub + this.session = session; + this.orderBomNode = orderBomNode; + this.orderProcessNode = orderProcessNode; + this.orderBomItem = orderBomItem; + this.orderProcessItem = orderProcessItem; + + init(); + } + + + private void init() { + // TODO Auto-generated method stub + this.setTitle("订单工艺对比"); + this.setPreferredSize(new Dimension(800, 600)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("订单工艺对比"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + JPanel panel = new JPanel(); + panel.add(this.titlePanel, BorderLayout.NORTH); + + this.table = getJTreeTable(null, null, header, null); + this.table2 = getJTreeTable2(null, null, header2, null); + + + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// 让分割线显示出箭头 + splitPane.setContinuousLayout(true);// 操作箭头,重绘图形 + splitPane.setLeftComponent(new JScrollPane(this.table)); + splitPane.setRightComponent(new JScrollPane(this.table2)); + + Adapter adapter = new Adapter(table); + Adapter adapter2 = new Adapter(table2); + + this.rootPanel = new JPanel(new FlowLayout()); + this.contrastButton = new JButton("对比"); + this.nContrastButton = new JButton("取消对比"); + + this.rootPanel.add(contrastButton); + this.rootPanel.add(nContrastButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(panel, BorderLayout.NORTH); + this.add(splitPane, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + + // 添加监听 + public void createActionEvent() { + this.contrastButton.addActionListener(this); + this.nContrastButton.addActionListener(this); + } + + // Jtable通用方法 + public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames, + Object[][] values) { + int simpleLen = 100; + int totleLen = 1500; + if (partsTable == null) { + this.map = new JTreeTableModel(this.orderBomNode); + this.map.setIsNotEditableRow(this.isNotEditableRow); + // map.setColumnIdentifiers(titleNames); + + partsTable = new JTreeTable(map); +// partsTable.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { +// +// 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); +// if(table.getValueAt(row, 2) != null && table.getValueAt(row, 2).toString().compareTo("1") == 0) { +// c.setBackground(Color.red); +// } +// else +// { +// c.setBackground(Color.white); +// } +// return c; +// } +// }); + partsTable.setIsNotEditableRow(this.isNotEditableRow); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(30); + partsTable.expandAll(); // 展开全部节点 + // 隐藏列 +// partsTable.HiddenCell(0); + + partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // 设置第一列宽度 + partsTable.getColumnModel().getColumn(1).setPreferredWidth(100); // 设置第二列宽度 + + partsTable.setHighlighters(HighlighterFactory.createSimpleStriping()); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + // Jtable通用方法 + public JTreeTable2 getJTreeTable2(JTreeTable2 partsTable, DefaultTableModel dtm, Object[] titleNames, + Object[][] values) { + int simpleLen = 100; + int totleLen = 1500; + if (partsTable == null) { + this.map2 = new JTreeTableModel2(this.orderProcessNode); + this.map2.setIsNotEditableRow(this.isNotEditableRow); + // map.setColumnIdentifiers(titleNames); + + partsTable = new JTreeTable2(map2); +// partsTable.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { +// +// 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); +// if(table.getValueAt(row, 1) != null && table.getValueAt(row, 1).toString().compareTo("1") == 0) { +// c.setBackground(Color.red); +// } +// else +// { +// c.setBackground(Color.white); +// } +// return c; +// } +// }); + partsTable.setIsNotEditableRow(this.isNotEditableRow); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(30); + partsTable.expandAll(); // 展开全部节点 + // 隐藏列 +// partsTable.HiddenCell(0); + + partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // 设置第一列宽度 + partsTable.getColumnModel().getColumn(1).setPreferredWidth(100); // 设置第二列宽度 + + partsTable.setHighlighters(HighlighterFactory.createSimpleStriping()); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.contrastButton)) { + //对比是否更改 +// List bomItemIdList = this.orderBomItem; +// bomItemIdList.removeAll(orderProcessItem); +// for (int i = 0; i < orderBomItem.size(); i++) { +// System.out.println(orderBomItem.get(i)); +// } +// List processItemIdList = this.orderProcessItem; +// processItemIdList.removeAll(this.orderBomItem); + + setSelect(this.orderBomNode,orderProcessItem); + setSelect(this.orderProcessNode,orderBomItem); + + this.table.invalidate(); + this.table2.invalidate(); + this.table.selectAll(); + this.table2.selectAll(); + + } + else if (source.equals(this.nContrastButton)) { + + setSelect(this.orderBomNode,"0"); + setSelect(this.orderProcessNode,"0"); + + this.table.invalidate(); + this.table2.invalidate(); + this.table.selectAll(); + this.table2.selectAll(); + } + } + + private void setSelect(DefaultMutableTreeTableNode node,List processItemIdList) + { + NodeBean nodeBean = (NodeBean) node.getUserObject(); + if(!processItemIdList.contains(nodeBean.getMbomId())) + { + nodeBean.setIsHave("1"); + } + if(node.getChildCount() > 0) + { + for (int i = 0; i < node.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) node.getChildAt(i); + setSelect(childNode,processItemIdList); + } + } + } + + private void setSelect(DefaultMutableTreeTableNode node,String select) + { + NodeBean nodeBean = (NodeBean) node.getUserObject(); + nodeBean.setIsHave(select); + if(node.getChildCount() > 0) + { + for (int i = 0; i < node.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) node.getChildAt(i); + setSelect(childNode,select); + } + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessHandler.java new file mode 100644 index 0000000..fb5fda8 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/OrderBOMContrastProcessHandler.java @@ -0,0 +1,30 @@ +package com.connor.ml.tcm.ML_05; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.ML_04.CreateOrderProcessCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class OrderBOMContrastProcessHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String id = AIFUtility.getCurrentPerspectiveDef().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + OrderBOMContrastProcessCommand command = new OrderBOMContrastProcessCommand(app.getTargetComponents(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/TableCellCheckboxRenderer.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..eecc181 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_05/TableCellCheckboxRenderer.java @@ -0,0 +1,75 @@ +package com.connor.ml.tcm.ML_05; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + //private TestTreeTableModel tableModel; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + + } + + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + public TableCellCheckboxRenderer(final JTreeTable2 jTreeTable2) { + // TODO Auto-generated constructor stub + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + + if(value != null) + { +// if(value.toString().equals("1")) +// { +// if(table.getColumnName(column).equals("改制") && hasFocus) +// { +// if(table.getValueAt(row, column + 1).toString().equals("1")) +// { +// table.setValueAt(0, row, column + 1); +// } +// } +// else if(table.getColumnName(column).equals("删除") && hasFocus) +// { +// if(table.getValueAt(row, column - 1).toString().equals("1")) +// { +// table.setValueAt(0, row, column - 1); +// } +// } +// } +// if(value.toString().equals("1")) +// { +// System.out.println(value.toString().equals("1") + "===="); +// } + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_06/SendBomToSAPCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_06/SendBomToSAPCommand.java new file mode 100644 index 0000000..c72f602 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_06/SendBomToSAPCommand.java @@ -0,0 +1,54 @@ +package com.connor.ml.tcm.ML_06; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class SendBomToSAPCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + + public SendBomToSAPCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //判断选中的是否为BOMLine + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + TCComponentItemRevision itemRevision = ((TCComponentBOMLine)comp).getItemRevision(); + //判断选中的对象类型 + String itemType = itemRevision.getStringProperty("object_type"); + if(itemType.compareTo("ML8_RefrigeratorRevision") != 0 + && itemType.compareTo("ML8_WashingRevision") != 0 + && itemType.compareTo("ML8_ColdRevision") != 0 + && itemType.compareTo("ML8_OthersRevision") != 0 + && itemType.compareTo("ML8_PartRevision") != 0 + && itemType.compareTo("ML8_RawMaterialRevision") != 0) + { + MessageBox.post("请选中冰箱柜、零部件、原辅材料对象!", "错误", MessageBox.ERROR); + return; + } + + //调用用户函数发送到SAP + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[2]; + obj[0] = itemRevision; + obj[1] = session.getUser().getUserId(); + userservice.call("ML_TCMUserSendSapBom", obj); + MessageBox.post("已发送到SAP!", "成功", MessageBox.INFORMATION); + super.executeModal(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_06/SendBomToSAPHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_06/SendBomToSAPHandler.java new file mode 100644 index 0000000..d741157 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_06/SendBomToSAPHandler.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ML_06; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.ML_05.OrderBOMContrastProcessCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class SendBomToSAPHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + SendBomToSAPCommand command = new SendBomToSAPCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTMap.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTMap.java new file mode 100644 index 0000000..f501508 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTMap.java @@ -0,0 +1,340 @@ +package com.connor.ml.tcm.ML_07; + +import java.awt.Dimension; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.swing.event.TableModelEvent; +import javax.swing.table.DefaultTableModel; + +public class CTMap extends DefaultTableModel implements CellSpan { + /** + * + */ + private static final long serialVersionUID = 1L; + protected int rowSize; + protected int columnSize; + protected int[][][] span; // CellSpan + protected boolean isEditable = true; + private List processRowList; + private Map> labelRows;//标注行 + private int row = -1; + private int column = -1; + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector<>(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector<>(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + public CTMap(int numColumns) { + Vector names = new Vector<>(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector<>(); +// setNumRows(numRows); +// setSize(new Dimension(numColumns, numRows)); + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // Auto-generated method stub + if (processRowList != null && processRowList.size() > 0) { + if (!processRowList.contains(arg0) || arg1 == 1 || arg1 == 2) { + return false; + } else { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + } else { + return true; + } + } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + //将标注行减1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null && listRow == row) { + labelRowList.remove(i); + } else if (labelRowList.get(i) != null && listRow > row) { + labelRowList.set(i, ((Integer)(listRow-1)).toString()); + } + } + } + super.removeRow(row); + } + + @Override + public int[] getSpan(int row, int column) { + // Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if (span[row][column][CellSpan.COLUMN] < 1 || span[row][column][CellSpan.ROW] < 1) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if (span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1 || span[startRow + i][startColumn + j][CellSpan.ROW] != 1) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) { + return true; + } + return false; + } + + @SuppressWarnings("unchecked") + public void addRow() { + + Vector newData = new Vector<>(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, getRowCount() - 1, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + @SuppressWarnings("rawtypes") + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + @SuppressWarnings("unchecked") + public void insertRow(int row) { + Vector rowData = new Vector<>(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); +// System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + +// int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } + } + span = newSpan; + rowSize = span.length;// 将可修改的行+1 + if (processRowList != null && processRowList.size() > 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) && processRowList.get(i) != null && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + } + //将标注行+1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null && i > index && listRow >= row) { + labelRowList.set(i, ((Integer)(listRow + 1)).toString()); + } + } + } + + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + @SuppressWarnings("rawtypes") + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size() - 1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount() - 1; i++) { + + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTUI.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTUI.java new file mode 100644 index 0000000..38ab838 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTUI.java @@ -0,0 +1,96 @@ +package com.connor.ml.tcm.ML_07; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c) { + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = ((CTable) table).getColumnModel() + .getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = ((CTable) table) + .rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = ((CTable) table).getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, + ((CTable) table).getRowHeight() + + ((CTable) table).getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) ((CTable) table).getModel(); + int numColumns = ((CTable) table).getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = ((CTable) table).getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = ((CTable) table).getRowMargin(); + int spacingWidth = ((CTable) table).getColumnModel().getColumnMargin(); + // System.out.println("X:"+cellRect.x+"Y:"+cellRect.y); + Color c = g.getColor(); + g.setColor(((CTable) table).getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + spacingHeight / 2, cellRect.width - spacingWidth, cellRect.height - spacingHeight); + + if (((CTable) table).isEditing() && ((CTable) table).getEditingRow() == row && ((CTable) table).getEditingColumn() == column) { + Component component = ((CTable) table).getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = ((CTable) table).getCellRenderer(row, column); + Component component = ((CTable) table).prepareRenderer(renderer, row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, ((CTable) table), cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); + } + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTable.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTable.java new file mode 100644 index 0000000..abbe6eb --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/CTable.java @@ -0,0 +1,288 @@ +package com.connor.ml.tcm.ML_07; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CTable extends JTable { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String[] types = MethodUtil.getProcessType(); + private String[] lovs = getLOV("ML8_Factory_LOV"); + Map map; +// HashMap lovMap; + private ArrayList excelMap = null; + private String sql; + + public CTable(TableModel model, ArrayList excelMap) { + super(model); + this.excelMap = excelMap; + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + map = new HashMap<>(); + + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + sql = pro.getProperty("ML_TCMPROCESSSELECTSQL2"); + } catch (Exception e2) { + MessageBox.post("错误:"+e2.getMessage(), "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + } + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + // @Override + // protected void processKeyEvent(KeyEvent keyevent) { + // // Auto-generated method stub + // if(keyevent.getKeyCode()==KeyEvent.VK_ENTER){ + // if(keyevent.isControlDown()) + // { + // System.out.println(1); + // } + // this.editCellAt(this.getSelectedRow(),this.getSelectedColumn()); + // } + // } + + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if (row < 0 || column < 0 || getRowCount() <= row || getColumnCount() <= column) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth(); + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + + spacing.height / 2, cellFrame.width - spacing.width, + cellFrame.height - spacing.height); + } + return cellFrame; + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); + } + + public void setCombo(int row, int col, TableCellEditor ce) { + map.put(new Point(row, col), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + if (this.getColumnName(column).equals("类型")) { +// if(typeComboBoxCellEditor.getSelectedIndex() > -1) { +// groupComboBoxCellEditor.removeAllItems(); +// String[] groups = MethodUtil.getProcessGroup(typeComboBoxCellEditor.getSelectedItem().toString()); +// for (int i = 0; i < groups.length; i++) { +// groupComboBoxCellEditor.addItem(groups[i]); +// } +// } +// return typeComboBoxCellEditor; + CTMap model = (CTMap) getModel(); + ComboBoxCellEditor cellEditer = new ComboBoxCellEditor(this, model, excelMap, sql, row, column, types); + return cellEditer; + } else if(this.getColumnName(column).equals("组名")) {//TODO + CTMap model = (CTMap) getModel(); + ComboBoxCellEditor cellEditer = new ComboBoxCellEditor(this, model, excelMap, sql, row, column, MethodUtil.getProcessGroup(model.getValueAt(row, 0).toString())); + return cellEditer; + } else if(this.getColumnName(column).equals("工厂")) { +// System.out.println("工厂:"+getValueAt(row, column)); + CTMap model = (CTMap) getModel(); + ComboBoxCellEditor cellEditer = new ComboBoxCellEditor(this, model, excelMap, sql, row, column, lovs); + return cellEditer; + } else { + return super.getCellEditor(row, column); + } + } + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // Auto-generated method stub + return super.getCellRenderer(row, column); + } + @Override + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + public void selectAllOrNull(String value){ + // Select All. The last column + for(int index = 0; index < getRowCount(); index ++){ + this.setValueAt(value, index, this.getColumnCount() - 3); + } + } + + @Override + public boolean isCellEditable(int row, int column) { + if(column==0 || column==1 || column==4 || column==5 || column==7 || column==8 || column==9 || column==11 || column==12 || column==13 || column==14 + || column==16 || column==18 || column==20 || column==22) + return true; + return false; + } + + private String[] getLOV(String name) { + try { + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType)session.getTypeComponent("ListOfValues"); + ListOfValuesInfo lov = lovType.find(name)[0].getListOfValues(); +// String[] dv = lov.getLOVDisplayValues(); + String[] rv = lov.getStringListOfValues(); +// for(int i=0; i implements TableCellEditor { + + /** + * + */ + private static final long serialVersionUID = 1L; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + + + public ComboBoxCellEditor(Object[] itmes) { + super(); + addItem(""); + for (int i = 0; i < itmes.length; i++) { + addItem(itmes[i]); + } + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + public ComboBoxCellEditor(JTable table, DefaultTableModel model, ArrayList excelMap, String sql, int row, int col) {//TODO 生产版本 + super(); +// for (int i = 0; i < itmes.length; i++) { +// addItem(itmes[i]); +// } + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent arg0) { + try { +// int row = table.getSelectedRow(); +// System.out.println("row:"+row); +// if(row<0) +// row = 0; + if(getSelectedIndex()<0) { + return; + } + String fac = "", group = ""; + if(col==0) { + fac = table.getValueAt(row, 3).toString(); + group = getSelectedItem().toString(); + }else if(col==3) { + group = table.getValueAt(row, 0).toString(); + fac = getSelectedItem().toString(); + } + if(group.isEmpty() || fac.isEmpty()) + return; + String id = table.getValueAt(row, 1).toString(); + String bom = table.getValueAt(row, 8).toString(); + ArrayList boms = new ArrayList<>(); + boms.add(bom); + for (int i = table.getRowCount() - 1; i >= 0; i--) { + String b = table.getValueAt(i, 8).toString(); + if (i != row && id.equals(table.getValueAt(i, 1).toString())) + if (!boms.contains(b)) { + boms.add(b); + } else { + model.removeRow(i); + } + } + for(String rev : boms) { + int fr = row; + for(int i=0; i rowList = new Vector<>(); + rowList.add(group);//组名 + rowList.add(id);//物料代码 + rowList.add(model.getValueAt(fr, 2).toString());//物料描述 + rowList.add(fac);//工厂 + rowList.add(prorev + rev);//生产版本号 + rowList.add(excels[7]);//版本描述 + rowList.add(excels[8]);//有效期始"20220101" + rowList.add("99991231");//有效期止 +// rowList.add(excels[0].substring(excels[0].length()-2));//可选BOM + rowList.add(rev);//可选BOM + rowList.add(model.getValueAt(fr, 9).toString());//BOM用途 + rowList.add(model.getValueAt(fr, 10).toString());//工艺路线组 + rowList.add(excels[4]);//组计数器 + rowList.add(excels[3]);//工作中心 + rowList.add(excels[5]);//接收位置 + rowList.add(excels[6]);//发货仓储地点 + rowList.add(model.getValueAt(fr, 15).toString());//处理标记 + System.out.println("插入数据"); + model.insertRow(fr + i++, rowList);// +(i++) +// model.fireTableDataChanged(); +// model.fireTableStructureChanged(); +// table.setModel(model); +// table.validate(); +// table.updateUI(); +// JViewport viewport = (JViewport)table.getParent(); +// // 滚动到最后一行 +// table.scrollRectToVisible(table.getCellRect(fr +(i++), 0, true)); +// // 设置视口位置 +// viewport.setViewPosition(new Point(0, table.getHeight())); +// model.insertRow(fr +(i++), new Object[] { "", id, fac, excels[0], "", "", "", "", "", "", "", "", "", "", "" });// +(i++) +// model.addRow(rowList);// +(i++) +// model.addRow(new Object[] { "", id, fac, excels[0], "", "", "", "", "", "", "", "", "", "", "" }); + repaint(); + } + if(first) { + MessageBox.post("工艺路线数据源表中未找到对应的工厂与产品组", "错误", MessageBox.ERROR); + } + } + if(col == 0 || col == 3) { + String processGroup = ""; + ResultSet rs = null; + try { + String selectSql = String.format(sql, id, fac); + System.out.println("selectSql:"+selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + + if (rs != null) { + System.out.println("rs!=null"); + while (rs.next()) { + processGroup = rs.getString("PLNNR"); + System.out.println("processGroup"+processGroup); + break; + } + } + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + DbPool.freeAll(); + } + + } + }catch(Exception e) { + e.printStackTrace(); + } + } + }); + } + + public ComboBoxCellEditor(JTable table, CTMap model, ArrayList excelMap, String sql, int row, int col, String[] values) {//TODO CTable + super(); + addItem(""); + for(String s : values) { + addItem(s); + } + Object value = model.getValueAt(row, col); + System.out.println(col+"=="+value); + if(value!=null && !value.toString().isEmpty()) { + if(!getItemAt(getSelectedIndex()).equals(value)) { + for(int i=0; i>"+getSelectedIndex()); + break; + } + } + } + }else + setSelectedIndex(-1); +// System.out.println(col+">>"+getSelectedIndex()); + + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent arg0) { + Object val = model.getValueAt(row, col); + System.out.println(table.getSelectedColumn()+">>"+col+":"+arg0.getItem()+"=="+getSelectedItem()+"=="+val); + if(table.getSelectedColumn() != col) + return; + if(getSelectedIndex()<0 || getSelectedItem()==null)// || val.toString().isEmpty() + return; + Object select = getSelectedItem(); + if(arg0.getItem().equals(select) && select.equals(model.getValueAt(row, col))) + return; + if(col==0) { + ComboBoxCellEditor group = (ComboBoxCellEditor) table.getCellEditor(row, 1); + group.removeAllItems(); + String[] groups = MethodUtil.getProcessGroup(select.toString()); + for (int i = 0; i < groups.length; i++) { + group.addItem(groups[i]); + } + group.setSelectedIndex(-1); + model.setValueAt("", row, 1); + model.setValueAt("", row, 6); + model.setValueAt("", row, 10); + model.setValueAt("", row, 12); + System.out.println("插入数据3"); +// model.fireTableDataChanged(); +// model.fireTableStructureChanged(); +// table.setModel(model); +// table.validate(); + //table.updateUI(); + JViewport viewport = (JViewport)table.getParent(); + // 滚动到最后一行 + table.scrollRectToVisible(table.getCellRect(row, 0, true)); + // 设置视口位置 + viewport.setViewPosition(new Point(0, table.getHeight())); + String id = model.getValueAt(row, 2).toString(); + for(int i=model.getRowCount()-1; i>=0; i--) { + if(i!=row && id.equals(model.getValueAt(i, 2).toString())) + model.removeRow(i); + + } + return; + } + String group = "", fac = ""; + if(col == 1) { + fac = model.getValueAt(row, 4).toString(); + group = getSelectedItem().toString(); + }else if(col == 4) { + group = model.getValueAt(row, 1).toString(); + fac = getSelectedItem().toString(); + } + if(fac.isEmpty() || group.isEmpty()) + return; +// System.out.println(arg0.getItem()+">>"+group+"++"+fac); + String id = model.getValueAt(row, 2).toString(); + for(int i=model.getRowCount()-1; i>=0; i--) { + if(i!=row && id.equals(model.getValueAt(i, 2).toString())) + model.removeRow(i); + + } + int fr = row; + for(int i=0; i check = new ArrayList<>(); + for(String[] excels : excelMap) { +// System.out.println(group+"=="+excels[0]+"=="+excels[1]); + if(!fac.equals(excels[0]) || !group.equals(excels[1])) + continue; + if(check.contains(excels[3])) + continue; + check.add(excels[3]); + if(first) { + first = false; +// model.setValueAt("", fr, 5);//关键日期5 + model.setValueAt(excels[3], fr, 6);//组计数器6 +// model.setValueAt("", fr, 7);//用途7 +// model.setValueAt("", fr, 8);//状态8 +// model.setValueAt("", fr, 9);//工序9 + model.setValueAt(excels[2], fr, 10);//工作中心10 +// model.setValueAt("", fr, 11);//控制代码11 + model.setValueAt(excels[4], fr, 12);//工序描述12 +// model.setValueAt("", fr, 13);//基本数量13 + model.setValueAt("", fr, 14);//工时14 + model.setValueAt("", fr, 16);//固定制造费用16 + model.setValueAt("", fr, 18);//动力费用18 + model.setValueAt("", fr, 20);//其他制造费用20 + model.setValueAt("", fr, 22);//排产准备时间22 + model.setValueAt(processGroup, fr, 24);//工艺路线组24 +// model.fireTableDataChanged(); +// System.out.println("插入数据4"); +// model.fireTableStructureChanged(); +// table.setModel(model); +// table.validate(); + //table.updateUI(); + JViewport viewport = (JViewport)table.getParent(); + // 滚动到最后一行 + table.scrollRectToVisible(table.getCellRect(fr, 0, true)); + // 设置视口位置 + viewport.setViewPosition(new Point(0, table.getHeight())); + continue; + } + Vector valuesList = new Vector<>(); + valuesList.add(model.getValueAt(fr, 0).toString());//类型0 + valuesList.add(group);//组名1 + valuesList.add(id);//物料编码2 + valuesList.add(model.getValueAt(fr, 3).toString());//物料描述3 + valuesList.add(fac);//工厂4 + valuesList.add(excels[5]);//关键日期5 "20220101" + valuesList.add(excels[3]);//组计数器6 + valuesList.add("1");//用途7 + valuesList.add("4");//状态8 + valuesList.add("10");//工序9 + valuesList.add(excels[2]);//工作中心10 + valuesList.add("PP03");//控制代码11 + valuesList.add(excels[4]);//工序描述12 + valuesList.add("1");//基本数量13 + valuesList.add("");//工时14 + valuesList.add("H");//工时单位15 + valuesList.add("");//固定制造费用16 + valuesList.add("H");//时间单位17 + valuesList.add("");//动力费用18 + valuesList.add("H");//时间单位19 + valuesList.add("");//其他制造费用20 + valuesList.add("H");//时间单位21 + valuesList.add("");//排产准备时间22 + valuesList.add("H");//时间单位23 +// valuesList.add(model.getValueAt(fr, 24).toString());//工艺路线组24 + valuesList.add(processGroup);//工艺路线组24 + valuesList.add("I");//处理标记25 + valuesList.add(model.getValueAt(fr, 26).toString());//对象UID26 + +// System.out.println("insertRow:"+(fr + i)); + model.insertRow(fr + i);//fr +(i++) + for(int j=0; j 99999){ + counter = 0; + } + counter = counter + 1; + return Long.toString(System.currentTimeMillis()) + "_" + counter; + } + + + private void populateAxisService() throws org.apache.axis2.AxisFault { + + //creating the Service with a unique name + _service = new org.apache.axis2.description.AxisService("SI_TCM2SAP_CA21_OUTService" + getUniqueSuffix()); + addAnonymousOperations(); + + //creating the operations + org.apache.axis2.description.AxisOperation __operation; + + _operations = new org.apache.axis2.description.AxisOperation[1]; + + __operation = new org.apache.axis2.description.OutInAxisOperation(); + + + __operation.setName(new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc", "SI_TCM2SAP_CA21_OUT")); + _service.addOperation(__operation); + + + + + _operations[0]=__operation; + + + } + + //populates the faults + private void populateFaults(){ + + + + } + + /** + *Constructor that takes in a configContext + */ + + public SI_TCM2SAP_CA21_OUTServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext, + java.lang.String targetEndpoint) + throws org.apache.axis2.AxisFault { + this(configurationContext,targetEndpoint,false); + } + + + /** + * Constructor that takes in a configContext and useseperate listner + */ + public SI_TCM2SAP_CA21_OUTServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext, + java.lang.String targetEndpoint, boolean useSeparateListener) + throws org.apache.axis2.AxisFault { + //To populate AxisService + populateAxisService(); + populateFaults(); + + _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service); + + + configurationContext = _serviceClient.getServiceContext().getConfigurationContext(); + + _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference( + targetEndpoint)); + _serviceClient.getOptions().setUseSeparateListener(useSeparateListener); + + + } + + /** + * Default Constructor + */ + public SI_TCM2SAP_CA21_OUTServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext) throws org.apache.axis2.AxisFault { + this(configurationContext,"http://xiprd.changhong.com:58000/dir/wsdl?p=ic/38143cf350a436a388bbba94bd81b36f"); +// this(configurationContext,"http://10.3.1.25:52000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_TCM&receiverParty=&receiverService=&interface=SI_TCM2SAP_CA21_OUT&interfaceNamespace=urn%3Achanghong.com%3ATCM%3Amlsc" ); + + } + + /** + * Default Constructor + */ + public SI_TCM2SAP_CA21_OUTServiceStub() throws org.apache.axis2.AxisFault { + this("http://xiprd.changhong.com:58000/dir/wsdl?p=ic/38143cf350a436a388bbba94bd81b36f"); +// this("http://10.3.1.25:52000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_TCM&receiverParty=&receiverService=&interface=SI_TCM2SAP_CA21_OUT&interfaceNamespace=urn%3Achanghong.com%3ATCM%3Amlsc" ); + + } + + /** + * Constructor taking the target endpoint + */ + public SI_TCM2SAP_CA21_OUTServiceStub(java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { + this(null,targetEndpoint); + } + + + + + /** + * Auto generated method signature + * + * @see mlsc.tcm.com.changhong.SI_TCM2SAP_CA21_OUTService#SI_TCM2SAP_CA21_OUT + * @param mT_TCM2SAP_CA210 + + */ + + + + public SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21 SI_TCM2SAP_CA21_OUT( + + SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21 mT_TCM2SAP_CA210) + + + throws java.rmi.RemoteException + + { + org.apache.axis2.context.MessageContext _messageContext = null; + try{ + org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); + _operationClient.getOptions().setAction("http://sap.com/xi/WebService/soap1.1"); + _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); + + + + addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&"); + + + // create a message context + _messageContext = new org.apache.axis2.context.MessageContext(); + + + + // create SOAP envelope with that payload + org.apache.axiom.soap.SOAPEnvelope env = null; + + + env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), + mT_TCM2SAP_CA210, + optimizeContent(new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc", + "SI_TCM2SAP_CA21_OUT"))); + + //adding SOAP soap_headers + _serviceClient.addHeadersToEnvelope(env); + // set the message context with that soap envelope + _messageContext.setEnvelope(env); + + // add the message contxt to the operation client + _operationClient.addMessageContext(_messageContext); + + //execute the operation client + _operationClient.execute(true); + + + org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext( + org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); + org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); + + + java.lang.Object object = fromOM( + _returnEnv.getBody().getFirstElement() , + SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21.class, + getEnvelopeNamespaces(_returnEnv)); + + + return (SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21)object; + + }catch(org.apache.axis2.AxisFault f){ + + org.apache.axiom.om.OMElement faultElt = f.getDetail(); + if (faultElt!=null){ + if (faultExceptionNameMap.containsKey(faultElt.getQName())){ + //make the fault by reflection + try{ + java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName()); + java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); + java.lang.Exception ex= + (java.lang.Exception) exceptionClass.newInstance(); + //message class + java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName()); + java.lang.Class messageClass = java.lang.Class.forName(messageClassName); + java.lang.Object messageObject = fromOM(faultElt,messageClass,null); + java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", + new java.lang.Class[]{messageClass}); + m.invoke(ex,new java.lang.Object[]{messageObject}); + + + throw new java.rmi.RemoteException(ex.getMessage(), ex); + }catch(java.lang.ClassCastException e){ + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.ClassNotFoundException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + }catch (java.lang.NoSuchMethodException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.reflect.InvocationTargetException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.IllegalAccessException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.InstantiationException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } + }else{ + throw f; + } + }else{ + throw f; + } + } finally { + _messageContext.getTransportOut().getSender().cleanup(_messageContext); + } + } + + /** + * Auto generated method signature for Asynchronous Invocations + * + * @see mlsc.tcm.com.changhong.SI_TCM2SAP_CA21_OUTService#startSI_TCM2SAP_CA21_OUT + * @param mT_TCM2SAP_CA210 + + */ + public void startSI_TCM2SAP_CA21_OUT( + + SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21 mT_TCM2SAP_CA210, + + final SI_TCM2SAP_CA21_OUTServiceCallbackHandler callback) + + throws java.rmi.RemoteException{ + + org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); + _operationClient.getOptions().setAction("http://sap.com/xi/WebService/soap1.1"); + _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); + + + + addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&"); + + + + // create SOAP envelope with that payload + org.apache.axiom.soap.SOAPEnvelope env=null; + final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); + + + //Style is Doc. + + + env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), + mT_TCM2SAP_CA210, + optimizeContent(new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc", + "SI_TCM2SAP_CA21_OUT"))); + + // adding SOAP soap_headers + _serviceClient.addHeadersToEnvelope(env); + // create message context with that soap envelope + _messageContext.setEnvelope(env); + + // add the message context to the operation client + _operationClient.addMessageContext(_messageContext); + + + + _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() { + public void onMessage(org.apache.axis2.context.MessageContext resultContext) { + try { + org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope(); + + java.lang.Object object = fromOM(resultEnv.getBody().getFirstElement(), + SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21.class, + getEnvelopeNamespaces(resultEnv)); + callback.receiveResultSI_TCM2SAP_CA21_OUT( + (SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21)object); + + } catch (org.apache.axis2.AxisFault e) { + callback.receiveErrorSI_TCM2SAP_CA21_OUT(e); + } + } + + public void onError(java.lang.Exception error) { + if (error instanceof org.apache.axis2.AxisFault) { + org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault) error; + org.apache.axiom.om.OMElement faultElt = f.getDetail(); + if (faultElt!=null){ + if (faultExceptionNameMap.containsKey(faultElt.getQName())){ + //make the fault by reflection + try{ + java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName()); + java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); + java.lang.Exception ex= + (java.lang.Exception) exceptionClass.newInstance(); + //message class + java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName()); + java.lang.Class messageClass = java.lang.Class.forName(messageClassName); + java.lang.Object messageObject = fromOM(faultElt,messageClass,null); + java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", + new java.lang.Class[]{messageClass}); + m.invoke(ex,new java.lang.Object[]{messageObject}); + + + callback.receiveErrorSI_TCM2SAP_CA21_OUT(new java.rmi.RemoteException(ex.getMessage(), ex)); + } catch(java.lang.ClassCastException e){ + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } catch (java.lang.ClassNotFoundException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } catch (java.lang.NoSuchMethodException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } catch (java.lang.reflect.InvocationTargetException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } catch (java.lang.IllegalAccessException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } catch (java.lang.InstantiationException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } catch (org.apache.axis2.AxisFault e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_CA21_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_CA21_OUT(error); + } + } + + public void onFault(org.apache.axis2.context.MessageContext faultContext) { + org.apache.axis2.AxisFault fault = org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(faultContext); + onError(fault); + } + + public void onComplete() { + try { + _messageContext.getTransportOut().getSender().cleanup(_messageContext); + } catch (org.apache.axis2.AxisFault axisFault) { + callback.receiveErrorSI_TCM2SAP_CA21_OUT(axisFault); + } + } + }); + + + org.apache.axis2.util.CallbackReceiver _callbackReceiver = null; + if ( _operations[0].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) { + _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); + _operations[0].setMessageReceiver( + _callbackReceiver); + } + + //execute the operation client + _operationClient.execute(false); + + } + + + + /** + * A utility method that copies the namepaces from the SOAPEnvelope + */ + private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope env){ + java.util.Map returnMap = new java.util.HashMap(); + java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces(); + while (namespaceIterator.hasNext()) { + org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace) namespaceIterator.next(); + returnMap.put(ns.getPrefix(),ns.getNamespaceURI()); + } + return returnMap; + } + + + + private javax.xml.namespace.QName[] opNameArray = null; + private boolean optimizeContent(javax.xml.namespace.QName opName) { + + + if (opNameArray == null) { + return false; + } + for (int i = 0; i < opNameArray.length; i++) { + if (opName.equals(opNameArray[i])) { + return true; + } + } + return false; + } + //http://xiqas.changhong.com:52000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_TCM&receiverParty=&receiverService=&interface=SI_TCM2SAP_CA21_OUT&interfaceNamespace=urn%3Achanghong.com%3ATCM%3Amlsc + public static class MT_SAP2TCM_CA21 + implements org.apache.axis2.databinding.ADBBean{ + + public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( + "urn:changhong.com:TCM:mlsc", + "MT_SAP2TCM_CA21", + "ns1"); + + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MT_SAP2TCM_CA21 + */ + + + protected DT_SAP2TCM_CA21 localMT_SAP2TCM_CA21 ; + + + /** + * Auto generated getter method + * @return DT_SAP2TCM_CA21 + */ + public DT_SAP2TCM_CA21 getMT_SAP2TCM_CA21(){ + return localMT_SAP2TCM_CA21; + } + + + + /** + * Auto generated setter method + * @param param MT_SAP2TCM_CA21 + */ + public void setMT_SAP2TCM_CA21(DT_SAP2TCM_CA21 param){ + + this.localMT_SAP2TCM_CA21=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,MY_QNAME){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MT_SAP2TCM_CA21.this.serialize(MY_QNAME,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + MY_QNAME,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + //We can safely assume an element has only one type associated with it + + if (localMT_SAP2TCM_CA21==null){ + throw new org.apache.axis2.databinding.ADBException("Property cannot be null!"); + } + localMT_SAP2TCM_CA21.serialize(MY_QNAME,factory,xmlWriter); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + + //We can safely assume an element has only one type associated with it + return localMT_SAP2TCM_CA21.getPullParser(MY_QNAME); + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MT_SAP2TCM_CA21 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MT_SAP2TCM_CA21 object = + new MT_SAP2TCM_CA21(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + while(!reader.isEndElement()) { + if (reader.isStartElement() ){ + + if (reader.isStartElement() && new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc","MT_SAP2TCM_CA21").equals(reader.getName())){ + + object.setMT_SAP2TCM_CA21(DT_SAP2TCM_CA21.Factory.parse(reader)); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + } else { + reader.next(); + } + } // end of while loop + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class MSG_BODY_type0 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = MSG_BODY_type0 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for HEADER + */ + + + protected HEADER_type0 localHEADER ; + + + /** + * Auto generated getter method + * @return HEADER_type0 + */ + public HEADER_type0 getHEADER(){ + return localHEADER; + } + + + + /** + * Auto generated setter method + * @param param HEADER + */ + public void setHEADER(HEADER_type0 param){ + + this.localHEADER=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MSG_BODY_type0.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":MSG_BODY_type0", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "MSG_BODY_type0", + xmlWriter); + } + + + } + + if (localHEADER==null){ + throw new org.apache.axis2.databinding.ADBException("HEADER cannot be null!!"); + } + localHEADER.serialize(new javax.xml.namespace.QName("","HEADER"), + factory,xmlWriter); + + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + + elementList.add(new javax.xml.namespace.QName("", + "HEADER")); + + + if (localHEADER==null){ + throw new org.apache.axis2.databinding.ADBException("HEADER cannot be null!!"); + } + elementList.add(localHEADER); + + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MSG_BODY_type0 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MSG_BODY_type0 object = + new MSG_BODY_type0(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"MSG_BODY_type0".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (MSG_BODY_type0)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","HEADER").equals(reader.getName())){ + + object.setHEADER(HEADER_type0.Factory.parse(reader)); + + reader.next(); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class MT_TCM2SAP_CA21 + implements org.apache.axis2.databinding.ADBBean{ + + public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( + "urn:changhong.com:TCM:mlsc", + "MT_TCM2SAP_CA21", + "ns1"); + + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MT_TCM2SAP_CA21 + */ + + + protected DT_TCM2SAP_CA21 localMT_TCM2SAP_CA21 ; + + + /** + * Auto generated getter method + * @return DT_TCM2SAP_CA21 + */ + public DT_TCM2SAP_CA21 getMT_TCM2SAP_CA21(){ + return localMT_TCM2SAP_CA21; + } + + + + /** + * Auto generated setter method + * @param param MT_TCM2SAP_CA21 + */ + public void setMT_TCM2SAP_CA21(DT_TCM2SAP_CA21 param){ + + this.localMT_TCM2SAP_CA21=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,MY_QNAME){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MT_TCM2SAP_CA21.this.serialize(MY_QNAME,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + MY_QNAME,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + //We can safely assume an element has only one type associated with it + + if (localMT_TCM2SAP_CA21==null){ + throw new org.apache.axis2.databinding.ADBException("Property cannot be null!"); + } + localMT_TCM2SAP_CA21.serialize(MY_QNAME,factory,xmlWriter); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + + //We can safely assume an element has only one type associated with it + return localMT_TCM2SAP_CA21.getPullParser(MY_QNAME); + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MT_TCM2SAP_CA21 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MT_TCM2SAP_CA21 object = + new MT_TCM2SAP_CA21(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + while(!reader.isEndElement()) { + if (reader.isStartElement() ){ + + if (reader.isStartElement() && new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc","MT_TCM2SAP_CA21").equals(reader.getName())){ + + object.setMT_TCM2SAP_CA21(DT_TCM2SAP_CA21.Factory.parse(reader)); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + } else { + reader.next(); + } + } // end of while loop + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class DT_TCM2SAP_CA21 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = DT_TCM2SAP_CA21 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MSG_HDR + */ + + + protected MSG_HDR_type0 localMSG_HDR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMSG_HDRTracker = false ; + + + /** + * Auto generated getter method + * @return MSG_HDR_type0 + */ + public MSG_HDR_type0 getMSG_HDR(){ + return localMSG_HDR; + } + + + + /** + * Auto generated setter method + * @param param MSG_HDR + */ + public void setMSG_HDR(MSG_HDR_type0 param){ + + if (param != null){ + //update the setting tracker + localMSG_HDRTracker = true; + } else { + localMSG_HDRTracker = false; + + } + + this.localMSG_HDR=param; + + + } + + + /** + * field for MSG_BODY + */ + + + protected MSG_BODY_type0 localMSG_BODY ; + + + /** + * Auto generated getter method + * @return MSG_BODY_type0 + */ + public MSG_BODY_type0 getMSG_BODY(){ + return localMSG_BODY; + } + + + + /** + * Auto generated setter method + * @param param MSG_BODY + */ + public void setMSG_BODY(MSG_BODY_type0 param){ + + this.localMSG_BODY=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + DT_TCM2SAP_CA21.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":DT_TCM2SAP_CA21", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "DT_TCM2SAP_CA21", + xmlWriter); + } + + + } + if (localMSG_HDRTracker){ + if (localMSG_HDR==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_HDR cannot be null!!"); + } + localMSG_HDR.serialize(new javax.xml.namespace.QName("","MSG_HDR"), + factory,xmlWriter); + } + if (localMSG_BODY==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_BODY cannot be null!!"); + } + localMSG_BODY.serialize(new javax.xml.namespace.QName("","MSG_BODY"), + factory,xmlWriter); + + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMSG_HDRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MSG_HDR")); + + + if (localMSG_HDR==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_HDR cannot be null!!"); + } + elementList.add(localMSG_HDR); + } + elementList.add(new javax.xml.namespace.QName("", + "MSG_BODY")); + + + if (localMSG_BODY==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_BODY cannot be null!!"); + } + elementList.add(localMSG_BODY); + + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static DT_TCM2SAP_CA21 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + DT_TCM2SAP_CA21 object = + new DT_TCM2SAP_CA21(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"DT_TCM2SAP_CA21".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (DT_TCM2SAP_CA21)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MSG_HDR").equals(reader.getName())){ + + object.setMSG_HDR(MSG_HDR_type0.Factory.parse(reader)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MSG_BODY").equals(reader.getName())){ + + object.setMSG_BODY(MSG_BODY_type0.Factory.parse(reader)); + + reader.next(); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class DT_SAP2TCM_CA21 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = DT_SAP2TCM_CA21 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MATNR + */ + + + protected java.lang.String localMATNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMATNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMATNR(){ + return localMATNR; + } + + + + /** + * Auto generated setter method + * @param param MATNR + */ + public void setMATNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMATNRTracker = true; + } else { + localMATNRTracker = false; + + } + + this.localMATNR=param; + + + } + + + /** + * field for WERKS + */ + + + protected java.lang.String localWERKS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localWERKSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getWERKS(){ + return localWERKS; + } + + + + /** + * Auto generated setter method + * @param param WERKS + */ + public void setWERKS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localWERKSTracker = true; + } else { + localWERKSTracker = false; + + } + + this.localWERKS=param; + + + } + + + /** + * field for PLNNR + */ + + + protected java.lang.String localPLNNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localPLNNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getPLNNR(){ + return localPLNNR; + } + + + + /** + * Auto generated setter method + * @param param PLNNR + */ + public void setPLNNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localPLNNRTracker = true; + } else { + localPLNNRTracker = false; + + } + + this.localPLNNR=param; + + + } + + + /** + * field for PLNAL + */ + + + protected java.lang.String localPLNAL ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localPLNALTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getPLNAL(){ + return localPLNAL; + } + + + + /** + * Auto generated setter method + * @param param PLNAL + */ + public void setPLNAL(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localPLNALTracker = true; + } else { + localPLNALTracker = false; + + } + + this.localPLNAL=param; + + + } + + + /** + * field for DATUV + */ + + + protected java.lang.String localDATUV ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localDATUVTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getDATUV(){ + return localDATUV; + } + + + + /** + * Auto generated setter method + * @param param DATUV + */ + public void setDATUV(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localDATUVTracker = true; + } else { + localDATUVTracker = false; + + } + + this.localDATUV=param; + + + } + + + /** + * field for VERWE + */ + + + protected java.lang.String localVERWE ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVERWETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVERWE(){ + return localVERWE; + } + + + + /** + * Auto generated setter method + * @param param VERWE + */ + public void setVERWE(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVERWETracker = true; + } else { + localVERWETracker = false; + + } + + this.localVERWE=param; + + + } + + + /** + * field for STATU + */ + + + protected java.lang.String localSTATU ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTATUTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTATU(){ + return localSTATU; + } + + + + /** + * Auto generated setter method + * @param param STATU + */ + public void setSTATU(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTATUTracker = true; + } else { + localSTATUTracker = false; + + } + + this.localSTATU=param; + + + } + + + /** + * field for VORNR + */ + + + protected java.lang.String localVORNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVORNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVORNR(){ + return localVORNR; + } + + + + /** + * Auto generated setter method + * @param param VORNR + */ + public void setVORNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVORNRTracker = true; + } else { + localVORNRTracker = false; + + } + + this.localVORNR=param; + + + } + + + /** + * field for STEUS + */ + + + protected java.lang.String localSTEUS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTEUSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTEUS(){ + return localSTEUS; + } + + + + /** + * Auto generated setter method + * @param param STEUS + */ + public void setSTEUS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTEUSTracker = true; + } else { + localSTEUSTracker = false; + + } + + this.localSTEUS=param; + + + } + + + /** + * field for ARBPL + */ + + + protected java.lang.String localARBPL ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localARBPLTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getARBPL(){ + return localARBPL; + } + + + + /** + * Auto generated setter method + * @param param ARBPL + */ + public void setARBPL(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localARBPLTracker = true; + } else { + localARBPLTracker = false; + + } + + this.localARBPL=param; + + + } + + + /** + * field for LTXA1 + */ + + + protected java.lang.String localLTXA1 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localLTXA1Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getLTXA1(){ + return localLTXA1; + } + + + + /** + * Auto generated setter method + * @param param LTXA1 + */ + public void setLTXA1(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localLTXA1Tracker = true; + } else { + localLTXA1Tracker = false; + + } + + this.localLTXA1=param; + + + } + + + /** + * field for BMSCH + */ + + + protected java.lang.String localBMSCH ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localBMSCHTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getBMSCH(){ + return localBMSCH; + } + + + + /** + * Auto generated setter method + * @param param BMSCH + */ + public void setBMSCH(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localBMSCHTracker = true; + } else { + localBMSCHTracker = false; + + } + + this.localBMSCH=param; + + + } + + + /** + * field for VGW01 + */ + + + protected java.lang.String localVGW01 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW01Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW01(){ + return localVGW01; + } + + + + /** + * Auto generated setter method + * @param param VGW01 + */ + public void setVGW01(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW01Tracker = true; + } else { + localVGW01Tracker = false; + + } + + this.localVGW01=param; + + + } + + + /** + * field for VGE01 + */ + + + protected java.lang.String localVGE01 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE01Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE01(){ + return localVGE01; + } + + + + /** + * Auto generated setter method + * @param param VGE01 + */ + public void setVGE01(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE01Tracker = true; + } else { + localVGE01Tracker = false; + + } + + this.localVGE01=param; + + + } + + + /** + * field for VGW02 + */ + + + protected java.lang.String localVGW02 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW02Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW02(){ + return localVGW02; + } + + + + /** + * Auto generated setter method + * @param param VGW02 + */ + public void setVGW02(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW02Tracker = true; + } else { + localVGW02Tracker = false; + + } + + this.localVGW02=param; + + + } + + + /** + * field for VGE02 + */ + + + protected java.lang.String localVGE02 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE02Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE02(){ + return localVGE02; + } + + + + /** + * Auto generated setter method + * @param param VGE02 + */ + public void setVGE02(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE02Tracker = true; + } else { + localVGE02Tracker = false; + + } + + this.localVGE02=param; + + + } + + + /** + * field for VGW03 + */ + + + protected java.lang.String localVGW03 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW03Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW03(){ + return localVGW03; + } + + + + /** + * Auto generated setter method + * @param param VGW03 + */ + public void setVGW03(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW03Tracker = true; + } else { + localVGW03Tracker = false; + + } + + this.localVGW03=param; + + + } + + + /** + * field for VGE03 + */ + + + protected java.lang.String localVGE03 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE03Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE03(){ + return localVGE03; + } + + + + /** + * Auto generated setter method + * @param param VGE03 + */ + public void setVGE03(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE03Tracker = true; + } else { + localVGE03Tracker = false; + + } + + this.localVGE03=param; + + + } + + + /** + * field for VGW04 + */ + + + protected java.lang.String localVGW04 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW04Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW04(){ + return localVGW04; + } + + + + /** + * Auto generated setter method + * @param param VGW04 + */ + public void setVGW04(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW04Tracker = true; + } else { + localVGW04Tracker = false; + + } + + this.localVGW04=param; + + + } + + + /** + * field for VGE04 + */ + + + protected java.lang.String localVGE04 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE04Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE04(){ + return localVGE04; + } + + + + /** + * Auto generated setter method + * @param param VGE04 + */ + public void setVGE04(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE04Tracker = true; + } else { + localVGE04Tracker = false; + + } + + this.localVGE04=param; + + + } + + + /** + * field for VGW05 + */ + + + protected java.lang.String localVGW05 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW05Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW05(){ + return localVGW05; + } + + + + /** + * Auto generated setter method + * @param param VGW05 + */ + public void setVGW05(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW05Tracker = true; + } else { + localVGW05Tracker = false; + + } + + this.localVGW05=param; + + + } + + + /** + * field for VGE05 + */ + + + protected java.lang.String localVGE05 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE05Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE05(){ + return localVGE05; + } + + + + /** + * Auto generated setter method + * @param param VGE05 + */ + public void setVGE05(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE05Tracker = true; + } else { + localVGE05Tracker = false; + + } + + this.localVGE05=param; + + + } + + + /** + * field for KZ + */ + + + protected java.lang.String localKZ ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localKZTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getKZ(){ + return localKZ; + } + + + + /** + * Auto generated setter method + * @param param KZ + */ + public void setKZ(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localKZTracker = true; + } else { + localKZTracker = false; + + } + + this.localKZ=param; + + + } + + + /** + * field for STATUS + */ + + + protected java.lang.String localSTATUS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTATUSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTATUS(){ + return localSTATUS; + } + + + + /** + * Auto generated setter method + * @param param STATUS + */ + public void setSTATUS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTATUSTracker = true; + } else { + localSTATUSTracker = false; + + } + + this.localSTATUS=param; + + + } + + + /** + * field for MESSAGE + */ + + + protected java.lang.String localMESSAGE ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMESSAGETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMESSAGE(){ + return localMESSAGE; + } + + + + /** + * Auto generated setter method + * @param param MESSAGE + */ + public void setMESSAGE(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMESSAGETracker = true; + } else { + localMESSAGETracker = false; + + } + + this.localMESSAGE=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + DT_SAP2TCM_CA21.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":DT_SAP2TCM_CA21", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "DT_SAP2TCM_CA21", + xmlWriter); + } + + + } + if (localMATNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MATNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MATNR"); + } + + } else { + xmlWriter.writeStartElement("MATNR"); + } + + + if (localMATNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMATNR); + + } + + xmlWriter.writeEndElement(); + } if (localWERKSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"WERKS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"WERKS"); + } + + } else { + xmlWriter.writeStartElement("WERKS"); + } + + + if (localWERKS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localWERKS); + + } + + xmlWriter.writeEndElement(); + } if (localPLNNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"PLNNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"PLNNR"); + } + + } else { + xmlWriter.writeStartElement("PLNNR"); + } + + + if (localPLNNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("PLNNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localPLNNR); + + } + + xmlWriter.writeEndElement(); + } if (localPLNALTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"PLNAL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"PLNAL"); + } + + } else { + xmlWriter.writeStartElement("PLNAL"); + } + + + if (localPLNAL==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("PLNAL cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localPLNAL); + + } + + xmlWriter.writeEndElement(); + } if (localDATUVTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"DATUV", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"DATUV"); + } + + } else { + xmlWriter.writeStartElement("DATUV"); + } + + + if (localDATUV==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("DATUV cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localDATUV); + + } + + xmlWriter.writeEndElement(); + } if (localVERWETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VERWE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VERWE"); + } + + } else { + xmlWriter.writeStartElement("VERWE"); + } + + + if (localVERWE==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VERWE cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVERWE); + + } + + xmlWriter.writeEndElement(); + } if (localSTATUTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STATU", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STATU"); + } + + } else { + xmlWriter.writeStartElement("STATU"); + } + + + if (localSTATU==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STATU cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTATU); + + } + + xmlWriter.writeEndElement(); + } if (localVORNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VORNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VORNR"); + } + + } else { + xmlWriter.writeStartElement("VORNR"); + } + + + if (localVORNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VORNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVORNR); + + } + + xmlWriter.writeEndElement(); + } if (localSTEUSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STEUS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STEUS"); + } + + } else { + xmlWriter.writeStartElement("STEUS"); + } + + + if (localSTEUS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STEUS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTEUS); + + } + + xmlWriter.writeEndElement(); + } if (localARBPLTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"ARBPL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"ARBPL"); + } + + } else { + xmlWriter.writeStartElement("ARBPL"); + } + + + if (localARBPL==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("ARBPL cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localARBPL); + + } + + xmlWriter.writeEndElement(); + } if (localLTXA1Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"LTXA1", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"LTXA1"); + } + + } else { + xmlWriter.writeStartElement("LTXA1"); + } + + + if (localLTXA1==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("LTXA1 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localLTXA1); + + } + + xmlWriter.writeEndElement(); + } if (localBMSCHTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"BMSCH", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"BMSCH"); + } + + } else { + xmlWriter.writeStartElement("BMSCH"); + } + + + if (localBMSCH==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("BMSCH cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localBMSCH); + + } + + xmlWriter.writeEndElement(); + } if (localVGW01Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW01", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW01"); + } + + } else { + xmlWriter.writeStartElement("VGW01"); + } + + + if (localVGW01==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW01 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW01); + + } + + xmlWriter.writeEndElement(); + } if (localVGE01Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE01", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE01"); + } + + } else { + xmlWriter.writeStartElement("VGE01"); + } + + + if (localVGE01==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE01 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE01); + + } + + xmlWriter.writeEndElement(); + } if (localVGW02Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW02", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW02"); + } + + } else { + xmlWriter.writeStartElement("VGW02"); + } + + + if (localVGW02==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW02 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW02); + + } + + xmlWriter.writeEndElement(); + } if (localVGE02Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE02", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE02"); + } + + } else { + xmlWriter.writeStartElement("VGE02"); + } + + + if (localVGE02==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE02 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE02); + + } + + xmlWriter.writeEndElement(); + } if (localVGW03Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW03", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW03"); + } + + } else { + xmlWriter.writeStartElement("VGW03"); + } + + + if (localVGW03==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW03 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW03); + + } + + xmlWriter.writeEndElement(); + } if (localVGE03Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE03", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE03"); + } + + } else { + xmlWriter.writeStartElement("VGE03"); + } + + + if (localVGE03==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE03 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE03); + + } + + xmlWriter.writeEndElement(); + } if (localVGW04Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW04", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW04"); + } + + } else { + xmlWriter.writeStartElement("VGW04"); + } + + + if (localVGW04==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW04 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW04); + + } + + xmlWriter.writeEndElement(); + } if (localVGE04Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE04", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE04"); + } + + } else { + xmlWriter.writeStartElement("VGE04"); + } + + + if (localVGE04==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE04 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE04); + + } + + xmlWriter.writeEndElement(); + } if (localVGW05Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW05", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW05"); + } + + } else { + xmlWriter.writeStartElement("VGW05"); + } + + + if (localVGW05==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW05 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW05); + + } + + xmlWriter.writeEndElement(); + } if (localVGE05Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE05", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE05"); + } + + } else { + xmlWriter.writeStartElement("VGE05"); + } + + + if (localVGE05==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE05 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE05); + + } + + xmlWriter.writeEndElement(); + } if (localKZTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"KZ", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"KZ"); + } + + } else { + xmlWriter.writeStartElement("KZ"); + } + + + if (localKZ==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("KZ cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localKZ); + + } + + xmlWriter.writeEndElement(); + } if (localSTATUSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STATUS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STATUS"); + } + + } else { + xmlWriter.writeStartElement("STATUS"); + } + + + if (localSTATUS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STATUS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTATUS); + + } + + xmlWriter.writeEndElement(); + } if (localMESSAGETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MESSAGE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MESSAGE"); + } + + } else { + xmlWriter.writeStartElement("MESSAGE"); + } + + + if (localMESSAGE==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MESSAGE cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMESSAGE); + + } + + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMATNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MATNR")); + + if (localMATNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMATNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + } + } if (localWERKSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "WERKS")); + + if (localWERKS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localWERKS)); + } else { + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + } + } if (localPLNNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "PLNNR")); + + if (localPLNNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localPLNNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("PLNNR cannot be null!!"); + } + } if (localPLNALTracker){ + elementList.add(new javax.xml.namespace.QName("", + "PLNAL")); + + if (localPLNAL != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localPLNAL)); + } else { + throw new org.apache.axis2.databinding.ADBException("PLNAL cannot be null!!"); + } + } if (localDATUVTracker){ + elementList.add(new javax.xml.namespace.QName("", + "DATUV")); + + if (localDATUV != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localDATUV)); + } else { + throw new org.apache.axis2.databinding.ADBException("DATUV cannot be null!!"); + } + } if (localVERWETracker){ + elementList.add(new javax.xml.namespace.QName("", + "VERWE")); + + if (localVERWE != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVERWE)); + } else { + throw new org.apache.axis2.databinding.ADBException("VERWE cannot be null!!"); + } + } if (localSTATUTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STATU")); + + if (localSTATU != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTATU)); + } else { + throw new org.apache.axis2.databinding.ADBException("STATU cannot be null!!"); + } + } if (localVORNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "VORNR")); + + if (localVORNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVORNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("VORNR cannot be null!!"); + } + } if (localSTEUSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STEUS")); + + if (localSTEUS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTEUS)); + } else { + throw new org.apache.axis2.databinding.ADBException("STEUS cannot be null!!"); + } + } if (localARBPLTracker){ + elementList.add(new javax.xml.namespace.QName("", + "ARBPL")); + + if (localARBPL != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localARBPL)); + } else { + throw new org.apache.axis2.databinding.ADBException("ARBPL cannot be null!!"); + } + } if (localLTXA1Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "LTXA1")); + + if (localLTXA1 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localLTXA1)); + } else { + throw new org.apache.axis2.databinding.ADBException("LTXA1 cannot be null!!"); + } + } if (localBMSCHTracker){ + elementList.add(new javax.xml.namespace.QName("", + "BMSCH")); + + if (localBMSCH != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBMSCH)); + } else { + throw new org.apache.axis2.databinding.ADBException("BMSCH cannot be null!!"); + } + } if (localVGW01Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW01")); + + if (localVGW01 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW01)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW01 cannot be null!!"); + } + } if (localVGE01Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE01")); + + if (localVGE01 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE01)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE01 cannot be null!!"); + } + } if (localVGW02Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW02")); + + if (localVGW02 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW02)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW02 cannot be null!!"); + } + } if (localVGE02Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE02")); + + if (localVGE02 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE02)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE02 cannot be null!!"); + } + } if (localVGW03Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW03")); + + if (localVGW03 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW03)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW03 cannot be null!!"); + } + } if (localVGE03Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE03")); + + if (localVGE03 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE03)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE03 cannot be null!!"); + } + } if (localVGW04Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW04")); + + if (localVGW04 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW04)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW04 cannot be null!!"); + } + } if (localVGE04Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE04")); + + if (localVGE04 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE04)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE04 cannot be null!!"); + } + } if (localVGW05Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW05")); + + if (localVGW05 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW05)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW05 cannot be null!!"); + } + } if (localVGE05Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE05")); + + if (localVGE05 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE05)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE05 cannot be null!!"); + } + } if (localKZTracker){ + elementList.add(new javax.xml.namespace.QName("", + "KZ")); + + if (localKZ != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localKZ)); + } else { + throw new org.apache.axis2.databinding.ADBException("KZ cannot be null!!"); + } + } if (localSTATUSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STATUS")); + + if (localSTATUS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTATUS)); + } else { + throw new org.apache.axis2.databinding.ADBException("STATUS cannot be null!!"); + } + } if (localMESSAGETracker){ + elementList.add(new javax.xml.namespace.QName("", + "MESSAGE")); + + if (localMESSAGE != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMESSAGE)); + } else { + throw new org.apache.axis2.databinding.ADBException("MESSAGE cannot be null!!"); + } + } + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static DT_SAP2TCM_CA21 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + DT_SAP2TCM_CA21 object = + new DT_SAP2TCM_CA21(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"DT_SAP2TCM_CA21".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (DT_SAP2TCM_CA21)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MATNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMATNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","WERKS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setWERKS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","PLNNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setPLNNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","PLNAL").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setPLNAL( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","DATUV").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setDATUV( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VERWE").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVERWE( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STATU").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTATU( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VORNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVORNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STEUS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTEUS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","ARBPL").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setARBPL( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","LTXA1").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setLTXA1( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","BMSCH").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setBMSCH( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW01").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW01( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE01").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE01( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW02").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW02( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE02").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE02( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW03").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW03( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE03").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE03( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW04").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW04( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE04").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE04( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW05").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW05( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE05").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE05( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","KZ").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setKZ( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STATUS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTATUS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MESSAGE").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMESSAGE( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class HEADER_type0 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = HEADER_type0 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MATNR + */ + + + protected java.lang.String localMATNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMATNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMATNR(){ + return localMATNR; + } + + + + /** + * Auto generated setter method + * @param param MATNR + */ + public void setMATNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMATNRTracker = true; + } else { + localMATNRTracker = false; + + } + + this.localMATNR=param; + + + } + + + /** + * field for WERKS + */ + + + protected java.lang.String localWERKS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localWERKSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getWERKS(){ + return localWERKS; + } + + + + /** + * Auto generated setter method + * @param param WERKS + */ + public void setWERKS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localWERKSTracker = true; + } else { + localWERKSTracker = false; + + } + + this.localWERKS=param; + + + } + + + /** + * field for PLNNR + */ + + + protected java.lang.String localPLNNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localPLNNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getPLNNR(){ + return localPLNNR; + } + + + + /** + * Auto generated setter method + * @param param PLNNR + */ + public void setPLNNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localPLNNRTracker = true; + } else { + localPLNNRTracker = false; + + } + + this.localPLNNR=param; + + + } + + + /** + * field for PLNAL + */ + + + protected java.lang.String localPLNAL ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localPLNALTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getPLNAL(){ + return localPLNAL; + } + + + + /** + * Auto generated setter method + * @param param PLNAL + */ + public void setPLNAL(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localPLNALTracker = true; + } else { + localPLNALTracker = false; + + } + + this.localPLNAL=param; + + + } + + + /** + * field for DATUV + */ + + + protected java.lang.String localDATUV ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localDATUVTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getDATUV(){ + return localDATUV; + } + + + + /** + * Auto generated setter method + * @param param DATUV + */ + public void setDATUV(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localDATUVTracker = true; + } else { + localDATUVTracker = false; + + } + + this.localDATUV=param; + + + } + + + /** + * field for VERWE + */ + + + protected java.lang.String localVERWE ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVERWETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVERWE(){ + return localVERWE; + } + + + + /** + * Auto generated setter method + * @param param VERWE + */ + public void setVERWE(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVERWETracker = true; + } else { + localVERWETracker = false; + + } + + this.localVERWE=param; + + + } + + + /** + * field for STATU + */ + + + protected java.lang.String localSTATU ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTATUTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTATU(){ + return localSTATU; + } + + + + /** + * Auto generated setter method + * @param param STATU + */ + public void setSTATU(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTATUTracker = true; + } else { + localSTATUTracker = false; + + } + + this.localSTATU=param; + + + } + + + /** + * field for VORNR + */ + + + protected java.lang.String localVORNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVORNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVORNR(){ + return localVORNR; + } + + + + /** + * Auto generated setter method + * @param param VORNR + */ + public void setVORNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVORNRTracker = true; + } else { + localVORNRTracker = false; + + } + + this.localVORNR=param; + + + } + + + /** + * field for STEUS + */ + + + protected java.lang.String localSTEUS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTEUSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTEUS(){ + return localSTEUS; + } + + + + /** + * Auto generated setter method + * @param param STEUS + */ + public void setSTEUS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTEUSTracker = true; + } else { + localSTEUSTracker = false; + + } + + this.localSTEUS=param; + + + } + + + /** + * field for ARBPL + */ + + + protected java.lang.String localARBPL ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localARBPLTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getARBPL(){ + return localARBPL; + } + + + + /** + * Auto generated setter method + * @param param ARBPL + */ + public void setARBPL(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localARBPLTracker = true; + } else { + localARBPLTracker = false; + + } + + this.localARBPL=param; + + + } + + + /** + * field for LTXA1 + */ + + + protected java.lang.String localLTXA1 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localLTXA1Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getLTXA1(){ + return localLTXA1; + } + + + + /** + * Auto generated setter method + * @param param LTXA1 + */ + public void setLTXA1(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localLTXA1Tracker = true; + } else { + localLTXA1Tracker = false; + + } + + this.localLTXA1=param; + + + } + + + /** + * field for BMSCH + */ + + + protected java.lang.String localBMSCH ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localBMSCHTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getBMSCH(){ + return localBMSCH; + } + + + + /** + * Auto generated setter method + * @param param BMSCH + */ + public void setBMSCH(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localBMSCHTracker = true; + } else { + localBMSCHTracker = false; + + } + + this.localBMSCH=param; + + + } + + + /** + * field for VGW01 + */ + + + protected java.lang.String localVGW01 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW01Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW01(){ + return localVGW01; + } + + + + /** + * Auto generated setter method + * @param param VGW01 + */ + public void setVGW01(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW01Tracker = true; + } else { + localVGW01Tracker = false; + + } + + this.localVGW01=param; + + + } + + + /** + * field for VGE01 + */ + + + protected java.lang.String localVGE01 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE01Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE01(){ + return localVGE01; + } + + + + /** + * Auto generated setter method + * @param param VGE01 + */ + public void setVGE01(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE01Tracker = true; + } else { + localVGE01Tracker = false; + + } + + this.localVGE01=param; + + + } + + + /** + * field for VGW02 + */ + + + protected java.lang.String localVGW02 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW02Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW02(){ + return localVGW02; + } + + + + /** + * Auto generated setter method + * @param param VGW02 + */ + public void setVGW02(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW02Tracker = true; + } else { + localVGW02Tracker = false; + + } + + this.localVGW02=param; + + + } + + + /** + * field for VGE02 + */ + + + protected java.lang.String localVGE02 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE02Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE02(){ + return localVGE02; + } + + + + /** + * Auto generated setter method + * @param param VGE02 + */ + public void setVGE02(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE02Tracker = true; + } else { + localVGE02Tracker = false; + + } + + this.localVGE02=param; + + + } + + + /** + * field for VGW03 + */ + + + protected java.lang.String localVGW03 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW03Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW03(){ + return localVGW03; + } + + + + /** + * Auto generated setter method + * @param param VGW03 + */ + public void setVGW03(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW03Tracker = true; + } else { + localVGW03Tracker = false; + + } + + this.localVGW03=param; + + + } + + + /** + * field for VGE03 + */ + + + protected java.lang.String localVGE03 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE03Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE03(){ + return localVGE03; + } + + + + /** + * Auto generated setter method + * @param param VGE03 + */ + public void setVGE03(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE03Tracker = true; + } else { + localVGE03Tracker = false; + + } + + this.localVGE03=param; + + + } + + + /** + * field for VGW04 + */ + + + protected java.lang.String localVGW04 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW04Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW04(){ + return localVGW04; + } + + + + /** + * Auto generated setter method + * @param param VGW04 + */ + public void setVGW04(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW04Tracker = true; + } else { + localVGW04Tracker = false; + + } + + this.localVGW04=param; + + + } + + + /** + * field for VGE04 + */ + + + protected java.lang.String localVGE04 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE04Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE04(){ + return localVGE04; + } + + + + /** + * Auto generated setter method + * @param param VGE04 + */ + public void setVGE04(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE04Tracker = true; + } else { + localVGE04Tracker = false; + + } + + this.localVGE04=param; + + + } + + + /** + * field for VGW05 + */ + + + protected java.lang.String localVGW05 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGW05Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGW05(){ + return localVGW05; + } + + + + /** + * Auto generated setter method + * @param param VGW05 + */ + public void setVGW05(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGW05Tracker = true; + } else { + localVGW05Tracker = false; + + } + + this.localVGW05=param; + + + } + + + /** + * field for VGE05 + */ + + + protected java.lang.String localVGE05 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVGE05Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVGE05(){ + return localVGE05; + } + + + + /** + * Auto generated setter method + * @param param VGE05 + */ + public void setVGE05(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVGE05Tracker = true; + } else { + localVGE05Tracker = false; + + } + + this.localVGE05=param; + + + } + + + /** + * field for KZ + */ + + + protected java.lang.String localKZ ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localKZTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getKZ(){ + return localKZ; + } + + + + /** + * Auto generated setter method + * @param param KZ + */ + public void setKZ(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localKZTracker = true; + } else { + localKZTracker = false; + + } + + this.localKZ=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + HEADER_type0.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":HEADER_type0", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "HEADER_type0", + xmlWriter); + } + + + } + if (localMATNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MATNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MATNR"); + } + + } else { + xmlWriter.writeStartElement("MATNR"); + } + + + if (localMATNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMATNR); + + } + + xmlWriter.writeEndElement(); + } if (localWERKSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"WERKS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"WERKS"); + } + + } else { + xmlWriter.writeStartElement("WERKS"); + } + + + if (localWERKS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localWERKS); + + } + + xmlWriter.writeEndElement(); + } if (localPLNNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"PLNNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"PLNNR"); + } + + } else { + xmlWriter.writeStartElement("PLNNR"); + } + + + if (localPLNNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("PLNNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localPLNNR); + + } + + xmlWriter.writeEndElement(); + } if (localPLNALTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"PLNAL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"PLNAL"); + } + + } else { + xmlWriter.writeStartElement("PLNAL"); + } + + + if (localPLNAL==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("PLNAL cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localPLNAL); + + } + + xmlWriter.writeEndElement(); + } if (localDATUVTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"DATUV", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"DATUV"); + } + + } else { + xmlWriter.writeStartElement("DATUV"); + } + + + if (localDATUV==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("DATUV cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localDATUV); + + } + + xmlWriter.writeEndElement(); + } if (localVERWETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VERWE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VERWE"); + } + + } else { + xmlWriter.writeStartElement("VERWE"); + } + + + if (localVERWE==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VERWE cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVERWE); + + } + + xmlWriter.writeEndElement(); + } if (localSTATUTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STATU", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STATU"); + } + + } else { + xmlWriter.writeStartElement("STATU"); + } + + + if (localSTATU==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STATU cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTATU); + + } + + xmlWriter.writeEndElement(); + } if (localVORNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VORNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VORNR"); + } + + } else { + xmlWriter.writeStartElement("VORNR"); + } + + + if (localVORNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VORNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVORNR); + + } + + xmlWriter.writeEndElement(); + } if (localSTEUSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STEUS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STEUS"); + } + + } else { + xmlWriter.writeStartElement("STEUS"); + } + + + if (localSTEUS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STEUS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTEUS); + + } + + xmlWriter.writeEndElement(); + } if (localARBPLTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"ARBPL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"ARBPL"); + } + + } else { + xmlWriter.writeStartElement("ARBPL"); + } + + + if (localARBPL==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("ARBPL cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localARBPL); + + } + + xmlWriter.writeEndElement(); + } if (localLTXA1Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"LTXA1", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"LTXA1"); + } + + } else { + xmlWriter.writeStartElement("LTXA1"); + } + + + if (localLTXA1==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("LTXA1 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localLTXA1); + + } + + xmlWriter.writeEndElement(); + } if (localBMSCHTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"BMSCH", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"BMSCH"); + } + + } else { + xmlWriter.writeStartElement("BMSCH"); + } + + + if (localBMSCH==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("BMSCH cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localBMSCH); + + } + + xmlWriter.writeEndElement(); + } if (localVGW01Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW01", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW01"); + } + + } else { + xmlWriter.writeStartElement("VGW01"); + } + + + if (localVGW01==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW01 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW01); + + } + + xmlWriter.writeEndElement(); + } if (localVGE01Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE01", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE01"); + } + + } else { + xmlWriter.writeStartElement("VGE01"); + } + + + if (localVGE01==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE01 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE01); + + } + + xmlWriter.writeEndElement(); + } if (localVGW02Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW02", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW02"); + } + + } else { + xmlWriter.writeStartElement("VGW02"); + } + + + if (localVGW02==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW02 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW02); + + } + + xmlWriter.writeEndElement(); + } if (localVGE02Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE02", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE02"); + } + + } else { + xmlWriter.writeStartElement("VGE02"); + } + + + if (localVGE02==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE02 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE02); + + } + + xmlWriter.writeEndElement(); + } if (localVGW03Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW03", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW03"); + } + + } else { + xmlWriter.writeStartElement("VGW03"); + } + + + if (localVGW03==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW03 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW03); + + } + + xmlWriter.writeEndElement(); + } if (localVGE03Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE03", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE03"); + } + + } else { + xmlWriter.writeStartElement("VGE03"); + } + + + if (localVGE03==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE03 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE03); + + } + + xmlWriter.writeEndElement(); + } if (localVGW04Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW04", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW04"); + } + + } else { + xmlWriter.writeStartElement("VGW04"); + } + + + if (localVGW04==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW04 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW04); + + } + + xmlWriter.writeEndElement(); + } if (localVGE04Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE04", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE04"); + } + + } else { + xmlWriter.writeStartElement("VGE04"); + } + + + if (localVGE04==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE04 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE04); + + } + + xmlWriter.writeEndElement(); + } if (localVGW05Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGW05", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGW05"); + } + + } else { + xmlWriter.writeStartElement("VGW05"); + } + + + if (localVGW05==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGW05 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGW05); + + } + + xmlWriter.writeEndElement(); + } if (localVGE05Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VGE05", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VGE05"); + } + + } else { + xmlWriter.writeStartElement("VGE05"); + } + + + if (localVGE05==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VGE05 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVGE05); + + } + + xmlWriter.writeEndElement(); + } if (localKZTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"KZ", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"KZ"); + } + + } else { + xmlWriter.writeStartElement("KZ"); + } + + + if (localKZ==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("KZ cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localKZ); + + } + + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMATNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MATNR")); + + if (localMATNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMATNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + } + } if (localWERKSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "WERKS")); + + if (localWERKS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localWERKS)); + } else { + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + } + } if (localPLNNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "PLNNR")); + + if (localPLNNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localPLNNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("PLNNR cannot be null!!"); + } + } if (localPLNALTracker){ + elementList.add(new javax.xml.namespace.QName("", + "PLNAL")); + + if (localPLNAL != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localPLNAL)); + } else { + throw new org.apache.axis2.databinding.ADBException("PLNAL cannot be null!!"); + } + } if (localDATUVTracker){ + elementList.add(new javax.xml.namespace.QName("", + "DATUV")); + + if (localDATUV != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localDATUV)); + } else { + throw new org.apache.axis2.databinding.ADBException("DATUV cannot be null!!"); + } + } if (localVERWETracker){ + elementList.add(new javax.xml.namespace.QName("", + "VERWE")); + + if (localVERWE != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVERWE)); + } else { + throw new org.apache.axis2.databinding.ADBException("VERWE cannot be null!!"); + } + } if (localSTATUTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STATU")); + + if (localSTATU != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTATU)); + } else { + throw new org.apache.axis2.databinding.ADBException("STATU cannot be null!!"); + } + } if (localVORNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "VORNR")); + + if (localVORNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVORNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("VORNR cannot be null!!"); + } + } if (localSTEUSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STEUS")); + + if (localSTEUS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTEUS)); + } else { + throw new org.apache.axis2.databinding.ADBException("STEUS cannot be null!!"); + } + } if (localARBPLTracker){ + elementList.add(new javax.xml.namespace.QName("", + "ARBPL")); + + if (localARBPL != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localARBPL)); + } else { + throw new org.apache.axis2.databinding.ADBException("ARBPL cannot be null!!"); + } + } if (localLTXA1Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "LTXA1")); + + if (localLTXA1 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localLTXA1)); + } else { + throw new org.apache.axis2.databinding.ADBException("LTXA1 cannot be null!!"); + } + } if (localBMSCHTracker){ + elementList.add(new javax.xml.namespace.QName("", + "BMSCH")); + + if (localBMSCH != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBMSCH)); + } else { + throw new org.apache.axis2.databinding.ADBException("BMSCH cannot be null!!"); + } + } if (localVGW01Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW01")); + + if (localVGW01 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW01)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW01 cannot be null!!"); + } + } if (localVGE01Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE01")); + + if (localVGE01 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE01)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE01 cannot be null!!"); + } + } if (localVGW02Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW02")); + + if (localVGW02 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW02)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW02 cannot be null!!"); + } + } if (localVGE02Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE02")); + + if (localVGE02 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE02)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE02 cannot be null!!"); + } + } if (localVGW03Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW03")); + + if (localVGW03 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW03)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW03 cannot be null!!"); + } + } if (localVGE03Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE03")); + + if (localVGE03 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE03)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE03 cannot be null!!"); + } + } if (localVGW04Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW04")); + + if (localVGW04 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW04)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW04 cannot be null!!"); + } + } if (localVGE04Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE04")); + + if (localVGE04 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE04)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE04 cannot be null!!"); + } + } if (localVGW05Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGW05")); + + if (localVGW05 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGW05)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGW05 cannot be null!!"); + } + } if (localVGE05Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "VGE05")); + + if (localVGE05 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVGE05)); + } else { + throw new org.apache.axis2.databinding.ADBException("VGE05 cannot be null!!"); + } + } if (localKZTracker){ + elementList.add(new javax.xml.namespace.QName("", + "KZ")); + + if (localKZ != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localKZ)); + } else { + throw new org.apache.axis2.databinding.ADBException("KZ cannot be null!!"); + } + } + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static HEADER_type0 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + HEADER_type0 object = + new HEADER_type0(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"HEADER_type0".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (HEADER_type0)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MATNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMATNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","WERKS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setWERKS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","PLNNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setPLNNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","PLNAL").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setPLNAL( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","DATUV").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setDATUV( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VERWE").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVERWE( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STATU").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTATU( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VORNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVORNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STEUS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTEUS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","ARBPL").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setARBPL( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","LTXA1").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setLTXA1( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","BMSCH").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setBMSCH( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW01").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW01( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE01").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE01( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW02").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW02( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE02").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE02( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW03").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW03( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE03").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE03( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW04").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW04( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE04").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE04( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGW05").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGW05( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VGE05").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVGE05( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","KZ").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setKZ( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class ExtensionMapper{ + + public static java.lang.Object getTypeObject(java.lang.String namespaceURI, + java.lang.String typeName, + javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "MSG_BODY_type0".equals(typeName)){ + + return MSG_BODY_type0.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "DT_TCM2SAP_CA21".equals(typeName)){ + + return DT_TCM2SAP_CA21.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "DT_SAP2TCM_CA21".equals(typeName)){ + + return DT_SAP2TCM_CA21.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "HEADER_type0".equals(typeName)){ + + return HEADER_type0.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "MSG_HDR_type0".equals(typeName)){ + + return MSG_HDR_type0.Factory.parse(reader); + + + } + + + throw new org.apache.axis2.databinding.ADBException("Unsupported type " + namespaceURI + " " + typeName); + } + + } + + public static class MSG_HDR_type0 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = MSG_HDR_type0 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MSGID + */ + + + protected java.lang.String localMSGID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMSGIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMSGID(){ + return localMSGID; + } + + + + /** + * Auto generated setter method + * @param param MSGID + */ + public void setMSGID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMSGIDTracker = true; + } else { + localMSGIDTracker = false; + + } + + this.localMSGID=param; + + + } + + + /** + * field for BUSID + */ + + + protected java.lang.String localBUSID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localBUSIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getBUSID(){ + return localBUSID; + } + + + + /** + * Auto generated setter method + * @param param BUSID + */ + public void setBUSID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localBUSIDTracker = true; + } else { + localBUSIDTracker = false; + + } + + this.localBUSID=param; + + + } + + + /** + * field for TLGID + */ + + + protected java.lang.String localTLGID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localTLGIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getTLGID(){ + return localTLGID; + } + + + + /** + * Auto generated setter method + * @param param TLGID + */ + public void setTLGID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localTLGIDTracker = true; + } else { + localTLGIDTracker = false; + + } + + this.localTLGID=param; + + + } + + + /** + * field for LGNAME + */ + + + protected java.lang.String localLGNAME ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localLGNAMETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getLGNAME(){ + return localLGNAME; + } + + + + /** + * Auto generated setter method + * @param param LGNAME + */ + public void setLGNAME(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localLGNAMETracker = true; + } else { + localLGNAMETracker = false; + + } + + this.localLGNAME=param; + + + } + + + /** + * field for DTSEND + */ + + + protected java.lang.String localDTSEND ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localDTSENDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getDTSEND(){ + return localDTSEND; + } + + + + /** + * Auto generated setter method + * @param param DTSEND + */ + public void setDTSEND(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localDTSENDTracker = true; + } else { + localDTSENDTracker = false; + + } + + this.localDTSEND=param; + + + } + + + /** + * field for SENDER + */ + + + protected java.lang.String localSENDER ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSENDERTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSENDER(){ + return localSENDER; + } + + + + /** + * Auto generated setter method + * @param param SENDER + */ + public void setSENDER(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSENDERTracker = true; + } else { + localSENDERTracker = false; + + } + + this.localSENDER=param; + + + } + + + /** + * field for RECEIVER + */ + + + protected java.lang.String localRECEIVER ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localRECEIVERTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getRECEIVER(){ + return localRECEIVER; + } + + + + /** + * Auto generated setter method + * @param param RECEIVER + */ + public void setRECEIVER(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localRECEIVERTracker = true; + } else { + localRECEIVERTracker = false; + + } + + this.localRECEIVER=param; + + + } + + + /** + * field for REEUSE + */ + + + protected java.lang.String localREEUSE ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localREEUSETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getREEUSE(){ + return localREEUSE; + } + + + + /** + * Auto generated setter method + * @param param REEUSE + */ + public void setREEUSE(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localREEUSETracker = true; + } else { + localREEUSETracker = false; + + } + + this.localREEUSE=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MSG_HDR_type0.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":MSG_HDR_type0", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "MSG_HDR_type0", + xmlWriter); + } + + + } + if (localMSGIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MSGID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MSGID"); + } + + } else { + xmlWriter.writeStartElement("MSGID"); + } + + + if (localMSGID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MSGID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMSGID); + + } + + xmlWriter.writeEndElement(); + } if (localBUSIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"BUSID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"BUSID"); + } + + } else { + xmlWriter.writeStartElement("BUSID"); + } + + + if (localBUSID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("BUSID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localBUSID); + + } + + xmlWriter.writeEndElement(); + } if (localTLGIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"TLGID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"TLGID"); + } + + } else { + xmlWriter.writeStartElement("TLGID"); + } + + + if (localTLGID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("TLGID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localTLGID); + + } + + xmlWriter.writeEndElement(); + } if (localLGNAMETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"LGNAME", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"LGNAME"); + } + + } else { + xmlWriter.writeStartElement("LGNAME"); + } + + + if (localLGNAME==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("LGNAME cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localLGNAME); + + } + + xmlWriter.writeEndElement(); + } if (localDTSENDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"DTSEND", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"DTSEND"); + } + + } else { + xmlWriter.writeStartElement("DTSEND"); + } + + + if (localDTSEND==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("DTSEND cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localDTSEND); + + } + + xmlWriter.writeEndElement(); + } if (localSENDERTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"SENDER", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"SENDER"); + } + + } else { + xmlWriter.writeStartElement("SENDER"); + } + + + if (localSENDER==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("SENDER cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSENDER); + + } + + xmlWriter.writeEndElement(); + } if (localRECEIVERTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"RECEIVER", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"RECEIVER"); + } + + } else { + xmlWriter.writeStartElement("RECEIVER"); + } + + + if (localRECEIVER==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("RECEIVER cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localRECEIVER); + + } + + xmlWriter.writeEndElement(); + } if (localREEUSETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"REEUSE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"REEUSE"); + } + + } else { + xmlWriter.writeStartElement("REEUSE"); + } + + + if (localREEUSE==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("REEUSE cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localREEUSE); + + } + + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMSGIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MSGID")); + + if (localMSGID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMSGID)); + } else { + throw new org.apache.axis2.databinding.ADBException("MSGID cannot be null!!"); + } + } if (localBUSIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "BUSID")); + + if (localBUSID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBUSID)); + } else { + throw new org.apache.axis2.databinding.ADBException("BUSID cannot be null!!"); + } + } if (localTLGIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "TLGID")); + + if (localTLGID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localTLGID)); + } else { + throw new org.apache.axis2.databinding.ADBException("TLGID cannot be null!!"); + } + } if (localLGNAMETracker){ + elementList.add(new javax.xml.namespace.QName("", + "LGNAME")); + + if (localLGNAME != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localLGNAME)); + } else { + throw new org.apache.axis2.databinding.ADBException("LGNAME cannot be null!!"); + } + } if (localDTSENDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "DTSEND")); + + if (localDTSEND != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localDTSEND)); + } else { + throw new org.apache.axis2.databinding.ADBException("DTSEND cannot be null!!"); + } + } if (localSENDERTracker){ + elementList.add(new javax.xml.namespace.QName("", + "SENDER")); + + if (localSENDER != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSENDER)); + } else { + throw new org.apache.axis2.databinding.ADBException("SENDER cannot be null!!"); + } + } if (localRECEIVERTracker){ + elementList.add(new javax.xml.namespace.QName("", + "RECEIVER")); + + if (localRECEIVER != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localRECEIVER)); + } else { + throw new org.apache.axis2.databinding.ADBException("RECEIVER cannot be null!!"); + } + } if (localREEUSETracker){ + elementList.add(new javax.xml.namespace.QName("", + "REEUSE")); + + if (localREEUSE != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localREEUSE)); + } else { + throw new org.apache.axis2.databinding.ADBException("REEUSE cannot be null!!"); + } + } + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MSG_HDR_type0 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MSG_HDR_type0 object = + new MSG_HDR_type0(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"MSG_HDR_type0".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (MSG_HDR_type0)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MSGID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMSGID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","BUSID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setBUSID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","TLGID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setTLGID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","LGNAME").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setLGNAME( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","DTSEND").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setDTSEND( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","SENDER").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSENDER( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","RECEIVER").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setRECEIVER( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","REEUSE").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setREEUSE( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + private org.apache.axiom.om.OMElement toOM(SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21 param, boolean optimizeContent) + throws org.apache.axis2.AxisFault { + + + try{ + return param.getOMElement(SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + } catch(org.apache.axis2.databinding.ADBException e){ + throw org.apache.axis2.AxisFault.makeFault(e); + } + + + } + + private org.apache.axiom.om.OMElement toOM(SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21 param, boolean optimizeContent) + throws org.apache.axis2.AxisFault { + + + try{ + return param.getOMElement(SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + } catch(org.apache.axis2.databinding.ADBException e){ + throw org.apache.axis2.AxisFault.makeFault(e); + } + + + } + + + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21 param, boolean optimizeContent) + throws org.apache.axis2.AxisFault{ + + + try{ + + org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); + emptyEnvelope.getBody().addChild(param.getOMElement(SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21.MY_QNAME,factory)); + return emptyEnvelope; + } catch(org.apache.axis2.databinding.ADBException e){ + throw org.apache.axis2.AxisFault.makeFault(e); + } + + + } + + + /* methods to provide back word compatibility */ + + + + + /** + * get the default envelope + */ + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory){ + return factory.getDefaultEnvelope(); + } + + + private java.lang.Object fromOM( + org.apache.axiom.om.OMElement param, + java.lang.Class type, + java.util.Map extraNamespaces) throws org.apache.axis2.AxisFault{ + + try { + + if (SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21.class.equals(type)){ + + return SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21.Factory.parse(param.getXMLStreamReaderWithoutCaching()); + + + } + + if (SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21.class.equals(type)){ + + return SI_TCM2SAP_CA21_OUTServiceStub.MT_SAP2TCM_CA21.Factory.parse(param.getXMLStreamReaderWithoutCaching()); + + + } + + } catch (java.lang.Exception e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + return null; + } + + + + + } + \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPCommand.java new file mode 100644 index 0000000..3eeeb9e --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPCommand.java @@ -0,0 +1,302 @@ +package com.connor.ml.tcm.ML_07; + +import java.awt.Dimension; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.ml.tcm.util.DbPool; +import com.teamcenter.rac.aif.AbstractAIFCommand; +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.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SendProcessToSAPCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent[] comps; + private TCSession session; + + public SendProcessToSAPCommand(InterfaceAIFComponent[] comps, TCSession session) { + // Auto-generated constructor stub + this.comps = comps; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // Auto-generated method stub + String option = session.getPreferenceService().getStringValue("ML_Process&ProductRev"); + if(option==null || option.isEmpty()) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR); + return; + } + TCComponent dataset = session.stringToComponent(option); + if(!dataset.isTypeOf("MSExcelX")) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR);//ASPAAIIN5kSPsC + return; + } + String dateStr = session.getPreferenceService().getStringValue("ML_Process&Product_Data"); + System.out.println("dateStr ==> "+ dateStr); + FileInputStream inpu = null; + XSSFWorkbook wb = null; + ArrayList excelMap = new ArrayList<>(); + try { + File file = ((TCComponentDataset)dataset).getTcFiles()[0].getFile(System.getProperty("java.io.tmpdir")); + inpu = new FileInputStream(file); + wb = new XSSFWorkbook(inpu); + XSSFSheet sheet = wb.getSheetAt(0); + for(int i=1; i compList = new ArrayList<>(); + for (int jj = 0; jj < comps.length; jj++) { + InterfaceAIFComponent comp = comps[jj]; + //判断选中的是否为BOMLine + if(comp instanceof TCComponentBOMLine) { + compList.add(((TCComponentBOMLine)comp).getItemRevision()); + } else if(comp instanceof TCComponentItemRevision) { + compList.add((TCComponentItemRevision)comp); + } else if(comp instanceof TCComponentTask) { + //选中的任务 + TCComponentTask task = (TCComponentTask)comp; + TCComponentContextList contextList = task.getRelatedList("root_target_attachments"); + for (int i = 0; i < contextList.getListCount(); i++) { + if (contextList.get(i).getComponent() instanceof TCComponentItemRevision) { + compList.add((TCComponentItemRevision)contextList.get(i).getComponent()); + } + } + } + } + + //comps = compList.toArray(new TCComponent[compList.size()]); + + List> dataList = new ArrayList>(); + List> haveList = new ArrayList>(); + StringBuilder error = new StringBuilder(""); + for (TCComponentItemRevision itemRevision : compList) { + //判断加工方式 + itemRevision.refresh(); + String processingMode = itemRevision.getStringProperty("ml8_ProcessingMode"); + if(!processingMode.equals("自制") && !processingMode.equals("ODM/OEM(销售)")) { + error.append(itemRevision).append("、"); + } + } + if(error.length()>0) { + MessageBox.post(error.deleteCharAt(error.length()-1).append(" 不是自制件和ODM/OEM(销售),不能进行工艺路线维护操作!").toString(), "错误", MessageBox.ERROR); + return; + } + for (TCComponentItemRevision itemRevision : compList) { + //获取界面显示的数据 + String selectItemId = itemRevision.getUid(); + String itemId = itemRevision.getStringProperty("item_id"); + if(itemId.indexOf("-") > 0) + { + itemId = itemId.split("-")[0]; + } + String objectName = itemRevision.getStringProperty("object_name"); + String factory = itemRevision.getStringProperty("ml8_Factory"); +// String fac = itemRevision.getProperty("ml8_Factory"); +// String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + + //根据物料编码、工厂、组计数器从工艺路线表中查询出工艺路线组的值 + InputStream input = null; + ResultSet rs = null; + boolean isHave = false; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), itemId, factory); + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + + if (rs != null) { + while (rs.next()) { + //添加数据 + List valuesList = new ArrayList(); + valuesList.add("");//类型 + valuesList.add("");//组名 + valuesList.add(itemId);//物料编码 + valuesList.add(objectName);//物料描述 + valuesList.add(factory);//工厂 + valuesList.add(dateStr);//关键日期 + valuesList.add("");//组计数器 + valuesList.add("1");//用途 + valuesList.add("4");//状态 + valuesList.add("10");//工序 + valuesList.add(rs.getString("ARBPL"));//工作中心 + valuesList.add("PP03");//控制代码 + valuesList.add(rs.getString("LTXA1"));//工序描述 + valuesList.add("1");//基本数量 + valuesList.add(rs.getString("VGW01"));//工时 + valuesList.add("H");//工时单位 + valuesList.add(rs.getString("VGW02"));//固定制造费用 + valuesList.add("H");//时间单位 + valuesList.add(rs.getString("VGW03"));//动力费用 + valuesList.add("H");//时间单位 + valuesList.add(rs.getString("VGW04"));//其他制造费用 + valuesList.add("H");//时间单位 + valuesList.add(rs.getString("VGW05"));//排产准备时间 + valuesList.add("H");//时间单位 + valuesList.add(rs.getString("PLNNR"));//工艺路线组 + valuesList.add("U");//处理标记 + valuesList.add(selectItemId);//对象UID + + dataList.add(valuesList); + haveList.add(valuesList); + isHave = true; + break; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e2) { + // Auto-generated catch block + e2.printStackTrace(); + } + } + if (rs != null) { + try { + rs.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + if(!isHave) + { + List valuesList = new ArrayList(); + valuesList.add("");//类型 + valuesList.add("");//组名 + valuesList.add(itemId);//物料编码 + valuesList.add(objectName);//物料描述 + valuesList.add(factory);//工厂 + valuesList.add(dateStr);//关键日期 + valuesList.add("");//组计数器 + valuesList.add("1");//用途 + valuesList.add("4");//状态 + valuesList.add("10");//工序 + valuesList.add("");//工作中心 + valuesList.add("PP03");//控制代码 + valuesList.add("");//工序描述 + valuesList.add("1");//基本数量 + valuesList.add("");//工时 + valuesList.add("H");//工时单位 + valuesList.add("");//固定制造费用 + valuesList.add("H");//时间单位 + valuesList.add("");//动力费用 + valuesList.add("H");//时间单位 + valuesList.add("");//其他制造费用 + valuesList.add("H");//时间单位 + valuesList.add("");//排产准备时间 + valuesList.add("H");//时间单位 + valuesList.add("");//工艺路线组 + valuesList.add("I");//处理标记 + valuesList.add(selectItemId);//对象UID + dataList.add(valuesList); + } + } + if(haveList.size() > 0) { + StringBuilder haveStringBuilder = new StringBuilder(); + for (int i = 0; i < haveList.size(); i++) { + haveStringBuilder.append("物料:"); + haveStringBuilder.append(haveList.get(i).get(2)); + haveStringBuilder.append("工厂:"); + haveStringBuilder.append(haveList.get(i).get(4)); + haveStringBuilder.append("组计数器:"); + haveStringBuilder.append(haveList.get(i).get(6)); + haveStringBuilder.append("\n"); + } + haveStringBuilder.append("已传递过工艺路线,是否重新传递?"); + JTextArea textArea = new JTextArea(haveStringBuilder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setPreferredSize(new Dimension(400, 300)); + int i = JOptionPane.showConfirmDialog(null, scrollPane, "重新传递", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + dataList.removeAll(haveList); + } + } + + new Thread() { + @Override + public void run() { + new SendProcessToSAPDialog(session, dataList, excelMap); + } + }.start(); + + + super.executeModal(); + } + + private XSSFRow getRow(XSSFSheet sheet, int num) throws Exception { + XSSFRow row = sheet.getRow(num); + if(row==null) + row = sheet.createRow(num); + return row; + } + private XSSFCell getCell(XSSFRow row, int col) throws Exception { + XSSFCell cell = row.getCell(col); + if(cell==null) + cell = row.createCell(col); + return cell; + } + private String getValue(XSSFCell cell) { + Object value = null; + CellType type = cell.getCellTypeEnum(); + if(type == CellType.STRING) + value = cell.getStringCellValue(); + else if(type == CellType.NUMERIC) + value = (int)cell.getNumericCellValue(); + return value + ""; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPDialog.java new file mode 100644 index 0000000..35a9808 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPDialog.java @@ -0,0 +1,592 @@ +package com.connor.ml.tcm.ML_07; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; + +import org.apache.axis2.Constants.Configuration; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HttpTransportProperties; +import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator; + +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.DT_SAP2TCM_CA21; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.DT_TCM2SAP_CA21; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.HEADER_type0; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.MSG_BODY_type0; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.MSG_HDR_type0; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21; +import com.connor.ml.tcm.ML_08.SendProductRevCommand; +import com.connor.ml.tcm.ML_18.ScreenShotTest; +import com.connor.ml.tcm.ML_07.CTMap; +import com.connor.ml.tcm.bean.SendSAPProcessBean; +import com.connor.ml.tcm.cloneProcess.WebApiUtil; +import com.connor.ml.tcm.util.Adapter; +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MLRequestEntity; +import com.connor.ml.tcm.util.MLtoERPEntity; +import com.connor.ml.tcm.util.MLtoERPEntity2; +import com.google.gson.Gson; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + + +public class SendProcessToSAPDialog extends AbstractAIFDialog implements ActionListener { + + /** + * + */ + private static final long serialVersionUID = 1L; + private TCSession session; + private String[] header = new String[] { "类型", "组名", "物料编码", "物料描述", "工厂", "关键日期", "组计数器", "用途", "状态", "工序", "工作中心", + "控制代码", "工序描述", "基本数量", "工时", "工时单位", "固定制造费用", "时间单位", "动力费用", "时间单位", "其他制造费用", + "时间单位", "排产准备时间", "时间单位", "工艺路线组", "处理标记", "对象UID" }; + + private List> dataTableList; + private String[][] dataValues; + private ArrayList excelMap; + + protected CTable mainTable;// 产品配置表 + private CTMap mainTableModel; + + private JPanel rootPanel; + private JButton sendButton; + private JButton closeButton; + private final String url = ""; + + public SendProcessToSAPDialog(TCSession session, List> dataTableList, ArrayList excelMap) { + // Auto-generated constructor stub + this.session = session; + this.dataTableList = dataTableList; + this.excelMap = excelMap; + + this.dataValues = new String[this.dataTableList.size()][]; + for (int i = 0; i < this.dataTableList.size(); i++) { + this.dataValues[i] = new String[this.dataTableList.get(i).size()]; + for (int j = 0; j < this.dataTableList.get(i).size(); j++) { + this.dataValues[i][j] = this.dataTableList.get(i).get(j); + } + } + + init(); + } + + private void init() { + // Auto-generated method stub + this.setTitle("传递的工艺路线数据"); + this.setPreferredSize(new Dimension(800, 600)); + + this.mainTable = getjTable(mainTable, mainTableModel, header, dataValues); + this.addData(dataValues); + this.rootPanel = new JPanel(new FlowLayout()); + this.sendButton = new JButton("传递"); + this.closeButton = new JButton("取消"); + + this.rootPanel.add(sendButton); + this.rootPanel.add(closeButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(new JScrollPane(this.mainTable), BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); +// this.show(); + this.setVisible(true); + } + + // 添加监听 + public void createActionEvent() { + this.sendButton.addActionListener(this); + this.closeButton.addActionListener(this); + } + + /*** + * Jtable通用方法 + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public CTable getjTable(CTable partsTable, CTMap dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + CTMap map = new CTMap(1, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); +// for(Object[] row : values) +// map.addRow(row); + partsTable = new CTable(map, excelMap); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.HiddenCell(titleNames.length - 1); + // 设置显示器渲染 + partsTable.setRowHeight(50); + new Adapter(partsTable); + + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + // //设置居中 + partsTable.setDefaultRenderer(Object.class, renderer); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public void addData(Object[][] cellData2) { + CTMap tableModel = (CTMap) this.mainTable.getModel(); + tableModel.insertRow(0); + for (int i = tableModel.getRowCount() - 1; i > 0; i--) { + tableModel.removeRow(0); + } + for (int i = cellData2.length - 1; i >= 0; i--) { + tableModel.insertRow(0); + for (int j = 0; j < cellData2[i].length; j++) { + tableModel.setValueAt(cellData2[i][j], 0, j); + } + } + tableModel.removeRow(cellData2.length); + // 表格数据不可修改 + this.mainTable.setEnabled(true); + // 更新表格 + this.mainTable.invalidate(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.sendButton)) { + //刷新表格 + mainTable.invalidate(); + System.out.println("表格已刷新,开始发送"); + InputStream input = null; + HashMap searches = new HashMap<>(); + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + StringBuffer messageString = new StringBuffer(); +// List itemRevisionList = new ArrayList(); + HashMap itemRevisionList = new HashMap<>(); + for (int i = 0; i < this.mainTable.getRowCount(); i++) { + if (this.mainTable.getValueAt(i, 0) == null || this.mainTable.getValueAt(i, 0).toString().isEmpty() + || this.mainTable.getValueAt(i, 0).toString().equals(" ")) { + continue; + } + if (this.mainTable.getValueAt(i, 1) == null || this.mainTable.getValueAt(i, 1).toString().isEmpty() + || this.mainTable.getValueAt(i, 1).toString().equals(" ")) { + continue; + } + + SendSAPProcessBean sendSAPProcessBean = new SendSAPProcessBean(); + sendSAPProcessBean.setMSGID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProcessBean.setBUSID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProcessBean.setTLGID("JT0001"); + sendSAPProcessBean.setTLGNAME("维护工艺路线接口"); + sendSAPProcessBean.setDTSEND(sdf.format(new Date())); + sendSAPProcessBean.setSENDER("TCM"); + sendSAPProcessBean.setRECEIVER("SAP"); + sendSAPProcessBean.setFREEUSE(""); + sendSAPProcessBean.setTYPE(this.mainTable.getValueAt(i, 0) == null ? "" : this.mainTable.getValueAt(i, 0).toString()); + sendSAPProcessBean.setGROUPNAME(this.mainTable.getValueAt(i, 1) == null ? "" : this.mainTable.getValueAt(i, 1).toString()); + sendSAPProcessBean.setMATNR(this.mainTable.getValueAt(i, 2) == null ? "" : this.mainTable.getValueAt(i, 2).toString()); + sendSAPProcessBean.setWERKS(this.mainTable.getValueAt(i, 4) == null ? "" : this.mainTable.getValueAt(i, 4).toString()); + sendSAPProcessBean.setDATUV(this.mainTable.getValueAt(i, 5) == null ? "" : this.mainTable.getValueAt(i, 5).toString()); + sendSAPProcessBean.setPLNAL(this.mainTable.getValueAt(i, 6) == null ? "" : this.mainTable.getValueAt(i, 6).toString()); + sendSAPProcessBean.setVERWE(this.mainTable.getValueAt(i, 7) == null ? "" : this.mainTable.getValueAt(i, 7).toString()); + sendSAPProcessBean.setSTATU(this.mainTable.getValueAt(i, 8) == null ? "" : this.mainTable.getValueAt(i, 8).toString()); + sendSAPProcessBean.setVORNR(this.mainTable.getValueAt(i, 9) == null ? "" : this.mainTable.getValueAt(i, 9).toString()); + sendSAPProcessBean.setARBPL(this.mainTable.getValueAt(i, 10) == null ? "" : this.mainTable.getValueAt(i, 10).toString()); + sendSAPProcessBean.setSTEUS(this.mainTable.getValueAt(i, 11) == null ? "" : this.mainTable.getValueAt(i, 11).toString()); + sendSAPProcessBean.setLTXA1(this.mainTable.getValueAt(i, 12) == null ? "" : this.mainTable.getValueAt(i, 12).toString()); + sendSAPProcessBean.setBMSCH(this.mainTable.getValueAt(i, 13) == null ? "" : this.mainTable.getValueAt(i, 13).toString()); + sendSAPProcessBean.setVGW01(this.mainTable.getValueAt(i, 14) == null ? "" : this.mainTable.getValueAt(i, 14).toString()); + sendSAPProcessBean.setVGE01(this.mainTable.getValueAt(i, 15) == null ? "" : this.mainTable.getValueAt(i, 15).toString()); + sendSAPProcessBean.setVGW02(this.mainTable.getValueAt(i, 16) == null ? "" : this.mainTable.getValueAt(i, 16).toString()); + sendSAPProcessBean.setVGE02(this.mainTable.getValueAt(i, 17) == null ? "" : this.mainTable.getValueAt(i, 17).toString()); + sendSAPProcessBean.setVGW03(this.mainTable.getValueAt(i, 18) == null ? "" : this.mainTable.getValueAt(i, 18).toString()); + sendSAPProcessBean.setVGE03(this.mainTable.getValueAt(i, 19) == null ? "" : this.mainTable.getValueAt(i, 19).toString()); + sendSAPProcessBean.setVGW04(this.mainTable.getValueAt(i, 20) == null ? "" : this.mainTable.getValueAt(i, 20).toString()); + sendSAPProcessBean.setVGE04(this.mainTable.getValueAt(i, 21) == null ? "" : this.mainTable.getValueAt(i, 21).toString()); + sendSAPProcessBean.setVGW05(this.mainTable.getValueAt(i, 22) == null ? "" : this.mainTable.getValueAt(i, 22).toString()); + sendSAPProcessBean.setVGE05(this.mainTable.getValueAt(i, 23) == null ? "" : this.mainTable.getValueAt(i, 23).toString()); + sendSAPProcessBean.setPLNNR(this.mainTable.getValueAt(i, 24) == null ? "" : this.mainTable.getValueAt(i, 24).toString()); + sendSAPProcessBean.setKZ(this.mainTable.getValueAt(i, 25) == null ? "" : this.mainTable.getValueAt(i, 25).toString()); + sendSAPProcessBean.setSTATUS(""); + sendSAPProcessBean.setMESSAGE(""); + +// SI_TCM2SAP_CA21_OUTServiceStub stub = new SI_TCM2SAP_CA21_OUTServiceStub(); +// +// HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator(); +// +// List authSchemes = new ArrayList<>(); +// +// authSchemes.add(Authenticator.BASIC); +// +// basicAuth.setAuthSchemes(authSchemes); +// +// basicAuth.setUsername("TCMCONN"); //TODO chailian +// +// basicAuth.setPassword("Zaq1xsw2"); //1q2w1Q2W!.@ +// +// basicAuth.setPreemptiveAuthentication(true); +// +//// Authenticator basicAuth = new Authenticator(); +//// basicAuth.setUsername("TCMCONN"); +//// basicAuth.setPassword("Zaq1xsw2"); +// stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuth); +// stub._getServiceClient().getOptions().setProperty(Configuration.CHARACTER_SET_ENCODING, "GBK"); +// stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300 * 1000); +// stub._getServiceClient().getOptions().setProperty(Configuration.HTTP_METHOD, HTTPConstants.HTTP_METHOD_POST); +// +// MSG_HDR_type0 mt_person = new MSG_HDR_type0(); +// mt_person.setMSGID(sendSAPProcessBean.getMSGID()); +// mt_person.setBUSID(sendSAPProcessBean.getBUSID()); +// mt_person.setTLGID(sendSAPProcessBean.getTLGID()); +// mt_person.setLGNAME(sendSAPProcessBean.getTLGNAME()); +// mt_person.setDTSEND(sendSAPProcessBean.getDTSEND()); +// mt_person.setSENDER(sendSAPProcessBean.getSENDER()); +// mt_person.setRECEIVER(sendSAPProcessBean.getRECEIVER()); +// mt_person.setREEUSE(sendSAPProcessBean.getFREEUSE()); +// MSG_BODY_type0 body_type0 = new MSG_BODY_type0(); +// HEADER_type0 type0 = new HEADER_type0(); +// type0.setMATNR(sendSAPProcessBean.getMATNR()); +// type0.setWERKS(sendSAPProcessBean.getWERKS()); +// type0.setPLNNR(""); +// type0.setPLNAL(sendSAPProcessBean.getPLNAL()); +// type0.setDATUV(sendSAPProcessBean.getDATUV()); +// type0.setVERWE(sendSAPProcessBean.getVERWE()); +// type0.setSTATU(sendSAPProcessBean.getSTATU()); +// type0.setVORNR(sendSAPProcessBean.getVORNR()); +// type0.setSTEUS(sendSAPProcessBean.getSTEUS()); +// type0.setARBPL(sendSAPProcessBean.getARBPL()); +// type0.setLTXA1(sendSAPProcessBean.getLTXA1()); +// type0.setBMSCH(sendSAPProcessBean.getBMSCH()); +// type0.setVGW01(sendSAPProcessBean.getVGW01()); +// type0.setVGE01(sendSAPProcessBean.getVGE01()); +// type0.setVGW02(sendSAPProcessBean.getVGW02()); +// type0.setVGE02(sendSAPProcessBean.getVGE02()); +// type0.setVGW03(sendSAPProcessBean.getVGW03()); +// type0.setVGE03(sendSAPProcessBean.getVGE03()); +// type0.setVGW04(sendSAPProcessBean.getVGW04()); +// type0.setVGE04(sendSAPProcessBean.getVGE04()); +// type0.setVGW05(sendSAPProcessBean.getVGW05()); +// type0.setVGE05(sendSAPProcessBean.getVGE05()); +// type0.setKZ(sendSAPProcessBean.getKZ()); + // 获取配置信息中的url + InputStream in = ScreenShotTest.class.getResourceAsStream("/toERP.properties"); + Properties p = new Properties(); + p.load(in); +// String url = p.getProperty("url"); + String url = "http://mlapp.meiling.com/plmwebapi/sap/setinfo"; + MLtoERPEntity mLtoERPEntity = new MLtoERPEntity(); + mLtoERPEntity.setInfotype("工艺路线"); + mLtoERPEntity.setInfocode(session.getUser().getUserId()); + mLtoERPEntity.setInfoname(p.getProperty("infoname")); + mLtoERPEntity.setInfodesc(""); + List list1 = new ArrayList(); + List list2 = new ArrayList(); + + MLtoERPEntity2 field1 = new MLtoERPEntity2(); + field1.setField("MATNR"); + field1.setValue(sendSAPProcessBean.getMATNR()); + list1.add(field1); + MLtoERPEntity2 field2 = new MLtoERPEntity2(); + field2.setField("WERKS"); + field2.setValue(sendSAPProcessBean.getWERKS()); + list1.add(field2); + MLtoERPEntity2 field3 = new MLtoERPEntity2(); + field3.setField("PLNNR"); + field3.setValue(""); + list1.add(field3); + MLtoERPEntity2 field4 = new MLtoERPEntity2(); + field4.setField("PLNAL"); + field4.setValue(sendSAPProcessBean.getPLNAL()); + list1.add(field4); + MLtoERPEntity2 field5 = new MLtoERPEntity2(); + field5.setField("DATUV"); + field5.setValue(sendSAPProcessBean.getDATUV()); + list1.add(field5); + MLtoERPEntity2 field6 = new MLtoERPEntity2(); + field6.setField("VERWE"); + field6.setValue(sendSAPProcessBean.getVERWE()); + list1.add(field6); + MLtoERPEntity2 field7 = new MLtoERPEntity2(); + field7.setField("STATU"); + field7.setValue(sendSAPProcessBean.getSTATU()); + list1.add(field7); + MLtoERPEntity2 field8 = new MLtoERPEntity2(); + field8.setField("VORNR"); + field8.setValue(sendSAPProcessBean.getVORNR()); + list1.add(field8); + MLtoERPEntity2 field9 = new MLtoERPEntity2(); + field9.setField("STEUS"); + field9.setValue(sendSAPProcessBean.getSTEUS()); + list1.add(field9); + MLtoERPEntity2 field10 = new MLtoERPEntity2(); + field10.setField("ARBPL"); + field10.setValue(sendSAPProcessBean.getARBPL()); + list1.add(field10); + MLtoERPEntity2 field11 = new MLtoERPEntity2(); + field11.setField("LTXA1"); + field11.setValue(sendSAPProcessBean.getLTXA1()); + list1.add(field11); + MLtoERPEntity2 field12 = new MLtoERPEntity2(); + field12.setField("BMSCH"); + field12.setValue(sendSAPProcessBean.getBMSCH()); + list1.add(field12); + MLtoERPEntity2 field13 = new MLtoERPEntity2(); + field13.setField("VGW01"); + field13.setValue(sendSAPProcessBean.getVGW01()); + list1.add(field13); + MLtoERPEntity2 field14 = new MLtoERPEntity2(); + field14.setField("VGE01"); + field14.setValue(sendSAPProcessBean.getVGE01()); + list1.add(field14); + MLtoERPEntity2 field15 = new MLtoERPEntity2(); + field15.setField("VGW02"); + field15.setValue(sendSAPProcessBean.getVGW02()); + list1.add(field15); + MLtoERPEntity2 field16 = new MLtoERPEntity2(); + field16.setField("VGE02"); + field16.setValue(sendSAPProcessBean.getVGE02()); + list1.add(field16); + MLtoERPEntity2 field17 = new MLtoERPEntity2(); + field17.setField("VGW03"); + field17.setValue(sendSAPProcessBean.getVGW03()); + list1.add(field17); + MLtoERPEntity2 field18 = new MLtoERPEntity2(); + field18.setField("VGE03"); + field18.setValue(sendSAPProcessBean.getVGE03()); + list1.add(field18); + MLtoERPEntity2 field19 = new MLtoERPEntity2(); + field19.setField("VGW04"); + field19.setValue(sendSAPProcessBean.getVGW04()); + list1.add(field19); + MLtoERPEntity2 field20 = new MLtoERPEntity2(); + field20.setField("VGE04"); + field20.setValue(sendSAPProcessBean.getVGE04()); + list1.add(field20); + MLtoERPEntity2 field21 = new MLtoERPEntity2(); + field21.setField("VGW05"); + field21.setValue(sendSAPProcessBean.getVGW05()); + list1.add(field21); + MLtoERPEntity2 field22 = new MLtoERPEntity2(); + field22.setField("VGE05"); + field22.setValue(sendSAPProcessBean.getVGE05()); + list1.add(field22); + MLtoERPEntity2 field23 = new MLtoERPEntity2(); + field23.setField("KZ"); + field23.setValue(sendSAPProcessBean.getKZ()); + list1.add(field23); + mLtoERPEntity.setData(list1); + mLtoERPEntity.setList(list2); + Gson gson = new Gson(); + String json = gson.toJson(mLtoERPEntity); + System.out.println("工艺路线json"); + System.out.println(json); + String doPostResult = WebApiUtil.doPost(url, json); + System.out.println("返回值:"+doPostResult); + MLRequestEntity resultEntity = gson.fromJson(doPostResult, MLRequestEntity.class); + String result = resultEntity.getResult(); + JSONObject fromObject = JSONObject.fromObject(result); + String PLNNRstr = fromObject.get("PLNNR").toString(); +// body_type0.setHEADER(type0); +// +// // 调用接口 +// DT_TCM2SAP_CA21 tcm2sap_CBSJQ = new DT_TCM2SAP_CA21(); +// tcm2sap_CBSJQ.setMSG_HDR(mt_person); +// tcm2sap_CBSJQ.setMSG_BODY(body_type0); +// MT_TCM2SAP_CA21 tcm2sap_CBSJQ2 = new MT_TCM2SAP_CA21(); +// tcm2sap_CBSJQ2.setMT_TCM2SAP_CA21(tcm2sap_CBSJQ); +// DT_SAP2TCM_CA21 sap2tcm_CA21 = stub.SI_TCM2SAP_CA21_OUT(tcm2sap_CBSJQ2).getMT_SAP2TCM_CA21(); +// + System.out.println("sap2tcm_CA21.getSTATUS():" + resultEntity.getErrcode()); + System.out.println("sap2tcm_CA21.getMESSAGE():" + resultEntity.getErrmsg()); + System.out.println("sap2tcm_CA21.getPLNNR():" + PLNNRstr); + +// String plnnr = sendSAPProcessBean.getVGE04(); + +// if (sap2tcm_CA21.getSTATUS().equals("S")) { + if ("0".equals(resultEntity.getErrcode())) { + sendSAPProcessBean.setSTATUS(resultEntity.getErrcode()); + sendSAPProcessBean.setMESSAGE(resultEntity.getErrmsg()); +// sendSAPProcessBean.setPLNNR(sap2tcm_CA21.getPLNNR()); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 将数据写入到表中 + try { + String id = sendSAPProcessBean.getMATNR(), factory = sendSAPProcessBean.getWERKS(); + String key = id +"@@"+ factory; + if(searches.containsKey(key)) { + sendSAPProcessBean.setKZ(searches.get(key)); + }else { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), id, factory); + System.out.println(selectSql); + DbPool.getConnection(); + ResultSet rs = DbPool.executeSelectSql(selectSql); + if(rs.next()) { + sendSAPProcessBean.setKZ("U"); + searches.put(key, "U"); + String deleteSql = String.format(pro.getProperty("ML_TCMPROCESDELETESQL"), id, factory); + System.out.println("deleteSql == "+deleteSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(deleteSql); + DbPool.connection.commit(); + }else { + sendSAPProcessBean.setKZ("I"); + searches.put(key, "I"); + } + } + + String insertSql = String.format(pro.getProperty("ML_TCMPROCESSINSERTSQL"), + UUID.randomUUID().toString().replace("-", ""), sendSAPProcessBean.getMSGID(), + sendSAPProcessBean.getBUSID(), sendSAPProcessBean.getTLGID(), + sendSAPProcessBean.getTLGNAME(), simpleDateFormat.format(new Date()), + sendSAPProcessBean.getSENDER(), sendSAPProcessBean.getRECEIVER(), + sendSAPProcessBean.getFREEUSE(), id, factory, PLNNRstr, + sendSAPProcessBean.getPLNAL(), sendSAPProcessBean.getDATUV(), + sendSAPProcessBean.getVERWE(), sendSAPProcessBean.getSTATU(), + sendSAPProcessBean.getVORNR(), sendSAPProcessBean.getSTEUS(), + sendSAPProcessBean.getARBPL(), sendSAPProcessBean.getLTXA1(), + sendSAPProcessBean.getBMSCH(), sendSAPProcessBean.getVGW01(), + sendSAPProcessBean.getVGE01(), sendSAPProcessBean.getVGW02(), + sendSAPProcessBean.getVGE02(), sendSAPProcessBean.getVGW03(), + sendSAPProcessBean.getVGE03(), sendSAPProcessBean.getVGW04(), + sendSAPProcessBean.getVGE04(), sendSAPProcessBean.getKZ(), + resultEntity.getErrcode(), resultEntity.getErrmsg(), + sendSAPProcessBean.getTYPE(), sendSAPProcessBean.getGROUPNAME(), + sendSAPProcessBean.getVGW05(),sendSAPProcessBean.getVGE05()); + /*if (sendSAPProcessBean.getKZ().equals("U")) { + insertSql = String.format(pro.getProperty("ML_TCMPROCESSUPDATESQL"), + sendSAPProcessBean.getMSGID(), sendSAPProcessBean.getBUSID(), + simpleDateFormat.format(new Date()), sendSAPProcessBean.getPLNNR(), + sendSAPProcessBean.getDATUV(), sendSAPProcessBean.getVERWE(), + sendSAPProcessBean.getSTATU(), sendSAPProcessBean.getVORNR(), + sendSAPProcessBean.getSTEUS(), sendSAPProcessBean.getARBPL(), + sendSAPProcessBean.getLTXA1(), sendSAPProcessBean.getBMSCH(), + sendSAPProcessBean.getVGW01(), sendSAPProcessBean.getVGW02(), + sendSAPProcessBean.getVGW03(), sendSAPProcessBean.getVGW04(), + sendSAPProcessBean.getKZ(), sendSAPProcessBean.getSTATUS(), + sendSAPProcessBean.getMESSAGE(), sendSAPProcessBean.getTYPE(), + sendSAPProcessBean.getGROUPNAME(), + sendSAPProcessBean.getVGW05(), sendSAPProcessBean.getMATNR(), + sendSAPProcessBean.getWERKS(), sendSAPProcessBean.getPLNAL()); + + // 更新生产版本表的工艺路线组 + String updateSql = String.format(pro.getProperty("ML_TCMPRODUCTREVUPDATEPLNNRSQL"), + sendSAPProcessBean.getPLNNR(), sendSAPProcessBean.getMATNR(), + sendSAPProcessBean.getWERKS(), plnnr); + System.out.println(updateSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(updateSql); + DbPool.connection.commit(); + }*/ + System.out.println(insertSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + DbPool.freeAll(); + } + + String uid = this.mainTable.getValueAt(i, 26) == null ? "" : this.mainTable.getValueAt(i, 26).toString(); + + System.out.println("uid"+uid); + TCComponent component = session.stringToComponent(uid); + if (component != null) { + System.out.println("add itemRevisionList"); + // 传递生产版本 +// itemRevisionList.put(component, this.mainTable.getValueAt(i, 1).toString()); + itemRevisionList.put(component, new String[] { this.mainTable.getValueAt(i, 1).toString(), + fromObject.get("WERKS").toString(), PLNNRstr }); + } + } +// if (sap2tcm_CA21.getMESSAGE()!=null && !sap2tcm_CA21.getMESSAGE().isEmpty() && sap2tcm_CA21.getMESSAGE().equals("E")) { + if (resultEntity.getErrcode()!=null && !resultEntity.getErrcode().isEmpty() && resultEntity.getErrcode().equals("1")) { + messageString.append("【物料代码】:" +fromObject.getString("MATNR").toString()); + messageString.append("【工厂】:" +fromObject.getString("WERKS").toString()); + messageString.append("【组计数器】:" +fromObject.getString("PLNAL").toString()); + messageString.append("【发送失败】:" + sendSAPProcessBean.getMESSAGE()); + messageString.append("\n"); + } + } + System.out.println("itemRevisionList.size()"+itemRevisionList.size()); + if (itemRevisionList.size() > 0) { + SendProductRevCommand command = new SendProductRevCommand(itemRevisionList, session, true); + try { + command.executeModal(); + } catch (Exception ex) { + // Auto-generated catch block + ex.printStackTrace(); + } + } + + this.dispose(); +// if (messageString.length() > 0) { +// MessageBox.post(messageString.toString(), "错误", MessageBox.ERROR); +// } else { +// MessageBox.post("发送成功!", "成功", MessageBox.INFORMATION); +// } + } catch (Exception e2) { + e2.printStackTrace(); + // : handle exception + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e2) { + // Auto-generated catch block + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + } else if (source.equals(this.closeButton)) { + this.dispose(); +// ((CTMap)mainTable.getModel()).addRow(new String[] { "1", "2" }); +// ((CTMap)mainTable.getModel()).insertRow(0); + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPHandler.java new file mode 100644 index 0000000..e0ee395 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/SendProcessToSAPHandler.java @@ -0,0 +1,38 @@ +package com.connor.ml.tcm.ML_07; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class SendProcessToSAPHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + new Thread() { + @Override + public void run() { + SendProcessToSAPCommand command = new SendProcessToSAPCommand(app.getTargetComponents(),session); + try { + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }.start(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/TableCellTextAreaRenderer.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..cbd66aa --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_07/TableCellTextAreaRenderer.java @@ -0,0 +1,164 @@ +package com.connor.ml.tcm.ML_07; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.connor.ml.tcm.util.MethodUtil; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private Map> labelRows;//标注行 + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + + setText(value == null ? "" : value.toString()); + if (table.getColumnName(column).equals("组名") && value != null && !value.toString().isEmpty()) + { + //获取工时费用等数据 + String[] values = MethodUtil.getProcessOther(table.getValueAt(row, column-1).toString(),value.toString()); + if(values != null && values.length >= 5) { + table.setValueAt(values[0], row, 14); + table.setValueAt(values[1], row, 16); + table.setValueAt(values[2], row, 18); + table.setValueAt(values[3], row, 20); + table.setValueAt(values[4], row, 22); + } + else + { + table.setValueAt("", row, 14); + table.setValueAt("", row, 16); + table.setValueAt("", row, 18); + table.setValueAt("", row, 20); + table.setValueAt("", row, 22); + } + } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + + //判断单元格选中并且为可修改状态 + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + //setBackground(Color.BLUE); + //setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SI_TCM2SAP_C223_OUTServiceCallbackHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SI_TCM2SAP_C223_OUTServiceCallbackHandler.java new file mode 100644 index 0000000..172d9da --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SI_TCM2SAP_C223_OUTServiceCallbackHandler.java @@ -0,0 +1,23 @@ +package com.connor.ml.tcm.ML_08; + +public abstract class SI_TCM2SAP_C223_OUTServiceCallbackHandler { + protected Object clientData; + + public SI_TCM2SAP_C223_OUTServiceCallbackHandler(Object clientData) { + this.clientData = clientData; + } + + public SI_TCM2SAP_C223_OUTServiceCallbackHandler() { + this.clientData = null; + } + + public Object getClientData() { + return this.clientData; + } + + public void receiveResultSI_TCM2SAP_C223_OUT(SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 result) { + } + + public void receiveErrorSI_TCM2SAP_C223_OUT(Exception e) { + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SI_TCM2SAP_C223_OUTServiceStub.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SI_TCM2SAP_C223_OUTServiceStub.java new file mode 100644 index 0000000..eec2215 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SI_TCM2SAP_C223_OUTServiceStub.java @@ -0,0 +1,3575 @@ +package com.connor.ml.tcm.ML_08; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMDataSource; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axiom.om.impl.llom.OMSourcedElementImpl; +import org.apache.axiom.soap.SOAPEnvelope; +import org.apache.axiom.soap.SOAPFactory; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.OperationClient; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.client.Stub; +import org.apache.axis2.client.async.AxisCallback; +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.MessageContext; +import org.apache.axis2.databinding.ADBBean; +import org.apache.axis2.databinding.ADBDataSource; +import org.apache.axis2.databinding.ADBException; +import org.apache.axis2.databinding.utils.BeanUtil; +import org.apache.axis2.databinding.utils.ConverterUtil; +import org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl; +import org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter; +import org.apache.axis2.description.AxisOperation; +import org.apache.axis2.description.AxisService; +import org.apache.axis2.description.OutInAxisOperation; +import org.apache.axis2.util.CallbackReceiver; +import org.apache.axis2.util.Utils; + +public class SI_TCM2SAP_C223_OUTServiceStub extends Stub { + protected AxisOperation[] _operations; + private HashMap faultExceptionNameMap; + private HashMap faultExceptionClassNameMap; + private HashMap faultMessageMap; + private static int counter = 0; + private QName[] opNameArray; + + private static synchronized String getUniqueSuffix() { + if (counter > 99999) { + counter = 0; + } + + ++counter; + return Long.toString(System.currentTimeMillis()) + "_" + counter; + } + + private void populateAxisService() throws AxisFault { + this._service = new AxisService("SI_TCM2SAP_C223_OUTService" + getUniqueSuffix()); + this.addAnonymousOperations(); + this._operations = new AxisOperation[1]; + AxisOperation __operation = new OutInAxisOperation(); + __operation.setName(new QName("urn:changhong.com:TCM:mlsc", "SI_TCM2SAP_C223_OUT")); + this._service.addOperation(__operation); + this._operations[0] = __operation; + } + + private void populateFaults() { + } + + public SI_TCM2SAP_C223_OUTServiceStub(ConfigurationContext configurationContext, String targetEndpoint) throws AxisFault { + this(configurationContext, targetEndpoint, false); + } + + public SI_TCM2SAP_C223_OUTServiceStub(ConfigurationContext configurationContext, String targetEndpoint, boolean useSeparateListener) throws AxisFault { + this.faultExceptionNameMap = new HashMap(); + this.faultExceptionClassNameMap = new HashMap(); + this.faultMessageMap = new HashMap(); + this.opNameArray = null; + this.populateAxisService(); + this.populateFaults(); + this._serviceClient = new ServiceClient(configurationContext, this._service); + configurationContext = this._serviceClient.getServiceContext().getConfigurationContext(); + this._serviceClient.getOptions().setTo(new EndpointReference(targetEndpoint)); + this._serviceClient.getOptions().setUseSeparateListener(useSeparateListener); + } + + public SI_TCM2SAP_C223_OUTServiceStub(ConfigurationContext configurationContext) throws AxisFault { + this(configurationContext, "http://xiprd.changhong.com:58000/dir/wsdl?p=ic/d2d9d24b858835e48de53cd31e58f2b1"); + } + + public SI_TCM2SAP_C223_OUTServiceStub() throws AxisFault { + this("http://xiprd.changhong.com:58000/dir/wsdl?p=ic/d2d9d24b858835e48de53cd31e58f2b1"); + } + + public SI_TCM2SAP_C223_OUTServiceStub(String targetEndpoint) throws AxisFault { + this((ConfigurationContext)null, targetEndpoint); + } + + public SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 SI_TCM2SAP_C223_OUT(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 mT_TCM2SAP_C2230) throws RemoteException { + MessageContext _messageContext = null; + + SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 var13; + try { + OMElement faultElt; + try { + OperationClient _operationClient = this._serviceClient.createClient(this._operations[0].getName()); + _operationClient.getOptions().setAction("http://sap.com/xi/WebService/soap1.1"); + _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); + this.addPropertyToOperationClient(_operationClient, "whttp:queryParameterSeparator", "&"); + _messageContext = new MessageContext(); + faultElt = null; + SOAPEnvelope env = this.toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), mT_TCM2SAP_C2230, this.optimizeContent(new QName("urn:changhong.com:TCM:mlsc", "SI_TCM2SAP_C223_OUT"))); + this._serviceClient.addHeadersToEnvelope(env); + _messageContext.setEnvelope(env); + _operationClient.addMessageContext(_messageContext); + System.out.println("execute"); + _operationClient.execute(true); + MessageContext _returnMessageContext = _operationClient.getMessageContext("In"); + SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); + Object object = this.fromOM(_returnEnv.getBody().getFirstElement(), SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.class, this.getEnvelopeNamespaces(_returnEnv)); + var13 = (SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223)object; + } catch (AxisFault var28) { + faultElt = var28.getDetail(); + if (faultElt != null) { + if (this.faultExceptionNameMap.containsKey(faultElt.getQName())) { + try { + String exceptionClassName = (String)this.faultExceptionClassNameMap.get(faultElt.getQName()); + Class exceptionClass = Class.forName(exceptionClassName); + Exception ex = (Exception)exceptionClass.newInstance(); + String messageClassName = (String)this.faultMessageMap.get(faultElt.getQName()); + Class messageClass = Class.forName(messageClassName); + Object messageObject = this.fromOM(faultElt, messageClass, (Map)null); + Method m = exceptionClass.getMethod("setFaultMessage", messageClass); + m.invoke(ex, messageObject); + throw new RemoteException(ex.getMessage(), ex); + } catch (ClassCastException var22) { + throw var28; + } catch (ClassNotFoundException var23) { + throw var28; + } catch (NoSuchMethodException var24) { + throw var28; + } catch (InvocationTargetException var25) { + throw var28; + } catch (IllegalAccessException var26) { + throw var28; + } catch (InstantiationException var27) { + throw var28; + } + } + + throw var28; + } + + throw var28; + } + } finally { + _messageContext.getTransportOut().getSender().cleanup(_messageContext); + } + + return var13; + } + + public void startSI_TCM2SAP_C223_OUT(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 mT_TCM2SAP_C2230, final SI_TCM2SAP_C223_OUTServiceCallbackHandler callback) throws RemoteException { + OperationClient _operationClient = this._serviceClient.createClient(this._operations[0].getName()); + _operationClient.getOptions().setAction("http://sap.com/xi/WebService/soap1.1"); + _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); + this.addPropertyToOperationClient(_operationClient, "whttp:queryParameterSeparator", "&"); + SOAPEnvelope env = null; + final MessageContext _messageContext = new MessageContext(); + env = this.toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), mT_TCM2SAP_C2230, this.optimizeContent(new QName("urn:changhong.com:TCM:mlsc", "SI_TCM2SAP_C223_OUT"))); + this._serviceClient.addHeadersToEnvelope(env); + _messageContext.setEnvelope(env); + _operationClient.addMessageContext(_messageContext); + _operationClient.setCallback(new AxisCallback() { + public void onMessage(MessageContext resultContext) { + try { + SOAPEnvelope resultEnv = resultContext.getEnvelope(); + Object object = SI_TCM2SAP_C223_OUTServiceStub.this.fromOM(resultEnv.getBody().getFirstElement(), SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.class, SI_TCM2SAP_C223_OUTServiceStub.this.getEnvelopeNamespaces(resultEnv)); + callback.receiveResultSI_TCM2SAP_C223_OUT((SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223)object); + } catch (AxisFault var4) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(var4); + } + + } + + public void onError(Exception error) { + if (error instanceof AxisFault) { + AxisFault f = (AxisFault)error; + OMElement faultElt = f.getDetail(); + if (faultElt != null) { + if (SI_TCM2SAP_C223_OUTServiceStub.this.faultExceptionNameMap.containsKey(faultElt.getQName())) { + try { + String exceptionClassName = (String)SI_TCM2SAP_C223_OUTServiceStub.this.faultExceptionClassNameMap.get(faultElt.getQName()); + Class exceptionClass = Class.forName(exceptionClassName); + Exception ex = (Exception)exceptionClass.newInstance(); + String messageClassName = (String)SI_TCM2SAP_C223_OUTServiceStub.this.faultMessageMap.get(faultElt.getQName()); + Class messageClass = Class.forName(messageClassName); + Object messageObject = SI_TCM2SAP_C223_OUTServiceStub.this.fromOM(faultElt, messageClass, (Map)null); + Method m = exceptionClass.getMethod("setFaultMessage", messageClass); + m.invoke(ex, messageObject); + callback.receiveErrorSI_TCM2SAP_C223_OUT(new RemoteException(ex.getMessage(), ex)); + } catch (ClassCastException var11) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (ClassNotFoundException var12) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (NoSuchMethodException var13) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (InvocationTargetException var14) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (IllegalAccessException var15) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (InstantiationException var16) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (AxisFault var17) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_C223_OUT(error); + } + + } + + public void onFault(MessageContext faultContext) { + AxisFault fault = Utils.getInboundFaultFromMessageContext(faultContext); + this.onError(fault); + } + + public void onComplete() { + try { + _messageContext.getTransportOut().getSender().cleanup(_messageContext); + } catch (AxisFault var2) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(var2); + } + + } + }); + CallbackReceiver _callbackReceiver = null; + if (this._operations[0].getMessageReceiver() == null && _operationClient.getOptions().isUseSeparateListener()) { + _callbackReceiver = new CallbackReceiver(); + this._operations[0].setMessageReceiver(_callbackReceiver); + } + + _operationClient.execute(false); + } + + private Map getEnvelopeNamespaces(SOAPEnvelope env) { + Map returnMap = new HashMap(); + Iterator namespaceIterator = env.getAllDeclaredNamespaces(); + + while(namespaceIterator.hasNext()) { + OMNamespace ns = (OMNamespace)namespaceIterator.next(); + returnMap.put(ns.getPrefix(), ns.getNamespaceURI()); + } + + return returnMap; + } + + private boolean optimizeContent(QName opName) { + if (this.opNameArray == null) { + return false; + } else { + for(int i = 0; i < this.opNameArray.length; ++i) { + if (opName.equals(this.opNameArray[i])) { + return true; + } + } + + return false; + } + } + + private OMElement toOM(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 param, boolean optimizeContent) throws AxisFault { + try { + return param.getOMElement(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.MY_QNAME, OMAbstractFactory.getOMFactory()); + } catch (ADBException var4) { + throw AxisFault.makeFault(var4); + } + } + + private OMElement toOM(SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 param, boolean optimizeContent) throws AxisFault { + try { + return param.getOMElement(SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.MY_QNAME, OMAbstractFactory.getOMFactory()); + } catch (ADBException var4) { + throw AxisFault.makeFault(var4); + } + } + + private SOAPEnvelope toEnvelope(SOAPFactory factory, SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 param, boolean optimizeContent) throws AxisFault { + try { + SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); + emptyEnvelope.getBody().addChild(param.getOMElement(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.MY_QNAME, factory)); + return emptyEnvelope; + } catch (ADBException var5) { + throw AxisFault.makeFault(var5); + } + } + + private SOAPEnvelope toEnvelope(SOAPFactory factory) { + return factory.getDefaultEnvelope(); + } + + private Object fromOM(OMElement param, Class type, Map extraNamespaces) throws AxisFault { + try { + if (SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.class.equals(type)) { + return SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.Factory.parse(param.getXMLStreamReaderWithoutCaching()); + } else { + return SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.class.equals(type) ? SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.Factory.parse(param.getXMLStreamReaderWithoutCaching()) : null; + } + } catch (Exception var5) { + throw AxisFault.makeFault(var5); + } + } + + public static class DT_SAP2TCM_C223 implements ADBBean { + protected String localMATNR; + protected boolean localMATNRTracker = false; + protected String localWERKS; + protected boolean localWERKSTracker = false; + protected String localVERID; + protected boolean localVERIDTracker = false; + protected String localSTATUS; + protected boolean localSTATUSTracker = false; + protected String localMESSAGE; + protected boolean localMESSAGETracker = false; + + private static String generatePrefix(String namespace) { + return namespace.equals("urn:changhong.com:TCM:mlsc") ? "ns1" : BeanUtil.getUniquePrefix(); + } + + public String getMATNR() { + return this.localMATNR; + } + + public void setMATNR(String param) { + if (param != null) { + this.localMATNRTracker = true; + } else { + this.localMATNRTracker = false; + } + + this.localMATNR = param; + } + + public String getWERKS() { + return this.localWERKS; + } + + public void setWERKS(String param) { + if (param != null) { + this.localWERKSTracker = true; + } else { + this.localWERKSTracker = false; + } + + this.localWERKS = param; + } + + public String getVERID() { + return this.localVERID; + } + + public void setVERID(String param) { + if (param != null) { + this.localVERIDTracker = true; + } else { + this.localVERIDTracker = false; + } + + this.localVERID = param; + } + + public String getSTATUS() { + return this.localSTATUS; + } + + public void setSTATUS(String param) { + if (param != null) { + this.localSTATUSTracker = true; + } else { + this.localSTATUSTracker = false; + } + + this.localSTATUS = param; + } + + public String getMESSAGE() { + return this.localMESSAGE; + } + + public void setMESSAGE(String param) { + if (param != null) { + this.localMESSAGETracker = true; + } else { + this.localMESSAGETracker = false; + } + + this.localMESSAGE = param; + } + + public static boolean isReaderMTOMAware(XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = Boolean.TRUE.equals(reader.getProperty("IsDatahandlersAwareParsing")); + } catch (IllegalArgumentException var2) { + isReaderMTOMAware = false; + } + + return isReaderMTOMAware; + } + + public OMElement getOMElement(QName parentQName, final OMFactory factory) throws ADBException { + OMDataSource dataSource = new ADBDataSource(this, parentQName) { + public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException { + DT_SAP2TCM_C223.this.serialize(this.parentQName, factory, xmlWriter); + } + }; + return new OMSourcedElementImpl(parentQName, factory, dataSource); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException, ADBException { + this.serialize(parentQName, factory, xmlWriter, false); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter, boolean serializeType) throws XMLStreamException, ADBException { + String prefix = null; + String namespace = null; + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + String namespacePrefix; + if (namespace != null && namespace.trim().length() > 0) { + namespacePrefix = xmlWriter.getPrefix(namespace); + if (namespacePrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType) { + namespacePrefix = this.registerPrefix(xmlWriter, "urn:changhong.com:TCM:mlsc"); + if (namespacePrefix != null && namespacePrefix.trim().length() > 0) { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":DT_SAP2TCM_C223", xmlWriter); + } else { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "DT_SAP2TCM_C223", xmlWriter); + } + } + + if (this.localMATNRTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "MATNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "MATNR"); + } + } else { + xmlWriter.writeStartElement("MATNR"); + } + + if (this.localMATNR == null) { + throw new ADBException("MATNR cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localMATNR); + xmlWriter.writeEndElement(); + } + + if (this.localWERKSTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "WERKS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "WERKS"); + } + } else { + xmlWriter.writeStartElement("WERKS"); + } + + if (this.localWERKS == null) { + throw new ADBException("WERKS cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localWERKS); + xmlWriter.writeEndElement(); + } + + if (this.localVERIDTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "VERID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "VERID"); + } + } else { + xmlWriter.writeStartElement("VERID"); + } + + if (this.localVERID == null) { + throw new ADBException("VERID cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localVERID); + xmlWriter.writeEndElement(); + } + + if (this.localSTATUSTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "STATUS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "STATUS"); + } + } else { + xmlWriter.writeStartElement("STATUS"); + } + + if (this.localSTATUS == null) { + throw new ADBException("STATUS cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localSTATUS); + xmlWriter.writeEndElement(); + } + + if (this.localMESSAGETracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "MESSAGE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "MESSAGE"); + } + } else { + xmlWriter.writeStartElement("MESSAGE"); + } + + if (this.localMESSAGE == null) { + throw new ADBException("MESSAGE cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localMESSAGE); + xmlWriter.writeEndElement(); + } + + xmlWriter.writeEndElement(); + } + + private void writeAttribute(String prefix, String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + } + + private void writeQNameAttribute(String namespace, String attName, QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String attributeNamespace = qname.getNamespaceURI(); + String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = this.registerPrefix(xmlWriter, attributeNamespace); + } + + String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + + } + + private void writeQName(QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname)); + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + + } + + private void writeQNames(QName[] qnames, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (qnames != null) { + StringBuffer stringToWrite = new StringBuffer(); + String namespaceURI = null; + String prefix = null; + + for(int i = 0; i < qnames.length; ++i) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI == null) { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } else { + prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null || prefix.length() == 0) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append(ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException { + String prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + for(prefix = generatePrefix(namespace); xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null; prefix = BeanUtil.getUniquePrefix()) { + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + public XMLStreamReader getPullParser(QName qName) throws ADBException { + ArrayList elementList = new ArrayList(); + ArrayList attribList = new ArrayList(); + if (this.localMATNRTracker) { + elementList.add(new QName("", "MATNR")); + if (this.localMATNR == null) { + throw new ADBException("MATNR cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localMATNR)); + } + + if (this.localWERKSTracker) { + elementList.add(new QName("", "WERKS")); + if (this.localWERKS == null) { + throw new ADBException("WERKS cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localWERKS)); + } + + if (this.localVERIDTracker) { + elementList.add(new QName("", "VERID")); + if (this.localVERID == null) { + throw new ADBException("VERID cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localVERID)); + } + + if (this.localSTATUSTracker) { + elementList.add(new QName("", "STATUS")); + if (this.localSTATUS == null) { + throw new ADBException("STATUS cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localSTATUS)); + } + + if (this.localMESSAGETracker) { + elementList.add(new QName("", "MESSAGE")); + if (this.localMESSAGE == null) { + throw new ADBException("MESSAGE cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localMESSAGE)); + } + + return new ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + } + + public static class Factory { + public static SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223 parse(XMLStreamReader reader) throws Exception { + SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223 object = new SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223(); + + try { + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + String content; + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + content = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + if (content != null) { + String nsPrefix = null; + if (content.indexOf(":") > -1) { + nsPrefix = content.substring(0, content.indexOf(":")); + } + + nsPrefix = nsPrefix == null ? "" : nsPrefix; + String type = content.substring(content.indexOf(":") + 1); + if (!"DT_SAP2TCM_C223".equals(type)) { + String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223)SI_TCM2SAP_C223_OUTServiceStub.ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + new Vector(); + reader.next(); + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "MATNR")).equals(reader.getName())) { + content = reader.getElementText(); + object.setMATNR(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "WERKS")).equals(reader.getName())) { + content = reader.getElementText(); + object.setWERKS(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "VERID")).equals(reader.getName())) { + content = reader.getElementText(); + object.setVERID(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "STATUS")).equals(reader.getName())) { + content = reader.getElementText(); + object.setSTATUS(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "MESSAGE")).equals(reader.getName())) { + content = reader.getElementText(); + object.setMESSAGE(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement()) { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } else { + return object; + } + } catch (XMLStreamException var6) { + throw new Exception(var6); + } + } + } + } + + public static class DT_TCM2SAP_C223 implements ADBBean { + protected SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0 localMSG_HDR; + protected boolean localMSG_HDRTracker = false; + protected SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0 localMSG_BODY; + + private static String generatePrefix(String namespace) { + return namespace.equals("urn:changhong.com:TCM:mlsc") ? "ns1" : BeanUtil.getUniquePrefix(); + } + + public SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0 getMSG_HDR() { + return this.localMSG_HDR; + } + + public void setMSG_HDR(SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0 param) { + if (param != null) { + this.localMSG_HDRTracker = true; + } else { + this.localMSG_HDRTracker = false; + } + + this.localMSG_HDR = param; + } + + public SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0 getMSG_BODY() { + return this.localMSG_BODY; + } + + public void setMSG_BODY(SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0 param) { + this.localMSG_BODY = param; + } + + public static boolean isReaderMTOMAware(XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = Boolean.TRUE.equals(reader.getProperty("IsDatahandlersAwareParsing")); + } catch (IllegalArgumentException var2) { + isReaderMTOMAware = false; + } + + return isReaderMTOMAware; + } + + public OMElement getOMElement(QName parentQName, final OMFactory factory) throws ADBException { + OMDataSource dataSource = new ADBDataSource(this, parentQName) { + public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException { + DT_TCM2SAP_C223.this.serialize(this.parentQName, factory, xmlWriter); + } + }; + return new OMSourcedElementImpl(parentQName, factory, dataSource); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException, ADBException { + this.serialize(parentQName, factory, xmlWriter, false); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter, boolean serializeType) throws XMLStreamException, ADBException { + String prefix = null; + String namespace = null; + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + String namespacePrefix; + if (namespace != null && namespace.trim().length() > 0) { + namespacePrefix = xmlWriter.getPrefix(namespace); + if (namespacePrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType) { + namespacePrefix = this.registerPrefix(xmlWriter, "urn:changhong.com:TCM:mlsc"); + if (namespacePrefix != null && namespacePrefix.trim().length() > 0) { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":DT_TCM2SAP_C223", xmlWriter); + } else { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "DT_TCM2SAP_C223", xmlWriter); + } + } + + if (this.localMSG_HDRTracker) { + if (this.localMSG_HDR == null) { + throw new ADBException("MSG_HDR cannot be null!!"); + } + + this.localMSG_HDR.serialize(new QName("", "MSG_HDR"), factory, xmlWriter); + } + + if (this.localMSG_BODY == null) { + throw new ADBException("MSG_BODY cannot be null!!"); + } else { + this.localMSG_BODY.serialize(new QName("", "MSG_BODY"), factory, xmlWriter); + xmlWriter.writeEndElement(); + } + } + + private void writeAttribute(String prefix, String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + } + + private void writeQNameAttribute(String namespace, String attName, QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String attributeNamespace = qname.getNamespaceURI(); + String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = this.registerPrefix(xmlWriter, attributeNamespace); + } + + String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + + } + + private void writeQName(QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname)); + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + + } + + private void writeQNames(QName[] qnames, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (qnames != null) { + StringBuffer stringToWrite = new StringBuffer(); + String namespaceURI = null; + String prefix = null; + + for(int i = 0; i < qnames.length; ++i) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI == null) { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } else { + prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null || prefix.length() == 0) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append(ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException { + String prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + for(prefix = generatePrefix(namespace); xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null; prefix = BeanUtil.getUniquePrefix()) { + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + public XMLStreamReader getPullParser(QName qName) throws ADBException { + ArrayList elementList = new ArrayList(); + ArrayList attribList = new ArrayList(); + if (this.localMSG_HDRTracker) { + elementList.add(new QName("", "MSG_HDR")); + if (this.localMSG_HDR == null) { + throw new ADBException("MSG_HDR cannot be null!!"); + } + + elementList.add(this.localMSG_HDR); + } + + elementList.add(new QName("", "MSG_BODY")); + if (this.localMSG_BODY == null) { + throw new ADBException("MSG_BODY cannot be null!!"); + } else { + elementList.add(this.localMSG_BODY); + return new ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + } + } + + public static class Factory { + public static SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223 parse(XMLStreamReader reader) throws Exception { + SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223 object = new SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223(); + + try { + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + if (fullTypeName != null) { + String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1) { + nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); + } + + nsPrefix = nsPrefix == null ? "" : nsPrefix; + String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1); + if (!"DT_TCM2SAP_C223".equals(type)) { + String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223)SI_TCM2SAP_C223_OUTServiceStub.ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + new Vector(); + reader.next(); + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "MSG_HDR")).equals(reader.getName())) { + object.setMSG_HDR(SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0.Factory.parse(reader)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "MSG_BODY")).equals(reader.getName())) { + object.setMSG_BODY(SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0.Factory.parse(reader)); + reader.next(); + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement()) { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } else { + return object; + } + } else { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } + } catch (XMLStreamException var6) { + throw new Exception(var6); + } + } + } + } + + public static class ExtensionMapper { + public static Object getTypeObject(String namespaceURI, String typeName, XMLStreamReader reader) throws Exception { + if ("urn:changhong.com:TCM:mlsc".equals(namespaceURI) && "MSG_BODY_type0".equals(typeName)) { + return SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0.Factory.parse(reader); + } else if ("urn:changhong.com:TCM:mlsc".equals(namespaceURI) && "HEADER_type0".equals(typeName)) { + return SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0.Factory.parse(reader); + } else if ("urn:changhong.com:TCM:mlsc".equals(namespaceURI) && "DT_SAP2TCM_C223".equals(typeName)) { + return SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223.Factory.parse(reader); + } else if ("urn:changhong.com:TCM:mlsc".equals(namespaceURI) && "DT_TCM2SAP_C223".equals(typeName)) { + return SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223.Factory.parse(reader); + } else if ("urn:changhong.com:TCM:mlsc".equals(namespaceURI) && "MSG_HDR_type0".equals(typeName)) { + return SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0.Factory.parse(reader); + } else { + throw new ADBException("Unsupported type " + namespaceURI + " " + typeName); + } + } + } + + public static class HEADER_type0 implements ADBBean { + protected String localMATNR; + protected boolean localMATNRTracker = false; + protected String localWERKS; + protected boolean localWERKSTracker = false; + protected String localVERID; + protected boolean localVERIDTracker = false; + protected String localTEXT1; + protected boolean localTEXT1Tracker = false; + protected String localADATU; + protected boolean localADATUTracker = false; + protected String localBDATU; + protected boolean localBDATUTracker = false; + protected String localSTLAL; + protected boolean localSTLALTracker = false; + protected String localSTLAN; + protected boolean localSTLANTracker = false; + protected String localPLNNR; + protected boolean localPLNNRTracker = false; + protected String localALNAL; + protected boolean localALNALTracker = false; + protected String localMDV01; + protected boolean localMDV01Tracker = false; + protected String localALORT; + protected boolean localALORTTracker = false; + protected String localELPRO; + protected boolean localELPROTracker = false; + protected String localKZ; + protected boolean localKZTracker = false; + + private static String generatePrefix(String namespace) { + return namespace.equals("urn:changhong.com:TCM:mlsc") ? "ns1" : BeanUtil.getUniquePrefix(); + } + + public String getMATNR() { + return this.localMATNR; + } + + public void setMATNR(String param) { + if (param != null) { + this.localMATNRTracker = true; + } else { + this.localMATNRTracker = false; + } + + this.localMATNR = param; + } + + public String getWERKS() { + return this.localWERKS; + } + + public void setWERKS(String param) { + if (param != null) { + this.localWERKSTracker = true; + } else { + this.localWERKSTracker = false; + } + + this.localWERKS = param; + } + + public String getVERID() { + return this.localVERID; + } + + public void setVERID(String param) { + if (param != null) { + this.localVERIDTracker = true; + } else { + this.localVERIDTracker = false; + } + + this.localVERID = param; + } + + public String getTEXT1() { + return this.localTEXT1; + } + + public void setTEXT1(String param) { + if (param != null) { + this.localTEXT1Tracker = true; + } else { + this.localTEXT1Tracker = false; + } + + this.localTEXT1 = param; + } + + public String getADATU() { + return this.localADATU; + } + + public void setADATU(String param) { + if (param != null) { + this.localADATUTracker = true; + } else { + this.localADATUTracker = false; + } + + this.localADATU = param; + } + + public String getBDATU() { + return this.localBDATU; + } + + public void setBDATU(String param) { + if (param != null) { + this.localBDATUTracker = true; + } else { + this.localBDATUTracker = false; + } + + this.localBDATU = param; + } + + public String getSTLAL() { + return this.localSTLAL; + } + + public void setSTLAL(String param) { + if (param != null) { + this.localSTLALTracker = true; + } else { + this.localSTLALTracker = false; + } + + this.localSTLAL = param; + } + + public String getSTLAN() { + return this.localSTLAN; + } + + public void setSTLAN(String param) { + if (param != null) { + this.localSTLANTracker = true; + } else { + this.localSTLANTracker = false; + } + + this.localSTLAN = param; + } + + public String getPLNNR() { + return this.localPLNNR; + } + + public void setPLNNR(String param) { + if (param != null) { + this.localPLNNRTracker = true; + } else { + this.localPLNNRTracker = false; + } + + this.localPLNNR = param; + } + + public String getALNAL() { + return this.localALNAL; + } + + public void setALNAL(String param) { + if (param != null) { + this.localALNALTracker = true; + } else { + this.localALNALTracker = false; + } + + this.localALNAL = param; + } + + public String getMDV01() { + return this.localMDV01; + } + + public void setMDV01(String param) { + if (param != null) { + this.localMDV01Tracker = true; + } else { + this.localMDV01Tracker = false; + } + + this.localMDV01 = param; + } + + public String getALORT() { + return this.localALORT; + } + + public void setALORT(String param) { + if (param != null) { + this.localALORTTracker = true; + } else { + this.localALORTTracker = false; + } + + this.localALORT = param; + } + + public String getELPRO() { + return this.localELPRO; + } + + public void setELPRO(String param) { + if (param != null) { + this.localELPROTracker = true; + } else { + this.localELPROTracker = false; + } + + this.localELPRO = param; + } + + public String getKZ() { + return this.localKZ; + } + + public void setKZ(String param) { + if (param != null) { + this.localKZTracker = true; + } else { + this.localKZTracker = false; + } + + this.localKZ = param; + } + + public static boolean isReaderMTOMAware(XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = Boolean.TRUE.equals(reader.getProperty("IsDatahandlersAwareParsing")); + } catch (IllegalArgumentException var2) { + isReaderMTOMAware = false; + } + + return isReaderMTOMAware; + } + + public OMElement getOMElement(QName parentQName, final OMFactory factory) throws ADBException { + OMDataSource dataSource = new ADBDataSource(this, parentQName) { + public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException { + HEADER_type0.this.serialize(this.parentQName, factory, xmlWriter); + } + }; + return new OMSourcedElementImpl(parentQName, factory, dataSource); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException, ADBException { + this.serialize(parentQName, factory, xmlWriter, false); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter, boolean serializeType) throws XMLStreamException, ADBException { + String prefix = null; + String namespace = null; + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + String namespacePrefix; + if (namespace != null && namespace.trim().length() > 0) { + namespacePrefix = xmlWriter.getPrefix(namespace); + if (namespacePrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType) { + namespacePrefix = this.registerPrefix(xmlWriter, "urn:changhong.com:TCM:mlsc"); + if (namespacePrefix != null && namespacePrefix.trim().length() > 0) { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":HEADER_type0", xmlWriter); + } else { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "HEADER_type0", xmlWriter); + } + } + + if (this.localMATNRTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "MATNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "MATNR"); + } + } else { + xmlWriter.writeStartElement("MATNR"); + } + + if (this.localMATNR == null) { + throw new ADBException("MATNR cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localMATNR); + xmlWriter.writeEndElement(); + } + + if (this.localWERKSTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "WERKS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "WERKS"); + } + } else { + xmlWriter.writeStartElement("WERKS"); + } + + if (this.localWERKS == null) { + throw new ADBException("WERKS cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localWERKS); + xmlWriter.writeEndElement(); + } + + if (this.localVERIDTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "VERID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "VERID"); + } + } else { + xmlWriter.writeStartElement("VERID"); + } + + if (this.localVERID == null) { + throw new ADBException("VERID cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localVERID); + xmlWriter.writeEndElement(); + } + + if (this.localTEXT1Tracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "TEXT1", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "TEXT1"); + } + } else { + xmlWriter.writeStartElement("TEXT1"); + } + + if (this.localTEXT1 == null) { + throw new ADBException("TEXT1 cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localTEXT1); + xmlWriter.writeEndElement(); + } + + if (this.localADATUTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "ADATU", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "ADATU"); + } + } else { + xmlWriter.writeStartElement("ADATU"); + } + + if (this.localADATU == null) { + throw new ADBException("ADATU cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localADATU); + xmlWriter.writeEndElement(); + } + + if (this.localBDATUTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "BDATU", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "BDATU"); + } + } else { + xmlWriter.writeStartElement("BDATU"); + } + + if (this.localBDATU == null) { + throw new ADBException("BDATU cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localBDATU); + xmlWriter.writeEndElement(); + } + + if (this.localSTLALTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "STLAL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "STLAL"); + } + } else { + xmlWriter.writeStartElement("STLAL"); + } + + if (this.localSTLAL == null) { + throw new ADBException("STLAL cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localSTLAL); + xmlWriter.writeEndElement(); + } + + if (this.localSTLANTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "STLAN", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "STLAN"); + } + } else { + xmlWriter.writeStartElement("STLAN"); + } + + if (this.localSTLAN == null) { + throw new ADBException("STLAN cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localSTLAN); + xmlWriter.writeEndElement(); + } + + if (this.localPLNNRTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "PLNNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "PLNNR"); + } + } else { + xmlWriter.writeStartElement("PLNNR"); + } + + if (this.localPLNNR == null) { + throw new ADBException("PLNNR cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localPLNNR); + xmlWriter.writeEndElement(); + } + + if (this.localALNALTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "ALNAL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "ALNAL"); + } + } else { + xmlWriter.writeStartElement("ALNAL"); + } + + if (this.localALNAL == null) { + throw new ADBException("ALNAL cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localALNAL); + xmlWriter.writeEndElement(); + } + + if (this.localMDV01Tracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "MDV01", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "MDV01"); + } + } else { + xmlWriter.writeStartElement("MDV01"); + } + + if (this.localMDV01 == null) { + throw new ADBException("MDV01 cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localMDV01); + xmlWriter.writeEndElement(); + } + + if (this.localALORTTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "ALORT", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "ALORT"); + } + } else { + xmlWriter.writeStartElement("ALORT"); + } + + if (this.localALORT == null) { + throw new ADBException("ALORT cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localALORT); + xmlWriter.writeEndElement(); + } + + if (this.localELPROTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "ELPRO", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "ELPRO"); + } + } else { + xmlWriter.writeStartElement("ELPRO"); + } + + if (this.localELPRO == null) { + throw new ADBException("ELPRO cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localELPRO); + xmlWriter.writeEndElement(); + } + + if (this.localKZTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "KZ", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "KZ"); + } + } else { + xmlWriter.writeStartElement("KZ"); + } + + if (this.localKZ == null) { + throw new ADBException("KZ cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localKZ); + xmlWriter.writeEndElement(); + } + + xmlWriter.writeEndElement(); + } + + private void writeAttribute(String prefix, String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + } + + private void writeQNameAttribute(String namespace, String attName, QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String attributeNamespace = qname.getNamespaceURI(); + String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = this.registerPrefix(xmlWriter, attributeNamespace); + } + + String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + + } + + private void writeQName(QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname)); + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + + } + + private void writeQNames(QName[] qnames, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (qnames != null) { + StringBuffer stringToWrite = new StringBuffer(); + String namespaceURI = null; + String prefix = null; + + for(int i = 0; i < qnames.length; ++i) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI == null) { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } else { + prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null || prefix.length() == 0) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append(ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException { + String prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + for(prefix = generatePrefix(namespace); xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null; prefix = BeanUtil.getUniquePrefix()) { + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + public XMLStreamReader getPullParser(QName qName) throws ADBException { + ArrayList elementList = new ArrayList(); + ArrayList attribList = new ArrayList(); + if (this.localMATNRTracker) { + elementList.add(new QName("", "MATNR")); + if (this.localMATNR == null) { + throw new ADBException("MATNR cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localMATNR)); + } + + if (this.localWERKSTracker) { + elementList.add(new QName("", "WERKS")); + if (this.localWERKS == null) { + throw new ADBException("WERKS cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localWERKS)); + } + + if (this.localVERIDTracker) { + elementList.add(new QName("", "VERID")); + if (this.localVERID == null) { + throw new ADBException("VERID cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localVERID)); + } + + if (this.localTEXT1Tracker) { + elementList.add(new QName("", "TEXT1")); + if (this.localTEXT1 == null) { + throw new ADBException("TEXT1 cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localTEXT1)); + } + + if (this.localADATUTracker) { + elementList.add(new QName("", "ADATU")); + if (this.localADATU == null) { + throw new ADBException("ADATU cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localADATU)); + } + + if (this.localBDATUTracker) { + elementList.add(new QName("", "BDATU")); + if (this.localBDATU == null) { + throw new ADBException("BDATU cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localBDATU)); + } + + if (this.localSTLALTracker) { + elementList.add(new QName("", "STLAL")); + if (this.localSTLAL == null) { + throw new ADBException("STLAL cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localSTLAL)); + } + + if (this.localSTLANTracker) { + elementList.add(new QName("", "STLAN")); + if (this.localSTLAN == null) { + throw new ADBException("STLAN cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localSTLAN)); + } + + if (this.localPLNNRTracker) { + elementList.add(new QName("", "PLNNR")); + if (this.localPLNNR == null) { + throw new ADBException("PLNNR cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localPLNNR)); + } + + if (this.localALNALTracker) { + elementList.add(new QName("", "ALNAL")); + if (this.localALNAL == null) { + throw new ADBException("ALNAL cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localALNAL)); + } + + if (this.localMDV01Tracker) { + elementList.add(new QName("", "MDV01")); + if (this.localMDV01 == null) { + throw new ADBException("MDV01 cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localMDV01)); + } + + if (this.localALORTTracker) { + elementList.add(new QName("", "ALORT")); + if (this.localALORT == null) { + throw new ADBException("ALORT cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localALORT)); + } + + if (this.localELPROTracker) { + elementList.add(new QName("", "ELPRO")); + if (this.localELPRO == null) { + throw new ADBException("ELPRO cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localELPRO)); + } + + if (this.localKZTracker) { + elementList.add(new QName("", "KZ")); + if (this.localKZ == null) { + throw new ADBException("KZ cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localKZ)); + } + + return new ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + } + + public static class Factory { + public static SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0 parse(XMLStreamReader reader) throws Exception { + SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0 object = new SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0(); + + try { + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + String content; + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + content = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + if (content != null) { + String nsPrefix = null; + if (content.indexOf(":") > -1) { + nsPrefix = content.substring(0, content.indexOf(":")); + } + + nsPrefix = nsPrefix == null ? "" : nsPrefix; + String type = content.substring(content.indexOf(":") + 1); + if (!"HEADER_type0".equals(type)) { + String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0)SI_TCM2SAP_C223_OUTServiceStub.ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + new Vector(); + reader.next(); + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "MATNR")).equals(reader.getName())) { + content = reader.getElementText(); + object.setMATNR(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "WERKS")).equals(reader.getName())) { + content = reader.getElementText(); + object.setWERKS(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "VERID")).equals(reader.getName())) { + content = reader.getElementText(); + object.setVERID(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "TEXT1")).equals(reader.getName())) { + content = reader.getElementText(); + object.setTEXT1(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "ADATU")).equals(reader.getName())) { + content = reader.getElementText(); + object.setADATU(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "BDATU")).equals(reader.getName())) { + content = reader.getElementText(); + object.setBDATU(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "STLAL")).equals(reader.getName())) { + content = reader.getElementText(); + object.setSTLAL(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "STLAN")).equals(reader.getName())) { + content = reader.getElementText(); + object.setSTLAN(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "PLNNR")).equals(reader.getName())) { + content = reader.getElementText(); + object.setPLNNR(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "ALNAL")).equals(reader.getName())) { + content = reader.getElementText(); + object.setALNAL(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "MDV01")).equals(reader.getName())) { + content = reader.getElementText(); + object.setMDV01(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "ALORT")).equals(reader.getName())) { + content = reader.getElementText(); + object.setALORT(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "ELPRO")).equals(reader.getName())) { + content = reader.getElementText(); + object.setELPRO(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "KZ")).equals(reader.getName())) { + content = reader.getElementText(); + object.setKZ(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement()) { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } else { + return object; + } + } catch (XMLStreamException var6) { + throw new Exception(var6); + } + } + } + } + + public static class MSG_BODY_type0 implements ADBBean { + protected SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0 localHEADER; + + private static String generatePrefix(String namespace) { + return namespace.equals("urn:changhong.com:TCM:mlsc") ? "ns1" : BeanUtil.getUniquePrefix(); + } + + public SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0 getHEADER() { + return this.localHEADER; + } + + public void setHEADER(SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0 param) { + this.localHEADER = param; + } + + public static boolean isReaderMTOMAware(XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = Boolean.TRUE.equals(reader.getProperty("IsDatahandlersAwareParsing")); + } catch (IllegalArgumentException var2) { + isReaderMTOMAware = false; + } + + return isReaderMTOMAware; + } + + public OMElement getOMElement(QName parentQName, final OMFactory factory) throws ADBException { + OMDataSource dataSource = new ADBDataSource(this, parentQName) { + public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException { + MSG_BODY_type0.this.serialize(this.parentQName, factory, xmlWriter); + } + }; + return new OMSourcedElementImpl(parentQName, factory, dataSource); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException, ADBException { + this.serialize(parentQName, factory, xmlWriter, false); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter, boolean serializeType) throws XMLStreamException, ADBException { + String prefix = null; + String namespace = null; + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + String namespacePrefix; + if (namespace != null && namespace.trim().length() > 0) { + namespacePrefix = xmlWriter.getPrefix(namespace); + if (namespacePrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType) { + namespacePrefix = this.registerPrefix(xmlWriter, "urn:changhong.com:TCM:mlsc"); + if (namespacePrefix != null && namespacePrefix.trim().length() > 0) { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":MSG_BODY_type0", xmlWriter); + } else { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "MSG_BODY_type0", xmlWriter); + } + } + + if (this.localHEADER == null) { + throw new ADBException("HEADER cannot be null!!"); + } else { + this.localHEADER.serialize(new QName("", "HEADER"), factory, xmlWriter); + xmlWriter.writeEndElement(); + } + } + + private void writeAttribute(String prefix, String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + } + + private void writeQNameAttribute(String namespace, String attName, QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String attributeNamespace = qname.getNamespaceURI(); + String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = this.registerPrefix(xmlWriter, attributeNamespace); + } + + String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + + } + + private void writeQName(QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname)); + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + + } + + private void writeQNames(QName[] qnames, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (qnames != null) { + StringBuffer stringToWrite = new StringBuffer(); + String namespaceURI = null; + String prefix = null; + + for(int i = 0; i < qnames.length; ++i) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI == null) { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } else { + prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null || prefix.length() == 0) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append(ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException { + String prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + for(prefix = generatePrefix(namespace); xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null; prefix = BeanUtil.getUniquePrefix()) { + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + public XMLStreamReader getPullParser(QName qName) throws ADBException { + ArrayList elementList = new ArrayList(); + ArrayList attribList = new ArrayList(); + elementList.add(new QName("", "HEADER")); + if (this.localHEADER == null) { + throw new ADBException("HEADER cannot be null!!"); + } else { + elementList.add(this.localHEADER); + return new ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + } + } + + public static class Factory { + public static SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0 parse(XMLStreamReader reader) throws Exception { + SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0 object = new SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0(); + + try { + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + if (fullTypeName != null) { + String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1) { + nsPrefix = fullTypeName.substring(0, fullTypeName.indexOf(":")); + } + + nsPrefix = nsPrefix == null ? "" : nsPrefix; + String type = fullTypeName.substring(fullTypeName.indexOf(":") + 1); + if (!"MSG_BODY_type0".equals(type)) { + String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0)SI_TCM2SAP_C223_OUTServiceStub.ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + new Vector(); + reader.next(); + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "HEADER")).equals(reader.getName())) { + object.setHEADER(SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0.Factory.parse(reader)); + reader.next(); + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement()) { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } else { + return object; + } + } else { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } + } catch (XMLStreamException var6) { + throw new Exception(var6); + } + } + } + } + + public static class MSG_HDR_type0 implements ADBBean { + protected String localMSGID; + protected boolean localMSGIDTracker = false; + protected String localBUSID; + protected boolean localBUSIDTracker = false; + protected String localTLGID; + protected boolean localTLGIDTracker = false; + protected String localLGNAME; + protected boolean localLGNAMETracker = false; + protected String localDTSEND; + protected boolean localDTSENDTracker = false; + protected String localSENDER; + protected boolean localSENDERTracker = false; + protected String localRECEIVER; + protected boolean localRECEIVERTracker = false; + protected String localREEUSE; + protected boolean localREEUSETracker = false; + + private static String generatePrefix(String namespace) { + return namespace.equals("urn:changhong.com:TCM:mlsc") ? "ns1" : BeanUtil.getUniquePrefix(); + } + + public String getMSGID() { + return this.localMSGID; + } + + public void setMSGID(String param) { + if (param != null) { + this.localMSGIDTracker = true; + } else { + this.localMSGIDTracker = false; + } + + this.localMSGID = param; + } + + public String getBUSID() { + return this.localBUSID; + } + + public void setBUSID(String param) { + if (param != null) { + this.localBUSIDTracker = true; + } else { + this.localBUSIDTracker = false; + } + + this.localBUSID = param; + } + + public String getTLGID() { + return this.localTLGID; + } + + public void setTLGID(String param) { + if (param != null) { + this.localTLGIDTracker = true; + } else { + this.localTLGIDTracker = false; + } + + this.localTLGID = param; + } + + public String getLGNAME() { + return this.localLGNAME; + } + + public void setLGNAME(String param) { + if (param != null) { + this.localLGNAMETracker = true; + } else { + this.localLGNAMETracker = false; + } + + this.localLGNAME = param; + } + + public String getDTSEND() { + return this.localDTSEND; + } + + public void setDTSEND(String param) { + if (param != null) { + this.localDTSENDTracker = true; + } else { + this.localDTSENDTracker = false; + } + + this.localDTSEND = param; + } + + public String getSENDER() { + return this.localSENDER; + } + + public void setSENDER(String param) { + if (param != null) { + this.localSENDERTracker = true; + } else { + this.localSENDERTracker = false; + } + + this.localSENDER = param; + } + + public String getRECEIVER() { + return this.localRECEIVER; + } + + public void setRECEIVER(String param) { + if (param != null) { + this.localRECEIVERTracker = true; + } else { + this.localRECEIVERTracker = false; + } + + this.localRECEIVER = param; + } + + public String getREEUSE() { + return this.localREEUSE; + } + + public void setREEUSE(String param) { + if (param != null) { + this.localREEUSETracker = true; + } else { + this.localREEUSETracker = false; + } + + this.localREEUSE = param; + } + + public static boolean isReaderMTOMAware(XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = Boolean.TRUE.equals(reader.getProperty("IsDatahandlersAwareParsing")); + } catch (IllegalArgumentException var2) { + isReaderMTOMAware = false; + } + + return isReaderMTOMAware; + } + + public OMElement getOMElement(QName parentQName, final OMFactory factory) throws ADBException { + OMDataSource dataSource = new ADBDataSource(this, parentQName) { + public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException { + MSG_HDR_type0.this.serialize(this.parentQName, factory, xmlWriter); + } + }; + return new OMSourcedElementImpl(parentQName, factory, dataSource); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException, ADBException { + this.serialize(parentQName, factory, xmlWriter, false); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter, boolean serializeType) throws XMLStreamException, ADBException { + String prefix = null; + String namespace = null; + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + String namespacePrefix; + if (namespace != null && namespace.trim().length() > 0) { + namespacePrefix = xmlWriter.getPrefix(namespace); + if (namespacePrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType) { + namespacePrefix = this.registerPrefix(xmlWriter, "urn:changhong.com:TCM:mlsc"); + if (namespacePrefix != null && namespacePrefix.trim().length() > 0) { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":MSG_HDR_type0", xmlWriter); + } else { + this.writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "MSG_HDR_type0", xmlWriter); + } + } + + if (this.localMSGIDTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "MSGID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "MSGID"); + } + } else { + xmlWriter.writeStartElement("MSGID"); + } + + if (this.localMSGID == null) { + throw new ADBException("MSGID cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localMSGID); + xmlWriter.writeEndElement(); + } + + if (this.localBUSIDTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "BUSID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "BUSID"); + } + } else { + xmlWriter.writeStartElement("BUSID"); + } + + if (this.localBUSID == null) { + throw new ADBException("BUSID cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localBUSID); + xmlWriter.writeEndElement(); + } + + if (this.localTLGIDTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "TLGID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "TLGID"); + } + } else { + xmlWriter.writeStartElement("TLGID"); + } + + if (this.localTLGID == null) { + throw new ADBException("TLGID cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localTLGID); + xmlWriter.writeEndElement(); + } + + if (this.localLGNAMETracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "LGNAME", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "LGNAME"); + } + } else { + xmlWriter.writeStartElement("LGNAME"); + } + + if (this.localLGNAME == null) { + throw new ADBException("LGNAME cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localLGNAME); + xmlWriter.writeEndElement(); + } + + if (this.localDTSENDTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "DTSEND", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "DTSEND"); + } + } else { + xmlWriter.writeStartElement("DTSEND"); + } + + if (this.localDTSEND == null) { + throw new ADBException("DTSEND cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localDTSEND); + xmlWriter.writeEndElement(); + } + + if (this.localSENDERTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "SENDER", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "SENDER"); + } + } else { + xmlWriter.writeStartElement("SENDER"); + } + + if (this.localSENDER == null) { + throw new ADBException("SENDER cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localSENDER); + xmlWriter.writeEndElement(); + } + + if (this.localRECEIVERTracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "RECEIVER", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "RECEIVER"); + } + } else { + xmlWriter.writeStartElement("RECEIVER"); + } + + if (this.localRECEIVER == null) { + throw new ADBException("RECEIVER cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localRECEIVER); + xmlWriter.writeEndElement(); + } + + if (this.localREEUSETracker) { + namespace = ""; + if (!namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + prefix = generatePrefix(namespace); + xmlWriter.writeStartElement(prefix, "REEUSE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } else { + xmlWriter.writeStartElement(namespace, "REEUSE"); + } + } else { + xmlWriter.writeStartElement("REEUSE"); + } + + if (this.localREEUSE == null) { + throw new ADBException("REEUSE cannot be null!!"); + } + + xmlWriter.writeCharacters(this.localREEUSE); + xmlWriter.writeEndElement(); + } + + xmlWriter.writeEndElement(); + } + + private void writeAttribute(String prefix, String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + } + + private void writeQNameAttribute(String namespace, String attName, QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String attributeNamespace = qname.getNamespaceURI(); + String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = this.registerPrefix(xmlWriter, attributeNamespace); + } + + String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + + } + + private void writeQName(QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname)); + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + + } + + private void writeQNames(QName[] qnames, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (qnames != null) { + StringBuffer stringToWrite = new StringBuffer(); + String namespaceURI = null; + String prefix = null; + + for(int i = 0; i < qnames.length; ++i) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI == null) { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } else { + prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null || prefix.length() == 0) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append(ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException { + String prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + for(prefix = generatePrefix(namespace); xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null; prefix = BeanUtil.getUniquePrefix()) { + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + public XMLStreamReader getPullParser(QName qName) throws ADBException { + ArrayList elementList = new ArrayList(); + ArrayList attribList = new ArrayList(); + if (this.localMSGIDTracker) { + elementList.add(new QName("", "MSGID")); + if (this.localMSGID == null) { + throw new ADBException("MSGID cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localMSGID)); + } + + if (this.localBUSIDTracker) { + elementList.add(new QName("", "BUSID")); + if (this.localBUSID == null) { + throw new ADBException("BUSID cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localBUSID)); + } + + if (this.localTLGIDTracker) { + elementList.add(new QName("", "TLGID")); + if (this.localTLGID == null) { + throw new ADBException("TLGID cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localTLGID)); + } + + if (this.localLGNAMETracker) { + elementList.add(new QName("", "LGNAME")); + if (this.localLGNAME == null) { + throw new ADBException("LGNAME cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localLGNAME)); + } + + if (this.localDTSENDTracker) { + elementList.add(new QName("", "DTSEND")); + if (this.localDTSEND == null) { + throw new ADBException("DTSEND cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localDTSEND)); + } + + if (this.localSENDERTracker) { + elementList.add(new QName("", "SENDER")); + if (this.localSENDER == null) { + throw new ADBException("SENDER cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localSENDER)); + } + + if (this.localRECEIVERTracker) { + elementList.add(new QName("", "RECEIVER")); + if (this.localRECEIVER == null) { + throw new ADBException("RECEIVER cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localRECEIVER)); + } + + if (this.localREEUSETracker) { + elementList.add(new QName("", "REEUSE")); + if (this.localREEUSE == null) { + throw new ADBException("REEUSE cannot be null!!"); + } + + elementList.add(ConverterUtil.convertToString(this.localREEUSE)); + } + + return new ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + } + + public static class Factory { + public static SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0 parse(XMLStreamReader reader) throws Exception { + SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0 object = new SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0(); + + try { + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + String content; + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type") != null) { + content = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type"); + if (content != null) { + String nsPrefix = null; + if (content.indexOf(":") > -1) { + nsPrefix = content.substring(0, content.indexOf(":")); + } + + nsPrefix = nsPrefix == null ? "" : nsPrefix; + String type = content.substring(content.indexOf(":") + 1); + if (!"MSG_HDR_type0".equals(type)) { + String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0)SI_TCM2SAP_C223_OUTServiceStub.ExtensionMapper.getTypeObject(nsUri, type, reader); + } + } + } + + new Vector(); + reader.next(); + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "MSGID")).equals(reader.getName())) { + content = reader.getElementText(); + object.setMSGID(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "BUSID")).equals(reader.getName())) { + content = reader.getElementText(); + object.setBUSID(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "TLGID")).equals(reader.getName())) { + content = reader.getElementText(); + object.setTLGID(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "LGNAME")).equals(reader.getName())) { + content = reader.getElementText(); + object.setLGNAME(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "DTSEND")).equals(reader.getName())) { + content = reader.getElementText(); + object.setDTSEND(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "SENDER")).equals(reader.getName())) { + content = reader.getElementText(); + object.setSENDER(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "RECEIVER")).equals(reader.getName())) { + content = reader.getElementText(); + object.setRECEIVER(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement() && (new QName("", "REEUSE")).equals(reader.getName())) { + content = reader.getElementText(); + object.setREEUSE(ConverterUtil.convertToString(content)); + reader.next(); + } + + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + if (reader.isStartElement()) { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } else { + return object; + } + } catch (XMLStreamException var6) { + throw new Exception(var6); + } + } + } + } + + public static class MT_SAP2TCM_C223 implements ADBBean { + public static final QName MY_QNAME = new QName("urn:changhong.com:TCM:mlsc", "MT_SAP2TCM_C223", "ns1"); + protected SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223 localMT_SAP2TCM_C223; + + private static String generatePrefix(String namespace) { + return namespace.equals("urn:changhong.com:TCM:mlsc") ? "ns1" : BeanUtil.getUniquePrefix(); + } + + public SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223 getMT_SAP2TCM_C223() { + return this.localMT_SAP2TCM_C223; + } + + public void setMT_SAP2TCM_C223(SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223 param) { + this.localMT_SAP2TCM_C223 = param; + } + + public static boolean isReaderMTOMAware(XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = Boolean.TRUE.equals(reader.getProperty("IsDatahandlersAwareParsing")); + } catch (IllegalArgumentException var2) { + isReaderMTOMAware = false; + } + + return isReaderMTOMAware; + } + + public OMElement getOMElement(QName parentQName, final OMFactory factory) throws ADBException { + OMDataSource dataSource = new ADBDataSource(this, MY_QNAME) { + public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException { + MT_SAP2TCM_C223.this.serialize(SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.MY_QNAME, factory, xmlWriter); + } + }; + return new OMSourcedElementImpl(MY_QNAME, factory, dataSource); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException, ADBException { + this.serialize(parentQName, factory, xmlWriter, false); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter, boolean serializeType) throws XMLStreamException, ADBException { + if (this.localMT_SAP2TCM_C223 == null) { + throw new ADBException("Property cannot be null!"); + } else { + this.localMT_SAP2TCM_C223.serialize(MY_QNAME, factory, xmlWriter); + } + } + + private void writeAttribute(String prefix, String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + } + + private void writeQNameAttribute(String namespace, String attName, QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String attributeNamespace = qname.getNamespaceURI(); + String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = this.registerPrefix(xmlWriter, attributeNamespace); + } + + String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + + } + + private void writeQName(QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname)); + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + + } + + private void writeQNames(QName[] qnames, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (qnames != null) { + StringBuffer stringToWrite = new StringBuffer(); + String namespaceURI = null; + String prefix = null; + + for(int i = 0; i < qnames.length; ++i) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI == null) { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } else { + prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null || prefix.length() == 0) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append(ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException { + String prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + for(prefix = generatePrefix(namespace); xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null; prefix = BeanUtil.getUniquePrefix()) { + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + public XMLStreamReader getPullParser(QName qName) throws ADBException { + return this.localMT_SAP2TCM_C223.getPullParser(MY_QNAME); + } + + public static class Factory { + public static SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 parse(XMLStreamReader reader) throws Exception { + SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 object = new SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223(); + + try { + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + new Vector(); + + while(true) { + while(!reader.isEndElement()) { + if (reader.isStartElement()) { + if (!reader.isStartElement() || !(new QName("urn:changhong.com:TCM:mlsc", "MT_SAP2TCM_C223")).equals(reader.getName())) { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } + + object.setMT_SAP2TCM_C223(SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223.Factory.parse(reader)); + } else { + reader.next(); + } + } + + return object; + } + } catch (XMLStreamException var3) { + throw new Exception(var3); + } + } + } + } + + public static class MT_TCM2SAP_C223 implements ADBBean { + public static final QName MY_QNAME = new QName("urn:changhong.com:TCM:mlsc", "MT_TCM2SAP_C223", "ns1"); + protected SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223 localMT_TCM2SAP_C223; + + private static String generatePrefix(String namespace) { + return namespace.equals("urn:changhong.com:TCM:mlsc") ? "ns1" : BeanUtil.getUniquePrefix(); + } + + public SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223 getMT_TCM2SAP_C223() { + return this.localMT_TCM2SAP_C223; + } + + public void setMT_TCM2SAP_C223(SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223 param) { + this.localMT_TCM2SAP_C223 = param; + } + + public static boolean isReaderMTOMAware(XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try { + isReaderMTOMAware = Boolean.TRUE.equals(reader.getProperty("IsDatahandlersAwareParsing")); + } catch (IllegalArgumentException var2) { + isReaderMTOMAware = false; + } + + return isReaderMTOMAware; + } + + public OMElement getOMElement(QName parentQName, final OMFactory factory) throws ADBException { + OMDataSource dataSource = new ADBDataSource(this, MY_QNAME) { + public void serialize(MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException { + MT_TCM2SAP_C223.this.serialize(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.MY_QNAME, factory, xmlWriter); + } + }; + return new OMSourcedElementImpl(MY_QNAME, factory, dataSource); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter) throws XMLStreamException, ADBException { + this.serialize(parentQName, factory, xmlWriter, false); + } + + public void serialize(QName parentQName, OMFactory factory, MTOMAwareXMLStreamWriter xmlWriter, boolean serializeType) throws XMLStreamException, ADBException { + if (this.localMT_TCM2SAP_C223 == null) { + throw new ADBException("Property cannot be null!"); + } else { + this.localMT_TCM2SAP_C223.serialize(MY_QNAME, factory, xmlWriter); + } + } + + private void writeAttribute(String prefix, String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + private void writeAttribute(String namespace, String attName, String attValue, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attValue); + } + + } + + private void writeQNameAttribute(String namespace, String attName, QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String attributeNamespace = qname.getNamespaceURI(); + String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = this.registerPrefix(xmlWriter, attributeNamespace); + } + + String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + this.registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + + } + + private void writeQName(QName qname, XMLStreamWriter xmlWriter) throws XMLStreamException { + String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + xmlWriter.writeCharacters(prefix + ":" + ConverterUtil.convertToString(qname)); + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + } else { + xmlWriter.writeCharacters(ConverterUtil.convertToString(qname)); + } + + } + + private void writeQNames(QName[] qnames, XMLStreamWriter xmlWriter) throws XMLStreamException { + if (qnames != null) { + StringBuffer stringToWrite = new StringBuffer(); + String namespaceURI = null; + String prefix = null; + + for(int i = 0; i < qnames.length; ++i) { + if (i > 0) { + stringToWrite.append(" "); + } + + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI == null) { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } else { + prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null || prefix.length() == 0) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix, namespaceURI); + } + + if (prefix.trim().length() > 0) { + stringToWrite.append(prefix).append(":").append(ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(ConverterUtil.convertToString(qnames[i])); + } + } + } + + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + private String registerPrefix(XMLStreamWriter xmlWriter, String namespace) throws XMLStreamException { + String prefix = xmlWriter.getPrefix(namespace); + if (prefix == null) { + for(prefix = generatePrefix(namespace); xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null; prefix = BeanUtil.getUniquePrefix()) { + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + public XMLStreamReader getPullParser(QName qName) throws ADBException { + return this.localMT_TCM2SAP_C223.getPullParser(MY_QNAME); + } + + public static class Factory { + public static SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 parse(XMLStreamReader reader) throws Exception { + SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 object = new SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223(); + + try { + while(!reader.isStartElement() && !reader.isEndElement()) { + reader.next(); + } + + new Vector(); + + while(true) { + while(!reader.isEndElement()) { + if (reader.isStartElement()) { + if (!reader.isStartElement() || !(new QName("urn:changhong.com:TCM:mlsc", "MT_TCM2SAP_C223")).equals(reader.getName())) { + throw new ADBException("Unexpected subelement " + reader.getLocalName()); + } + + object.setMT_TCM2SAP_C223(SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223.Factory.parse(reader)); + } else { + reader.next(); + } + } + + return object; + } + } catch (XMLStreamException var3) { + throw new Exception(var3); + } + } + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevCommand.java new file mode 100644 index 0000000..a81e7a4 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevCommand.java @@ -0,0 +1,713 @@ +package com.connor.ml.tcm.ML_08; + +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import java.awt.Dimension; +import java.awt.Window; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class SendProductRevCommand extends AbstractAIFCommand { + private TCSession session; + + private boolean isProcess = false; + + private HashMap map = null; + + public SendProductRevCommand(InterfaceAIFComponent[] comps, TCSession session) { + this.map = (HashMap) new HashMap<>(); + byte b; + int i; + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; + for (i = (arrayOfInterfaceAIFComponent = comps).length, b = 0; b < i;) { + InterfaceAIFComponent comp = arrayOfInterfaceAIFComponent[b]; + this.map.put((TCComponent) comp, null); + b++; + } + this.session = session; + } + + public SendProductRevCommand(InterfaceAIFComponent[] comps, TCSession session, boolean isProcess) { + this.map = (HashMap) new HashMap<>(); + byte b; + int i; + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; + for (i = (arrayOfInterfaceAIFComponent = comps).length, b = 0; b < i;) { + InterfaceAIFComponent comp = arrayOfInterfaceAIFComponent[b]; + this.map.put((TCComponent) comp, null); + b++; + } + this.session = session; + this.isProcess = isProcess; + } + + public SendProductRevCommand(HashMap map, TCSession session, boolean isProcess) { + this.map = map; + this.session = session; + this.isProcess = isProcess; + } + + public void executeModal() throws Exception { + System.out.println("SendProductRevCommand:" + this.isProcess); + String option = this.session.getPreferenceService().getStringValue("ML_Process&ProductRev"); + if (option == null || option.isEmpty()) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR); + return; + } + TCComponent dataset = this.session.stringToComponent(option); + if (!dataset.isTypeOf("MSExcelX")) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR);// ASPAAIIN5kSPsC//QCPAAIId5kSPsC + return; + } + String dateStr = this.session.getPreferenceService().getStringValue("ML_Process&Product_Data"); + System.out.println("dateStr ==> " + dateStr); + FileInputStream inpu = null; + XSSFWorkbook wb = null; + final ArrayList excelMap = (ArrayList) new ArrayList<>(); + try { + File file = ((TCComponentDataset) dataset).getTcFiles()[0].getFile(System.getProperty("java.io.tmpdir")); + inpu = new FileInputStream(file); + wb = new XSSFWorkbook(inpu); + XSSFSheet sheet = wb.getSheetAt(0); + for (int i = 1; i < sheet.getLastRowNum(); i++) { + XSSFRow row = getRow(sheet, i); + String rev = getValue(getCell(row, 7)); + if (!rev.isEmpty()) + excelMap.add(new String[] { rev, getValue(getCell(row, 0)), getValue(getCell(row, 1)), + getValue(getCell(row, 3)), getValue(getCell(row, 4)), getValue(getCell(row, 5)), + getValue(getCell(row, 6)), getValue(getCell(row, 8)), dateStr }); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AIFUtility.getActiveDesktop(), "错误:" + e.getMessage(), "ERROR", MessageBox.ERROR); + return; + } finally { + if (wb != null) + wb.close(); + if (inpu != null) + inpu.close(); + } + final List> dataTableList = new ArrayList<>(); + List> haveList = new ArrayList<>(); + System.out.println("----start SendProductRevCommand"); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + if (this.isProcess) { + for (TCComponent comp : this.map.keySet()) { + TCComponentItemRevision itemRevision = null; + TCComponentBOMLine topline = null; + if (comp instanceof TCComponentBOMLine) { + topline = (TCComponentBOMLine) comp; + itemRevision = ((TCComponentBOMLine) comp).getItemRevision(); + } else if (comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) comp; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) this.session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + } + if (itemRevision == null) { + MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR); + continue; + } + if (itemRevision.getType().equals("ML8_RefrigeratorRevision") + || itemRevision.getType().equals("ML8_ColdRevision")) { + System.out.println("type ok"); + try { + List childBomLineList = new ArrayList<>(); + AIFComponentContext[] childrens = topline.getChildren(); + byte b; + int i; + AIFComponentContext[] arrayOfAIFComponentContext1; + for (i = (arrayOfAIFComponentContext1 = childrens).length, b = 0; b < i;) { + AIFComponentContext children = arrayOfAIFComponentContext1[b]; + TCComponentBOMLine childBomLine = (TCComponentBOMLine) children.getComponent(); + if (childBomLine.getStringProperty("ML8_ProjectTeam") != null + && childBomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) + childBomLineList.add(childBomLine); + b++; + } + if (childBomLineList.size() <= 0) + childBomLineList.add(itemRevision); + String str1 = itemRevision.getStringProperty("item_id"); + if (str1.indexOf("-") > 0) + str1 = str1.split("-")[0]; + String[] pros = this.map.get(comp); + String str2 = pros[0], str3 = pros[1], str4 = pros[2]; + String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + List> list = new ArrayList<>(); + String str5 = ""; + String str6 = ""; + String str7 = ""; + String str8 = ""; + String str9 = ""; + String str10 = ""; + String classERPCode = ""; + for (String[] excels : excelMap) { + if (excels[1].equals(str3) && excels[2].equals(str2)) { + List valueList = new ArrayList<>(); + valueList.add(excels[2]); + valueList.add(excels[0]); + valueList.add(excels[7]); + valueList.add(excels[4]); + valueList.add(excels[3]); + valueList.add(excels[5]); + valueList.add(excels[6]); + list.add(valueList); + } + } + if (list.size() <= 0) { + MessageBox.post("通过工厂:" + str3 + " 组名:" + map.get(comp) + " 未找到数据!", "错误", + MessageBox.ERROR); + return; + } + List list1 = new ArrayList<>(); + for (int j = 0; j < list.size(); j++) { + List valueList = list.get(j); + str5 = valueList.get(1); + str6 = valueList.get(2); + str7 = valueList.get(3); + str8 = valueList.get(4); + str9 = valueList.get(5); + str10 = valueList.get(6); + if (!list1.contains(str5)) { + list1.add(str5); + for (int k = 0; k < childBomLineList.size(); k++) { + String bom = (new DecimalFormat("00")).format((k + 1)); + str5 = String.valueOf(str5.substring(0, str5.length() - 2)) + bom; + InputStream input2 = null; + ResultSet rs2 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), + new Object[] { str1, str3, str7, str5 }); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + if (rs2 != null && classERPCode.compareTo(ERPCode) == 0) { + System.out.println("classERPCode" + classERPCode + "ERPCode" + ERPCode); + if (rs2.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(str1); + valuesList.add(str3); + valuesList.add(str5); + valuesList.add(str6); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add(bom); + valuesList.add("1"); + valuesList.add(str4); + valuesList.add(str7); + valuesList.add(str8); + valuesList.add(str9); + valuesList.add(str10); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input2 != null) + try { + input2.close(); + } catch (IOException e2) { + e2.printStackTrace(); + } + if (rs2 != null) + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + System.out.println("!isHave" + isHave); + if (!isHave) { + System.out.println("!isHave"); + List rowList = new ArrayList<>(); + rowList.add(str1); + rowList.add(str3); + rowList.add(str5); + rowList.add(str6); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add(bom); + rowList.add("1"); + rowList.add(str4); + rowList.add(str7); + rowList.add(str8); + rowList.add(str9); + rowList.add(str10); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + continue; + } + String itemId = itemRevision.getStringProperty("item_id"); + if (itemId.indexOf("-") > 0) + itemId = itemId.split("-")[0]; + String group = ((String[]) this.map.get(comp))[0], factory = ((String[]) this.map.get(comp))[1], + processGroup = ((String[]) this.map.get(comp))[2]; + List> classValueList = new ArrayList<>(); + String productionRev = ""; + String lineName = ""; + String groupNo = ""; + String workCenter = ""; + String receiveLocation = ""; + String storageLocation = ""; + for (String[] excels : excelMap) { + if (excels[1].equals(factory) && excels[2].equals(group)) { + List valueList = new ArrayList<>(); + valueList.add(excels[2]); + valueList.add(excels[0]); + valueList.add(excels[7]); + valueList.add(excels[4]); + valueList.add(excels[3]); + valueList.add(excels[5]); + valueList.add(excels[6]); + classValueList.add(valueList); + } + } + if (classValueList.size() <= 0) { + MessageBox.post("通过工厂:" + factory + " 组名:" + map.get(comp) + " 未找到数据!", "错误", + MessageBox.ERROR); + input.close(); + return; + } + List productionRevList = new ArrayList<>(); + for (int ii = 0; ii < classValueList.size(); ii++) { + List valueList = classValueList.get(ii); + productionRev = valueList.get(1); + lineName = valueList.get(2); + groupNo = valueList.get(3); + workCenter = valueList.get(4); + receiveLocation = valueList.get(5); + storageLocation = valueList.get(6); + if (!productionRevList.contains(productionRev)) { + productionRevList.add(productionRev); + ResultSet rs2 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), + new Object[] { itemId, factory, groupNo, productionRev }); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + if (rs2 != null) + if (rs2.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(itemId); + valuesList.add(factory); + valuesList.add(productionRev); + valuesList.add(lineName); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add("01"); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(groupNo); + valuesList.add(workCenter); + valuesList.add(receiveLocation); + valuesList.add(storageLocation); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs2 != null) + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + if (!isHave) { + List rowList = new ArrayList<>(); + rowList.add(itemId); + rowList.add(factory); + rowList.add(productionRev); + rowList.add(lineName); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add("01"); + rowList.add("1"); + rowList.add(processGroup); + rowList.add(groupNo); + rowList.add(workCenter); + rowList.add(receiveLocation); + rowList.add(storageLocation); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + } + } else { + for (TCComponent comp : this.map.keySet()) { + TCComponentItemRevision itemRevision = null; + TCComponentBOMLine topline = null; + if (comp instanceof TCComponentBOMLine) { + topline = (TCComponentBOMLine) comp; + itemRevision = topline.getItemRevision(); + } else if (comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) comp; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) this.session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + } + if (itemRevision == null) { + MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR); + continue; + } + if (itemRevision.getType().equals("ML8_RefrigeratorRevision") + || itemRevision.getType().equals("ML8_ColdRevision")) { + System.out.println("type ok"); + try { + List childBomLineList = new ArrayList<>(); + AIFComponentContext[] childrens = topline.getChildren(); + byte b; + int j; + AIFComponentContext[] arrayOfAIFComponentContext1; + for (j = (arrayOfAIFComponentContext1 = childrens).length, b = 0; b < j;) { + AIFComponentContext children = arrayOfAIFComponentContext1[b]; + TCComponentBOMLine childBomLine = (TCComponentBOMLine) children.getComponent(); + if (childBomLine.getStringProperty("ML8_ProjectTeam") != null + && childBomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) + childBomLineList.add(childBomLine); + b++; + } + if (childBomLineList.size() <= 0) + childBomLineList.add(itemRevision); + String str1 = itemRevision.getStringProperty("item_id"); + String str2 = itemRevision.getStringProperty("object_name"); + if (str1.indexOf("-") > 0) + str1 = str1.split("-")[0]; + String str3 = itemRevision.getStringProperty("ml8_Factory"); + System.out.println("factory:"+str3); + if(str3 == null || "".equals(str3.trim())) { + String stringProperty = topline.getStringProperty("bl_ML8_PartRevision_ml8_Factory"); + str3 = stringProperty; + System.out.println("factory:"+str3); + } + String str4 = ""; + ResultSet resultSet = null; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), + str1, str3 ); + System.out.println("selectSql:" + selectSql); + DbPool.getConnection(); + resultSet = DbPool.executeSelectSql(selectSql); + if (resultSet != null) { + System.out.println("rs!=null"); + while (resultSet.next()) { + str4 = resultSet.getString("PLNNR"); + System.out.println("processGroup" + str4); + } + } else { + DbPool.executeUpdateSql(selectSql); + } + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (resultSet != null) + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + DbPool.freeAll(); + } + if (str4.isEmpty()) + MessageBox.post("工艺路线表中未找到对应物料的工艺路线组", "错误", MessageBox.ERROR); + for (int i = 0; i < childBomLineList.size(); i++) { + String bom = (new DecimalFormat("00")).format((i + 1)); + ResultSet rs2 = null; + boolean bool = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL2"), + new Object[] { str1, str3 }); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + if (rs2 != null) + if (rs2.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(""); + valuesList.add(str1); + valuesList.add(str2); + valuesList.add(str3); + valuesList.add(""); + valuesList.add(""); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add(bom); + valuesList.add("1"); + valuesList.add(str4); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + bool = true; + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs2 != null) + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + System.out.println("!isHave" + bool); + if (!bool) { + System.out.println("!isHave"); + List rowList = new ArrayList<>(); + rowList.add(""); + rowList.add(str1); + rowList.add(str2); + rowList.add(str3); + rowList.add(""); + rowList.add(""); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add(bom); + rowList.add("1"); + rowList.add(str4); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + continue; + } + String itemId = itemRevision.getStringProperty("item_id"); + String name = itemRevision.getStringProperty("object_name"); + if (itemId.indexOf("-") > 0) + itemId = itemId.split("-")[0]; + String factory = itemRevision.getStringProperty("ml8_Factory"); + System.out.println("factory:"+factory); + System.out.println("factory:" + factory); + if(factory == null || "".equals(factory.trim())) { + String stringProperty = topline.getStringProperty("bl_ML8_PartRevision_ml8_Factory"); + factory = stringProperty; + System.out.println("factory:"+factory); + } + String processGroup = ""; + ResultSet rs = null; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), + itemId, factory); + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + if (rs != null) + while (rs.next()) + processGroup = rs.getString("PLNNR"); + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (input != null) + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + if (rs != null) + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (processGroup.isEmpty()) + MessageBox.post("工艺路线表中未找到对应物料的工艺路线组", "错误", MessageBox.ERROR); + ResultSet rs3 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL2"), + new Object[] { itemId, factory }); + System.out.println(selectSql); + DbPool.getConnection(); + rs3 = DbPool.executeSelectSql(selectSql); + if (rs3 != null) + if (rs3.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(""); + valuesList.add(itemId); + valuesList.add(name); + valuesList.add(factory); + valuesList.add(""); + valuesList.add(""); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add("01"); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs3 != null) + try { + rs3.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + if (!isHave) { + List rowList = new ArrayList<>(); + rowList.add(""); + rowList.add(itemId); + rowList.add(name); + rowList.add(factory); + rowList.add(""); + rowList.add(""); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add("01"); + rowList.add("1"); + rowList.add(processGroup); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + input.close(); + System.out.println("haveList size" + haveList.size()); + if (haveList.size() > 0) { + StringBuilder haveStringBuilder = new StringBuilder(); + for (int i = 0; i < haveList.size(); i++) { + haveStringBuilder.append("物料:"); + haveStringBuilder.append(haveList.get(i).get(0)); + haveStringBuilder.append("工厂:"); + haveStringBuilder.append(haveList.get(i).get(1)); + haveStringBuilder.append("组计数器:"); + haveStringBuilder.append(haveList.get(i).get(9)); + haveStringBuilder.append("\n"); + } + + JTextArea textArea = new JTextArea(haveStringBuilder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setPreferredSize(new Dimension(400, 300)); + int i = JOptionPane.showConfirmDialog(null, scrollPane, "重新传递", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + dataTableList.removeAll(haveList); + } + } + System.out.println(String.valueOf(dataTableList.size()) + "dataTableList" + this.isProcess); + (new Thread() { + public void run() { + if (SendProductRevCommand.this.isProcess) { + MethodUtil.sendProductRev(dataTableList, SendProductRevCommand.this.session); + } else { + System.out.println("excelMap:" + excelMap.size()); + new SendProductRevDialog(SendProductRevCommand.this.session, dataTableList, excelMap); + } + } + }).start(); + super.executeModal(); + } + + private XSSFRow getRow(XSSFSheet sheet, int num) throws Exception { + XSSFRow row = sheet.getRow(num); + if (row == null) + row = sheet.createRow(num); + return row; + } + + private XSSFCell getCell(XSSFRow row, int col) throws Exception { + XSSFCell cell = row.getCell(col); + if (cell == null) + cell = row.createCell(col); + return cell; + } + + private String getValue(XSSFCell cell) { + Object value = null; + CellType type = cell.getCellTypeEnum(); + if (type == CellType.STRING) { + value = cell.getStringCellValue(); + } else if (type == CellType.NUMERIC) { + value = Integer.valueOf((int) cell.getNumericCellValue()); + } + return "" + value; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevDialog.java new file mode 100644 index 0000000..c6488f7 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevDialog.java @@ -0,0 +1,419 @@ +package com.connor.ml.tcm.ML_08; + +import com.connor.ml.tcm.ML_07.ComboBoxCellEditor; +import com.connor.ml.tcm.ML_18.ScreenShotTest; +import com.connor.ml.tcm.bean.SendSAPProductRevBean; +import com.connor.ml.tcm.cloneProcess.WebApiUtil; +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MLRequestEntity; +import com.connor.ml.tcm.util.MLtoERPEntity; +import com.connor.ml.tcm.util.MLtoERPEntity2; +import com.google.gson.Gson; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; +import java.util.UUID; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import net.sf.json.JSONObject; + +public class SendProductRevDialog extends AbstractAIFDialog implements ActionListener { + private static final long serialVersionUID = 1L; + private String[] columns = new String[]{"组名", "物料代码", "物料描述", "工厂", "生产版本号", "版本描述", "有效期始", "有效期止", "可选BOM", "BOM用途", "工艺路线组", "组计数器", "工作中心", "接收位置", "发货仓储地点", "处理标记"}; + private Properties pro; + private List> dataTableList; + private Object[][] values; + private JTable mainTable; + private JPanel rootPanel; + private JButton sendButton; + private JButton closeButton; + private ArrayList excelMap; + private String[] lovs = this.getLOV("ML8_Factory_LOV"); + private String factory = ""; + private TCSession session; + + public SendProductRevDialog(TCSession session, List> dataTableList, ArrayList excelMap) { + this.dataTableList = dataTableList; + this.excelMap = excelMap; + this.session = session; + this.values = new String[this.dataTableList.size()][]; + + for(int i = 0; i < this.dataTableList.size(); ++i) { + this.values[i] = new String[((List)this.dataTableList.get(i)).size()]; + + for(int j = 0; j < ((List)this.dataTableList.get(i)).size(); ++j) { + this.values[i][j] = ((List)this.dataTableList.get(i)).get(j); + } + } + + BufferedInputStream input = null; + + try { + input = new BufferedInputStream(this.getClass().getResourceAsStream("/sql.properties")); + this.pro = new Properties(); + this.pro.load(input); + } catch (Exception var14) { + MessageBox.post("错误:" + var14.getMessage(), "错误!", 1); + var14.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception var13) { + var13.printStackTrace(); + } + } + + } + + this.init(); + } + + public SendProductRevDialog(TCSession session, List> dataTableList, ArrayList excelMap, String factory) { + this.dataTableList = dataTableList; + this.excelMap = excelMap; + this.factory = factory; + this.values = new String[this.dataTableList.size()][]; + + for(int i = 0; i < this.dataTableList.size(); ++i) { + this.values[i] = new String[((List)this.dataTableList.get(i)).size()]; + + for(int j = 0; j < ((List)this.dataTableList.get(i)).size(); ++j) { + this.values[i][j] = ((List)this.dataTableList.get(i)).get(j); + } + } + + BufferedInputStream input = null; + + try { + input = new BufferedInputStream(this.getClass().getResourceAsStream("/sql.properties")); + this.pro = new Properties(); + this.pro.load(input); + } catch (Exception var15) { + MessageBox.post("错误:" + var15.getMessage(), "错误!", 1); + var15.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception var14) { + var14.printStackTrace(); + } + } + + } + + this.init(); + } + + private void init() { + this.setTitle("传递的生产版本数据"); + this.setPreferredSize(new Dimension(800, 600)); + this.mainTable = this.getjTable(this.mainTable, (DefaultTableModel)null, this.columns, this.values); + this.rootPanel = new JPanel(new FlowLayout()); + this.sendButton = new JButton("传递"); + this.closeButton = new JButton("取消"); + this.rootPanel.add(this.sendButton); + this.rootPanel.add(this.closeButton); + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(new JScrollPane(this.mainTable), "Center"); + this.add(this.rootPanel, "South"); + this.pack(); + this.setLocationRelativeTo((Component)null); + this.setVisible(true); + } + + public void createActionEvent() { + this.sendButton.addActionListener(this); + this.closeButton.addActionListener(this); + } + + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)) { + private static final long serialVersionUID = 1L; + + public TableCellEditor getCellEditor(int row, int column) { + DefaultTableModel model; + ComboBoxCellEditor groupComboBoxCellEditor; + String fac; + int i; + String[] vs; + if (column == 0) { + model = (DefaultTableModel)this.getModel(); + groupComboBoxCellEditor = new ComboBoxCellEditor(this, model, SendProductRevDialog.this.excelMap, SendProductRevDialog.this.pro.getProperty("ML_TCMPROCESSSELECTSQL2"), row, column); + fac = this.getValueAt(row, 3).toString(); + if (fac.isEmpty()) { + return groupComboBoxCellEditor; + } else { + if (groupComboBoxCellEditor.getItemCount() == 0) { + ArrayList list = new ArrayList(); + + for(i = 0; i < SendProductRevDialog.this.excelMap.size(); ++i) { + vs = (String[])SendProductRevDialog.this.excelMap.get(i); + if (vs[1].equals(fac) && !list.contains(vs[2])) { + list.add(vs[2]); + } + } + + System.out.println("list:" + list.size()); + groupComboBoxCellEditor.addItem(""); + Iterator var11 = list.iterator(); + + while(var11.hasNext()) { + String s = (String)var11.next(); + groupComboBoxCellEditor.addItem(s); + } + } + + return groupComboBoxCellEditor; + } + } else if (column == 3 && SendProductRevDialog.this.factory.isEmpty()) { + model = (DefaultTableModel)this.getModel(); + groupComboBoxCellEditor = new ComboBoxCellEditor(this, model, SendProductRevDialog.this.excelMap, SendProductRevDialog.this.pro.getProperty("ML_TCMPROCESSSELECTSQL2"), row, column); + groupComboBoxCellEditor.addItem(""); + i = (vs = SendProductRevDialog.this.lovs).length; + + for(int var6 = 0; var6 < i; ++var6) { + fac = vs[var6]; + groupComboBoxCellEditor.addItem(fac); + } + + return groupComboBoxCellEditor; + } else { + return super.getCellEditor(); + } + } + }; + partsTable.setRowHeight(30); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for(int i = 0; i < titleNames.length; ++i) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(titleNames, 0); + Object[][] var8 = values; + int var7 = values.length; + + for(int var6 = 0; var6 < var7; ++var6) { + Object[] row = var8[var6]; + tableModel.addRow(row); + } + } + + return tableModel; + } + + public void addData(Object[][] cellData) { + DefaultTableModel tableModel = (DefaultTableModel)this.mainTable.getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter(this.getTableModel((DefaultTableModel)null, this.columns, cellData)); + this.mainTable.setRowSorter(sorter); + + for(int i = 0; i < cellData.length; ++i) { + tableModel.addRow(cellData[i]); + } + + this.mainTable.setEnabled(true); + this.mainTable.invalidate(); + } + + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + if (source.equals(this.sendButton)) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + StringBuffer messageString = new StringBuffer(); + + for(int i = 0; i < this.mainTable.getRowCount(); ++i) { + System.out.println("setMATNR:" + this.mainTable.getValueAt(i, 1) + " >> " + this.mainTable.getValueAt(i, 0)); + SendSAPProductRevBean sendSAPProductRevBean = new SendSAPProductRevBean(); + sendSAPProductRevBean.setMSGID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setBUSID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setTLGID("JT0001"); + sendSAPProductRevBean.setTLGNAME("维护生产版本接口"); + sendSAPProductRevBean.setDTSEND(sdf.format(new Date())); + sendSAPProductRevBean.setSENDER("TCM"); + sendSAPProductRevBean.setRECEIVER("SAP"); + sendSAPProductRevBean.setFREEUSE(""); + sendSAPProductRevBean.setMATNR(this.mainTable.getValueAt(i, 1) == null ? "" : this.mainTable.getValueAt(i, 1).toString()); + sendSAPProductRevBean.setWERKS(this.mainTable.getValueAt(i, 3) == null ? "" : this.mainTable.getValueAt(i, 3).toString()); + sendSAPProductRevBean.setVERID(this.mainTable.getValueAt(i, 4) == null ? "" : this.mainTable.getValueAt(i, 4).toString()); + sendSAPProductRevBean.setTEXT1(this.mainTable.getValueAt(i, 5) == null ? "" : this.mainTable.getValueAt(i, 5).toString()); + sendSAPProductRevBean.setADATU(this.mainTable.getValueAt(i, 6) == null ? "" : this.mainTable.getValueAt(i, 6).toString()); + sendSAPProductRevBean.setBDATU(this.mainTable.getValueAt(i, 7) == null ? "" : this.mainTable.getValueAt(i, 7).toString()); + sendSAPProductRevBean.setSTLAL(this.mainTable.getValueAt(i, 8) == null ? "" : this.mainTable.getValueAt(i, 8).toString()); + sendSAPProductRevBean.setSTLAN(this.mainTable.getValueAt(i, 9) == null ? "" : this.mainTable.getValueAt(i, 9).toString()); + sendSAPProductRevBean.setPLNNR(this.mainTable.getValueAt(i, 10) == null ? "" : this.mainTable.getValueAt(i, 10).toString()); + sendSAPProductRevBean.setALNAL(this.mainTable.getValueAt(i, 11) == null ? "" : this.mainTable.getValueAt(i, 11).toString()); + sendSAPProductRevBean.setMDV01(this.mainTable.getValueAt(i, 12) == null ? "" : this.mainTable.getValueAt(i, 12).toString()); + sendSAPProductRevBean.setALORT(this.mainTable.getValueAt(i, 13) == null ? "" : this.mainTable.getValueAt(i, 13).toString()); + sendSAPProductRevBean.setELPRO(this.mainTable.getValueAt(i, 14) == null ? "" : this.mainTable.getValueAt(i, 14).toString()); + sendSAPProductRevBean.setKZ(this.mainTable.getValueAt(i, 15) == null ? "" : this.mainTable.getValueAt(i, 15).toString()); + InputStream in = ScreenShotTest.class.getResourceAsStream("/toERP.properties"); + Properties p = new Properties(); + p.load(in); + String url = "http://mlapp.meiling.com/plmwebapi/sap/setinfo"; + MLtoERPEntity mLtoERPEntity = new MLtoERPEntity(); + mLtoERPEntity.setInfotype("生产版本"); + mLtoERPEntity.setInfocode(this.session.getUser().getUserId()); + mLtoERPEntity.setInfoname(p.getProperty("infoname")); + mLtoERPEntity.setInfodesc(""); + List list1 = new ArrayList(); + List list2 = new ArrayList(); + MLtoERPEntity2 field1 = new MLtoERPEntity2(); + field1.setField("MATNR"); + field1.setValue(sendSAPProductRevBean.getMATNR()); + list1.add(field1); + MLtoERPEntity2 field2 = new MLtoERPEntity2(); + field2.setField("WERKS"); + field2.setValue(sendSAPProductRevBean.getWERKS()); + list1.add(field2); + MLtoERPEntity2 field3 = new MLtoERPEntity2(); + field3.setField("VERID"); + field3.setValue(sendSAPProductRevBean.getVERID()); + list1.add(field3); + MLtoERPEntity2 field4 = new MLtoERPEntity2(); + field4.setField("TEXT1"); + field4.setValue(sendSAPProductRevBean.getTEXT1()); + list1.add(field4); + MLtoERPEntity2 field5 = new MLtoERPEntity2(); + field5.setField("ADATU"); + field5.setValue(sendSAPProductRevBean.getADATU()); + list1.add(field5); + MLtoERPEntity2 field6 = new MLtoERPEntity2(); + field6.setField("BDATU"); + field6.setValue(sendSAPProductRevBean.getBDATU()); + list1.add(field6); + MLtoERPEntity2 field7 = new MLtoERPEntity2(); + field7.setField("STLAL"); + field7.setValue(sendSAPProductRevBean.getSTLAL()); + list1.add(field7); + MLtoERPEntity2 field8 = new MLtoERPEntity2(); + field8.setField("STLAN"); + field8.setValue(sendSAPProductRevBean.getSTLAN()); + list1.add(field8); + MLtoERPEntity2 field9 = new MLtoERPEntity2(); + field9.setField("PLNNR"); + field9.setValue(sendSAPProductRevBean.getPLNNR()); + list1.add(field9); + MLtoERPEntity2 field10 = new MLtoERPEntity2(); + field10.setField("ALNAL"); + field10.setValue(sendSAPProductRevBean.getALNAL()); + list1.add(field10); + MLtoERPEntity2 field11 = new MLtoERPEntity2(); + field11.setField("MDV01"); + field11.setValue(sendSAPProductRevBean.getMDV01()); + list1.add(field11); + MLtoERPEntity2 field12 = new MLtoERPEntity2(); + field12.setField("ALORT"); + field12.setValue(sendSAPProductRevBean.getALORT()); + list1.add(field12); + MLtoERPEntity2 field13 = new MLtoERPEntity2(); + field13.setField("ELPRO"); + field13.setValue(sendSAPProductRevBean.getELPRO()); + list1.add(field13); + mLtoERPEntity.setData(list1); + mLtoERPEntity.setList(list2); + Gson gson = new Gson(); + String json = gson.toJson(mLtoERPEntity); + System.out.println(json); + String doPostResult = WebApiUtil.doPost(url, json); + MLRequestEntity resultEntity = (MLRequestEntity)gson.fromJson(doPostResult, MLRequestEntity.class); + String result = resultEntity.getResult(); + JSONObject fromObject = JSONObject.fromObject(result); + String status = resultEntity.getErrcode(); + System.out.println("当前数据库操作类型 UorI " + sendSAPProductRevBean.getKZ() + "生产版本号" + sendSAPProductRevBean.getVERID() + "传递结果 SorE" + status); + if (status.equals("0") || status.equals("1")) { + try { + String insertSql = String.format(this.pro.getProperty("ML_TCMPRODUCTREVINSERTSQL"), UUID.randomUUID().toString().replace("-", ""), sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), sendSAPProductRevBean.getTLGID(), sendSAPProductRevBean.getTLGNAME(), sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getSENDER(), sendSAPProductRevBean.getRECEIVER(), sendSAPProductRevBean.getFREEUSE(), sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), sendSAPProductRevBean.getVERID(), sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), sendSAPProductRevBean.getBDATU(), sendSAPProductRevBean.getSTLAL(), sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), status, resultEntity.getErrmsg()); + if (sendSAPProductRevBean.getKZ().equals("U")) { + insertSql = String.format(this.pro.getProperty("ML_TCMPRODUCTREVUPDATESQL"), sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getVERID(), sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), sendSAPProductRevBean.getBDATU(), sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), status, resultEntity.getErrmsg(), sendSAPProductRevBean.getSTLAL(), sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getVERID()); + } + + System.out.println(insertSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception var38) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", 1); + var38.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } + + if (resultEntity.getErrcode() != null && !resultEntity.getErrcode().isEmpty() && status.equals("1")) { + messageString.append("【物料代码】:" + fromObject.getString("MATNR").toString()); + messageString.append("【工厂】:" + fromObject.getString("WERKS").toString()); + messageString.append("【生产版本】:" + fromObject.getString("VERID").toString()); + messageString.append("【发送失败】:" + resultEntity.getErrmsg()); + messageString.append("\n"); + } + } + + this.dispose(); + MessageBox.post("传递成功!", "成功", 2); + } catch (Exception var40) { + } + } else if (source.equals(this.closeButton)) { + this.dispose(); + } + + } + + private String[] getLOV(String name) { + try { + TCSession session = (TCSession)AIFUtility.getCurrentApplication().getSession(); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType)session.getTypeComponent("ListOfValues"); + ListOfValuesInfo lov = lovType.find(name)[0].getListOfValues(); + String[] rv = lov.getStringListOfValues(); + return rv; + } catch (Exception var6) { + var6.printStackTrace(); + MessageBox.post(AIFUtility.getActiveDesktop(), "获取LOV【" + name + "】发生错误:" + var6.getMessage(), "ERROR", 1); + return new String[0]; + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevHandler.java new file mode 100644 index 0000000..71bd152 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08/SendProductRevHandler.java @@ -0,0 +1,34 @@ +package com.connor.ml.tcm.ML_08; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class SendProductRevHandler extends AbstractHandler { + public Object execute(ExecutionEvent arg0) throws ExecutionException { + final AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + final TCSession session = (TCSession)app.getSession(); + + try { + (new Thread() { + public void run() { + SendProductRevCommand command = new SendProductRevCommand(app.getTargetComponents(), session); + + try { + command.executeModal(); + } catch (Exception var3) { + var3.printStackTrace(); + } + + } + }).start(); + } catch (Exception var5) { + var5.printStackTrace(); + } + + return null; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SI_TCM2SAP_C223_OUTServiceCallbackHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SI_TCM2SAP_C223_OUTServiceCallbackHandler.java new file mode 100644 index 0000000..fb912ac --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SI_TCM2SAP_C223_OUTServiceCallbackHandler.java @@ -0,0 +1,66 @@ + +/** + * SI_TCM2SAP_C223_OUTServiceCallbackHandler.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: 1.4.1 Built on : Aug 13, 2008 (05:03:35 LKT) + */ + +package com.connor.ml.tcm.ML_08备份; + + /** + * SI_TCM2SAP_C223_OUTServiceCallbackHandler Callback class, Users can extend this class and implement + * their own receiveResult and receiveError methods. + */ + public abstract class SI_TCM2SAP_C223_OUTServiceCallbackHandler{ + + + + protected Object clientData; + + /** + * User can pass in any object that needs to be accessed once the NonBlocking + * Web service call is finished and appropriate method of this CallBack is called. + * @param clientData Object mechanism by which the user can pass in user data + * that will be avilable at the time this callback is called. + */ + public SI_TCM2SAP_C223_OUTServiceCallbackHandler(Object clientData){ + this.clientData = clientData; + } + + /** + * Please use this constructor if you don't want to set any clientData + */ + public SI_TCM2SAP_C223_OUTServiceCallbackHandler(){ + this.clientData = null; + } + + /** + * Get the client data + */ + + public Object getClientData() { + return clientData; + } + + + /** + * auto generated Axis2 call back method for SI_TCM2SAP_C223_OUT method + * override this method for handling normal response from SI_TCM2SAP_C223_OUT operation + */ + public void receiveResultSI_TCM2SAP_C223_OUT( + SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 result + ) { + } + + /** + * auto generated Axis2 Error handler + * override this method for handling error response from SI_TCM2SAP_C223_OUT operation + */ + public void receiveErrorSI_TCM2SAP_C223_OUT(java.lang.Exception e) { + } + + + + } + \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SI_TCM2SAP_C223_OUTServiceStub.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SI_TCM2SAP_C223_OUTServiceStub.java new file mode 100644 index 0000000..0942fa5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SI_TCM2SAP_C223_OUTServiceStub.java @@ -0,0 +1,6188 @@ + +/** + * SI_TCM2SAP_C223_OUTServiceStub.java + * + * This file was auto-generated from WSDL + * by the Apache Axis2 version: 1.4.1 Built on : Aug 13, 2008 (05:03:35 LKT) + */ +package com.connor.ml.tcm.ML_08备份; + + + + /* + * SI_TCM2SAP_C223_OUTServiceStub java implementation + */ + + + public class SI_TCM2SAP_C223_OUTServiceStub extends org.apache.axis2.client.Stub + { + protected org.apache.axis2.description.AxisOperation[] _operations; + + //hashmaps to keep the fault mapping + private java.util.HashMap faultExceptionNameMap = new java.util.HashMap(); + private java.util.HashMap faultExceptionClassNameMap = new java.util.HashMap(); + private java.util.HashMap faultMessageMap = new java.util.HashMap(); + + private static int counter = 0; + + private static synchronized String getUniqueSuffix(){ + // reset the counter if it is greater than 99999 + if (counter > 99999){ + counter = 0; + } + counter = counter + 1; + return Long.toString(System.currentTimeMillis()) + "_" + counter; + } + + + private void populateAxisService() throws org.apache.axis2.AxisFault { + + //creating the Service with a unique name + _service = new org.apache.axis2.description.AxisService("SI_TCM2SAP_C223_OUTService" + getUniqueSuffix()); + addAnonymousOperations(); + + //creating the operations + org.apache.axis2.description.AxisOperation __operation; + + _operations = new org.apache.axis2.description.AxisOperation[1]; + + __operation = new org.apache.axis2.description.OutInAxisOperation(); + + + __operation.setName(new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc", "SI_TCM2SAP_C223_OUT")); + _service.addOperation(__operation); + + + + + _operations[0]=__operation; + + + } + + //populates the faults + private void populateFaults(){ + + + + } + + /** + *Constructor that takes in a configContext + */ + + public SI_TCM2SAP_C223_OUTServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext, + java.lang.String targetEndpoint) + throws org.apache.axis2.AxisFault { + this(configurationContext,targetEndpoint,false); + } + + + /** + * Constructor that takes in a configContext and useseperate listner + */ + public SI_TCM2SAP_C223_OUTServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext, + java.lang.String targetEndpoint, boolean useSeparateListener) + throws org.apache.axis2.AxisFault { + //To populate AxisService + populateAxisService(); + populateFaults(); + + _serviceClient = new org.apache.axis2.client.ServiceClient(configurationContext,_service); + + + configurationContext = _serviceClient.getServiceContext().getConfigurationContext(); + + _serviceClient.getOptions().setTo(new org.apache.axis2.addressing.EndpointReference( + targetEndpoint)); + _serviceClient.getOptions().setUseSeparateListener(useSeparateListener); + + + } + + /** + * Default Constructor + */ + public SI_TCM2SAP_C223_OUTServiceStub(org.apache.axis2.context.ConfigurationContext configurationContext) throws org.apache.axis2.AxisFault { + + this(configurationContext,"http://xiprd.changhong.com:58000/dir/wsdl?p=ic/d2d9d24b858835e48de53cd31e58f2b1"); +// this(configurationContext,"http://10.3.1.25:52000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_TCM&receiverParty=&receiverService=&interface=SI_TCM2SAP_C223_OUT&interfaceNamespace=urn%3Achanghong.com%3ATCM%3Amlsc" ); + + //10.3.1.24 + } + + /** + * Default Constructor + */ + public SI_TCM2SAP_C223_OUTServiceStub() throws org.apache.axis2.AxisFault { + this("http://xiprd.changhong.com:58000/dir/wsdl?p=ic/d2d9d24b858835e48de53cd31e58f2b1"); +// this("http://10.3.1.25:52000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_TCM&receiverParty=&receiverService=&interface=SI_TCM2SAP_C223_OUT&interfaceNamespace=urn%3Achanghong.com%3ATCM%3Amlsc" ); + + } + + /** + * Constructor taking the target endpoint + */ + public SI_TCM2SAP_C223_OUTServiceStub(java.lang.String targetEndpoint) throws org.apache.axis2.AxisFault { + this(null,targetEndpoint); + } + + + + + /** + * Auto generated method signature + * + * @seeSI_TCM2SAP_C223_OUTService#SI_TCM2SAP_C223_OUT + * @param mT_TCM2SAP_C2230 + + */ + + + + public SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 SI_TCM2SAP_C223_OUT( + + SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 mT_TCM2SAP_C2230) + + + throws java.rmi.RemoteException + + { + org.apache.axis2.context.MessageContext _messageContext = null; + try{ + org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); + _operationClient.getOptions().setAction("http://sap.com/xi/WebService/soap1.1"); + _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); + + + + addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&"); + + + // create a message context + _messageContext = new org.apache.axis2.context.MessageContext(); + + + + // create SOAP envelope with that payload + org.apache.axiom.soap.SOAPEnvelope env = null; + + + env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), + mT_TCM2SAP_C2230, + optimizeContent(new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc", + "SI_TCM2SAP_C223_OUT"))); + + //adding SOAP soap_headers + _serviceClient.addHeadersToEnvelope(env); + // set the message context with that soap envelope + _messageContext.setEnvelope(env); + + // add the message contxt to the operation client + _operationClient.addMessageContext(_messageContext); + + //execute the operation client + System.out.println("execute"); + _operationClient.execute(true); + + + org.apache.axis2.context.MessageContext _returnMessageContext = _operationClient.getMessageContext( + org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); + org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); + + + java.lang.Object object = fromOM( + _returnEnv.getBody().getFirstElement() , + SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.class, + getEnvelopeNamespaces(_returnEnv)); + + + return (SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223)object; + + }catch(org.apache.axis2.AxisFault f){ + + org.apache.axiom.om.OMElement faultElt = f.getDetail(); + if (faultElt!=null){ + if (faultExceptionNameMap.containsKey(faultElt.getQName())){ + //make the fault by reflection + try{ + java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName()); + java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); + java.lang.Exception ex= + (java.lang.Exception) exceptionClass.newInstance(); + //message class + java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName()); + java.lang.Class messageClass = java.lang.Class.forName(messageClassName); + java.lang.Object messageObject = fromOM(faultElt,messageClass,null); + java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", + new java.lang.Class[]{messageClass}); + m.invoke(ex,new java.lang.Object[]{messageObject}); + + + throw new java.rmi.RemoteException(ex.getMessage(), ex); + }catch(java.lang.ClassCastException e){ + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.ClassNotFoundException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + }catch (java.lang.NoSuchMethodException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.reflect.InvocationTargetException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.IllegalAccessException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } catch (java.lang.InstantiationException e) { + // we cannot intantiate the class - throw the original Axis fault + throw f; + } + }else{ + throw f; + } + }else{ + throw f; + } + } finally { + _messageContext.getTransportOut().getSender().cleanup(_messageContext); + } + } + + /** + * Auto generated method signature for Asynchronous Invocations + * + * @seeSI_TCM2SAP_C223_OUTService#startSI_TCM2SAP_C223_OUT + * @param mT_TCM2SAP_C2230 + + */ + public void startSI_TCM2SAP_C223_OUT( + + SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 mT_TCM2SAP_C2230, + + final SI_TCM2SAP_C223_OUTServiceCallbackHandler callback) + + throws java.rmi.RemoteException{ + + org.apache.axis2.client.OperationClient _operationClient = _serviceClient.createClient(_operations[0].getName()); + _operationClient.getOptions().setAction("http://sap.com/xi/WebService/soap1.1"); + _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); + + + + addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&"); + + + + // create SOAP envelope with that payload + org.apache.axiom.soap.SOAPEnvelope env=null; + final org.apache.axis2.context.MessageContext _messageContext = new org.apache.axis2.context.MessageContext(); + + + //Style is Doc. + + + env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), + mT_TCM2SAP_C2230, + optimizeContent(new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc", + "SI_TCM2SAP_C223_OUT"))); + + // adding SOAP soap_headers + _serviceClient.addHeadersToEnvelope(env); + // create message context with that soap envelope + _messageContext.setEnvelope(env); + + // add the message context to the operation client + _operationClient.addMessageContext(_messageContext); + + + + _operationClient.setCallback(new org.apache.axis2.client.async.AxisCallback() { + public void onMessage(org.apache.axis2.context.MessageContext resultContext) { + try { + org.apache.axiom.soap.SOAPEnvelope resultEnv = resultContext.getEnvelope(); + + java.lang.Object object = fromOM(resultEnv.getBody().getFirstElement(), + SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.class, + getEnvelopeNamespaces(resultEnv)); + callback.receiveResultSI_TCM2SAP_C223_OUT( + (SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223)object); + + } catch (org.apache.axis2.AxisFault e) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(e); + } + } + + public void onError(java.lang.Exception error) { + if (error instanceof org.apache.axis2.AxisFault) { + org.apache.axis2.AxisFault f = (org.apache.axis2.AxisFault) error; + org.apache.axiom.om.OMElement faultElt = f.getDetail(); + if (faultElt!=null){ + if (faultExceptionNameMap.containsKey(faultElt.getQName())){ + //make the fault by reflection + try{ + java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName()); + java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); + java.lang.Exception ex= + (java.lang.Exception) exceptionClass.newInstance(); + //message class + java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName()); + java.lang.Class messageClass = java.lang.Class.forName(messageClassName); + java.lang.Object messageObject = fromOM(faultElt,messageClass,null); + java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", + new java.lang.Class[]{messageClass}); + m.invoke(ex,new java.lang.Object[]{messageObject}); + + + callback.receiveErrorSI_TCM2SAP_C223_OUT(new java.rmi.RemoteException(ex.getMessage(), ex)); + } catch(java.lang.ClassCastException e){ + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (java.lang.ClassNotFoundException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (java.lang.NoSuchMethodException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (java.lang.reflect.InvocationTargetException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (java.lang.IllegalAccessException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (java.lang.InstantiationException e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } catch (org.apache.axis2.AxisFault e) { + // we cannot intantiate the class - throw the original Axis fault + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_C223_OUT(f); + } + } else { + callback.receiveErrorSI_TCM2SAP_C223_OUT(error); + } + } + + public void onFault(org.apache.axis2.context.MessageContext faultContext) { + org.apache.axis2.AxisFault fault = org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(faultContext); + onError(fault); + } + + public void onComplete() { + try { + _messageContext.getTransportOut().getSender().cleanup(_messageContext); + } catch (org.apache.axis2.AxisFault axisFault) { + callback.receiveErrorSI_TCM2SAP_C223_OUT(axisFault); + } + } + }); + + + org.apache.axis2.util.CallbackReceiver _callbackReceiver = null; + if ( _operations[0].getMessageReceiver()==null && _operationClient.getOptions().isUseSeparateListener()) { + _callbackReceiver = new org.apache.axis2.util.CallbackReceiver(); + _operations[0].setMessageReceiver( + _callbackReceiver); + } + + //execute the operation client + _operationClient.execute(false); + + } + + + + /** + * A utility method that copies the namepaces from the SOAPEnvelope + */ + private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope env){ + java.util.Map returnMap = new java.util.HashMap(); + java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces(); + while (namespaceIterator.hasNext()) { + org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace) namespaceIterator.next(); + returnMap.put(ns.getPrefix(),ns.getNamespaceURI()); + } + return returnMap; + } + + + + private javax.xml.namespace.QName[] opNameArray = null; + private boolean optimizeContent(javax.xml.namespace.QName opName) { + + + if (opNameArray == null) { + return false; + } + for (int i = 0; i < opNameArray.length; i++) { + if (opName.equals(opNameArray[i])) { + return true; + } + } + return false; + } + //http://xiprd.changhong.com:58000/XISOAPAdapter/MessageServlet?senderParty=&senderService=BC_TCM&receiverParty=&receiverService=&interface=SI_TCM2SAP_C223_OUT&interfaceNamespace=urn%3Achanghong.com%3ATCM%3Amlsc + public static class MSG_BODY_type0 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = MSG_BODY_type0 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for HEADER + */ + + + protected HEADER_type0 localHEADER ; + + + /** + * Auto generated getter method + * @return HEADER_type0 + */ + public HEADER_type0 getHEADER(){ + return localHEADER; + } + + + + /** + * Auto generated setter method + * @param param HEADER + */ + public void setHEADER(HEADER_type0 param){ + + this.localHEADER=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MSG_BODY_type0.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":MSG_BODY_type0", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "MSG_BODY_type0", + xmlWriter); + } + + + } + + if (localHEADER==null){ + throw new org.apache.axis2.databinding.ADBException("HEADER cannot be null!!"); + } + localHEADER.serialize(new javax.xml.namespace.QName("","HEADER"), + factory,xmlWriter); + + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + + elementList.add(new javax.xml.namespace.QName("", + "HEADER")); + + + if (localHEADER==null){ + throw new org.apache.axis2.databinding.ADBException("HEADER cannot be null!!"); + } + elementList.add(localHEADER); + + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MSG_BODY_type0 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MSG_BODY_type0 object = + new MSG_BODY_type0(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"MSG_BODY_type0".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (MSG_BODY_type0)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","HEADER").equals(reader.getName())){ + + object.setHEADER(HEADER_type0.Factory.parse(reader)); + + reader.next(); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class HEADER_type0 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = HEADER_type0 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MATNR + */ + + + protected java.lang.String localMATNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMATNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMATNR(){ + return localMATNR; + } + + + + /** + * Auto generated setter method + * @param param MATNR + */ + public void setMATNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMATNRTracker = true; + } else { + localMATNRTracker = false; + + } + + this.localMATNR=param; + + + } + + + /** + * field for WERKS + */ + + + protected java.lang.String localWERKS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localWERKSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getWERKS(){ + return localWERKS; + } + + + + /** + * Auto generated setter method + * @param param WERKS + */ + public void setWERKS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localWERKSTracker = true; + } else { + localWERKSTracker = false; + + } + + this.localWERKS=param; + + + } + + + /** + * field for VERID + */ + + + protected java.lang.String localVERID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVERIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVERID(){ + return localVERID; + } + + + + /** + * Auto generated setter method + * @param param VERID + */ + public void setVERID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVERIDTracker = true; + } else { + localVERIDTracker = false; + + } + + this.localVERID=param; + + + } + + + /** + * field for TEXT1 + */ + + + protected java.lang.String localTEXT1 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localTEXT1Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getTEXT1(){ + return localTEXT1; + } + + + + /** + * Auto generated setter method + * @param param TEXT1 + */ + public void setTEXT1(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localTEXT1Tracker = true; + } else { + localTEXT1Tracker = false; + + } + + this.localTEXT1=param; + + + } + + + /** + * field for ADATU + */ + + + protected java.lang.String localADATU ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localADATUTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getADATU(){ + return localADATU; + } + + + + /** + * Auto generated setter method + * @param param ADATU + */ + public void setADATU(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localADATUTracker = true; + } else { + localADATUTracker = false; + + } + + this.localADATU=param; + + + } + + + /** + * field for BDATU + */ + + + protected java.lang.String localBDATU ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localBDATUTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getBDATU(){ + return localBDATU; + } + + + + /** + * Auto generated setter method + * @param param BDATU + */ + public void setBDATU(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localBDATUTracker = true; + } else { + localBDATUTracker = false; + + } + + this.localBDATU=param; + + + } + + + /** + * field for STLAL + */ + + + protected java.lang.String localSTLAL ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTLALTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTLAL(){ + return localSTLAL; + } + + + + /** + * Auto generated setter method + * @param param STLAL + */ + public void setSTLAL(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTLALTracker = true; + } else { + localSTLALTracker = false; + + } + + this.localSTLAL=param; + + + } + + + /** + * field for STLAN + */ + + + protected java.lang.String localSTLAN ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTLANTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTLAN(){ + return localSTLAN; + } + + + + /** + * Auto generated setter method + * @param param STLAN + */ + public void setSTLAN(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTLANTracker = true; + } else { + localSTLANTracker = false; + + } + + this.localSTLAN=param; + + + } + + + /** + * field for PLNNR + */ + + + protected java.lang.String localPLNNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localPLNNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getPLNNR(){ + return localPLNNR; + } + + + + /** + * Auto generated setter method + * @param param PLNNR + */ + public void setPLNNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localPLNNRTracker = true; + } else { + localPLNNRTracker = false; + + } + + this.localPLNNR=param; + + + } + + + /** + * field for ALNAL + */ + + + protected java.lang.String localALNAL ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localALNALTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getALNAL(){ + return localALNAL; + } + + + + /** + * Auto generated setter method + * @param param ALNAL + */ + public void setALNAL(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localALNALTracker = true; + } else { + localALNALTracker = false; + + } + + this.localALNAL=param; + + + } + + + /** + * field for MDV01 + */ + + + protected java.lang.String localMDV01 ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMDV01Tracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMDV01(){ + return localMDV01; + } + + + + /** + * Auto generated setter method + * @param param MDV01 + */ + public void setMDV01(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMDV01Tracker = true; + } else { + localMDV01Tracker = false; + + } + + this.localMDV01=param; + + + } + + + /** + * field for ALORT + */ + + + protected java.lang.String localALORT ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localALORTTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getALORT(){ + return localALORT; + } + + + + /** + * Auto generated setter method + * @param param ALORT + */ + public void setALORT(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localALORTTracker = true; + } else { + localALORTTracker = false; + + } + + this.localALORT=param; + + + } + + + /** + * field for ELPRO + */ + + + protected java.lang.String localELPRO ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localELPROTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getELPRO(){ + return localELPRO; + } + + + + /** + * Auto generated setter method + * @param param ELPRO + */ + public void setELPRO(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localELPROTracker = true; + } else { + localELPROTracker = false; + + } + + this.localELPRO=param; + + + } + + + /** + * field for KZ + */ + + + protected java.lang.String localKZ ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localKZTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getKZ(){ + return localKZ; + } + + + + /** + * Auto generated setter method + * @param param KZ + */ + public void setKZ(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localKZTracker = true; + } else { + localKZTracker = false; + + } + + this.localKZ=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + HEADER_type0.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":HEADER_type0", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "HEADER_type0", + xmlWriter); + } + + + } + if (localMATNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MATNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MATNR"); + } + + } else { + xmlWriter.writeStartElement("MATNR"); + } + + + if (localMATNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMATNR); + + } + + xmlWriter.writeEndElement(); + } if (localWERKSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"WERKS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"WERKS"); + } + + } else { + xmlWriter.writeStartElement("WERKS"); + } + + + if (localWERKS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localWERKS); + + } + + xmlWriter.writeEndElement(); + } if (localVERIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VERID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VERID"); + } + + } else { + xmlWriter.writeStartElement("VERID"); + } + + + if (localVERID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VERID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVERID); + + } + + xmlWriter.writeEndElement(); + } if (localTEXT1Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"TEXT1", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"TEXT1"); + } + + } else { + xmlWriter.writeStartElement("TEXT1"); + } + + + if (localTEXT1==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("TEXT1 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localTEXT1); + + } + + xmlWriter.writeEndElement(); + } if (localADATUTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"ADATU", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"ADATU"); + } + + } else { + xmlWriter.writeStartElement("ADATU"); + } + + + if (localADATU==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("ADATU cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localADATU); + + } + + xmlWriter.writeEndElement(); + } if (localBDATUTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"BDATU", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"BDATU"); + } + + } else { + xmlWriter.writeStartElement("BDATU"); + } + + + if (localBDATU==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("BDATU cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localBDATU); + + } + + xmlWriter.writeEndElement(); + } if (localSTLALTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STLAL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STLAL"); + } + + } else { + xmlWriter.writeStartElement("STLAL"); + } + + + if (localSTLAL==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STLAL cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTLAL); + + } + + xmlWriter.writeEndElement(); + } if (localSTLANTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STLAN", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STLAN"); + } + + } else { + xmlWriter.writeStartElement("STLAN"); + } + + + if (localSTLAN==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STLAN cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTLAN); + + } + + xmlWriter.writeEndElement(); + } if (localPLNNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"PLNNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"PLNNR"); + } + + } else { + xmlWriter.writeStartElement("PLNNR"); + } + + + if (localPLNNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("PLNNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localPLNNR); + + } + + xmlWriter.writeEndElement(); + } if (localALNALTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"ALNAL", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"ALNAL"); + } + + } else { + xmlWriter.writeStartElement("ALNAL"); + } + + + if (localALNAL==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("ALNAL cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localALNAL); + + } + + xmlWriter.writeEndElement(); + } if (localMDV01Tracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MDV01", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MDV01"); + } + + } else { + xmlWriter.writeStartElement("MDV01"); + } + + + if (localMDV01==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MDV01 cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMDV01); + + } + + xmlWriter.writeEndElement(); + } if (localALORTTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"ALORT", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"ALORT"); + } + + } else { + xmlWriter.writeStartElement("ALORT"); + } + + + if (localALORT==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("ALORT cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localALORT); + + } + + xmlWriter.writeEndElement(); + } if (localELPROTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"ELPRO", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"ELPRO"); + } + + } else { + xmlWriter.writeStartElement("ELPRO"); + } + + + if (localELPRO==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("ELPRO cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localELPRO); + + } + + xmlWriter.writeEndElement(); + } if (localKZTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"KZ", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"KZ"); + } + + } else { + xmlWriter.writeStartElement("KZ"); + } + + + if (localKZ==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("KZ cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localKZ); + + } + + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMATNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MATNR")); + + if (localMATNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMATNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + } + } if (localWERKSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "WERKS")); + + if (localWERKS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localWERKS)); + } else { + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + } + } if (localVERIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "VERID")); + + if (localVERID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVERID)); + } else { + throw new org.apache.axis2.databinding.ADBException("VERID cannot be null!!"); + } + } if (localTEXT1Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "TEXT1")); + + if (localTEXT1 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localTEXT1)); + } else { + throw new org.apache.axis2.databinding.ADBException("TEXT1 cannot be null!!"); + } + } if (localADATUTracker){ + elementList.add(new javax.xml.namespace.QName("", + "ADATU")); + + if (localADATU != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localADATU)); + } else { + throw new org.apache.axis2.databinding.ADBException("ADATU cannot be null!!"); + } + } if (localBDATUTracker){ + elementList.add(new javax.xml.namespace.QName("", + "BDATU")); + + if (localBDATU != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBDATU)); + } else { + throw new org.apache.axis2.databinding.ADBException("BDATU cannot be null!!"); + } + } if (localSTLALTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STLAL")); + + if (localSTLAL != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTLAL)); + } else { + throw new org.apache.axis2.databinding.ADBException("STLAL cannot be null!!"); + } + } if (localSTLANTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STLAN")); + + if (localSTLAN != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTLAN)); + } else { + throw new org.apache.axis2.databinding.ADBException("STLAN cannot be null!!"); + } + } if (localPLNNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "PLNNR")); + + if (localPLNNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localPLNNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("PLNNR cannot be null!!"); + } + } if (localALNALTracker){ + elementList.add(new javax.xml.namespace.QName("", + "ALNAL")); + + if (localALNAL != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localALNAL)); + } else { + throw new org.apache.axis2.databinding.ADBException("ALNAL cannot be null!!"); + } + } if (localMDV01Tracker){ + elementList.add(new javax.xml.namespace.QName("", + "MDV01")); + + if (localMDV01 != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMDV01)); + } else { + throw new org.apache.axis2.databinding.ADBException("MDV01 cannot be null!!"); + } + } if (localALORTTracker){ + elementList.add(new javax.xml.namespace.QName("", + "ALORT")); + + if (localALORT != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localALORT)); + } else { + throw new org.apache.axis2.databinding.ADBException("ALORT cannot be null!!"); + } + } if (localELPROTracker){ + elementList.add(new javax.xml.namespace.QName("", + "ELPRO")); + + if (localELPRO != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localELPRO)); + } else { + throw new org.apache.axis2.databinding.ADBException("ELPRO cannot be null!!"); + } + } if (localKZTracker){ + elementList.add(new javax.xml.namespace.QName("", + "KZ")); + + if (localKZ != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localKZ)); + } else { + throw new org.apache.axis2.databinding.ADBException("KZ cannot be null!!"); + } + } + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static HEADER_type0 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + HEADER_type0 object = + new HEADER_type0(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"HEADER_type0".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (HEADER_type0)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MATNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMATNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","WERKS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setWERKS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VERID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVERID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","TEXT1").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setTEXT1( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","ADATU").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setADATU( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","BDATU").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setBDATU( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STLAL").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTLAL( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STLAN").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTLAN( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","PLNNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setPLNNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","ALNAL").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setALNAL( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MDV01").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMDV01( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","ALORT").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setALORT( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","ELPRO").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setELPRO( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","KZ").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setKZ( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class ExtensionMapper{ + + public static java.lang.Object getTypeObject(java.lang.String namespaceURI, + java.lang.String typeName, + javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "MSG_BODY_type0".equals(typeName)){ + + return MSG_BODY_type0.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "HEADER_type0".equals(typeName)){ + + return HEADER_type0.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "DT_SAP2TCM_C223".equals(typeName)){ + + return DT_SAP2TCM_C223.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "DT_TCM2SAP_C223".equals(typeName)){ + + return DT_TCM2SAP_C223.Factory.parse(reader); + + + } + + + if ( + "urn:changhong.com:TCM:mlsc".equals(namespaceURI) && + "MSG_HDR_type0".equals(typeName)){ + + return MSG_HDR_type0.Factory.parse(reader); + + + } + + + throw new org.apache.axis2.databinding.ADBException("Unsupported type " + namespaceURI + " " + typeName); + } + + } + + public static class DT_SAP2TCM_C223 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = DT_SAP2TCM_C223 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MATNR + */ + + + protected java.lang.String localMATNR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMATNRTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMATNR(){ + return localMATNR; + } + + + + /** + * Auto generated setter method + * @param param MATNR + */ + public void setMATNR(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMATNRTracker = true; + } else { + localMATNRTracker = false; + + } + + this.localMATNR=param; + + + } + + + /** + * field for WERKS + */ + + + protected java.lang.String localWERKS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localWERKSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getWERKS(){ + return localWERKS; + } + + + + /** + * Auto generated setter method + * @param param WERKS + */ + public void setWERKS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localWERKSTracker = true; + } else { + localWERKSTracker = false; + + } + + this.localWERKS=param; + + + } + + + /** + * field for VERID + */ + + + protected java.lang.String localVERID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localVERIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getVERID(){ + return localVERID; + } + + + + /** + * Auto generated setter method + * @param param VERID + */ + public void setVERID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localVERIDTracker = true; + } else { + localVERIDTracker = false; + + } + + this.localVERID=param; + + + } + + + /** + * field for STATUS + */ + + + protected java.lang.String localSTATUS ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSTATUSTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSTATUS(){ + return localSTATUS; + } + + + + /** + * Auto generated setter method + * @param param STATUS + */ + public void setSTATUS(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSTATUSTracker = true; + } else { + localSTATUSTracker = false; + + } + + this.localSTATUS=param; + + + } + + + /** + * field for MESSAGE + */ + + + protected java.lang.String localMESSAGE ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMESSAGETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMESSAGE(){ + return localMESSAGE; + } + + + + /** + * Auto generated setter method + * @param param MESSAGE + */ + public void setMESSAGE(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMESSAGETracker = true; + } else { + localMESSAGETracker = false; + + } + + this.localMESSAGE=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + DT_SAP2TCM_C223.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":DT_SAP2TCM_C223", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "DT_SAP2TCM_C223", + xmlWriter); + } + + + } + if (localMATNRTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MATNR", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MATNR"); + } + + } else { + xmlWriter.writeStartElement("MATNR"); + } + + + if (localMATNR==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMATNR); + + } + + xmlWriter.writeEndElement(); + } if (localWERKSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"WERKS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"WERKS"); + } + + } else { + xmlWriter.writeStartElement("WERKS"); + } + + + if (localWERKS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localWERKS); + + } + + xmlWriter.writeEndElement(); + } if (localVERIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"VERID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"VERID"); + } + + } else { + xmlWriter.writeStartElement("VERID"); + } + + + if (localVERID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("VERID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localVERID); + + } + + xmlWriter.writeEndElement(); + } if (localSTATUSTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"STATUS", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"STATUS"); + } + + } else { + xmlWriter.writeStartElement("STATUS"); + } + + + if (localSTATUS==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("STATUS cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSTATUS); + + } + + xmlWriter.writeEndElement(); + } if (localMESSAGETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MESSAGE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MESSAGE"); + } + + } else { + xmlWriter.writeStartElement("MESSAGE"); + } + + + if (localMESSAGE==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MESSAGE cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMESSAGE); + + } + + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMATNRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MATNR")); + + if (localMATNR != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMATNR)); + } else { + throw new org.apache.axis2.databinding.ADBException("MATNR cannot be null!!"); + } + } if (localWERKSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "WERKS")); + + if (localWERKS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localWERKS)); + } else { + throw new org.apache.axis2.databinding.ADBException("WERKS cannot be null!!"); + } + } if (localVERIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "VERID")); + + if (localVERID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localVERID)); + } else { + throw new org.apache.axis2.databinding.ADBException("VERID cannot be null!!"); + } + } if (localSTATUSTracker){ + elementList.add(new javax.xml.namespace.QName("", + "STATUS")); + + if (localSTATUS != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSTATUS)); + } else { + throw new org.apache.axis2.databinding.ADBException("STATUS cannot be null!!"); + } + } if (localMESSAGETracker){ + elementList.add(new javax.xml.namespace.QName("", + "MESSAGE")); + + if (localMESSAGE != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMESSAGE)); + } else { + throw new org.apache.axis2.databinding.ADBException("MESSAGE cannot be null!!"); + } + } + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static DT_SAP2TCM_C223 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + DT_SAP2TCM_C223 object = + new DT_SAP2TCM_C223(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"DT_SAP2TCM_C223".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (DT_SAP2TCM_C223)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MATNR").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMATNR( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","WERKS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setWERKS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","VERID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setVERID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","STATUS").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSTATUS( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MESSAGE").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMESSAGE( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class DT_TCM2SAP_C223 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = DT_TCM2SAP_C223 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MSG_HDR + */ + + + protected MSG_HDR_type0 localMSG_HDR ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMSG_HDRTracker = false ; + + + /** + * Auto generated getter method + * @return MSG_HDR_type0 + */ + public MSG_HDR_type0 getMSG_HDR(){ + return localMSG_HDR; + } + + + + /** + * Auto generated setter method + * @param param MSG_HDR + */ + public void setMSG_HDR(MSG_HDR_type0 param){ + + if (param != null){ + //update the setting tracker + localMSG_HDRTracker = true; + } else { + localMSG_HDRTracker = false; + + } + + this.localMSG_HDR=param; + + + } + + + /** + * field for MSG_BODY + */ + + + protected MSG_BODY_type0 localMSG_BODY ; + + + /** + * Auto generated getter method + * @return MSG_BODY_type0 + */ + public MSG_BODY_type0 getMSG_BODY(){ + return localMSG_BODY; + } + + + + /** + * Auto generated setter method + * @param param MSG_BODY + */ + public void setMSG_BODY(MSG_BODY_type0 param){ + + this.localMSG_BODY=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + DT_TCM2SAP_C223.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":DT_TCM2SAP_C223", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "DT_TCM2SAP_C223", + xmlWriter); + } + + + } + if (localMSG_HDRTracker){ + if (localMSG_HDR==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_HDR cannot be null!!"); + } + localMSG_HDR.serialize(new javax.xml.namespace.QName("","MSG_HDR"), + factory,xmlWriter); + } + if (localMSG_BODY==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_BODY cannot be null!!"); + } + localMSG_BODY.serialize(new javax.xml.namespace.QName("","MSG_BODY"), + factory,xmlWriter); + + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMSG_HDRTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MSG_HDR")); + + + if (localMSG_HDR==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_HDR cannot be null!!"); + } + elementList.add(localMSG_HDR); + } + elementList.add(new javax.xml.namespace.QName("", + "MSG_BODY")); + + + if (localMSG_BODY==null){ + throw new org.apache.axis2.databinding.ADBException("MSG_BODY cannot be null!!"); + } + elementList.add(localMSG_BODY); + + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static DT_TCM2SAP_C223 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + DT_TCM2SAP_C223 object = + new DT_TCM2SAP_C223(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"DT_TCM2SAP_C223".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (DT_TCM2SAP_C223)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MSG_HDR").equals(reader.getName())){ + + object.setMSG_HDR(MSG_HDR_type0.Factory.parse(reader)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MSG_BODY").equals(reader.getName())){ + + object.setMSG_BODY(MSG_BODY_type0.Factory.parse(reader)); + + reader.next(); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class MT_SAP2TCM_C223 + implements org.apache.axis2.databinding.ADBBean{ + + public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( + "urn:changhong.com:TCM:mlsc", + "MT_SAP2TCM_C223", + "ns1"); + + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MT_SAP2TCM_C223 + */ + + + protected DT_SAP2TCM_C223 localMT_SAP2TCM_C223 ; + + + /** + * Auto generated getter method + * @return DT_SAP2TCM_C223 + */ + public DT_SAP2TCM_C223 getMT_SAP2TCM_C223(){ + return localMT_SAP2TCM_C223; + } + + + + /** + * Auto generated setter method + * @param param MT_SAP2TCM_C223 + */ + public void setMT_SAP2TCM_C223(DT_SAP2TCM_C223 param){ + + this.localMT_SAP2TCM_C223=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,MY_QNAME){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MT_SAP2TCM_C223.this.serialize(MY_QNAME,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + MY_QNAME,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + //We can safely assume an element has only one type associated with it + + if (localMT_SAP2TCM_C223==null){ + throw new org.apache.axis2.databinding.ADBException("Property cannot be null!"); + } + localMT_SAP2TCM_C223.serialize(MY_QNAME,factory,xmlWriter); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + + //We can safely assume an element has only one type associated with it + return localMT_SAP2TCM_C223.getPullParser(MY_QNAME); + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MT_SAP2TCM_C223 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MT_SAP2TCM_C223 object = + new MT_SAP2TCM_C223(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + while(!reader.isEndElement()) { + if (reader.isStartElement() ){ + + if (reader.isStartElement() && new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc","MT_SAP2TCM_C223").equals(reader.getName())){ + + object.setMT_SAP2TCM_C223(DT_SAP2TCM_C223.Factory.parse(reader)); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + } else { + reader.next(); + } + } // end of while loop + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class MT_TCM2SAP_C223 + implements org.apache.axis2.databinding.ADBBean{ + + public static final javax.xml.namespace.QName MY_QNAME = new javax.xml.namespace.QName( + "urn:changhong.com:TCM:mlsc", + "MT_TCM2SAP_C223", + "ns1"); + + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MT_TCM2SAP_C223 + */ + + + protected DT_TCM2SAP_C223 localMT_TCM2SAP_C223 ; + + + /** + * Auto generated getter method + * @return DT_TCM2SAP_C223 + */ + public DT_TCM2SAP_C223 getMT_TCM2SAP_C223(){ + return localMT_TCM2SAP_C223; + } + + + + /** + * Auto generated setter method + * @param param MT_TCM2SAP_C223 + */ + public void setMT_TCM2SAP_C223(DT_TCM2SAP_C223 param){ + + this.localMT_TCM2SAP_C223=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,MY_QNAME){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MT_TCM2SAP_C223.this.serialize(MY_QNAME,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + MY_QNAME,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + //We can safely assume an element has only one type associated with it + + if (localMT_TCM2SAP_C223==null){ + throw new org.apache.axis2.databinding.ADBException("Property cannot be null!"); + } + localMT_TCM2SAP_C223.serialize(MY_QNAME,factory,xmlWriter); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + + //We can safely assume an element has only one type associated with it + return localMT_TCM2SAP_C223.getPullParser(MY_QNAME); + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MT_TCM2SAP_C223 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MT_TCM2SAP_C223 object = + new MT_TCM2SAP_C223(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + while(!reader.isEndElement()) { + if (reader.isStartElement() ){ + + if (reader.isStartElement() && new javax.xml.namespace.QName("urn:changhong.com:TCM:mlsc","MT_TCM2SAP_C223").equals(reader.getName())){ + + object.setMT_TCM2SAP_C223(DT_TCM2SAP_C223.Factory.parse(reader)); + + } // End of if for expected property start element + + else{ + // A start element we are not expecting indicates an invalid parameter was passed + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + } + + } else { + reader.next(); + } + } // end of while loop + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + public static class MSG_HDR_type0 + implements org.apache.axis2.databinding.ADBBean{ + /* This type was generated from the piece of schema that had + name = MSG_HDR_type0 + Namespace URI = urn:changhong.com:TCM:mlsc + Namespace Prefix = ns1 + */ + + + private static java.lang.String generatePrefix(java.lang.String namespace) { + if(namespace.equals("urn:changhong.com:TCM:mlsc")){ + return "ns1"; + } + return org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + + + /** + * field for MSGID + */ + + + protected java.lang.String localMSGID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localMSGIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getMSGID(){ + return localMSGID; + } + + + + /** + * Auto generated setter method + * @param param MSGID + */ + public void setMSGID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localMSGIDTracker = true; + } else { + localMSGIDTracker = false; + + } + + this.localMSGID=param; + + + } + + + /** + * field for BUSID + */ + + + protected java.lang.String localBUSID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localBUSIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getBUSID(){ + return localBUSID; + } + + + + /** + * Auto generated setter method + * @param param BUSID + */ + public void setBUSID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localBUSIDTracker = true; + } else { + localBUSIDTracker = false; + + } + + this.localBUSID=param; + + + } + + + /** + * field for TLGID + */ + + + protected java.lang.String localTLGID ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localTLGIDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getTLGID(){ + return localTLGID; + } + + + + /** + * Auto generated setter method + * @param param TLGID + */ + public void setTLGID(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localTLGIDTracker = true; + } else { + localTLGIDTracker = false; + + } + + this.localTLGID=param; + + + } + + + /** + * field for LGNAME + */ + + + protected java.lang.String localLGNAME ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localLGNAMETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getLGNAME(){ + return localLGNAME; + } + + + + /** + * Auto generated setter method + * @param param LGNAME + */ + public void setLGNAME(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localLGNAMETracker = true; + } else { + localLGNAMETracker = false; + + } + + this.localLGNAME=param; + + + } + + + /** + * field for DTSEND + */ + + + protected java.lang.String localDTSEND ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localDTSENDTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getDTSEND(){ + return localDTSEND; + } + + + + /** + * Auto generated setter method + * @param param DTSEND + */ + public void setDTSEND(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localDTSENDTracker = true; + } else { + localDTSENDTracker = false; + + } + + this.localDTSEND=param; + + + } + + + /** + * field for SENDER + */ + + + protected java.lang.String localSENDER ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localSENDERTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getSENDER(){ + return localSENDER; + } + + + + /** + * Auto generated setter method + * @param param SENDER + */ + public void setSENDER(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localSENDERTracker = true; + } else { + localSENDERTracker = false; + + } + + this.localSENDER=param; + + + } + + + /** + * field for RECEIVER + */ + + + protected java.lang.String localRECEIVER ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localRECEIVERTracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getRECEIVER(){ + return localRECEIVER; + } + + + + /** + * Auto generated setter method + * @param param RECEIVER + */ + public void setRECEIVER(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localRECEIVERTracker = true; + } else { + localRECEIVERTracker = false; + + } + + this.localRECEIVER=param; + + + } + + + /** + * field for REEUSE + */ + + + protected java.lang.String localREEUSE ; + + /* This tracker boolean wil be used to detect whether the user called the set method + * for this attribute. It will be used to determine whether to include this field + * in the serialized XML + */ + protected boolean localREEUSETracker = false ; + + + /** + * Auto generated getter method + * @return java.lang.String + */ + public java.lang.String getREEUSE(){ + return localREEUSE; + } + + + + /** + * Auto generated setter method + * @param param REEUSE + */ + public void setREEUSE(java.lang.String param){ + + if (param != null){ + //update the setting tracker + localREEUSETracker = true; + } else { + localREEUSETracker = false; + + } + + this.localREEUSE=param; + + + } + + + /** + * isReaderMTOMAware + * @return true if the reader supports MTOM + */ + public static boolean isReaderMTOMAware(javax.xml.stream.XMLStreamReader reader) { + boolean isReaderMTOMAware = false; + + try{ + isReaderMTOMAware = java.lang.Boolean.TRUE.equals(reader.getProperty(org.apache.axiom.om.OMConstants.IS_DATA_HANDLERS_AWARE)); + }catch(java.lang.IllegalArgumentException e){ + isReaderMTOMAware = false; + } + return isReaderMTOMAware; + } + + + /** + * + * @param parentQName + * @param factory + * @return org.apache.axiom.om.OMElement + */ + public org.apache.axiom.om.OMElement getOMElement ( + final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory) throws org.apache.axis2.databinding.ADBException{ + + + + org.apache.axiom.om.OMDataSource dataSource = + new org.apache.axis2.databinding.ADBDataSource(this,parentQName){ + + public void serialize(org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + MSG_HDR_type0.this.serialize(parentQName,factory,xmlWriter); + } + }; + return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl( + parentQName,factory,dataSource); + + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + serialize(parentQName,factory,xmlWriter,false); + } + + public void serialize(final javax.xml.namespace.QName parentQName, + final org.apache.axiom.om.OMFactory factory, + org.apache.axis2.databinding.utils.writer.MTOMAwareXMLStreamWriter xmlWriter, + boolean serializeType) + throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException{ + + + + + java.lang.String prefix = null; + java.lang.String namespace = null; + + + prefix = parentQName.getPrefix(); + namespace = parentQName.getNamespaceURI(); + + if ((namespace != null) && (namespace.trim().length() > 0)) { + java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); + if (writerPrefix != null) { + xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); + } else { + if (prefix == null) { + prefix = generatePrefix(namespace); + } + + xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + } else { + xmlWriter.writeStartElement(parentQName.getLocalPart()); + } + + if (serializeType){ + + + java.lang.String namespacePrefix = registerPrefix(xmlWriter,"urn:changhong.com:TCM:mlsc"); + if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)){ + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + namespacePrefix+":MSG_HDR_type0", + xmlWriter); + } else { + writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","type", + "MSG_HDR_type0", + xmlWriter); + } + + + } + if (localMSGIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"MSGID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"MSGID"); + } + + } else { + xmlWriter.writeStartElement("MSGID"); + } + + + if (localMSGID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("MSGID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localMSGID); + + } + + xmlWriter.writeEndElement(); + } if (localBUSIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"BUSID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"BUSID"); + } + + } else { + xmlWriter.writeStartElement("BUSID"); + } + + + if (localBUSID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("BUSID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localBUSID); + + } + + xmlWriter.writeEndElement(); + } if (localTLGIDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"TLGID", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"TLGID"); + } + + } else { + xmlWriter.writeStartElement("TLGID"); + } + + + if (localTLGID==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("TLGID cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localTLGID); + + } + + xmlWriter.writeEndElement(); + } if (localLGNAMETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"LGNAME", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"LGNAME"); + } + + } else { + xmlWriter.writeStartElement("LGNAME"); + } + + + if (localLGNAME==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("LGNAME cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localLGNAME); + + } + + xmlWriter.writeEndElement(); + } if (localDTSENDTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"DTSEND", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"DTSEND"); + } + + } else { + xmlWriter.writeStartElement("DTSEND"); + } + + + if (localDTSEND==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("DTSEND cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localDTSEND); + + } + + xmlWriter.writeEndElement(); + } if (localSENDERTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"SENDER", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"SENDER"); + } + + } else { + xmlWriter.writeStartElement("SENDER"); + } + + + if (localSENDER==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("SENDER cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localSENDER); + + } + + xmlWriter.writeEndElement(); + } if (localRECEIVERTracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"RECEIVER", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"RECEIVER"); + } + + } else { + xmlWriter.writeStartElement("RECEIVER"); + } + + + if (localRECEIVER==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("RECEIVER cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localRECEIVER); + + } + + xmlWriter.writeEndElement(); + } if (localREEUSETracker){ + namespace = ""; + if (! namespace.equals("")) { + prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + xmlWriter.writeStartElement(prefix,"REEUSE", namespace); + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } else { + xmlWriter.writeStartElement(namespace,"REEUSE"); + } + + } else { + xmlWriter.writeStartElement("REEUSE"); + } + + + if (localREEUSE==null){ + // write the nil attribute + + throw new org.apache.axis2.databinding.ADBException("REEUSE cannot be null!!"); + + }else{ + + + xmlWriter.writeCharacters(localREEUSE); + + } + + xmlWriter.writeEndElement(); + } + xmlWriter.writeEndElement(); + + + } + + /** + * Util method to write an attribute with the ns prefix + */ + private void writeAttribute(java.lang.String prefix,java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (xmlWriter.getPrefix(namespace) == null) { + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + + } + + xmlWriter.writeAttribute(namespace,attName,attValue); + + } + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeAttribute(java.lang.String namespace,java.lang.String attName, + java.lang.String attValue,javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException{ + if (namespace.equals("")) + { + xmlWriter.writeAttribute(attName,attValue); + } + else + { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace,attName,attValue); + } + } + + + /** + * Util method to write an attribute without the ns prefix + */ + private void writeQNameAttribute(java.lang.String namespace, java.lang.String attName, + javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + java.lang.String attributeNamespace = qname.getNamespaceURI(); + java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); + if (attributePrefix == null) { + attributePrefix = registerPrefix(xmlWriter, attributeNamespace); + } + java.lang.String attributeValue; + if (attributePrefix.trim().length() > 0) { + attributeValue = attributePrefix + ":" + qname.getLocalPart(); + } else { + attributeValue = qname.getLocalPart(); + } + + if (namespace.equals("")) { + xmlWriter.writeAttribute(attName, attributeValue); + } else { + registerPrefix(xmlWriter, namespace); + xmlWriter.writeAttribute(namespace, attName, attributeValue); + } + } + /** + * method to handle Qnames + */ + + private void writeQName(javax.xml.namespace.QName qname, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + java.lang.String namespaceURI = qname.getNamespaceURI(); + if (namespaceURI != null) { + java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); + if (prefix == null) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + xmlWriter.writeCharacters(prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } else { + // i.e this is the default namespace + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + + } else { + xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); + } + } + + private void writeQNames(javax.xml.namespace.QName[] qnames, + javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { + + if (qnames != null) { + // we have to store this data until last moment since it is not possible to write any + // namespace data after writing the charactor data + java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); + java.lang.String namespaceURI = null; + java.lang.String prefix = null; + + for (int i = 0; i < qnames.length; i++) { + if (i > 0) { + stringToWrite.append(" "); + } + namespaceURI = qnames[i].getNamespaceURI(); + if (namespaceURI != null) { + prefix = xmlWriter.getPrefix(namespaceURI); + if ((prefix == null) || (prefix.length() == 0)) { + prefix = generatePrefix(namespaceURI); + xmlWriter.writeNamespace(prefix, namespaceURI); + xmlWriter.setPrefix(prefix,namespaceURI); + } + + if (prefix.trim().length() > 0){ + stringToWrite.append(prefix).append(":").append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } else { + stringToWrite.append(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); + } + } + xmlWriter.writeCharacters(stringToWrite.toString()); + } + + } + + + /** + * Register a namespace prefix + */ + private java.lang.String registerPrefix(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { + java.lang.String prefix = xmlWriter.getPrefix(namespace); + + if (prefix == null) { + prefix = generatePrefix(namespace); + + while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { + prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); + } + + xmlWriter.writeNamespace(prefix, namespace); + xmlWriter.setPrefix(prefix, namespace); + } + + return prefix; + } + + + + /** + * databinding method to get an XML representation of this object + * + */ + public javax.xml.stream.XMLStreamReader getPullParser(javax.xml.namespace.QName qName) + throws org.apache.axis2.databinding.ADBException{ + + + + java.util.ArrayList elementList = new java.util.ArrayList(); + java.util.ArrayList attribList = new java.util.ArrayList(); + + if (localMSGIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "MSGID")); + + if (localMSGID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localMSGID)); + } else { + throw new org.apache.axis2.databinding.ADBException("MSGID cannot be null!!"); + } + } if (localBUSIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "BUSID")); + + if (localBUSID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localBUSID)); + } else { + throw new org.apache.axis2.databinding.ADBException("BUSID cannot be null!!"); + } + } if (localTLGIDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "TLGID")); + + if (localTLGID != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localTLGID)); + } else { + throw new org.apache.axis2.databinding.ADBException("TLGID cannot be null!!"); + } + } if (localLGNAMETracker){ + elementList.add(new javax.xml.namespace.QName("", + "LGNAME")); + + if (localLGNAME != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localLGNAME)); + } else { + throw new org.apache.axis2.databinding.ADBException("LGNAME cannot be null!!"); + } + } if (localDTSENDTracker){ + elementList.add(new javax.xml.namespace.QName("", + "DTSEND")); + + if (localDTSEND != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localDTSEND)); + } else { + throw new org.apache.axis2.databinding.ADBException("DTSEND cannot be null!!"); + } + } if (localSENDERTracker){ + elementList.add(new javax.xml.namespace.QName("", + "SENDER")); + + if (localSENDER != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localSENDER)); + } else { + throw new org.apache.axis2.databinding.ADBException("SENDER cannot be null!!"); + } + } if (localRECEIVERTracker){ + elementList.add(new javax.xml.namespace.QName("", + "RECEIVER")); + + if (localRECEIVER != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localRECEIVER)); + } else { + throw new org.apache.axis2.databinding.ADBException("RECEIVER cannot be null!!"); + } + } if (localREEUSETracker){ + elementList.add(new javax.xml.namespace.QName("", + "REEUSE")); + + if (localREEUSE != null){ + elementList.add(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localREEUSE)); + } else { + throw new org.apache.axis2.databinding.ADBException("REEUSE cannot be null!!"); + } + } + + return new org.apache.axis2.databinding.utils.reader.ADBXMLStreamReaderImpl(qName, elementList.toArray(), attribList.toArray()); + + + + } + + + + /** + * Factory class that keeps the parse method + */ + public static class Factory{ + + + + + /** + * static method to create the object + * Precondition: If this object is an element, the current or next start element starts this object and any intervening reader events are ignorable + * If this object is not an element, it is a complex type and the reader is at the event just after the outer start element + * Postcondition: If this object is an element, the reader is positioned at its end element + * If this object is a complex type, the reader is positioned at the end element of its outer element + */ + public static MSG_HDR_type0 parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{ + MSG_HDR_type0 object = + new MSG_HDR_type0(); + + int event; + java.lang.String nillableValue = null; + java.lang.String prefix =""; + java.lang.String namespaceuri =""; + try { + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + + if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){ + java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", + "type"); + if (fullTypeName!=null){ + java.lang.String nsPrefix = null; + if (fullTypeName.indexOf(":") > -1){ + nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); + } + nsPrefix = nsPrefix==null?"":nsPrefix; + + java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1); + + if (!"MSG_HDR_type0".equals(type)){ + //find namespace for the prefix + java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); + return (MSG_HDR_type0)ExtensionMapper.getTypeObject( + nsUri,type,reader); + } + + + } + + + } + + + + + // Note all attributes that were handled. Used to differ normal attributes + // from anyAttributes. + java.util.Vector handledAttributes = new java.util.Vector(); + + + + + reader.next(); + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","MSGID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setMSGID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","BUSID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setBUSID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","TLGID").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setTLGID( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","LGNAME").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setLGNAME( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","DTSEND").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setDTSEND( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","SENDER").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setSENDER( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","RECEIVER").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setRECEIVER( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + + while (!reader.isStartElement() && !reader.isEndElement()) reader.next(); + + if (reader.isStartElement() && new javax.xml.namespace.QName("","REEUSE").equals(reader.getName())){ + + java.lang.String content = reader.getElementText(); + + object.setREEUSE( + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(content)); + + reader.next(); + + } // End of if for expected property start element + + else { + + } + + while (!reader.isStartElement() && !reader.isEndElement()) + reader.next(); + + if (reader.isStartElement()) + // A start element we are not expecting indicates a trailing invalid property + throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); + + + + + } catch (javax.xml.stream.XMLStreamException e) { + throw new java.lang.Exception(e); + } + + return object; + } + + }//end of factory class + + + + } + + + private org.apache.axiom.om.OMElement toOM(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 param, boolean optimizeContent) + throws org.apache.axis2.AxisFault { + + + try{ + return param.getOMElement(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + } catch(org.apache.axis2.databinding.ADBException e){ + throw org.apache.axis2.AxisFault.makeFault(e); + } + + + } + + private org.apache.axiom.om.OMElement toOM(SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223 param, boolean optimizeContent) + throws org.apache.axis2.AxisFault { + + + try{ + return param.getOMElement(SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.MY_QNAME, + org.apache.axiom.om.OMAbstractFactory.getOMFactory()); + } catch(org.apache.axis2.databinding.ADBException e){ + throw org.apache.axis2.AxisFault.makeFault(e); + } + + + } + + + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory,SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223 param, boolean optimizeContent) + throws org.apache.axis2.AxisFault{ + + + try{ + + org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope(); + emptyEnvelope.getBody().addChild(param.getOMElement(SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.MY_QNAME,factory)); + return emptyEnvelope; + } catch(org.apache.axis2.databinding.ADBException e){ + throw org.apache.axis2.AxisFault.makeFault(e); + } + + + } + + + /* methods to provide back word compatibility */ + + + + + /** + * get the default envelope + */ + private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory){ + return factory.getDefaultEnvelope(); + } + + + private java.lang.Object fromOM( + org.apache.axiom.om.OMElement param, + java.lang.Class type, + java.util.Map extraNamespaces) throws org.apache.axis2.AxisFault{ + + try { + + if (SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.class.equals(type)){ + + return SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223.Factory.parse(param.getXMLStreamReaderWithoutCaching()); + + + } + + if (SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.class.equals(type)){ + + return SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223.Factory.parse(param.getXMLStreamReaderWithoutCaching()); + + + } + + } catch (java.lang.Exception e) { + throw org.apache.axis2.AxisFault.makeFault(e); + } + return null; + } + + + + + } + \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevCommand.java new file mode 100644 index 0000000..a323f28 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevCommand.java @@ -0,0 +1,877 @@ +package com.connor.ml.tcm.ML_08备份; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; + +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SendProductRevCommand extends AbstractAIFCommand { + +// private InterfaceAIFComponent[] comps; + private TCSession session; + private boolean isProcess = false; + private HashMap map = null; + + public SendProductRevCommand(InterfaceAIFComponent[] comps, TCSession session) { + // Auto-generated constructor stub + map = new HashMap<>(); + for(InterfaceAIFComponent comp : comps) { + map.put((TCComponent) comp, null); + } + this.session = session; + } + + public SendProductRevCommand(InterfaceAIFComponent[] comps, TCSession session, boolean isProcess) { + // Auto-generated constructor stub +// this.comps = comps; + map = new HashMap<>(); + for(InterfaceAIFComponent comp : comps) { + map.put((TCComponent) comp, null); + } + this.session = session; + this.isProcess = isProcess; + } + public SendProductRevCommand(HashMap map, TCSession session, boolean isProcess) { + // Auto-generated constructor stub + this.map = map; + this.session = session; + this.isProcess = isProcess; + } + + @Override + public void executeModal() throws Exception { + System.out.println("SendProductRevCommand:"+isProcess); + String option = session.getPreferenceService().getStringValue("ML_Process&ProductRev"); + if(option==null || option.isEmpty()) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR); + return; + } + TCComponent dataset = session.stringToComponent(option); + if(!dataset.isTypeOf("MSExcelX")) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR);//ASPAAIIN5kSPsC//QCPAAIId5kSPsC + return; + } + String dateStr = session.getPreferenceService().getStringValue("ML_Process&Product_Data"); + System.out.println("dateStr ==> "+ dateStr); + FileInputStream inpu = null; + XSSFWorkbook wb = null; + ArrayList excelMap = new ArrayList<>(); + try { + File file = ((TCComponentDataset)dataset).getTcFiles()[0].getFile(System.getProperty("java.io.tmpdir")); + inpu = new FileInputStream(file); + wb = new XSSFWorkbook(inpu); + XSSFSheet sheet = wb.getSheetAt(0); + for(int i=1; i> dataTableList = new ArrayList>(); + List> haveList = new ArrayList>(); + System.out.println("----start SendProductRevCommand"); +// TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); +// List compList = new ArrayList(); +// for (int i = 0; i < comps.length; i++) { +// InterfaceAIFComponent comp = comps[i]; +// TCComponentItemRevision itemRevision = null; +// // 判断选中的是否为BOMLine +// if ((comp instanceof TCComponentBOMLine)) { +// itemRevision = ((TCComponentBOMLine) comp).getItemRevision(); +// } else if (comp instanceof TCComponentItemRevision) { +// itemRevision = (TCComponentItemRevision) comp; +// } +// if (itemRevision == null) { +// MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR); +// continue; +// } +// compList.add(comp); +// +// // 获取扩产线信息 +// String itemId = itemRevision.getStringProperty("item_id"); +// System.out.println(itemId); +// // 获取工厂 +// String factory = itemRevision.getStringProperty("ml8_Factory"); +// if (itemId.indexOf("-") > 0) { +// // 获取产线 +// String id = itemId.split("-")[0]; +// String line = itemId.split("-")[1]; +// String value = factory + "|" + line; +// System.out.println(value); +// // 获取要扩的产线 +// TCPreferenceService service = session.getPreferenceService(); +// String[] values = service.getStringValues("ML_MBOM_ExtendLine"); +// for (int j = 0; j < values.length; j++) { +// if (values[j].indexOf("-") > 0) { +// System.out.println("values[j]:" + values[j]); +// String[] lineValues = values[j].split("-"); +// System.out.println("lineValues[0]:" + lineValues[0]); +// if (value.compareTo(lineValues[0]) == 0) { +// String lineCode = lineValues[1]; +// String[] lineCodes = new String[] { lineCode }; +// if (lineCode.indexOf(",") > 0) { +// lineCodes = lineCode.split(","); +// } +// +// for (int k = 0; k < lineCodes.length; k++) { +// System.out.println("lineCodes[k]:" + lineCodes[k]); +// +// TCComponentItem findItem = itemType.find(id + "-" + lineCodes[k]); +// if (findItem != null) { +// compList.add(findItem.getLatestItemRevision()); +// } +// +// } +// } +// } +// } +// } +// } +// comps = compList.toArray(new InterfaceAIFComponent[compList.size()]); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + if(isProcess) { + for (TCComponent comp : map.keySet()) {//TODO for + // InterfaceAIFComponent comp = comps[jj]; + TCComponentItemRevision itemRevision = null; + TCComponentBOMLine topline = null; + // 判断选中的是否为BOMLine + if ((comp instanceof TCComponentBOMLine)) { + topline = (TCComponentBOMLine) comp; + itemRevision = ((TCComponentBOMLine) comp).getItemRevision(); + } else if (comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) comp; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + } + if (itemRevision == null) { + MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR); + continue; + } + + if (itemRevision.getType().equals("ML8_RefrigeratorRevision") || itemRevision.getType().equals("ML8_ColdRevision")) { + System.out.println("type ok"); + // 如果是冰箱柜版本获取BOM-Line的替代项目组(ML8_ProjectTeam)属性值为“A0”的数量 + try { + List childBomLineList = new ArrayList(); + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine childBomLine = ((TCComponentBOMLine) children.getComponent()); + if (childBomLine.getStringProperty("ML8_ProjectTeam") != null && childBomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) { + childBomLineList.add(childBomLine); + } + } + if (childBomLineList.size() <= 0) { + childBomLineList.add(itemRevision); + } + // 获取要传递的属性 + String itemId = itemRevision.getStringProperty("item_id"); +// String name = itemRevision.getStringProperty("object_name"); + if (itemId.indexOf("-") > 0) { + itemId = itemId.split("-")[0]; + } + + String[] pros = map.get(comp); + String group = pros[0], factory = pros[1], processGroup = pros[2]; +// String factory = itemRevision.getStringProperty("ml8_Factory"); +// String lineCode = itemRevision.getStringProperty("ml8_LineCode"); + String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + + // 将结果保存 + List> classValueList = new ArrayList>(); + + String productionRev = ""; + String lineName = ""; + String groupNo = ""; + String workCenter = ""; + String receiveLocation = ""; + String storageLocation = ""; + String classERPCode = ""; + for (String[] excels : excelMap) { + if (excels[1].equals(factory) && excels[2].equals(group)) { + List valueList = new ArrayList(); + valueList.add(excels[2]);//组名 + valueList.add(excels[0]);//生产版本号 + valueList.add(excels[7]);//版本描述 + valueList.add(excels[4]);//组计数器 + valueList.add(excels[3]);//工作中心 + valueList.add(excels[5]); + valueList.add(excels[6]); + classValueList.add(valueList); + } + } + if (classValueList.size() <= 0) { + MessageBox.post("通过工厂:" + factory + " 组名:" + map.get(comp) + " 未找到数据!", "错误", MessageBox.ERROR); + return; + } + List productionRevList = new ArrayList(); + for (int ii = 0; ii < classValueList.size(); ii++) { + List valueList = classValueList.get(ii); + + productionRev = valueList.get(1);//生产版本号 + lineName = valueList.get(2);//版本描述 + groupNo = valueList.get(3);//组计数器 + workCenter = valueList.get(4);//工作中心 + receiveLocation = valueList.get(5); + storageLocation = valueList.get(6); + +// String value = ""; +// // 获取工作中心后两位 +// if (!workCenter.isEmpty()) { +// value = workCenter.substring(workCenter.length() - 2, workCenter.length()); +// if (value.indexOf("0") == 0) { +// value = value.substring(value.length() - 1, value.length()) + "0"; +// } +// } + + if (productionRevList.contains(productionRev)) { + continue; + } else { + productionRevList.add(productionRev); + } + + // 根据物料编码、工厂、组计数器从工艺路线表中查询出工艺路线组的值 + + for (int i = 0; i < childBomLineList.size(); i++) { +// String bom = lineCode + (i + 1); + String bom = new DecimalFormat("00").format(i + 1); + productionRev = productionRev.substring(0, productionRev.length()-2) + bom; + // 根据物料编码、工厂、可选BOM从生产版本表中查询出工艺路线组的值 + InputStream input2 = null; + ResultSet rs2 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), itemId, factory, groupNo, productionRev);// bom); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + + if (rs2 != null && classERPCode.compareTo(ERPCode) == 0) { + + System.out.println("classERPCode"+classERPCode+"ERPCode"+ERPCode); + + while (rs2.next()) { + // 添加数据 + List valuesList = new ArrayList(); + valuesList.add(itemId);//物料代码 +// valuesList.add(name);//物料描述 + valuesList.add(factory);//工厂 + // valuesList.add(value + bom);//生产版本号 + valuesList.add(productionRev);//生产版本号 + valuesList.add(lineName);//版本描述 + valuesList.add(dateStr);//有效期始 + valuesList.add("99991231");//有效期止 + valuesList.add(bom);//可选BOM + valuesList.add("1");//BOM用途 + valuesList.add(processGroup);//工艺路线组 + valuesList.add(groupNo);//组计数器 + valuesList.add(workCenter);//工作中心 + valuesList.add(receiveLocation);//接收位置 + valuesList.add(storageLocation);//发货仓储地点 + valuesList.add("U");//处理标记 + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + break; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input2 != null) { + try { + input2.close(); + } catch (IOException e2) { + // Auto-generated catch block + e2.printStackTrace(); + } + } + if (rs2 != null) { + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + + System.out.println("!isHave"+isHave); + + if (!isHave) { + System.out.println("!isHave"); + List rowList = new ArrayList(); + rowList.add(itemId); +// rowList.add(name);//物料描述 + rowList.add(factory); +// rowList.add(value + bom); + rowList.add(productionRev);//生产版本号 + rowList.add(lineName); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add(bom); + rowList.add("1"); + rowList.add(processGroup); + rowList.add(groupNo); + rowList.add(workCenter); + rowList.add(receiveLocation); + rowList.add(storageLocation); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + } catch (Exception e) { + // : handle exception + e.printStackTrace(); + } + } else { +// String type = "零部件"; + String itemId = itemRevision.getStringProperty("item_id"); +// String name = itemRevision.getStringProperty("object_name"); + if (itemId.indexOf("-") > 0) { + itemId = itemId.split("-")[0]; + } + String group = map.get(comp)[0], factory = map.get(comp)[1], processGroup = map.get(comp)[2]; +// String factory = itemRevision.getStringProperty("ml8_Factory"); + // String lineCode = itemRevision.getStringProperty("ml8_LineCode"); +// String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + + List> classValueList = new ArrayList>(); + + String productionRev = ""; + String lineName = ""; + String groupNo = ""; + String workCenter = ""; + String receiveLocation = ""; + String storageLocation = ""; +// String classLineCode = ""; + for (String[] excels : excelMap) { + if (excels[1].equals(factory) && excels[2].equals(group)) { + List valueList = new ArrayList(); + valueList.add(excels[2]);//组名 + valueList.add(excels[0]);//生产版本号 + valueList.add(excels[7]);//版本描述 + valueList.add(excels[4]);//组计数器 + valueList.add(excels[3]);//工作中心 + valueList.add(excels[5]); + valueList.add(excels[6]); + classValueList.add(valueList); + } + } + + if (classValueList.size() <= 0) { + MessageBox.post("通过工厂:" + factory + " 组名:" + map.get(comp) + " 未找到数据!", "错误", MessageBox.ERROR); + input.close(); + return; + } + List productionRevList = new ArrayList(); + for (int ii = 0; ii < classValueList.size(); ii++) { + List valueList = classValueList.get(ii); + + productionRev = valueList.get(1); + lineName = valueList.get(2); + groupNo = valueList.get(3); + workCenter = valueList.get(4); + receiveLocation = valueList.get(5); + storageLocation = valueList.get(6); + //classLineCode = valueList.get(7); + + if (productionRevList.contains(productionRev)) { + continue; + } else { + productionRevList.add(productionRev); + } + + // 根据物料编码、工厂、组计数器从工艺路线表中查询出工艺路线组的值 + + // 根据物料编码、工厂、可选BOM从生产版本表中查询出工艺路线组的值 + ResultSet rs2 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), itemId, factory,groupNo,productionRev);// (lineCode+1)); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + + if (rs2 != null) {// && classERPCode.compareTo(ERPCode) == 0 + +// System.out.println("classERPCode"+classERPCode+"ERPCode"+ERPCode); + while (rs2.next()) { + // 添加数据 + List valuesList = new ArrayList(); + valuesList.add(itemId); +// valuesList.add(name); + valuesList.add(factory); + valuesList.add(productionRev); + valuesList.add(lineName); + valuesList.add(dateStr); + valuesList.add("99991231"); +// valuesList.add(productionRev.substring(productionRev.length()-2)); + valuesList.add("01"); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(groupNo); + valuesList.add(workCenter); + valuesList.add(receiveLocation); + valuesList.add(storageLocation); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + break; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs2 != null) { + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + + if (!isHave) { + // 根据工厂和工艺路线组 + List rowList = new ArrayList(); + rowList.add(itemId); +// rowList.add(name); + rowList.add(factory); + rowList.add(productionRev); + rowList.add(lineName); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add("01"); + rowList.add("1"); + rowList.add(processGroup); + rowList.add(groupNo); + rowList.add(workCenter); + rowList.add(receiveLocation); + rowList.add(storageLocation); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + } + }else {//TODO for + for (TCComponent comp : map.keySet()) { + // InterfaceAIFComponent comp = comps[jj]; + TCComponentItemRevision itemRevision = null; + TCComponentBOMLine topline = null; + // 判断选中的是否为BOMLine + if (comp instanceof TCComponentBOMLine) { + topline = (TCComponentBOMLine) comp; + itemRevision = topline.getItemRevision(); + } else if (comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) comp; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + } + if (itemRevision == null) { + MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR); + continue; + } + + if (itemRevision.getType().equals("ML8_RefrigeratorRevision") || itemRevision.getType().equals("ML8_ColdRevision")) { + System.out.println("type ok"); + // 如果是冰箱柜版本获取BOM-Line的替代项目组(ML8_ProjectTeam)属性值为“A0”的数量 + try { + List childBomLineList = new ArrayList(); + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine childBomLine = ((TCComponentBOMLine) children.getComponent()); + if (childBomLine.getStringProperty("ML8_ProjectTeam") != null && childBomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) { + childBomLineList.add(childBomLine); + } + } + if (childBomLineList.size() <= 0) { + childBomLineList.add(itemRevision); + } + // 获取要传递的属性 + String itemId = itemRevision.getStringProperty("item_id"); + String name = itemRevision.getStringProperty("object_name"); + if (itemId.indexOf("-") > 0) { + itemId = itemId.split("-")[0]; + } + + String factory = itemRevision.getStringProperty("ml8_Factory"); +// String lineCode = itemRevision.getStringProperty("ml8_LineCode"); +// String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + + // boolean isClassHave = false; + // 根据物料编码、工厂、组计数器从工艺路线表中查询出工艺路线组的值 + String processGroup = ""; + ResultSet rs = null; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), itemId, factory); + System.out.println("selectSql:"+selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + + if (rs != null) { + System.out.println("rs!=null"); + while (rs.next()) { + processGroup = rs.getString("PLNNR"); + System.out.println("processGroup"+processGroup); + } + }else { + DbPool.executeUpdateSql(selectSql); + } + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + DbPool.freeAll(); + } + + if(processGroup.isEmpty()) { +// System.out.println("processGroup.isEmpty()"); + MessageBox.post("工艺路线表中未找到对应物料的工艺路线组", "错误", MessageBox.ERROR); + } + + for (int i = 0; i < childBomLineList.size(); i++) { +// String bom = lineCode + (i + 1); + String bom = new DecimalFormat("00").format(i + 1); + // 根据物料编码、工厂、可选BOM从生产版本表中查询出工艺路线组的值 + ResultSet rs2 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL2"), itemId, factory);// bom); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + + if (rs2 != null) {// && classERPCode.compareTo(ERPCode) == 0 +// System.out.println("classERPCode"+classERPCode+"ERPCode"+ERPCode); + + while (rs2.next()) { + // 添加数据 + List valuesList = new ArrayList(); + valuesList.add("");//组名 + valuesList.add(itemId);//物料代码 + valuesList.add(name);//物料代码 + valuesList.add(factory);//工厂 +// valuesList.add(value + bom);//生产版本号 + valuesList.add("");//生产版本号 + valuesList.add("");//版本描述 + valuesList.add(dateStr);//有效期始 + valuesList.add("99991231");//有效期止 + valuesList.add(bom);//可选BOM + valuesList.add("1");//BOM用途 + valuesList.add(processGroup);//工艺路线组 + valuesList.add("");//组计数器 + valuesList.add("");//工作中心 + valuesList.add("");//接收位置 + valuesList.add("");//发货仓储地点 + valuesList.add("U");//处理标记 + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + break; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs2 != null) { + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + + System.out.println("!isHave"+isHave); + + if (!isHave) { + System.out.println("!isHave"); + List rowList = new ArrayList(); + rowList.add("");//组名 + rowList.add(itemId);//物料代码 + rowList.add(name);//物料代码 + rowList.add(factory);//工厂 + rowList.add("");//生产版本号 + rowList.add("");//版本描述 + rowList.add(dateStr);//有效期始 + rowList.add("99991231");//有效期止 + rowList.add(bom);//可选BOM + rowList.add("1");//BOM用途 + rowList.add(processGroup);//工艺路线组 + rowList.add("");//组计数器 + rowList.add("");//工作中心 + rowList.add("");//接收位置 + rowList.add("");//发货仓储地点 + rowList.add("I");//处理标记 + dataTableList.add(rowList); + } + } + } catch (Exception e) { + // : handle exception + e.printStackTrace(); + } + } else { + String itemId = itemRevision.getStringProperty("item_id"); + String name = itemRevision.getStringProperty("object_name"); + if (itemId.indexOf("-") > 0) { + itemId = itemId.split("-")[0]; + } + String factory = itemRevision.getStringProperty("ml8_Factory"); + System.out.println("factory:"+factory); +// String lineCode = itemRevision.getStringProperty("ml8_LineCode"); +// String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + + // 根据物料编码、工厂、组计数器从工艺路线表中查询出工艺路线组的值 + String processGroup = ""; + ResultSet rs = null; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), itemId, factory); + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + + if (rs != null) { + while (rs.next()) { + processGroup = rs.getString("PLNNR"); + } + } + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // Auto-generated catch block + e.printStackTrace(); + } + } + if (rs != null) { + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } +// DbPool.freeAll(); + } + + if(processGroup.isEmpty()) + { + MessageBox.post("工艺路线表中未找到对应物料的工艺路线组", "错误", MessageBox.ERROR); + } + // 根据物料编码、工厂、可选BOM从生产版本表中查询出工艺路线组的值 + ResultSet rs3 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL2"), itemId, factory);// (lineCode+1));,groupNo,productionRev + System.out.println(selectSql); + DbPool.getConnection(); + rs3 = DbPool.executeSelectSql(selectSql); + + if (rs3 != null) {// && classERPCode.compareTo(ERPCode) == 0 + +// System.out.println("classERPCode"+classERPCode+"ERPCode"+ERPCode); + while (rs3.next()) { + // 添加数据 + List valuesList = new ArrayList(); + valuesList.add("");//组名 + valuesList.add(itemId); + valuesList.add(name); + valuesList.add(factory); + valuesList.add(""); + valuesList.add(""); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add("01"); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + break; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs3 != null) { + try { + rs3.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + + if (!isHave) { + // 根据工厂和工艺路线组 + List rowList = new ArrayList(); + rowList.add("");//组名 + rowList.add(itemId);//物料代码 + rowList.add(name);//物料代码 + rowList.add(factory);//工厂 + rowList.add("");//生产版本号 + rowList.add("");//版本描述 + rowList.add(dateStr);//有效期始 + rowList.add("99991231");//有效期止 + rowList.add("01");//可选BOM + rowList.add("1");//BOM用途 + rowList.add(processGroup);//工艺路线组 + rowList.add("");//组计数器 + rowList.add("");//工作中心 + rowList.add("");//接收位置 + rowList.add("");//发货仓储地点 + rowList.add("I");//处理标记 + dataTableList.add(rowList); + } + } + }//TODO for + } + input.close(); + + System.out.println("haveList size"+haveList.size()); + + if (haveList.size() > 0) { + StringBuilder haveStringBuilder = new StringBuilder(); + for (int i = 0; i < haveList.size(); i++) { + haveStringBuilder.append("物料:"); + haveStringBuilder.append(haveList.get(i).get(0)); + haveStringBuilder.append("工厂:"); + haveStringBuilder.append(haveList.get(i).get(1)); + haveStringBuilder.append("组计数器:"); + haveStringBuilder.append(haveList.get(i).get(9)); + haveStringBuilder.append("\n"); + } + + JTextArea textArea = new JTextArea(haveStringBuilder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + + int i = JOptionPane.showConfirmDialog(null, scrollPane, "重新传递", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + dataTableList.removeAll(haveList); + } + } + + System.out.println(dataTableList.size()+"dataTableList" + isProcess); + new Thread() { + @Override + public void run() { + if (isProcess) { + MethodUtil.sendProductRev(dataTableList,session); + } else { + System.out.println("excelMap:"+excelMap.size()); + new SendProductRevDialog(session, dataTableList, excelMap); + } + } + }.start(); + + super.executeModal(); + } + + private XSSFRow getRow(XSSFSheet sheet, int num) throws Exception { + XSSFRow row = sheet.getRow(num); + if(row==null) + row = sheet.createRow(num); + return row; + } + private XSSFCell getCell(XSSFRow row, int col) throws Exception { + XSSFCell cell = row.getCell(col); + if(cell==null) + cell = row.createCell(col); + return cell; + } + private String getValue(XSSFCell cell) { + Object value = null; + CellType type = cell.getCellTypeEnum(); + if(type == CellType.STRING) + value = cell.getStringCellValue(); + else if(type == CellType.NUMERIC) + value = (int)cell.getNumericCellValue(); + return value + ""; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevCommand01.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevCommand01.java new file mode 100644 index 0000000..9d22c01 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevCommand01.java @@ -0,0 +1,700 @@ +package com.connor.ml.tcm.ML_08备份; + +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import java.awt.Window; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class SendProductRevCommand01 extends AbstractAIFCommand { + private TCSession session; + + private boolean isProcess = false; + + private HashMap map = null; + + public SendProductRevCommand01(InterfaceAIFComponent[] comps, TCSession session) { + this.map = (HashMap) new HashMap<>(); + byte b; + int i; + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; + for (i = (arrayOfInterfaceAIFComponent = comps).length, b = 0; b < i;) { + InterfaceAIFComponent comp = arrayOfInterfaceAIFComponent[b]; + this.map.put((TCComponent) comp, null); + b++; + } + this.session = session; + } + + public SendProductRevCommand01(InterfaceAIFComponent[] comps, TCSession session, boolean isProcess) { + this.map = (HashMap) new HashMap<>(); + byte b; + int i; + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; + for (i = (arrayOfInterfaceAIFComponent = comps).length, b = 0; b < i;) { + InterfaceAIFComponent comp = arrayOfInterfaceAIFComponent[b]; + this.map.put((TCComponent) comp, null); + b++; + } + this.session = session; + this.isProcess = isProcess; + } + + public SendProductRevCommand01(HashMap map, TCSession session, boolean isProcess) { + this.map = map; + this.session = session; + this.isProcess = isProcess; + } + + public void executeModal() throws Exception { + System.out.println("SendProductRevCommand:" + this.isProcess); + String option = this.session.getPreferenceService().getStringValue("ML_Process&ProductRev"); + if (option == null || option.isEmpty()) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR); + return; + } + TCComponent dataset = this.session.stringToComponent(option); + if (!dataset.isTypeOf("MSExcelX")) { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", MessageBox.ERROR);// ASPAAIIN5kSPsC//QCPAAIId5kSPsC + return; + } + String dateStr = this.session.getPreferenceService().getStringValue("ML_Process&Product_Data"); + System.out.println("dateStr ==> " + dateStr); + FileInputStream inpu = null; + XSSFWorkbook wb = null; + final ArrayList excelMap = (ArrayList) new ArrayList<>(); + try { + File file = ((TCComponentDataset) dataset).getTcFiles()[0].getFile(System.getProperty("java.io.tmpdir")); + inpu = new FileInputStream(file); + wb = new XSSFWorkbook(inpu); + XSSFSheet sheet = wb.getSheetAt(0); + for (int i = 1; i < sheet.getLastRowNum(); i++) { + XSSFRow row = getRow(sheet, i); + String rev = getValue(getCell(row, 7)); + if (rev !=null && !rev.isEmpty()) + excelMap.add(new String[] { rev, getValue(getCell(row, 0)), getValue(getCell(row, 1)), + getValue(getCell(row, 3)), getValue(getCell(row, 4)), getValue(getCell(row, 5)), + getValue(getCell(row, 6)), getValue(getCell(row, 8)), dateStr }); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AIFUtility.getActiveDesktop(), "错误:" + e.getMessage(), "ERROR", MessageBox.ERROR); + return; + } finally { + if (wb != null) + wb.close(); + if (inpu != null) + inpu.close(); + } + final List> dataTableList = new ArrayList<>(); + List> haveList = new ArrayList<>(); + System.out.println("----start SendProductRevCommand"); + InputStream input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + if (this.isProcess) { + for (TCComponent comp : this.map.keySet()) { + TCComponentItemRevision itemRevision = null; + TCComponentBOMLine topline = null; + if (comp instanceof TCComponentBOMLine) { + topline = (TCComponentBOMLine) comp; + itemRevision = ((TCComponentBOMLine) comp).getItemRevision(); + } else if (comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) comp; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) this.session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + } + if (itemRevision == null) { + MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR); + continue; + } + if (itemRevision.getType().equals("ML8_RefrigeratorRevision") + || itemRevision.getType().equals("ML8_ColdRevision")) { + System.out.println("type ok"); + try { + List childBomLineList = new ArrayList<>(); + AIFComponentContext[] childrens = topline.getChildren(); + byte b; + int i; + AIFComponentContext[] arrayOfAIFComponentContext1; + for (i = (arrayOfAIFComponentContext1 = childrens).length, b = 0; b < i;) { + AIFComponentContext children = arrayOfAIFComponentContext1[b]; + TCComponentBOMLine childBomLine = (TCComponentBOMLine) children.getComponent(); + if (childBomLine.getStringProperty("ML8_ProjectTeam") != null + && childBomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) + childBomLineList.add(childBomLine); + b++; + } + if (childBomLineList.size() <= 0) + childBomLineList.add(itemRevision); + String str1 = itemRevision.getStringProperty("item_id"); + if (str1.indexOf("-") > 0) + str1 = str1.split("-")[0]; + String[] pros = this.map.get(comp); + String str2 = pros[0], str3 = pros[1], str4 = pros[2]; + String ERPCode = itemRevision.getStringProperty("ml8_ERPCode"); + List> list = new ArrayList<>(); + String str5 = ""; + String str6 = ""; + String str7 = ""; + String str8 = ""; + String str9 = ""; + String str10 = ""; + String classERPCode = ""; + for (String[] excels : excelMap) { + if (excels[1].equals(str3) && excels[2].equals(str2)) { + List valueList = new ArrayList<>(); + valueList.add(excels[2]); + valueList.add(excels[0]); + valueList.add(excels[7]); + valueList.add(excels[4]); + valueList.add(excels[3]); + valueList.add(excels[5]); + valueList.add(excels[6]); + list.add(valueList); + } + } + if (list.size() <= 0) { + MessageBox.post("通过工厂:" + str3 + " 组名:" + map.get(comp) + " 未找到数据!", "错误", + MessageBox.ERROR); + return; + } + List list1 = new ArrayList<>(); + for (int j = 0; j < list.size(); j++) { + List valueList = list.get(j); + str5 = valueList.get(1); + str6 = valueList.get(2); + str7 = valueList.get(3); + str8 = valueList.get(4); + str9 = valueList.get(5); + str10 = valueList.get(6); + if (!list1.contains(str5)) { + list1.add(str5); + for (int k = 0; k < childBomLineList.size(); k++) { + String bom = (new DecimalFormat("00")).format((k + 1)); + str5 = String.valueOf(str5.substring(0, str5.length() - 2)) + bom; + InputStream input2 = null; + ResultSet rs2 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), + new Object[] { str1, str3, str7, str5 }); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + if (rs2 != null && classERPCode.compareTo(ERPCode) == 0) { + System.out.println("classERPCode" + classERPCode + "ERPCode" + ERPCode); + if (rs2.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(str1); + valuesList.add(str3); + valuesList.add(str5); + valuesList.add(str6); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add(bom); + valuesList.add("1"); + valuesList.add(str4); + valuesList.add(str7); + valuesList.add(str8); + valuesList.add(str9); + valuesList.add(str10); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input2 != null) + try { + input2.close(); + } catch (IOException e2) { + e2.printStackTrace(); + } + if (rs2 != null) + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + System.out.println("!isHave" + isHave); + if (!isHave) { + System.out.println("!isHave"); + List rowList = new ArrayList<>(); + rowList.add(str1); + rowList.add(str3); + rowList.add(str5); + rowList.add(str6); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add(bom); + rowList.add("1"); + rowList.add(str4); + rowList.add(str7); + rowList.add(str8); + rowList.add(str9); + rowList.add(str10); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + continue; + } + String itemId = itemRevision.getStringProperty("item_id"); + if (itemId.indexOf("-") > 0) + itemId = itemId.split("-")[0]; + String group = ((String[]) this.map.get(comp))[0], factory = ((String[]) this.map.get(comp))[1], + processGroup = ((String[]) this.map.get(comp))[2]; + List> classValueList = new ArrayList<>(); + String productionRev = ""; + String lineName = ""; + String groupNo = ""; + String workCenter = ""; + String receiveLocation = ""; + String storageLocation = ""; + for (String[] excels : excelMap) { + if (excels[1].equals(factory) && excels[2].equals(group)) { + List valueList = new ArrayList<>(); + valueList.add(excels[2]); + valueList.add(excels[0]); + valueList.add(excels[7]); + valueList.add(excels[4]); + valueList.add(excels[3]); + valueList.add(excels[5]); + valueList.add(excels[6]); + classValueList.add(valueList); + } + } + if (classValueList.size() <= 0) { + MessageBox.post("通过工厂:" + factory + " 组名:" + map.get(comp) + " 未找到数据!", "错误", + MessageBox.ERROR); + input.close(); + return; + } + List productionRevList = new ArrayList<>(); + for (int ii = 0; ii < classValueList.size(); ii++) { + List valueList = classValueList.get(ii); + productionRev = valueList.get(1); + lineName = valueList.get(2); + groupNo = valueList.get(3); + workCenter = valueList.get(4); + receiveLocation = valueList.get(5); + storageLocation = valueList.get(6); + if (!productionRevList.contains(productionRev)) { + productionRevList.add(productionRev); + ResultSet rs2 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), + new Object[] { itemId, factory, groupNo, productionRev }); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + if (rs2 != null) + if (rs2.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(itemId); + valuesList.add(factory); + valuesList.add(productionRev); + valuesList.add(lineName); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add("01"); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(groupNo); + valuesList.add(workCenter); + valuesList.add(receiveLocation); + valuesList.add(storageLocation); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs2 != null) + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + if (!isHave) { + List rowList = new ArrayList<>(); + rowList.add(itemId); + rowList.add(factory); + rowList.add(productionRev); + rowList.add(lineName); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add("01"); + rowList.add("1"); + rowList.add(processGroup); + rowList.add(groupNo); + rowList.add(workCenter); + rowList.add(receiveLocation); + rowList.add(storageLocation); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + } + } else { + for (TCComponent comp : this.map.keySet()) { + TCComponentItemRevision itemRevision = null; + TCComponentBOMLine topline = null; + if (comp instanceof TCComponentBOMLine) { + topline = (TCComponentBOMLine) comp; + itemRevision = topline.getItemRevision(); + } else if (comp instanceof TCComponentItemRevision) { + itemRevision = (TCComponentItemRevision) comp; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) this.session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + topline = bomWindow.setWindowTopLine(itemRevision.getItem(), itemRevision, null, null); + } + if (itemRevision == null) { + MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR); + continue; + } + if (itemRevision.getType().equals("ML8_RefrigeratorRevision") + || itemRevision.getType().equals("ML8_ColdRevision")) { + System.out.println("type ok"); + try { + List childBomLineList = new ArrayList<>(); + AIFComponentContext[] childrens = topline.getChildren(); + byte b; + int j; + AIFComponentContext[] arrayOfAIFComponentContext1; + for (j = (arrayOfAIFComponentContext1 = childrens).length, b = 0; b < j;) { + AIFComponentContext children = arrayOfAIFComponentContext1[b]; + TCComponentBOMLine childBomLine = (TCComponentBOMLine) children.getComponent(); + if (childBomLine.getStringProperty("ML8_ProjectTeam") != null + && childBomLine.getStringProperty("ML8_ProjectTeam").equals("A0")) + childBomLineList.add(childBomLine); + b++; + } + if (childBomLineList.size() <= 0) + childBomLineList.add(itemRevision); + String str1 = itemRevision.getStringProperty("item_id"); + String str2 = itemRevision.getStringProperty("object_name"); + if (str1.indexOf("-") > 0) + str1 = str1.split("-")[0]; + String str3 = itemRevision.getStringProperty("ml8_Factory"); + String str4 = ""; + ResultSet resultSet = null; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), + new Object[] { str1, str3 }); + System.out.println("selectSql:" + selectSql); + DbPool.getConnection(); + resultSet = DbPool.executeSelectSql(selectSql); + if (resultSet != null) { + System.out.println("rs!=null"); + while (resultSet.next()) { + str4 = resultSet.getString("PLNNR"); + System.out.println("processGroup" + str4); + } + } else { + DbPool.executeUpdateSql(selectSql); + } + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (resultSet != null) + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + DbPool.freeAll(); + } + if (str4.isEmpty()) + System.out.println("processGroup.isEmpty()"); + MessageBox.post("工艺路线表中未找到对应物料的工艺路线组", "错误", MessageBox.ERROR); + for (int i = 0; i < childBomLineList.size(); i++) { + String bom = (new DecimalFormat("00")).format((i + 1)); + ResultSet rs2 = null; + boolean bool = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL2"), + new Object[] { str1, str3 }); + System.out.println(selectSql); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + if (rs2 != null) + if (rs2.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(""); + valuesList.add(str1); + valuesList.add(str2); + valuesList.add(str3); + valuesList.add(""); + valuesList.add(""); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add(bom); + valuesList.add("1"); + valuesList.add(str4); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + bool = true; + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs2 != null) + try { + rs2.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + System.out.println("!isHave" + bool); + if (!bool) { + System.out.println("!isHave"); + List rowList = new ArrayList<>(); + rowList.add(""); + rowList.add(str1); + rowList.add(str2); + rowList.add(str3); + rowList.add(""); + rowList.add(""); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add(bom); + rowList.add("1"); + rowList.add(str4); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + continue; + } + String itemId = itemRevision.getStringProperty("item_id"); + String name = itemRevision.getStringProperty("object_name"); + if (itemId.indexOf("-") > 0) + itemId = itemId.split("-")[0]; + String factory = itemRevision.getStringProperty("ml8_Factory"); + System.out.println("factory:" + factory); + String processGroup = ""; + ResultSet rs = null; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), + new Object[] { itemId, factory }); + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + if (rs != null) + while (rs.next()) + processGroup = rs.getString("PLNNR"); + } catch (Exception e) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e.printStackTrace(); + } finally { + if (input != null) + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + if (rs != null) + try { + rs.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + if (processGroup.isEmpty()) { + MessageBox.post("工艺路线表中未找到对应物料的工艺路线组", "错误", MessageBox.ERROR); + } + ResultSet rs3 = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL2"), + new Object[] { itemId, factory }); + System.out.println(selectSql); + DbPool.getConnection(); + rs3 = DbPool.executeSelectSql(selectSql); + if (rs3 != null) + if (rs3.next()) { + List valuesList = new ArrayList<>(); + valuesList.add(""); + valuesList.add(itemId); + valuesList.add(name); + valuesList.add(factory); + valuesList.add(""); + valuesList.add(""); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add("01"); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add("U"); + dataTableList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs3 != null) + try { + rs3.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + DbPool.freeAll(); + } + if (!isHave) { + List rowList = new ArrayList<>(); + rowList.add(""); + rowList.add(itemId); + rowList.add(name); + rowList.add(factory); + rowList.add(""); + rowList.add(""); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add("01"); + rowList.add("1"); + rowList.add(processGroup); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add("I"); + dataTableList.add(rowList); + } + } + } + input.close(); + System.out.println("haveList size" + haveList.size()); + if (haveList.size() > 0) { + StringBuilder haveStringBuilder = new StringBuilder(); + for (int i = 0; i < haveList.size(); i++) { + haveStringBuilder.append("物料:"); + haveStringBuilder.append(haveList.get(i).get(0)); + haveStringBuilder.append("工厂:"); + haveStringBuilder.append(haveList.get(i).get(1)); + haveStringBuilder.append("组计数器:"); + haveStringBuilder.append(haveList.get(i).get(9)); + haveStringBuilder.append("\n"); + } + + JTextArea textArea = new JTextArea(haveStringBuilder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + + int i = JOptionPane.showConfirmDialog(null, scrollPane, "重新传递", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + dataTableList.removeAll(haveList); + } + } + System.out.println(String.valueOf(dataTableList.size()) + "dataTableList" + this.isProcess); + (new Thread() { + public void run() { + if (SendProductRevCommand01.this.isProcess) { + MethodUtil.sendProductRev(dataTableList, SendProductRevCommand01.this.session); + } else { + System.out.println("excelMap:" + excelMap.size()); + } + } + }).start(); + super.executeModal(); + } + + private XSSFRow getRow(XSSFSheet sheet, int num) throws Exception { + XSSFRow row = sheet.getRow(num); + if (row == null) + row = sheet.createRow(num); + return row; + } + + private XSSFCell getCell(XSSFRow row, int col) throws Exception { + XSSFCell cell = row.getCell(col); + if (cell == null) + cell = row.createCell(col); + return cell; + } + + private String getValue(XSSFCell cell) { + Object value = null; + CellType type = cell.getCellTypeEnum(); + if (type == CellType.STRING) { + value = cell.getStringCellValue(); + } else if (type == CellType.NUMERIC) { + value = Integer.valueOf((int) cell.getNumericCellValue()); + } + return value+""; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevDialog.java new file mode 100644 index 0000000..e064ca9 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_08澶囦唤/SendProductRevDialog.java @@ -0,0 +1,559 @@ +package com.connor.ml.tcm.ML_08备份; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Properties; +import java.util.UUID; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.axis2.Constants.Configuration; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HttpTransportProperties; +import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator; + +import com.connor.ml.tcm.ML_07.ComboBoxCellEditor; +import com.connor.ml.tcm.ML_08备份.SI_TCM2SAP_C223_OUTServiceStub.DT_SAP2TCM_C223; +import com.connor.ml.tcm.ML_08备份.SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223; +import com.connor.ml.tcm.ML_08备份.SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0; +import com.connor.ml.tcm.ML_08备份.SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0; +import com.connor.ml.tcm.ML_08备份.SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0; +import com.connor.ml.tcm.ML_08备份.SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223; +import com.connor.ml.tcm.ML_18.ScreenShotTest; +import com.connor.ml.tcm.bean.SendSAPProductRevBean; +import com.connor.ml.tcm.cloneProcess.WebApiUtil; +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MLRequestEntity; +import com.connor.ml.tcm.util.MLtoERPEntity; +import com.connor.ml.tcm.util.MLtoERPEntity2; +import com.google.gson.Gson; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class SendProductRevDialog extends AbstractAIFDialog implements ActionListener { + + /** + * + */ + private static final long serialVersionUID = 1L; +// private TCSession session; + private String[] columns = new String[] { "组名", "物料代码", "物料描述", "工厂", "生产版本号", "版本描述", "有效期始", "有效期止", "可选BOM", "BOM用途", "工艺路线组", + "组计数器", "工作中心", "接收位置", "发货仓储地点", "处理标记" }; + + private Properties pro; + private List> dataTableList; + private Object[][] values; + + // 系统界面 + private JTable mainTable; + + private JPanel rootPanel; + private JButton sendButton; + private JButton closeButton; + private ArrayList excelMap; + private String[] lovs = getLOV("ML8_Factory_LOV"); + private String factory = ""; + private TCSession session; + + public SendProductRevDialog(TCSession session, List> dataTableList, ArrayList excelMap) { + // Auto-generated constructor stub +// this.session = session; + this.dataTableList = dataTableList; + this.excelMap = excelMap; + this.session = session; + // 根据查询获取对象 + this.values = new String[this.dataTableList.size()][]; + for (int i = 0; i < this.dataTableList.size(); i++) { + this.values[i] = new String[this.dataTableList.get(i).size()]; + for (int j = 0; j < this.dataTableList.get(i).size(); j++) { + this.values[i][j] = this.dataTableList.get(i).get(j); + } + } + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro = new Properties(); + pro.load(input); + } catch (Exception e2) { + MessageBox.post("错误:"+e2.getMessage(), "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + } + + init(); + } + public SendProductRevDialog(TCSession session, List> dataTableList, ArrayList excelMap, String factory) { + // Auto-generated constructor stub +// this.session = session; + this.dataTableList = dataTableList; + this.excelMap = excelMap; + this.factory = factory; + + // 根据查询获取对象 + this.values = new String[this.dataTableList.size()][]; + for (int i = 0; i < this.dataTableList.size(); i++) { + this.values[i] = new String[this.dataTableList.get(i).size()]; + for (int j = 0; j < this.dataTableList.get(i).size(); j++) { + this.values[i][j] = this.dataTableList.get(i).get(j); + } + } + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + pro = new Properties(); + pro.load(input); + } catch (Exception e2) { + MessageBox.post("错误:"+e2.getMessage(), "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + } + + init(); + } + + private void init() { + // Auto-generated method stub + this.setTitle("传递的生产版本数据"); + this.setPreferredSize(new Dimension(800, 600)); + + this.mainTable = getjTable(mainTable, null, columns, values); +// this.addData(values); + this.rootPanel = new JPanel(new FlowLayout()); + this.sendButton = new JButton("传递"); + this.closeButton = new JButton("取消"); + + this.rootPanel.add(sendButton); + this.rootPanel.add(closeButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(new JScrollPane(this.mainTable), BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); +// this.show(); + this.setVisible(true); + } + + // 添加监听 + public void createActionEvent() { + this.sendButton.addActionListener(this); + this.closeButton.addActionListener(this); + } + + /*** + * Jtable通用方法 + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)) { + /** + * + */ + private static final long serialVersionUID = 1L; + @Override + public TableCellEditor getCellEditor(int row, int column) {//TODO + if(column==0) { + DefaultTableModel model = (DefaultTableModel)getModel(); + ComboBoxCellEditor groupComboBoxCellEditor = new ComboBoxCellEditor(this, model, excelMap, pro.getProperty("ML_TCMPROCESSSELECTSQL2"), row, column); + String fac = getValueAt(row, 3).toString(); + if(fac.isEmpty()) + return groupComboBoxCellEditor; +// System.out.println("fac:"+fac); + if(groupComboBoxCellEditor.getItemCount()==0) { + ArrayList list = new ArrayList<>(); + for(int i=0; i sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { +// tableModel = new DefaultTableModel(values, titleNames); + tableModel = new DefaultTableModel(titleNames, 0); + for(Object[] row : values) + tableModel.addRow(row); + } + return tableModel; + } + + public void addData(Object[][] cellData) { + DefaultTableModel tableModel = (DefaultTableModel) this.mainTable.getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter(this.getTableModel(null, this.columns, cellData)); + this.mainTable.setRowSorter(sorter); + for (int i = 0; i < cellData.length; i++) { + tableModel.addRow(cellData[i]); + } + // 表格数据不可修改 + this.mainTable.setEnabled(true); + // 更新表格 + this.mainTable.invalidate(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.sendButton)) { + try { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + StringBuffer messageString = new StringBuffer(); + for (int i = 0; i < this.mainTable.getRowCount(); i++) { + System.out.println("setMATNR:"+this.mainTable.getValueAt(i, 1)+" >> "+this.mainTable.getValueAt(i, 0)); + + SendSAPProductRevBean sendSAPProductRevBean = new SendSAPProductRevBean(); + sendSAPProductRevBean.setMSGID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setBUSID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setTLGID("JT0001"); + sendSAPProductRevBean.setTLGNAME("维护生产版本接口"); + sendSAPProductRevBean.setDTSEND(sdf.format(new Date())); + sendSAPProductRevBean.setSENDER("TCM"); + sendSAPProductRevBean.setRECEIVER("SAP"); + sendSAPProductRevBean.setFREEUSE(""); + sendSAPProductRevBean.setMATNR(this.mainTable.getValueAt(i, 1) == null ? "" : this.mainTable.getValueAt(i, 1).toString()); +// sendSAPProductRevBean.setWERKS(this.mainTable.getValueAt(i, 2) == null ? "" : this.mainTable.getValueAt(i, 2).toString()); + sendSAPProductRevBean.setWERKS(this.mainTable.getValueAt(i, 3) == null ? "" : this.mainTable.getValueAt(i, 3).toString()); + sendSAPProductRevBean.setVERID(this.mainTable.getValueAt(i, 4) == null ? "" : this.mainTable.getValueAt(i, 4).toString()); + sendSAPProductRevBean.setTEXT1(this.mainTable.getValueAt(i, 5) == null ? "" : this.mainTable.getValueAt(i, 5).toString()); + sendSAPProductRevBean.setADATU(this.mainTable.getValueAt(i, 6) == null ? "" : this.mainTable.getValueAt(i, 6).toString()); + sendSAPProductRevBean.setBDATU(this.mainTable.getValueAt(i, 7) == null ? "" : this.mainTable.getValueAt(i, 7).toString()); + sendSAPProductRevBean.setSTLAL(this.mainTable.getValueAt(i, 8) == null ? "" : this.mainTable.getValueAt(i, 8).toString()); + sendSAPProductRevBean.setSTLAN(this.mainTable.getValueAt(i, 9) == null ? "" : this.mainTable.getValueAt(i, 9).toString()); + sendSAPProductRevBean.setPLNNR(this.mainTable.getValueAt(i, 10) == null ? "" : this.mainTable.getValueAt(i, 10).toString()); + sendSAPProductRevBean.setALNAL(this.mainTable.getValueAt(i, 11) == null ? "" : this.mainTable.getValueAt(i, 11).toString()); + sendSAPProductRevBean.setMDV01(this.mainTable.getValueAt(i, 12) == null ? "" : this.mainTable.getValueAt(i, 12).toString()); + sendSAPProductRevBean.setALORT(this.mainTable.getValueAt(i, 13) == null ? "" : this.mainTable.getValueAt(i, 13).toString()); + sendSAPProductRevBean.setELPRO(this.mainTable.getValueAt(i, 14) == null ? "" : this.mainTable.getValueAt(i, 14).toString()); + sendSAPProductRevBean.setKZ(this.mainTable.getValueAt(i, 15) == null ? "" : this.mainTable.getValueAt(i, 15).toString()); + + +// SI_TCM2SAP_C223_OUTServiceStub stub = new SI_TCM2SAP_C223_OUTServiceStub(); +// +// HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator(); +// +// List authSchemes = new ArrayList<>(); +// +// authSchemes.add(Authenticator.BASIC); +// +// basicAuth.setAuthSchemes(authSchemes); +// +// basicAuth.setUsername("chailian"); //TODO TCMCONN +// +// basicAuth.setPassword("1q2w1Q2W!.@"); //Zaq1xsw2 +// +// basicAuth.setPreemptiveAuthentication(true); +// +//// Authenticator basicAuth = new Authenticator(); +//// basicAuth.setUsername("TCMCONN"); +//// basicAuth.setPassword("Zaq1xsw2"); +// stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuth); +// stub._getServiceClient().getOptions().setProperty(Configuration.CHARACTER_SET_ENCODING, "GBK"); +// stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300 * 1000); +// stub._getServiceClient().getOptions().setProperty(Configuration.HTTP_METHOD, HTTPConstants.HTTP_METHOD_POST); +// +// MSG_HDR_type0 mt_person = new MSG_HDR_type0(); +// mt_person.setMSGID(sendSAPProductRevBean.getMSGID()); +// mt_person.setBUSID(sendSAPProductRevBean.getBUSID()); +// mt_person.setTLGID(sendSAPProductRevBean.getTLGID()); +// mt_person.setLGNAME(sendSAPProductRevBean.getTLGNAME()); +// mt_person.setDTSEND(sendSAPProductRevBean.getDTSEND()); +// mt_person.setSENDER(sendSAPProductRevBean.getSENDER()); +// mt_person.setRECEIVER(sendSAPProductRevBean.getRECEIVER()); +// mt_person.setREEUSE(sendSAPProductRevBean.getFREEUSE()); +// MSG_BODY_type0 body_type0 = new MSG_BODY_type0(); +// HEADER_type0 type0 = new HEADER_type0(); +// type0.setMATNR(sendSAPProductRevBean.getMATNR()); +// type0.setWERKS(sendSAPProductRevBean.getWERKS()); +// type0.setVERID(sendSAPProductRevBean.getVERID()); +// type0.setTEXT1(sendSAPProductRevBean.getTEXT1()); +// type0.setADATU(sendSAPProductRevBean.getADATU()); +// type0.setBDATU(sendSAPProductRevBean.getBDATU()); +// type0.setSTLAL(sendSAPProductRevBean.getSTLAL()); +// type0.setSTLAN(sendSAPProductRevBean.getSTLAN()); +// type0.setPLNNR(sendSAPProductRevBean.getPLNNR()); +// type0.setALNAL(sendSAPProductRevBean.getALNAL()); +// type0.setMDV01(sendSAPProductRevBean.getMDV01()); +// type0.setALORT(sendSAPProductRevBean.getALORT()); +// type0.setELPRO(sendSAPProductRevBean.getELPRO()); +// type0.setKZ(sendSAPProductRevBean.getKZ()); +// body_type0.setHEADER(type0); + // 获取配置信息中的url + InputStream in = ScreenShotTest.class.getResourceAsStream("/toERP.properties"); + Properties p = new Properties(); + p.load(in); + String url = "http://mlapp.meiling.com/plmwebapi/sap/setinfo"; +// String url = p.getProperty("url"); + MLtoERPEntity mLtoERPEntity = new MLtoERPEntity(); + mLtoERPEntity.setInfotype("生产版本"); + mLtoERPEntity.setInfocode(session.getUser().getUserId()); + mLtoERPEntity.setInfoname(p.getProperty("infoname")); + mLtoERPEntity.setInfodesc(""); + List list1 = new ArrayList(); + List list2 = new ArrayList(); + + MLtoERPEntity2 field1 = new MLtoERPEntity2(); + field1.setField("MATNR"); + field1.setValue(sendSAPProductRevBean.getMATNR()); + list1.add(field1); + MLtoERPEntity2 field2 = new MLtoERPEntity2(); + field2.setField("WERKS"); + field2.setValue(sendSAPProductRevBean.getWERKS()); + list1.add(field2); + MLtoERPEntity2 field3 = new MLtoERPEntity2(); + field3.setField("VERID"); + field3.setValue(sendSAPProductRevBean.getVERID()); + list1.add(field3); + MLtoERPEntity2 field4 = new MLtoERPEntity2(); + field4.setField("TEXT1"); + field4.setValue(sendSAPProductRevBean.getTEXT1()); + list1.add(field4); + MLtoERPEntity2 field5 = new MLtoERPEntity2(); + field5.setField("ADATU"); + field5.setValue(sendSAPProductRevBean.getADATU()); + list1.add(field5); + MLtoERPEntity2 field6 = new MLtoERPEntity2(); + field6.setField("BDATU"); + field6.setValue(sendSAPProductRevBean.getBDATU()); + list1.add(field6); + MLtoERPEntity2 field7 = new MLtoERPEntity2(); + field7.setField("STLAL"); + field7.setValue(sendSAPProductRevBean.getSTLAL()); + list1.add(field7); + MLtoERPEntity2 field8 = new MLtoERPEntity2(); + field8.setField("STLAN"); + field8.setValue(sendSAPProductRevBean.getSTLAN()); + list1.add(field8); + MLtoERPEntity2 field9 = new MLtoERPEntity2(); + field9.setField("PLNNR"); + field9.setValue(sendSAPProductRevBean.getPLNNR()); + list1.add(field9); + MLtoERPEntity2 field10 = new MLtoERPEntity2(); + field10.setField("ALNAL"); + field10.setValue(sendSAPProductRevBean.getALNAL()); + list1.add(field10); + MLtoERPEntity2 field11 = new MLtoERPEntity2(); + field11.setField("MDV01"); + field11.setValue(sendSAPProductRevBean.getMDV01()); + list1.add(field11); + MLtoERPEntity2 field12 = new MLtoERPEntity2(); + field12.setField("ALORT"); + field12.setValue(sendSAPProductRevBean.getALORT()); + list1.add(field12); + MLtoERPEntity2 field13 = new MLtoERPEntity2(); + field13.setField("ELPRO"); + field13.setValue(sendSAPProductRevBean.getELPRO()); + list1.add(field13); + mLtoERPEntity.setData(list1); + mLtoERPEntity.setList(list2); + Gson gson = new Gson(); + String json = gson.toJson(mLtoERPEntity); + System.out.println(json); + String doPostResult = WebApiUtil.doPost(url, json); + MLRequestEntity resultEntity = gson.fromJson(doPostResult, MLRequestEntity.class); + String result = resultEntity.getResult(); + JSONObject fromObject = JSONObject.fromObject(result); + String status = resultEntity.getErrcode(); +// // 调用接口 +// DT_TCM2SAP_C223 tcm2sap_CBSJQ = new DT_TCM2SAP_C223(); +// tcm2sap_CBSJQ.setMSG_HDR(mt_person); +// tcm2sap_CBSJQ.setMSG_BODY(body_type0); +// MT_TCM2SAP_C223 tcm2sap_CBSJQ2 = new MT_TCM2SAP_C223(); +// tcm2sap_CBSJQ2.setMT_TCM2SAP_C223(tcm2sap_CBSJQ); +// DT_SAP2TCM_C223 sap2tcm_CA21 = stub.SI_TCM2SAP_C223_OUT(tcm2sap_CBSJQ2).getMT_SAP2TCM_C223(); +// String status = sap2tcm_CA21.getSTATUS(); + + System.out.println("当前数据库操作类型 UorI "+sendSAPProductRevBean.getKZ() + +"生产版本号"+sendSAPProductRevBean.getVERID()+"传递结果 SorE"+status); + + if (status.equals("0") || status.equals("1")) { + // 将数据写入到表中 + try { + String insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVINSERTSQL"), + UUID.randomUUID().toString().replace("-", ""), sendSAPProductRevBean.getMSGID(), + sendSAPProductRevBean.getBUSID(), sendSAPProductRevBean.getTLGID(), + sendSAPProductRevBean.getTLGNAME(), sendSAPProductRevBean.getDTSEND(), + sendSAPProductRevBean.getSENDER(), sendSAPProductRevBean.getRECEIVER(), + sendSAPProductRevBean.getFREEUSE(), sendSAPProductRevBean.getMATNR(), + sendSAPProductRevBean.getWERKS(), sendSAPProductRevBean.getVERID(), + sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), + sendSAPProductRevBean.getBDATU(), sendSAPProductRevBean.getSTLAL(), + sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), + sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), + sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), + status, resultEntity.getErrmsg()); + if (sendSAPProductRevBean.getKZ().equals("U")) { + insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVUPDATESQL"), + sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), + sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getVERID(), + sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), + sendSAPProductRevBean.getBDATU(), //sendSAPProductRevBean.getSTLAL(), + sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), + sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), + sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), + status, resultEntity.getErrmsg(), + sendSAPProductRevBean.getSTLAL(), + sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), + sendSAPProductRevBean.getALNAL(),sendSAPProductRevBean.getVERID()); + } + System.out.println(insertSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } + +// if (sap2tcm_CA21.getMESSAGE() != null && !sap2tcm_CA21.getMESSAGE().isEmpty()) { + if (resultEntity.getErrcode() != null && !resultEntity.getErrcode().isEmpty()) { + if(status.equals("1")) { + messageString.append("【物料代码】:"+fromObject.getString("MATNR").toString()); + messageString.append("【工厂】:"+fromObject.getString("WERKS").toString()); + messageString.append("【生产版本】:"+fromObject.getString("VERID").toString()); + messageString.append("【发送失败】:"+resultEntity.getErrmsg()); + messageString.append("\n"); + } + } + } + +// System.out.println(messageString); +// if(messageString.length() > 0) +// { +// MessageBox.post(messageString.toString(), "错误", MessageBox.ERROR); +// } +// else +// { + +// } + this.dispose(); + MessageBox.post("传递成功!", "成功", MessageBox.INFORMATION); + } catch (Exception e2) { + // : handle exception + } + } else if (source.equals(this.closeButton)) { + this.dispose(); +// ((DefaultTableModel)mainTable.getModel()).addRow(new Object[] { "", "id", "fac", "excels[0]", "", "", "", "", "", "", "", "", "", "", "" }); + } + } + + private String[] getLOV(String name) { + try { + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType)session.getTypeComponent("ListOfValues"); + ListOfValuesInfo lov = lovType.find(name)[0].getListOfValues(); +// String[] dv = lov.getLOVDisplayValues(); + String[] rv = lov.getStringListOfValues(); +// for(int i=0; i processRowList; + private Map> labelRows;//标注行 + private int row = -1; + private int column = -1; + + public CTMap(int numRows, int numColumns) { + Vector names = new Vector<>(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector<>(); + setNumRows(numRows); + setSize(new Dimension(numColumns, numRows)); + } + + public CTMap(int numColumns) { + Vector names = new Vector<>(numColumns); + names.setSize(numColumns); + setColumnIdentifiers(names); + dataVector = new Vector<>(); +// setNumRows(numRows); +// setSize(new Dimension(numColumns, numRows)); + } + + public int getRow() { + return row; + } + + public void setRow(int row) { + this.row = row; + } + + public int getColumn() { + return column; + } + + public void setColumn(int column) { + this.column = column; + } + + public void setEditable(boolean isEditable) { + this.isEditable = isEditable; + } + + public List getProcessRowList() { + return processRowList; + } + + public void setProcessRowList(List processRowList) { + this.processRowList = processRowList; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // Auto-generated method stub + if (processRowList != null && processRowList.size() > 0) { + if (!processRowList.contains(arg0) || arg1 == 1 || arg1 == 2) { + return false; + } else { + if (arg0 == row && arg1 == column) { + return this.isEditable; + } else { + return false; + } + } + } else { + return true; + } + } + + @Override + public void removeRow(int row) { + // 将可修改的行-1 + if (processRowList != null && processRowList.size() > 0) { + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (processRowList.get(i) != null && processRowList.get(i) == row) { + processRowList.remove(i); + } else if (processRowList.get(i) != null && processRowList.get(i) > row) { + processRowList.set(i, processRowList.get(i) - 1); + } + } + } + //将标注行减1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null && listRow == row) { + labelRowList.remove(i); + } else if (labelRowList.get(i) != null && listRow > row) { + labelRowList.set(i, ((Integer)(listRow-1)).toString()); + } + } + } + super.removeRow(row); + } + + @Override + public int[] getSpan(int row, int column) { + // Auto-generated method stub + if (isOutOfBounds(row, column)) { + int[] ret_code = { 1, 1 }; + return ret_code; + } + return span[row][column]; + } + + @Override + public void setSpan(int[] span, int row, int column) { + // Auto-generated method stub + if (isOutOfBounds(row, column)) + return; + this.span[row][column] = span; + } + + @Override + public boolean isVisible(int row, int column) { + // Auto-generated method stub + if (isOutOfBounds(row, column)) + return false; + if (span[row][column][CellSpan.COLUMN] < 1 || span[row][column][CellSpan.ROW] < 1) + return false; + return true; + } + + @Override + public void combine(int[] rows, int[] columns) { + // Auto-generated method stub + + int rowSpan = rows.length; + int columnSpan = columns.length; + int startRow = rows[0]; + int startColumn = columns[0]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + if (span[startRow + i][startColumn + j][CellSpan.COLUMN] != 1 || span[startRow + i][startColumn + j][CellSpan.ROW] != 1) { + // System.out.println("can't combine"); + return; + } + } + } + for (int i = 0, ii = 0; i < rowSpan; i++, ii--) { + for (int j = 0, jj = 0; j < columnSpan; j++, jj--) { + span[startRow + i][startColumn + j][CellSpan.COLUMN] = jj; + span[startRow + i][startColumn + j][CellSpan.ROW] = ii; + // System.out.println("r " +ii +" c " +jj); + } + } + span[startRow][startColumn][CellSpan.COLUMN] = columnSpan; + span[startRow][startColumn][CellSpan.ROW] = rowSpan; + } + + // @Override + // public boolean isCellEditable(int arg0, int arg1) { + // if(arg1 == 1 ) + // { + // return false; + // } + // return super.isCellEditable(arg0, arg1); + // } + // + public void setSize(Dimension size) { + columnSize = size.width; + rowSize = size.height; + span = new int[rowSize][columnSize][2]; // 2: COLUMN,ROW + initValue(); + } + + protected boolean isOutOfBounds(int row, int column) { + if ((row < 0) || (rowSize <= row) || (column < 0) || (columnSize <= column)) { + return true; + } + return false; + } + + @SuppressWarnings("unchecked") + public void addRow() { + + Vector newData = new Vector<>(getColumnCount()); + dataVector.add(newData); + + // + newRowsAdded(new TableModelEvent(this, getRowCount() - 1, getRowCount() - 1, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows + 1][numColumns][2]; + System.arraycopy(oldSpan, 0, span, 0, numRows); + for (int i = 0; i < numColumns; i++) { + span[numRows][i][CellSpan.COLUMN] = 1; + span[numRows][i][CellSpan.ROW] = 1; + } + rowSize = span.length; + } + + @SuppressWarnings("rawtypes") + public void addColumn(Object columnName) { + + int[][][] oldSpan = span; + int numRows = oldSpan.length; + int numColumns = oldSpan[0].length; + span = new int[numRows][numColumns + 1][2]; + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[0].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + + columnSize = span[0].length; + addColumn(columnName, (Vector) null); + } + + @SuppressWarnings("unchecked") + public void insertRow(int row) { + Vector rowData = new Vector<>(getColumnCount()); + int index = 0; + + dataVector.insertElementAt(rowData, row); +// System.out.println("size:" + dataVector.size()); + + // + newRowsAdded(new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT)); + int[][][] newSpan = new int[span.length + 1][span[0].length][2]; + +// int numRows = span.length; + int numColumns = span[0].length; + for (int i = 0; i < newSpan.length; i++) { + if (i < row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i][j][0]; + newSpan[i][j][1] = span[i][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } else if (i == row) { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = 1; + newSpan[i][j][1] = 1; + } + } else { + for (int j = 0; j < numColumns; j++) { + newSpan[i][j][0] = span[i - 1][j][0]; + newSpan[i][j][1] = span[i - 1][j][1]; + // newSpan[i][j][0] = 1; + // newSpan[i][j][1] = 1; + } + } + } + span = newSpan; + rowSize = span.length;// 将可修改的行+1 + if (processRowList != null && processRowList.size() > 0) { + + for (int i = processRowList.size() - 1; i >= 0; i--) { + if (!processRowList.contains(row) && processRowList.get(i) != null && processRowList.get(i) == row - 1) { + index = i + 1; + processRowList.add(i + 1, row); + } else if (processRowList.get(i) != null && processRowList.get(i) == row) { + index = i + 1; + processRowList.add(i + 1, row + 1); + } else if (processRowList.get(i) != null && i > index && processRowList.get(i) >= row) { + processRowList.set(i, processRowList.get(i) + 1); + } + } + } + //将标注行+1 + if (labelRows != null && labelRows.size() > 0 && labelRows.keySet().contains(row)) { + List labelRowList = labelRows.get(row); + for (int i = labelRowList.size() - 1; i >= 0; i--) { + Integer listRow = (Integer.parseInt(labelRowList.get(i))); + if (labelRowList.get(i) != null && i > index && listRow >= row) { + labelRowList.set(i, ((Integer)(listRow + 1)).toString()); + } + } + } + + } + + protected void initValue() { + System.out.println(span.length); + for (int i = 0; i < span.length; i++) { + for (int j = 0; j < span[i].length; j++) { + span[i][j][CellSpan.COLUMN] = 1; + span[i][j][CellSpan.ROW] = 1; + } + } + } + + public void split(int row, int column) { + if (isOutOfBounds(row, column)) + return; + int columnSpan = span[row][column][CellSpan.COLUMN]; + int rowSpan = span[row][column][CellSpan.ROW]; + for (int i = 0; i < rowSpan; i++) { + for (int j = 0; j < columnSpan; j++) { + span[row + i][column + j][CellSpan.COLUMN] = 1; + span[row + i][column + j][CellSpan.ROW] = 1; + } + } + } + + @SuppressWarnings("rawtypes") + public void removeCol() { + + columnIdentifiers.removeElementAt(columnIdentifiers.size() - 1); + dataVector.setSize(getRowCount()); + + for (int i = 0; i < getRowCount() - 1; i++) { + + ((Vector) dataVector.elementAt(i)).setSize(getColumnCount()); + } + fireTableStructureChanged(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CTUI.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CTUI.java new file mode 100644 index 0000000..a993e2d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CTUI.java @@ -0,0 +1,96 @@ +package com.connor.ml.tcm.ML_13; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Rectangle; + +import javax.swing.JComponent; +import javax.swing.plaf.basic.BasicTableUI; +import javax.swing.table.TableCellRenderer; + +public class CTUI extends BasicTableUI { + + public void paint(Graphics g, JComponent c) { + Rectangle oldClipBounds = g.getClipBounds(); + Rectangle clipBounds = new Rectangle(oldClipBounds); + int tableWidth = ((CTable) table).getColumnModel() + .getTotalColumnWidth(); + clipBounds.width = Math.min(clipBounds.width, tableWidth); + g.setClip(clipBounds); + + int firstIndex = ((CTable) table) + .rowAtPoint(new Point(0, clipBounds.y)); + int lastIndex = ((CTable) table).getRowCount() - 1; + Rectangle rowRect = new Rectangle(0, 0, tableWidth, + ((CTable) table).getRowHeight() + + ((CTable) table).getRowMargin()); + rowRect.y = firstIndex * rowRect.height; + for (int index = firstIndex; index <= lastIndex; index++) { + if (rowRect.intersects(clipBounds)) { + // System.out.println(); // debug + // System.out.print("" + index +": "); // row + paintRow(g, index); + } + rowRect.y += rowRect.height; + } + g.setClip(oldClipBounds); + } + + private void paintRow(Graphics g, int row) { + Rectangle rect = g.getClipBounds(); + boolean drawn = false; + CellSpan cellAtt = (CellSpan) ((CTable) table).getModel(); + int numColumns = ((CTable) table).getColumnCount(); + + for (int column = 0; column < numColumns; column++) { + Rectangle cellRect = ((CTable) table).getCellRect(row, column, true); + + int cellRow, cellColumn; + if (cellAtt.isVisible(row, column)) { + cellRow = row; + cellColumn = column; + // System.out.print(" "+column+" "); // debug + } else { + cellRow = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + cellColumn = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + // System.out.print(" ("+column+")"); // debug + } + if (cellRect.intersects(rect)) { + drawn = true; + paintCell(g, cellRect, cellRow, cellColumn); + } else { + if (drawn) + break; + } + } + + } + + private void paintCell(Graphics g, Rectangle cellRect, int row, int column) { + int spacingHeight = ((CTable) table).getRowMargin(); + int spacingWidth = ((CTable) table).getColumnModel().getColumnMargin(); + // System.out.println("X:"+cellRect.x+"Y:"+cellRect.y); + Color c = g.getColor(); + g.setColor(((CTable) table).getGridColor()); + g.drawRect(cellRect.x, cellRect.y, cellRect.width - 1, cellRect.height - 1); + g.setColor(c); + + cellRect.setBounds(cellRect.x + spacingWidth / 2, cellRect.y + spacingHeight / 2, cellRect.width - spacingWidth, cellRect.height - spacingHeight); + + if (((CTable) table).isEditing() && ((CTable) table).getEditingRow() == row && ((CTable) table).getEditingColumn() == column) { + Component component = ((CTable) table).getEditorComponent(); + component.setBounds(cellRect); + component.validate(); + } else { + TableCellRenderer renderer = ((CTable) table).getCellRenderer(row, column); + Component component = ((CTable) table).prepareRenderer(renderer, row, column); + + if (component.getParent() == null) { + rendererPane.add(component); + } + rendererPane.paintComponent(g, component, ((CTable) table), cellRect.x, cellRect.y, cellRect.width, cellRect.height, true); + } + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CTable.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CTable.java new file mode 100644 index 0000000..c408afd --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CTable.java @@ -0,0 +1,265 @@ +package com.connor.ml.tcm.ML_13; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.MouseEvent; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableModel; + +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.util.MessageBox; + +public class CTable extends JTable { + + /** + * + */ + private static final long serialVersionUID = 1L; +// ComboBoxCellEditor typeComboBoxCellEditor = new ComboBoxCellEditor(MethodUtil.getProcessType()); +// ComboBoxCellEditor groupComboBoxCellEditor = new ComboBoxCellEditor(new String[] {}); + Map map; + private ArrayList excelMap; + private String sql; + + public CTable(TableModel model, ArrayList excelMap) { + super(model); + this.excelMap = excelMap; + setUI(new CTUI()); + getTableHeader().setReorderingAllowed(false); + setCellSelectionEnabled(true); + setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + map = new HashMap<>(); + + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + sql = pro.getProperty("ML_TCMPROCESSSELECTSQL2"); + } catch (Exception e2) { + MessageBox.post("错误:"+e2.getMessage(), "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + } + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValue(row, col); + if (!"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + // @Override + // protected void processKeyEvent(KeyEvent keyevent) { + // // Auto-generated method stub + // if(keyevent.getKeyCode()==KeyEvent.VK_ENTER){ + // if(keyevent.isControlDown()) + // { + // System.out.println(1); + // } + // this.editCellAt(this.getSelectedRow(),this.getSelectedColumn()); + // } + // } + + public Rectangle getCellRect(int row, int column, boolean includeSpacing) { + Rectangle sRect = super.getCellRect(row, column, includeSpacing); + if (row < 0 || column < 0 || getRowCount() <= row || getColumnCount() <= column) { + return sRect; + } + CellSpan cellAtt = (CellSpan) getModel(); + if (!cellAtt.isVisible(row, column)) { + int temp_row = row; + int temp_column = column; + row += cellAtt.getSpan(temp_row, temp_column)[CellSpan.ROW]; + column += cellAtt.getSpan(temp_row, temp_column)[CellSpan.COLUMN]; + } + int[] n = cellAtt.getSpan(row, column); + + int index = 0; + int columnMargin = getColumnModel().getColumnMargin(); + Rectangle cellFrame = new Rectangle(); + int aCellHeight = rowHeight + rowMargin; + cellFrame.y = row * aCellHeight; + cellFrame.height = n[CellSpan.ROW] * aCellHeight; + + Enumeration eeration = getColumnModel().getColumns(); + while (eeration.hasMoreElements()) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width = aColumn.getWidth(); + if (index == column) + break; + cellFrame.x += cellFrame.width; + index++; + } + for (int i = 0; i < n[CellSpan.COLUMN] - 1; i++) { + TableColumn aColumn = (TableColumn) eeration.nextElement(); + cellFrame.width += aColumn.getWidth() + columnMargin; + } + + if (!includeSpacing) { + Dimension spacing = getIntercellSpacing(); + cellFrame.setBounds(cellFrame.x + spacing.width / 2, cellFrame.y + + spacing.height / 2, cellFrame.width - spacing.width, + cellFrame.height - spacing.height); + } + return cellFrame; + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel().getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + + private int[] rowColumnAtPoint(Point point) { + int[] retValue = { -1, -1 }; + int row = point.y / (rowHeight + rowMargin); + if ((row < 0) || (getRowCount() <= row)) + return retValue; + int column = getColumnModel().getColumnIndexAtX(point.x); + + CellSpan cellAtt = (CellSpan) getModel(); + + if (cellAtt.isVisible(row, column)) { + retValue[CellSpan.COLUMN] = column; + retValue[CellSpan.ROW] = row; + return retValue; + } + retValue[CellSpan.COLUMN] = column + cellAtt.getSpan(row, column)[CellSpan.COLUMN]; + retValue[CellSpan.ROW] = row + cellAtt.getSpan(row, column)[CellSpan.ROW]; + return retValue; + } + + public int rowAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.ROW]; + } + + public int columnAtPoint(Point point) { + return rowColumnAtPoint(point)[CellSpan.COLUMN]; + } + + public void columnSelectionChanged(ListSelectionEvent e) { + repaint(); + } + + public void valueChanged(ListSelectionEvent e) { + int firstIndex = e.getFirstIndex(); + int lastIndex = e.getLastIndex(); + if (firstIndex == -1 && lastIndex == -1) { // Selection cleared. + repaint(); + } + Rectangle dirtyRegion = getCellRect(firstIndex, 0, false); + int numCoumns = getColumnCount(); + int index = firstIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + index = lastIndex; + for (int i = 0; i < numCoumns; i++) { + dirtyRegion.add(getCellRect(index, i, false)); + } + repaint(dirtyRegion.x, dirtyRegion.y, dirtyRegion.width, dirtyRegion.height); + } + + public void setCombo(int row, int col, TableCellEditor ce) { + map.put(new Point(row, col), ce); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + if (this.getColumnName(column).equals("类型")) { +// ComboBoxCellEditor typeComboBoxCellEditor = new ComboBoxCellEditor(MethodUtil.getProcessType()); +// typeComboBoxCellEditor.addActionListener(new ActionListener() { +// @Override +// public void actionPerformed(ActionEvent e) { +// // Auto-generated method stub +// if(typeComboBoxCellEditor.getSelectedIndex() > -1) { +// ComboBoxCellEditor groupComboBoxCellEditor = (ComboBoxCellEditor) getCellEditor(row, 2); +// groupComboBoxCellEditor.removeAllItems(); +// String[] groups = MethodUtil.getProcessGroup(typeComboBoxCellEditor.getSelectedItem().toString()); +// groupComboBoxCellEditor.addItem(""); +// for (int i = 0; i < groups.length; i++) { +// groupComboBoxCellEditor.addItem(groups[i]); +// } +// } +// } +// }); + CTMap model = (CTMap) getModel(); + ComboBoxCellEditor typeComboBoxCellEditor = new ComboBoxCellEditor(this, model, excelMap, sql, row, column, MethodUtil.getProcessType()); + return typeComboBoxCellEditor; + } else if(this.getColumnName(column).equals("组名")) {//TODO + CTMap model = (CTMap) getModel(); + ComboBoxCellEditor groupComboBoxCellEditor = + new ComboBoxCellEditor(this, model, excelMap, sql, row, column, MethodUtil.getProcessGroup(model.getValueAt(row, 1).toString())); + return groupComboBoxCellEditor; + } else { + return super.getCellEditor(row,column); + } + } + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // Auto-generated method stub + return super.getCellRenderer(row, column); + } + public void setRowHeight(int row, int rowHeight) { + super.setRowHeight(row, rowHeight); + } + + public void selectAllOrNull(String value){ + // Select All. The last column + for(int index = 0; index < getRowCount(); index ++){ + this.setValueAt(value, index, this.getColumnCount() - 3); + } + } + + private String getValue(int row, int col) { + Object value = getValueAt(row, col); + if(value==null) + return ""; + return value.toString(); + } + // @Override + // public boolean isCellSelected(int i, int j) { + // if( i == 1 || i == 3) + // { + // //this.clearSelection(); + // return false; + // } + // else + // { + // return super.isCellSelected(i, j); + // } + // } + +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CellSpan.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CellSpan.java new file mode 100644 index 0000000..8cf7502 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/CellSpan.java @@ -0,0 +1,15 @@ +package com.connor.ml.tcm.ML_13; + +public interface CellSpan { + public final int ROW = 0; + public final int COLUMN = 1; + + public int[] getSpan(int row, int column); + + public void setSpan(int[] span, int row, int column); + + public boolean isVisible(int row, int column); + + public void combine(int[] rows, int[] columns); + +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/ComboBoxCellEditor.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/ComboBoxCellEditor.java new file mode 100644 index 0000000..541044d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/ComboBoxCellEditor.java @@ -0,0 +1,291 @@ +package com.connor.ml.tcm.ML_13; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.EventObject; +import java.util.Vector; + +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.event.CellEditorListener; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellEditor; + +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.util.MessageBox; + +public class ComboBoxCellEditor extends JComboBox implements TableCellEditor { + + /** + * + */ + private static final long serialVersionUID = 1L; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + + public ComboBoxCellEditor(Object[] itmes) { + super(); + for (int i = 0; i < itmes.length; i++) { + addItem(itmes[i]); + } + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + } + + public ComboBoxCellEditor(JTable table, CTMap model, ArrayList excelMap, String sql, int row, int col, String[] values) {//TODO CTable + super(); + addItem(""); + for(String s : values) { + addItem(s); + } + Object value = model.getValueAt(row, col); + System.out.println(col+"=="+value); + if(value!=null && !value.toString().isEmpty()) { +// cellEditer.setSelectedItem(value); +// System.out.println("getSelectedIndex>>"+getSelectedIndex()); + if(!getItemAt(getSelectedIndex()).equals(value)) { + for(int i=0; i>"+getSelectedIndex()); + break; + } + } + } + }else + setSelectedIndex(-1); +// System.out.println(col+">>"+getSelectedIndex()); + + addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent event) { + fireEditingStopped(); + } + }); + addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent arg0) { + System.out.println("itemStateChanged:"+table.getSelectedColumn()+">>"+col+"=="+table.getSelectedRow()+">>"+row); + if(table.getSelectedColumn() != col) + return; + if(getSelectedIndex()<0) + return; + Object select = getSelectedItem(); + if(arg0.getItem().equals(select) && select.equals(getValue(table, row, col))) + return; + if(col==1) { + ComboBoxCellEditor group = (ComboBoxCellEditor) table.getCellEditor(row, 2); + group.removeAllItems(); + String[] groups = MethodUtil.getProcessGroup(select.toString()); + for (int i = 0; i < groups.length; i++) { + group.addItem(groups[i]); + } + group.setSelectedIndex(-1); + model.setValueAt("", row, 2); + model.setValueAt("", row, 7); + model.setValueAt("", row, 11); + model.setValueAt("", row, 13); + model.setValueAt("", row, 25); + String id = getValue(table, row, 3); + for(int i=model.getRowCount()-1; i>=0; i--) { + if(i!=row && id.equals(getValue(table, i, 3))) + model.removeRow(i); + } + return; + } + String group = getSelectedItem().toString(); + String fac = getValue(table, row, 5); + if(group.isEmpty() || fac.isEmpty() || excelMap==null) + return; + CTMap model = (CTMap) table.getModel(); + String id = getValue(table, row, 3); + for(int i=table.getRowCount()-1; i>=0; i--) { + if(i==row || !id.equals(getValue(table, i, 3))) + continue; + model.removeRow(i); + } + int fr = row; + for(int i=0; i valuesList = new Vector<>(); + valuesList.add(getValue(table, fr, 0));//批次产品描述0 + valuesList.add(getValue(table, fr, 1));//类型1 + valuesList.add(group);//组名2 + valuesList.add(id);//物料编码3 + valuesList.add(getValue(table, fr, 4));//物料描述4 + valuesList.add(fac);//工厂5 + valuesList.add(excels[5]);//关键日期6 + valuesList.add(excels[3]);//组计数器7 + valuesList.add("1");//用途8 + valuesList.add("4");//状态9 + valuesList.add("10");//工序10 + valuesList.add(excels[2]);//工作中心11 + valuesList.add("PP03");//控制代码12 + valuesList.add(excels[4]);//工序描述13 + valuesList.add("1");//基本数量14 + valuesList.add("");//工时15 + valuesList.add("H");//工时单位 + valuesList.add("");//固定制造费用 + valuesList.add("H");//时间单位 + valuesList.add("");//动力费用 + valuesList.add("H");//时间单位 + valuesList.add("");//其他制造费用 + valuesList.add("H");//时间单位 + valuesList.add("");//排产准备时间 + valuesList.add("H");//时间单位 + valuesList.add(processGroup);//工艺路线组 + valuesList.add("I");//处理标记 + +// model.insertRow(fr +(i++), valuesList); + model.insertRow(fr + i);//fr +(i++) + for(int j=0; j excelMap = new ArrayList<>(); + try { + File file = ((TCComponentDataset)dataset).getTcFiles()[0].getFile(System.getProperty("java.io.tmpdir")); + inpu = new FileInputStream(file); + wb = new XSSFWorkbook(inpu); + XSSFSheet sheet = wb.getSheetAt(0); + for(int i=1; i sendOAPropertyBeanList = new ArrayList(); +// sendOAPropertyBeanList.add(sendOAPropertyBean); +// +// sendOABean.setData(sendOAPropertyBeanList); + + + String json = JSON.toJSONString(sendOABean); + + String result = MethodUtil.sendPost("http://mlapp.meiling.com/mlwebapi/plm/getinfo", json); + + if(result.indexOf("\"errcode\":\"1\"") >= 0) + { + MessageBox.post(result,"失败", MessageBox.ERROR); + return; + } + System.out.println(result); + + Date currentime = new Date(); + System.out.println("调用接口耗时:" + (currentime.getTime() - sourcetime.getTime()) / 1000 + "s"); + + Map lineEroCodeMap=new HashMap(); +// Map> eroCodeFactoryMap=new HashMap>(); + //TODO 根据产线获取分类中的ERP班组编码 + //获取返回结果 + JSONObject resultJson = JSONObject.fromObject(result); + JSONArray jsonArray = resultJson.getJSONArray("list"); + + Map descMap = new HashMap(); + for (int i=0; i < jsonArray.size(); i++) { + + //获取物料代码、物料描述、工厂、产线、可选BOM信息 + String itemId = ""; + String batch = ""; + JSONObject jsonObject = jsonArray.getJSONObject(i); + Iterator iter = jsonObject.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + switch (entry.getKey().toString()) { + case "物料编码": + itemId = entry.getValue().toString(); + break; + case "批次": + batch = entry.getValue().toString(); + break; + default: + break; + } + } + if(descMap.containsKey(batch)) + continue; + String desc = ""; + if(itemId.startsWith("ML")) { + TCComponentItem[] item = itemType.findItems(itemId); + if(item != null && item.length>0) { + desc = item[0].getLatestItemRevision().getStringProperty("ml8_StdDesc"); + } + descMap.put(batch, desc); + } + } + + + List> dataList = new ArrayList>(); + List> haveList = new ArrayList>(); + List valueList = new ArrayList(); + for (int i=0; i < jsonArray.size(); i++) { + + //获取物料代码、物料描述、工厂、产线、可选BOM信息 + String itemId = ""; + String objectName = ""; + String factory = ""; + String lineCode = ""; +// String bom = ""; + String batch = ""; + JSONObject jsonObject = jsonArray.getJSONObject(i); + Iterator iter = jsonObject.entrySet().iterator(); + while (iter.hasNext()) { + Map.Entry entry = (Map.Entry) iter.next(); + switch (entry.getKey().toString()) { + case "物料编码": + itemId = entry.getValue().toString(); + break; + case "物料描述": + objectName = entry.getValue().toString(); + break; + case "工厂": + factory = entry.getValue().toString(); + break; + case "物料线体": + lineCode = entry.getValue().toString(); + break; +// case "可选BOM": +// bom = entry.getValue().toString(); +// break; + case "批次": + batch = entry.getValue().toString(); + break; + default: + break; + } + } + if(lineCode.indexOf("-") > 0) + { + //factory = lineCode.split("-")[0]; + lineCode = lineCode.split("-")[1]; + } + System.out.println("lineCode:"+lineCode); + System.out.println("factory:"+factory); + + String ERPCode="erpcode"; + if(lineEroCodeMap.containsKey(lineCode)) { + ERPCode=lineEroCodeMap.get(lineCode); + } + + System.out.println("ERPCOde : "+ERPCode); + + String desc = ""; + if(descMap.containsKey(batch)) + { + desc = descMap.get(batch); + } + //根据产线(对应TCM的‘ERP班组编码’)从“组计数器”分类库中获取数据 +// String groupNo = ""; + String work = ""; +// String lineName = ""; +// String classERPCode = ""; +// String classFactory = ""; + + String keyString = ERPCode+"fac:"+factory; + + System.out.println("erp fac"+keyString); + + //物料代码、组计数器、工作中心数据相同时,删除重复的行 + String value = itemId + "-" + work; + if(valueList.contains(value)) { + continue; + } + valueList.add(value); + + //根据物料编码、工厂、组计数器从工艺路线表中查询出工艺路线组的值 + ResultSet rs = null; + boolean isHave = false; + try { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), itemId, factory); + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + + if (rs != null) { + while (rs.next()) { + //添加数据 + List valuesList = new ArrayList(); + valuesList.add(desc); + valuesList.add(""); + valuesList.add(""); + valuesList.add(itemId); + valuesList.add(objectName); + valuesList.add(factory); + valuesList.add(dateStr); + valuesList.add(""); + valuesList.add("1"); + valuesList.add("4"); + valuesList.add("10"); + valuesList.add(rs.getString("ARBPL")); + valuesList.add("PP03"); + valuesList.add(rs.getString("LTXA1")); + valuesList.add("1"); + valuesList.add(rs.getString("VGW01")); + valuesList.add("H"); + valuesList.add(rs.getString("VGW02")); + valuesList.add("H"); + valuesList.add(rs.getString("VGW03")); + valuesList.add("H"); + valuesList.add(rs.getString("VGW04")); + valuesList.add("H"); + valuesList.add(rs.getString("VGW05")); + valuesList.add("H"); + valuesList.add(rs.getString("PLNNR")); + valuesList.add("U"); + + dataList.add(valuesList); + haveList.add(valuesList); + isHave = true; + break; + } + } + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException e2) { + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + if(!isHave) { + //添加数据 + List valuesList = new ArrayList(); + valuesList.add(desc); + valuesList.add(""); + valuesList.add(""); + valuesList.add(itemId); + valuesList.add(objectName); + valuesList.add(factory); + valuesList.add(dateStr); + valuesList.add(""); + valuesList.add("1"); + valuesList.add("4"); + valuesList.add("10"); + valuesList.add(""); + valuesList.add("PP03"); + valuesList.add(""); + valuesList.add("1"); + valuesList.add(""); + valuesList.add("H"); + valuesList.add(""); + valuesList.add("H"); + valuesList.add(""); + valuesList.add("H"); + valuesList.add(""); + valuesList.add("H"); + valuesList.add(""); + valuesList.add("H"); + valuesList.add(""); + valuesList.add("I"); + + dataList.add(valuesList); + } + } + + if(haveList.size() > 0) { + StringBuilder haveStringBuilder = new StringBuilder(); + for (int i = 0; i < haveList.size(); i++) { + haveStringBuilder.append("物料:"); + haveStringBuilder.append(haveList.get(i).get(3)); + haveStringBuilder.append("工厂:"); + haveStringBuilder.append(haveList.get(i).get(5)); +// haveStringBuilder.append("组计数器:"); +// haveStringBuilder.append(haveList.get(i).get(6)); + haveStringBuilder.append("\n"); + } + haveStringBuilder.append("已传递过工艺路线,是否重新传递?"); + JTextArea textArea = new JTextArea(haveStringBuilder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setPreferredSize(new Dimension(400, 300)); + int i = JOptionPane.showConfirmDialog(null, scrollPane, "重新传递", JOptionPane.YES_NO_OPTION); + if (i != JOptionPane.YES_OPTION) { + dataList.removeAll(haveList); + } + } + + + new Thread() { + @Override + public void run() { + new GetMBomDialog(session, dataList, result, excelMap); + } + }.start(); + + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + } + else if (source.equals(this.closeButton)) { + this.dispose(); + } + } + + private XSSFRow getRow(XSSFSheet sheet, int num) throws Exception { + XSSFRow row = sheet.getRow(num); + if(row==null) + row = sheet.createRow(num); + return row; + } + private XSSFCell getCell(XSSFRow row, int col) throws Exception { + XSSFCell cell = row.getCell(col); + if(cell==null) + cell = row.createCell(col); + return cell; + } + private String getValue(XSSFCell cell) { + Object value = null; + CellType type = cell.getCellTypeEnum(); + if(type == CellType.STRING) + value = cell.getStringCellValue(); + else if(type == CellType.NUMERIC) + value = (int)cell.getNumericCellValue(); + return value + ""; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomCommand.java new file mode 100644 index 0000000..c61d690 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomCommand.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ML_13; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class GetMBomCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + + public GetMBomCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + new Thread() { + @Override + public void run() { + GetBatchNoDialog dialog = new GetBatchNoDialog(session); + } + }.start(); + super.executeModal(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomDialog.java new file mode 100644 index 0000000..7864f84 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomDialog.java @@ -0,0 +1,543 @@ +package com.connor.ml.tcm.ML_13; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.InputStream; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; + +import org.apache.axis2.Constants.Configuration; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator; + +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.DT_SAP2TCM_CA21; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.DT_TCM2SAP_CA21; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.HEADER_type0; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.MSG_BODY_type0; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.MSG_HDR_type0; +import com.connor.ml.tcm.ML_07.SI_TCM2SAP_CA21_OUTServiceStub.MT_TCM2SAP_CA21; +import com.connor.ml.tcm.ML_18.ScreenShotTest; +import com.connor.ml.tcm.bean.SendSAPProcessBean; +import com.connor.ml.tcm.cloneProcess.WebApiUtil; +import com.connor.ml.tcm.util.Adapter; +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MLRequestEntity; +import com.connor.ml.tcm.util.MLtoERPEntity; +import com.connor.ml.tcm.util.MLtoERPEntity2; +import com.connor.ml.tcm.util.MethodUtil; +import com.google.gson.Gson; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class GetMBomDialog extends AbstractAIFDialog implements ActionListener { + + /** + * + */ + private static final long serialVersionUID = 1L; + private TCSession session; + private String[] header = new String[] { "批次产品描述", "类型", "组名", "物料编码", "物料描述", "工厂", "关键日期", "组计数器", "用途", "状态", "工序", "工作中心", "控制代码", "工序描述", + "基本数量", "工时", "工时单位", "固定制造费用", "时间单位", "动力费用", "时间单位", "其他制造费用", "时间单位", "排产准备时间", "时间单位", "工艺路线组", "处理标记" }; + + private String result = ""; + + private List> valuesList; + private String[][] dataValues; + + protected CTable mainTable;// 产品配置表 + private CTMap mainTableModel; + + private JPanel rootPanel; + private JButton sendButton; + private JButton closeButton; + private ArrayList excelMap; + + public GetMBomDialog(TCSession session, List> valuesList, String result, ArrayList excelMap) { + // Auto-generated constructor stub + this.session = session; + this.valuesList = valuesList; + this.excelMap = excelMap; + + dataValues = new String[this.valuesList.size()][]; + for (int i = 0; i < this.valuesList.size(); i++) { + dataValues[i] = new String[this.valuesList.get(i).size()]; + for (int j = 0; j < this.valuesList.get(i).size(); j++) { + dataValues[i][j] = this.valuesList.get(i).get(j); + } + } + this.result = result; + + init(); + } + + private void init() { + // Auto-generated method stub + this.setTitle("传递的工艺路线数据"); + this.setPreferredSize(new Dimension(800, 600)); + + this.mainTable = getjTable(mainTable, mainTableModel, header, dataValues); +// this.addData(dataValues); + this.rootPanel = new JPanel(new FlowLayout()); + this.sendButton = new JButton("传递"); + this.closeButton = new JButton("取消"); + + this.rootPanel.add(sendButton); + this.rootPanel.add(closeButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(new JScrollPane(this.mainTable), BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); + this.setVisible(true); + } + + // 添加监听 + public void createActionEvent() { + this.sendButton.addActionListener(this); + this.closeButton.addActionListener(this); + } + + /*** + * Jtable通用方法 + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public CTable getjTable(CTable partsTable, CTMap dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 100; + if (partsTable == null) { + CTMap map = new CTMap(1, titleNames.length); + map.setColumnIdentifiers(titleNames); + map.setEditable(false); + partsTable = new CTable(map, excelMap); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.HiddenCell(titleNames.length - 1); + // 设置显示器渲染 + partsTable.setRowHeight(50); + new Adapter(partsTable); + + TableCellTextAreaRenderer renderer = new TableCellTextAreaRenderer(); + // //设置居中 + partsTable.setDefaultRenderer(Object.class, renderer); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + for(int i=0; i 0; i--) { + tableModel.removeRow(0); + } + for (int i = cellData2.length - 1; i >= 0; i--) { + tableModel.insertRow(0); + for (int j = 0; j < cellData2[i].length; j++) { + tableModel.setValueAt(cellData2[i][j], 0, j); + } + } + tableModel.removeRow(cellData2.length); + // 表格数据不可修改 + // this.mainTable.setEnabled(true); + // 更新表格 + this.mainTable.invalidate(); + } + + @Override + public void actionPerformed(ActionEvent e) {//TODO + // Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.sendButton)) { + InputStream input = null; + try { + HashMap searches = new HashMap<>(); + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + StringBuffer messageString = new StringBuffer(); + HashMap groupMap = new HashMap<>(); + for (int i = 0; i < this.mainTable.getRowCount(); i++) { + Object v1 = this.mainTable.getValueAt(i, 1); + if (v1 == null || v1.toString().isEmpty() || v1.toString().equals(" ")) { + continue; + } + Object v2 = this.mainTable.getValueAt(i, 2); + if (v2 == null || v2.toString().isEmpty() || v2.toString().equals(" ")) { + continue; + } + // 拼接XML字符串 + SendSAPProcessBean sendSAPProcessBean = new SendSAPProcessBean(); + sendSAPProcessBean.setMSGID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProcessBean.setBUSID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProcessBean.setTLGID("JT0001"); + sendSAPProcessBean.setTLGNAME("维护工艺路线接口"); + sendSAPProcessBean.setDTSEND(sdf.format(new Date())); + sendSAPProcessBean.setSENDER("TCM"); + sendSAPProcessBean.setRECEIVER("SAP"); + sendSAPProcessBean.setFREEUSE(""); + sendSAPProcessBean.setTYPE(this.mainTable.getValueAt(i, 1) == null ? "" : this.mainTable.getValueAt(i, 1).toString()); + sendSAPProcessBean.setGROUPNAME(this.mainTable.getValueAt(i, 2) == null ? "" : this.mainTable.getValueAt(i, 2).toString()); + sendSAPProcessBean.setMATNR(this.mainTable.getValueAt(i, 3) == null ? "" : this.mainTable.getValueAt(i, 3).toString()); + sendSAPProcessBean.setWERKS(this.mainTable.getValueAt(i, 5) == null ? "" : this.mainTable.getValueAt(i, 5).toString()); + sendSAPProcessBean.setDATUV(this.mainTable.getValueAt(i, 6) == null ? "" : this.mainTable.getValueAt(i, 6).toString()); + sendSAPProcessBean.setPLNAL(this.mainTable.getValueAt(i, 7) == null ? "" : this.mainTable.getValueAt(i, 7).toString()); + sendSAPProcessBean.setVERWE(this.mainTable.getValueAt(i, 8) == null ? "" : this.mainTable.getValueAt(i, 8).toString()); + sendSAPProcessBean.setSTATU(this.mainTable.getValueAt(i, 9) == null ? "" : this.mainTable.getValueAt(i, 9).toString()); + sendSAPProcessBean.setVORNR(this.mainTable.getValueAt(i, 10) == null ? "" : this.mainTable.getValueAt(i, 10).toString()); + sendSAPProcessBean.setARBPL(this.mainTable.getValueAt(i, 11) == null ? "" : this.mainTable.getValueAt(i, 11).toString()); + sendSAPProcessBean.setSTEUS(this.mainTable.getValueAt(i, 12) == null ? "" : this.mainTable.getValueAt(i, 12).toString()); + sendSAPProcessBean.setLTXA1(this.mainTable.getValueAt(i, 13) == null ? "" : this.mainTable.getValueAt(i, 13).toString()); + sendSAPProcessBean.setBMSCH(this.mainTable.getValueAt(i, 14) == null ? "" : this.mainTable.getValueAt(i, 14).toString()); + sendSAPProcessBean.setVGW01(this.mainTable.getValueAt(i, 15) == null ? "" : this.mainTable.getValueAt(i, 15).toString()); + sendSAPProcessBean.setVGE01(this.mainTable.getValueAt(i, 16) == null ? "" : this.mainTable.getValueAt(i, 16).toString()); + sendSAPProcessBean.setVGW02(this.mainTable.getValueAt(i, 17) == null ? "" : this.mainTable.getValueAt(i, 17).toString()); + sendSAPProcessBean.setVGE02(this.mainTable.getValueAt(i, 18) == null ? "" : this.mainTable.getValueAt(i, 18).toString()); + sendSAPProcessBean.setVGW03(this.mainTable.getValueAt(i, 19) == null ? "" : this.mainTable.getValueAt(i, 19).toString()); + sendSAPProcessBean.setVGE03(this.mainTable.getValueAt(i, 20) == null ? "" : this.mainTable.getValueAt(i, 20).toString()); + sendSAPProcessBean.setVGW04(this.mainTable.getValueAt(i, 21) == null ? "" : this.mainTable.getValueAt(i, 21).toString()); + sendSAPProcessBean.setVGE04(this.mainTable.getValueAt(i, 22) == null ? "" : this.mainTable.getValueAt(i, 22).toString()); + sendSAPProcessBean.setVGW05(this.mainTable.getValueAt(i, 23) == null ? "" : this.mainTable.getValueAt(i, 23).toString()); + sendSAPProcessBean.setVGE05(this.mainTable.getValueAt(i, 24) == null ? "" : this.mainTable.getValueAt(i, 24).toString()); + sendSAPProcessBean.setPLNNR(this.mainTable.getValueAt(i, 25) == null ? "" : this.mainTable.getValueAt(i, 25).toString()); + sendSAPProcessBean.setKZ(this.mainTable.getValueAt(i, 26) == null ? "" : this.mainTable.getValueAt(i, 26).toString()); + sendSAPProcessBean.setSTATUS(""); + sendSAPProcessBean.setMESSAGE(""); + +// SI_TCM2SAP_CA21_OUTServiceStub stub = new SI_TCM2SAP_CA21_OUTServiceStub(); +// +// Authenticator basicAuth = new Authenticator(); +// +// List authSchemes = new ArrayList<>(); +// +// authSchemes.add(Authenticator.BASIC); +// +// basicAuth.setAuthSchemes(authSchemes); +// +// basicAuth.setUsername("chailian"); //TODO TCMCONN +// +// basicAuth.setPassword("1q2w1Q2W!.@"); // Zaq1xsw2 +// +// basicAuth.setPreemptiveAuthentication(true); +// +//// Authenticator basicAuth = new Authenticator(); +//// basicAuth.setUsername("TCMCONN"); +//// basicAuth.setPassword("Zaq1xsw2"); +// stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuth); +// stub._getServiceClient().getOptions().setProperty(Configuration.CHARACTER_SET_ENCODING, "GBK"); +// stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300 * 1000); +// stub._getServiceClient().getOptions().setProperty(Configuration.HTTP_METHOD, HTTPConstants.HTTP_METHOD_POST); +// +// MSG_HDR_type0 mt_person = new MSG_HDR_type0(); +// mt_person.setMSGID(sendSAPProcessBean.getMSGID()); +// mt_person.setBUSID(sendSAPProcessBean.getBUSID()); +// mt_person.setTLGID(sendSAPProcessBean.getTLGID()); +// mt_person.setLGNAME(sendSAPProcessBean.getTLGNAME()); +// mt_person.setDTSEND(sendSAPProcessBean.getDTSEND()); +// mt_person.setSENDER(sendSAPProcessBean.getSENDER()); +// mt_person.setRECEIVER(sendSAPProcessBean.getRECEIVER()); +// mt_person.setREEUSE(sendSAPProcessBean.getFREEUSE()); +// MSG_BODY_type0 body_type0 = new MSG_BODY_type0(); +// HEADER_type0 type0 = new HEADER_type0(); +// type0.setMATNR(sendSAPProcessBean.getMATNR()); +// type0.setWERKS(sendSAPProcessBean.getWERKS()); +// type0.setPLNNR(sendSAPProcessBean.getPLNNR()); +// type0.setPLNAL(sendSAPProcessBean.getPLNAL()); +// type0.setDATUV(sendSAPProcessBean.getDATUV()); +// type0.setVERWE(sendSAPProcessBean.getVERWE()); +// type0.setSTATU(sendSAPProcessBean.getSTATU()); +// type0.setVORNR(sendSAPProcessBean.getVORNR()); +// type0.setSTEUS(sendSAPProcessBean.getSTEUS()); +// type0.setARBPL(sendSAPProcessBean.getARBPL()); +// type0.setLTXA1(sendSAPProcessBean.getLTXA1()); +// type0.setBMSCH(sendSAPProcessBean.getBMSCH()); +// type0.setVGW01(sendSAPProcessBean.getVGW01()); +// type0.setVGE01(sendSAPProcessBean.getVGE01()); +// type0.setVGW02(sendSAPProcessBean.getVGW02()); +// type0.setVGE02(sendSAPProcessBean.getVGE02()); +// type0.setVGW03(sendSAPProcessBean.getVGW03()); +// type0.setVGE03(sendSAPProcessBean.getVGE03()); +// type0.setVGW04(sendSAPProcessBean.getVGW04()); +// type0.setVGE04(sendSAPProcessBean.getVGE04()); +// type0.setVGW05(sendSAPProcessBean.getVGW05()); +// type0.setVGE05(sendSAPProcessBean.getVGE05()); +// type0.setKZ(sendSAPProcessBean.getKZ()); +// +// body_type0.setHEADER(type0); +// +// // 调用接口 +// DT_TCM2SAP_CA21 tcm2sap_CBSJQ = new DT_TCM2SAP_CA21(); +// tcm2sap_CBSJQ.setMSG_HDR(mt_person); +// tcm2sap_CBSJQ.setMSG_BODY(body_type0); +// MT_TCM2SAP_CA21 tcm2sap_CBSJQ2 = new MT_TCM2SAP_CA21(); +// tcm2sap_CBSJQ2.setMT_TCM2SAP_CA21(tcm2sap_CBSJQ); +// DT_SAP2TCM_CA21 sap2tcm_CA21 = stub.SI_TCM2SAP_CA21_OUT(tcm2sap_CBSJQ2).getMT_SAP2TCM_CA21(); +// +//// String plnnr = sendSAPProcessBean.getPLNNR(); + // 获取配置信息中的url + InputStream in = ScreenShotTest.class.getResourceAsStream("/toERP.properties"); + Properties p = new Properties(); + p.load(in); + String url = "http://mlapp.meiling.com/plmwebapi/sap/setinfo"; +// String url = p.getProperty("url"); + MLtoERPEntity mLtoERPEntity = new MLtoERPEntity(); + mLtoERPEntity.setInfotype("工艺路线"); + mLtoERPEntity.setInfocode(session.getUser().getUserId()); + mLtoERPEntity.setInfoname(p.getProperty("infoname")); + mLtoERPEntity.setInfodesc(""); + List list1 = new ArrayList(); + List list2 = new ArrayList(); + + MLtoERPEntity2 field1 = new MLtoERPEntity2(); + field1.setField("MATNR"); + field1.setValue(sendSAPProcessBean.getMATNR()); + list1.add(field1); + MLtoERPEntity2 field2 = new MLtoERPEntity2(); + field2.setField("WERKS"); + field2.setValue(sendSAPProcessBean.getWERKS()); + list1.add(field2); + MLtoERPEntity2 field3 = new MLtoERPEntity2(); + field3.setField("PLNNR"); + field3.setValue(sendSAPProcessBean.getPLNNR()); + list1.add(field3); + MLtoERPEntity2 field4 = new MLtoERPEntity2(); + field4.setField("PLNAL"); + field4.setValue(sendSAPProcessBean.getPLNAL()); + list1.add(field4); + MLtoERPEntity2 field5 = new MLtoERPEntity2(); + field5.setField("DATUV"); + field5.setValue(sendSAPProcessBean.getDATUV()); + list1.add(field5); + MLtoERPEntity2 field6 = new MLtoERPEntity2(); + field6.setField("VERWE"); + field6.setValue(sendSAPProcessBean.getVERWE()); + list1.add(field6); + MLtoERPEntity2 field7 = new MLtoERPEntity2(); + field7.setField("STATU"); + field7.setValue(sendSAPProcessBean.getSTATU()); + list1.add(field7); + MLtoERPEntity2 field8 = new MLtoERPEntity2(); + field8.setField("VORNR"); + field8.setValue(sendSAPProcessBean.getVORNR()); + list1.add(field8); + MLtoERPEntity2 field9 = new MLtoERPEntity2(); + field9.setField("STEUS"); + field9.setValue(sendSAPProcessBean.getSTEUS()); + list1.add(field9); + MLtoERPEntity2 field10 = new MLtoERPEntity2(); + field10.setField("ARBPL"); + field10.setValue(sendSAPProcessBean.getARBPL()); + list1.add(field10); + MLtoERPEntity2 field11 = new MLtoERPEntity2(); + field11.setField("LTXA1"); + field11.setValue(sendSAPProcessBean.getLTXA1()); + list1.add(field11); + MLtoERPEntity2 field12 = new MLtoERPEntity2(); + field12.setField("BMSCH"); + field12.setValue(sendSAPProcessBean.getBMSCH()); + list1.add(field12); + MLtoERPEntity2 field13 = new MLtoERPEntity2(); + field13.setField("VGW01"); + field13.setValue(sendSAPProcessBean.getVGW01()); + list1.add(field13); + MLtoERPEntity2 field14 = new MLtoERPEntity2(); + field14.setField("VGE01"); + field14.setValue(sendSAPProcessBean.getVGE01()); + list1.add(field14); + MLtoERPEntity2 field15 = new MLtoERPEntity2(); + field15.setField("VGW02"); + field15.setValue(sendSAPProcessBean.getVGW02()); + list1.add(field15); + MLtoERPEntity2 field16 = new MLtoERPEntity2(); + field16.setField("VGE02"); + field16.setValue(sendSAPProcessBean.getVGE02()); + list1.add(field16); + MLtoERPEntity2 field17 = new MLtoERPEntity2(); + field17.setField("VGW03"); + field17.setValue(sendSAPProcessBean.getVGW03()); + list1.add(field17); + MLtoERPEntity2 field18 = new MLtoERPEntity2(); + field18.setField("VGE03"); + field18.setValue(sendSAPProcessBean.getVGE03()); + list1.add(field18); + MLtoERPEntity2 field19 = new MLtoERPEntity2(); + field19.setField("VGW04"); + field19.setValue(sendSAPProcessBean.getVGW04()); + list1.add(field19); + MLtoERPEntity2 field20 = new MLtoERPEntity2(); + field20.setField("VGE04"); + field20.setValue(sendSAPProcessBean.getVGE04()); + list1.add(field20); + MLtoERPEntity2 field21 = new MLtoERPEntity2(); + field21.setField("VGW05"); + field21.setValue(sendSAPProcessBean.getVGW05()); + list1.add(field21); + MLtoERPEntity2 field22 = new MLtoERPEntity2(); + field22.setField("VGE05"); + field22.setValue(sendSAPProcessBean.getVGE05()); + list1.add(field22); + MLtoERPEntity2 field23 = new MLtoERPEntity2(); + field23.setField("KZ"); + field23.setValue(sendSAPProcessBean.getKZ()); + list1.add(field23); + mLtoERPEntity.setData(list1); + mLtoERPEntity.setList(list2); + Gson gson = new Gson(); + String json = gson.toJson(mLtoERPEntity); + System.out.println("加贸工艺路线json"); + System.out.println(json); + String doPostResult = WebApiUtil.doPost(url, json); + MLRequestEntity resultEntity = gson.fromJson(doPostResult, MLRequestEntity.class); + String result = resultEntity.getResult(); + JSONObject fromObject = JSONObject.fromObject(result); + String PLNNRstr = fromObject.get("PLNNR").toString(); + System.out.println("getSTATUS:" + resultEntity.getErrcode()); + System.out.println("getMESSAGE:" + resultEntity.getErrmsg()); + System.out.println("getPLNNR:" + PLNNRstr); + +// if (sap2tcm_CA21.getSTATUS().equals("S")) { + if (resultEntity.getErrcode().equals("0")) { +// sendSAPProcessBean.setSTATUS(sap2tcm_CA21.getSTATUS()); +// sendSAPProcessBean.setMESSAGE(sap2tcm_CA21.getMESSAGE()); +// sendSAPProcessBean.setPLNNR(sap2tcm_CA21.getPLNNR()); + + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // 将数据写入到表中 + try { + String id = sendSAPProcessBean.getMATNR(), factory = sendSAPProcessBean.getWERKS(); + String key = id +"@@"+ factory; + if(searches.containsKey(key)) { + sendSAPProcessBean.setKZ(searches.get(key)); + }else { + String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), id, factory); + System.out.println(selectSql); + DbPool.getConnection(); + ResultSet rs = DbPool.executeSelectSql(selectSql); + if(rs.next()) { + sendSAPProcessBean.setKZ("U"); + searches.put(key, "U"); + String deleteSql = String.format(pro.getProperty("ML_TCMPROCESDELETESQL"), id, factory); + System.out.println("deleteSql == "+deleteSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(deleteSql); + DbPool.connection.commit(); + }else { + sendSAPProcessBean.setKZ("I"); + searches.put(key, "I"); + } + } + String insertSql = String.format(pro.getProperty("ML_TCMPROCESSINSERTSQL"), + UUID.randomUUID().toString().replace("-", ""), sendSAPProcessBean.getMSGID(), + sendSAPProcessBean.getBUSID(), sendSAPProcessBean.getTLGID(), + sendSAPProcessBean.getTLGNAME(), simpleDateFormat.format(new Date()), + sendSAPProcessBean.getSENDER(), sendSAPProcessBean.getRECEIVER(), + sendSAPProcessBean.getFREEUSE(), sendSAPProcessBean.getMATNR(), + sendSAPProcessBean.getWERKS(), PLNNRstr, + sendSAPProcessBean.getPLNAL(), sendSAPProcessBean.getDATUV(), + sendSAPProcessBean.getVERWE(), sendSAPProcessBean.getSTATU(), + sendSAPProcessBean.getVORNR(), sendSAPProcessBean.getSTEUS(), + sendSAPProcessBean.getARBPL(), sendSAPProcessBean.getLTXA1(), + sendSAPProcessBean.getBMSCH(), sendSAPProcessBean.getVGW01(), + sendSAPProcessBean.getVGE01(), sendSAPProcessBean.getVGW02(), + sendSAPProcessBean.getVGE02(), sendSAPProcessBean.getVGW03(), + sendSAPProcessBean.getVGE03(), sendSAPProcessBean.getVGW04(), + sendSAPProcessBean.getVGE04(), sendSAPProcessBean.getKZ(), + resultEntity.getErrcode(), resultEntity.getErrmsg(), + sendSAPProcessBean.getTYPE(), sendSAPProcessBean.getGROUPNAME(), + sendSAPProcessBean.getVGW05(),sendSAPProcessBean.getVGE05()); + System.out.println(insertSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } +// if (sap2tcm_CA21.getSTATUS().equals("E")) { + if (resultEntity.getErrcode().equals("1")) { + messageString.append("传递ERROR:"); + if (resultEntity.getErrcode() != null && !resultEntity.getErrcode().isEmpty()) { + messageString.append("【物料代码】:" +fromObject.getString("MATNR").toString()); + messageString.append("【工厂】:" +fromObject.getString("WERKS").toString()); + messageString.append("【组计数器】:" +fromObject.getString("PLNAL").toString()); + messageString.append("【发送失败】:" + resultEntity.getErrmsg()); + messageString.append("\n"); + } + } + System.out.println("groupMap:"+mainTable.getValueAt(i, 3)+" >> "+mainTable.getValueAt(i, 2)+" + "+mainTable.getValueAt(i, 25)); + groupMap.put(this.mainTable.getValueAt(i, 3).toString(), new String[] { this.mainTable.getValueAt(i, 2).toString(), + PLNNRstr }); + } + if (messageString.length() > 0) { + System.out.println("messageString:"+messageString); + MessageBox.post(messageString.toString(), "错误", MessageBox.ERROR); + } else { + MethodUtil.GetProductRev(result, session, true, groupMap); + this.dispose(); + } + } catch (Exception e2) { + // : handle exception + e2.printStackTrace(); + }finally { + if (input != null) { + try { + input.close(); + } catch (Exception e2) { + // Auto-generated catch block + e2.printStackTrace(); + } + } + } + } else if (source.equals(this.closeButton)) { + this.dispose(); + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomHandler.java new file mode 100644 index 0000000..b1e362a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/GetMBomHandler.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ML_13; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.ML_12.SendSpecialProcessToMesCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class GetMBomHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + GetMBomCommand command = new GetMBomCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/TableCellTextAreaRenderer.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/TableCellTextAreaRenderer.java new file mode 100644 index 0000000..a0d1295 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_13/TableCellTextAreaRenderer.java @@ -0,0 +1,164 @@ +package com.connor.ml.tcm.ML_13; + +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.JTextPane; +import javax.swing.table.TableCellRenderer; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; + +import com.connor.ml.tcm.util.MethodUtil; + +public class TableCellTextAreaRenderer extends JTextPane implements + TableCellRenderer { + private List processRows; + private Map> labelRows;//标注行 + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + } + + public Map> getLabelRows() { + return labelRows; + } + + public void setLabelRows(Map> labelRows) { + this.labelRows = labelRows; + } + + public TableCellTextAreaRenderer() { + // setLineWrap(true);//自动换行 + // setWrapStyleWord(true); + + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + int maxPreferredHeight = 0; + + setText(value == null ? "" : value.toString()); + if (table.getColumnName(column).equals("组名") && value != null && !value.toString().isEmpty()) + { + //获取工时费用等数据 + String[] values = MethodUtil.getProcessOther(table.getValueAt(row, column-1).toString(),value.toString()); + if(values != null && values.length >= 5) { + table.setValueAt(values[0], row, 15); + table.setValueAt(values[1], row, 17); + table.setValueAt(values[2], row, 19); + table.setValueAt(values[3], row, 21); + table.setValueAt(values[4], row, 23); + } + else + { + table.setValueAt("", row, 15); + table.setValueAt("", row, 17); + table.setValueAt("", row, 19); + table.setValueAt("", row, 21); + table.setValueAt("", row, 23); + } + } + + for (int i = 0; i < table.getColumnCount(); i++) { + setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + maxPreferredHeight = Math.max(maxPreferredHeight, + getPreferredSize().height); + } + + //判断单元格选中并且为可修改状态 + if (isSelected) { + // setBackground(new Color(0, 120, 215)); + //setBackground(Color.BLUE); + //setForeground(Color.black); + } + if (table.getRowHeight(row) != maxPreferredHeight)// 少了这行则处理器瞎忙 + { + table.setRowHeight(row, maxPreferredHeight); + } + return this; + } + + // 设置字体,如一个字符串中需要包含多个字体样式,可创建多个SimpleAttributeSet,并将字符串拆分开,按顺序使用Document的insertString方法插入 + private void setTextFont(String value, int index, String font) { + // TODO Auto-generated method stub + SimpleAttributeSet set = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set, font);// 设置字体样式 + SimpleAttributeSet set2 = new SimpleAttributeSet(); + // StyleConstants.setForeground(set, Color.red);//设置文字颜色 + StyleConstants.setFontFamily(set2, "Courier New");// 设置字体样式 + // StyleConstants.setFontSize(set2, 10); + Document doc = this.getStyledDocument(); + try { + // 插入前需要先删除 + doc.remove(0, value.toString().length()); + value = value.replaceAll(" ", ""); + doc.insertString(doc.getLength(), + value.toString().substring(0, index), set2); + doc.insertString(doc.getLength(), + value.toString().substring(index, index + 1), set); + doc.insertString( + doc.getLength(), + value.toString().substring(index + 1, + value.toString().length()), set2); + if (value.toString() + .substring(index + 1, value.toString().length()) == null + || value.toString() + .substring(index + 1, value.toString().length()) + .equals("")) { + doc.insertString(doc.getLength(), " ", set2); + } + } catch (BadLocationException e) { + e.printStackTrace(); + } finally { + set = null; + doc = null; + System.gc(); + } + } + // + // @Override + // public Component getTableCellRendererComponent(JTable table, Object + // value, boolean isSelected, boolean hasFocus, + // int row, int column) { + // // TODO Auto-generated method stub + // int maxPreferredHeight = 0; + // for (int i = 0; i < table.getColumnCount(); i++) { + // setText("" + table.getValueAt(row, i)); + // setSize(table.getColumnModel().getColumn(column).getWidth(), 0); + // maxPreferredHeight = Math.max(maxPreferredHeight, + // getPreferredSize().height); + // } + // setBorder(BorderFactory.createLineBorder(Color.white)); + // setBackground(Color.white); + // setForeground(Color.black); + // if(isSelected){ + // setBackground(new Color(0, 120, 215)); + // setForeground(Color.white); + // } + // String val=(String) table.getValueAt(row, column); + // int w=0; + // if(val!=null){ + // w=val.length()*6/table.getColumn(table.getColumnName(column)).getWidth(); + // } + // if(w!=0){ + // //System.out.println("height:"+table.getRowHeight()*(w+1)); + // table.setRowHeight(row,table.getRowHeight()*(w+1)); + // } + // + // + // setText(value == null ? "" : value.toString()); + // return this; + // } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetBatchNoDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetBatchNoDialog.java new file mode 100644 index 0000000..d43bbf8 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetBatchNoDialog.java @@ -0,0 +1,479 @@ +package com.connor.ml.tcm.ML_14; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import com.alibaba.fastjson.JSON; +import com.connor.ml.tcm.bean.SendOABean; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GetBatchNoDialog extends AbstractAIFDialog implements ActionListener { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private TCSession session; + + private JPanel mainPanel; + private JLabel batchNoLabel; + private JTextField batchNoTextField; + private JPanel rootPanel; + private JButton sendButton; + private JButton closeButton; + + public GetBatchNoDialog(TCSession session) { + // Auto-generated constructor stub + this.session = session; + + init(); + } + + private void init() { + // Auto-generated method stub + this.setTitle("获取加贸BOM"); + this.setPreferredSize(new Dimension(300, 130)); + + this.mainPanel = new JPanel(new FlowLayout()); + this.batchNoLabel = new JLabel("批次号:"); + this.batchNoLabel.setPreferredSize(new Dimension(50, 30)); + this.batchNoTextField = new JTextField(); + this.batchNoTextField.setPreferredSize(new Dimension(150, 30)); + + this.mainPanel.add(batchNoLabel); + this.mainPanel.add(batchNoTextField); + + this.rootPanel = new JPanel(new FlowLayout()); + this.sendButton = new JButton("获取"); + this.closeButton = new JButton("取消"); + + this.rootPanel.add(sendButton); + this.rootPanel.add(closeButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(mainPanel, BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); + this.setVisible(true); + } + + // 添加监听 + public void createActionEvent() { + this.sendButton.addActionListener(this); + this.closeButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.sendButton)) { + //调用加贸接口传递批号 + try { + SendOABean sendOABean = new SendOABean(); + sendOABean.setInfotype("加贸自制件"); + sendOABean.setInfocode(this.batchNoTextField.getText()); + sendOABean.setInfoname("获取加贸信息"); +// +// SendOAPropertyBean sendOAPropertyBean = new SendOAPropertyBean(); +// sendOAPropertyBean.setField("批号"); +// sendOAPropertyBean.setValue(this.batchNoTextField.getText()); +// +// List sendOAPropertyBeanList = new ArrayList(); +// sendOAPropertyBeanList.add(sendOAPropertyBean); +// +// sendOABean.setData(sendOAPropertyBeanList); + + String json=JSON.toJSONString(sendOABean); + System.out.println(json); + String result = MethodUtil.sendPost("http://mlapp.meiling.com/mlwebapi/plm/getinfo", json); + + if(result.indexOf("\"errcode\":\"1\"") >= 0) + { + MessageBox.post(result,"失败", MessageBox.ERROR); + return; + } + System.out.println(result); + + + MethodUtil.GetProductRev(result, session, false, null); + + //获取返回结果 +// JSONObject resultJson = JSONObject.fromObject(result); +// +// JSONArray jsonArray = resultJson.getJSONArray("list"); +// List> dataList = new ArrayList>(); +// List> haveList = new ArrayList>(); +// for (int i=0; i < jsonArray.size(); i++) { +// +// //获取物料代码、物料描述、工厂、产线、可选BOM信息 +// String itemId = ""; +// String objectName = ""; +// String factory = ""; +// String lineCode = ""; +// String bom = ""; +// JSONObject jsonObject = jsonArray.getJSONObject(i); +// Iterator iter = jsonObject.entrySet().iterator(); +// while (iter.hasNext()) { +// Map.Entry entry = (Map.Entry) iter.next(); +// switch (entry.getKey().toString()) { +// case "物料编码": +// itemId = entry.getValue().toString(); +// break; +// case "物料描述": +// objectName = entry.getValue().toString(); +// break; +// case "工厂": +// factory = entry.getValue().toString(); +// break; +// case "物料线体": +// lineCode = entry.getValue().toString(); +// break; +// case "可选的BOM": +// bom = entry.getValue().toString(); +// break; +// default: +// break; +// } +// } +// if(itemId.indexOf("-") > 0) +// { +// itemId = itemId.split("-")[0]; +// } +// //根据产线获取分类中的ERP班组编码 +// TCClassificationService classificationService = session +// .getClassificationService(); +// ICSSearchResult[] results = classificationService.searchICOs( +// "组计数器字典", null, 0); +// String ERPCode = ""; +// String line = ""; +// for (int j = 0; j < results.length ; j++) { +// String icoUID = results[j].getIcoUid(); +// TCComponentICO ico = (TCComponentICO) session +// .stringToComponent(icoUID); +// ico.getClassifiedObject(); +// ICSProperty[] icsProps = ico.getICSProperties(true); +// +// ICSPropertyDescription[] icsDs = ico +// .getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// if (icsD.getName().compareTo("ERP班组编码") == 0) { +// ERPCode = value; +// } +// if (icsD.getName().compareTo("产线") == 0) { +// line = value; +// } +// } +// if(line.compareTo(lineCode) == 0) +// { +// break; +// } +// } +// // 将结果保存 +// List> classValueList = new ArrayList>(); +// //根据产线(对应TCM的‘ERP班组编码’)从“组计数器”分类库中获取数据 +// boolean isClassHave = false; +// String productionRev = ""; +// String lineName = ""; +// String classLineCode = ""; +// String groupNo = ""; +// String workCenter = ""; +// String receiveLocation = ""; +// String storageLocation = ""; +// String classERPCode = ""; +// String classFactory = ""; +// for (int j = 0; j < results.length ; j++) { +// String icoUID = results[j].getIcoUid(); +// TCComponentICO ico = (TCComponentICO) session +// .stringToComponent(icoUID); +// ico.getClassifiedObject(); +// ICSProperty[] icsProps = ico.getICSProperties(true); +// +// ICSPropertyDescription[] icsDs = ico +// .getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// if (icsD.getName().compareTo("ERP班组编码") == 0) { +// classERPCode = value; +// } +// if (icsD.getName().compareTo("工厂") == 0) { +// classFactory = value; +// } +// if (icsD.getName().compareTo("生产版本") == 0) { +// productionRev = value; +// } +// if (icsD.getName().compareTo("产线名称") == 0) { +// lineName = value; +// } +// if (icsD.getName().compareTo("产线代码") == 0) { +// classLineCode = value; +// } +// if (icsD.getName().compareTo("组计数器") == 0) { +// groupNo = value; +// } +// if (icsD.getName().compareTo("接收位置") == 0) { +// receiveLocation = value; +// } +// if (icsD.getName().compareTo("发货仓储位置") == 0) { +// storageLocation = value; +// } +// if (icsD.getName().compareTo("工作中心") == 0) { +// workCenter = value; +// } +// } +// if(classERPCode.compareTo(ERPCode) == 0 && classFactory.compareTo(factory) == 0) +// { +// List valueList = new ArrayList(); +// valueList.add(productionRev); +// valueList.add(lineName); +// valueList.add(groupNo); +// valueList.add(workCenter); +// valueList.add(receiveLocation); +// valueList.add(storageLocation); +// valueList.add(classLineCode); +// classValueList.add(valueList); +// } +// } +// String type = "零部件"; +// if(itemId.indexOf("ML") == 0) +// { +// type = "产品"; +// } +// if (classValueList.size() <= 0) { +// MessageBox.post("通过工厂:" + factory + "ERPCode:" + ERPCode + "类别:" + type + "未找到数据!", "错误", +// MessageBox.ERROR); +// return; +// } +// List productionRevList = new ArrayList(); +// for (int ii = 0; ii < classValueList.size(); ii++) { +// List valueList = classValueList.get(ii); +// +// productionRev = valueList.get(0); +// lineName = valueList.get(1); +// groupNo = valueList.get(2); +// workCenter = valueList.get(3); +// receiveLocation = valueList.get(4); +// storageLocation = valueList.get(5); +// classLineCode = valueList.get(6); +// +// if (productionRevList.contains(productionRev)) { +// continue; +// } else { +// productionRevList.add(productionRev); +// } +// +// //根据物料编码、工厂、组计数器从工艺路线表中查询出工艺路线组的值 +// InputStream input = null; +// ResultSet rs = null; +// boolean isHave = false; +// try { +// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// String selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), itemId, factory, +// lineCode); +// System.out.println(selectSql); +// DbPool.getConnection(); +// rs = DbPool.executeSelectSql(selectSql); +// +// if (rs != null) { +// while (rs.next()) { +// //添加数据 +// List valuesList = new ArrayList(); +// valuesList.add(itemId); +// valuesList.add(factory); +// valuesList.add(productionRev); +// valuesList.add(lineName); +// valuesList.add("20210101"); +// valuesList.add("99991231"); +// valuesList.add(classLineCode + "1"); +// valuesList.add("1"); +// valuesList.add(rs.getString("PLNNR")); +// valuesList.add(groupNo); +// valuesList.add(workCenter); +// valuesList.add(receiveLocation); +// valuesList.add(storageLocation); +//// +//// +//// valuesList.add(rs.getString("MATNR")); +//// valuesList.add(rs.getString("WERKS")); +//// valuesList.add(rs.getString("VERID")); +//// valuesList.add(rs.getString("TEXT1")); +//// valuesList.add("20200101"); +//// valuesList.add("99991231"); +//// valuesList.add(rs.getString("STLAL")); +//// valuesList.add("1"); +//// valuesList.add(rs.getString("PLNNR")); +//// valuesList.add(rs.getString("ALNAL")); +//// valuesList.add(rs.getString("MDV01")); +//// valuesList.add(rs.getString("ALORT")); +//// valuesList.add(rs.getString("ELPRO")); +// valuesList.add("U"); +// +// dataList.add(valuesList); +// haveList.add(valuesList); +// isHave = true; +// break; +// } +// } +// } catch (Exception e2) { +// MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); +// e2.printStackTrace(); +// } finally { +// if (input != null) { +// try { +// input.close(); +// } catch (IOException e2) { +// // Auto-generated catch block +// e2.printStackTrace(); +// } +// } +// if (rs != null) { +// try { +// rs.close(); +// } catch (SQLException e2) { +// e2.printStackTrace(); +// } +// } +// DbPool.freeAll(); +// } +// +// if(!isHave) +// { +// String processGroup = ""; +// InputStream input2 = null; +// ResultSet rs2 = null; +// try { +// input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); +// Properties pro = new Properties(); +// pro.load(input); +// String selectSql = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL"), itemId, factory, +// groupNo); +// System.out.println(selectSql); +// DbPool.getConnection(); +// rs2 = DbPool.executeSelectSql(selectSql); +// +// if (rs2 != null) { +// while (rs2.next()) { +// processGroup = rs2.getString("PLNNR"); +// } +// } +// } catch (Exception e2) { +// MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); +// e2.printStackTrace(); +// } finally { +// if (input2 != null) { +// try { +// input2.close(); +// } catch (IOException e2) { +// // Auto-generated catch block +// e2.printStackTrace(); +// } +// } +// if (rs2 != null) { +// try { +// rs2.close(); +// } catch (SQLException e2) { +// e2.printStackTrace(); +// } +// } +// DbPool.freeAll(); +// } +// //获取前趋任务 +//// TCComponentScheduleTask AA = null; +//// +//// TCProperty property = AA.getTCProperty("TaskDependency"); +// +// //添加数据 +// List valuesList = new ArrayList(); +// valuesList.add(itemId); +// valuesList.add(factory); +// valuesList.add(productionRev); +// valuesList.add(lineName); +// valuesList.add("20210101"); +// valuesList.add("99991231"); +// valuesList.add(classLineCode + "1"); +// valuesList.add("1"); +// valuesList.add(processGroup); +// valuesList.add(groupNo); +// valuesList.add(workCenter); +// valuesList.add(receiveLocation); +// valuesList.add(storageLocation); +// valuesList.add("I"); +// +// dataList.add(valuesList); +// } +// +// } +// } +// +// if(haveList.size() > 0) +// { +// StringBuilder haveStringBuilder = new StringBuilder(); +// for (int i = 0; i < haveList.size(); i++) { +// haveStringBuilder.append("物料:"); +// haveStringBuilder.append(haveList.get(i).get(0)); +// haveStringBuilder.append("工厂:"); +// haveStringBuilder.append(haveList.get(i).get(1)); +// haveStringBuilder.append("组计数器:"); +// haveStringBuilder.append(haveList.get(i).get(9)); +// haveStringBuilder.append("\n"); +// } +// +// int i = JOptionPane.showConfirmDialog(null, haveStringBuilder+"已传递过生产版本,是否重新传递?", "重新传递", JOptionPane.YES_NO_OPTION); +// if (i != JOptionPane.YES_OPTION) { +// dataList.removeAll(haveList); +// } +// } +// +// new Thread() { +// @Override +// public void run() { +// SendProductRevDialog dialog = new SendProductRevDialog(session, dataList); +// } +// }.start(); + } catch (Exception e1) { + // Auto-generated catch block + e1.printStackTrace(); + } + + } + else if (source.equals(this.closeButton)) { + this.dispose(); + } + } + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevCommand.java new file mode 100644 index 0000000..f266a98 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevCommand.java @@ -0,0 +1,36 @@ +package com.connor.ml.tcm.ML_14; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCSession; + +public class GetProductRevCommand extends AbstractAIFCommand { + +// private InterfaceAIFComponent comp; + private TCSession session; +// private boolean isProcess = false; + + public GetProductRevCommand(InterfaceAIFComponent comp, TCSession session) { + // Auto-generated constructor stub +// this.comp = comp; + this.session = session; + } + + public GetProductRevCommand(InterfaceAIFComponent comp, TCSession session, boolean isProcess) { + // Auto-generated constructor stub +// this.comp = comp; + this.session = session; +// this.isProcess = isProcess; + } + @Override + public void executeModal() throws Exception { + // Auto-generated method stub + new Thread() { + @Override + public void run() { + new GetBatchNoDialog(session); + } + }.start(); + super.executeModal(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevDialog.java new file mode 100644 index 0000000..e64efa1 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevDialog.java @@ -0,0 +1,443 @@ +package com.connor.ml.tcm.ML_14; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Properties; +import java.util.UUID; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.axis2.Constants.Configuration; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HttpTransportProperties; +import org.apache.axis2.transport.http.HttpTransportProperties.Authenticator; + +import com.connor.ml.tcm.ML_08.SI_TCM2SAP_C223_OUTServiceStub; +import com.connor.ml.tcm.ML_08.SI_TCM2SAP_C223_OUTServiceStub.DT_TCM2SAP_C223; +import com.connor.ml.tcm.ML_08.SI_TCM2SAP_C223_OUTServiceStub.HEADER_type0; +import com.connor.ml.tcm.ML_08.SI_TCM2SAP_C223_OUTServiceStub.MSG_BODY_type0; +import com.connor.ml.tcm.ML_08.SI_TCM2SAP_C223_OUTServiceStub.MSG_HDR_type0; +import com.connor.ml.tcm.ML_08.SI_TCM2SAP_C223_OUTServiceStub.MT_SAP2TCM_C223; +import com.connor.ml.tcm.ML_08.SI_TCM2SAP_C223_OUTServiceStub.MT_TCM2SAP_C223; +import com.connor.ml.tcm.ML_18.ScreenShotTest; +import com.connor.ml.tcm.bean.SendSAPProductRevBean; +import com.connor.ml.tcm.cloneProcess.WebApiUtil; +import com.connor.ml.tcm.util.DbPool; +import com.connor.ml.tcm.util.MLRequestEntity; +import com.connor.ml.tcm.util.MLtoERPEntity; +import com.connor.ml.tcm.util.MLtoERPEntity2; +import com.connor.ml.tcm.util.MethodUtil; +import com.google.gson.Gson; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONObject; + +public class GetProductRevDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private String[] columns = new String[] { "物料代码","工厂","生产版本号","版本描述", "有效期始", "有效期止", "可选BOM" + , "BOM用途", "工艺路线组", "组计数器", "工作中心", "接收位置", "发货仓储地点","处理标记"}; + + private List> dataTableList; + private Object[][] values; + + //系统界面 + private JTable mainTable; + + private JPanel rootPanel; + private JButton sendButton; + private JButton closeButton; + + public GetProductRevDialog(TCSession session, List> dataTableList) { + // TODO Auto-generated constructor stub + this.session = session; + this.dataTableList = dataTableList; + + //根据查询获取对象 + this.values=new String[this.dataTableList.size()][]; + for (int i = 0; i < this.dataTableList.size(); i++) { + this.values[i]=new String[this.dataTableList.get(i).size()]; + for (int j = 0; j < this.dataTableList.get(i).size(); j++) { + this.values[i][j]=this.dataTableList.get(i).get(j); + } + } + + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("传递的生产版本数据"); + this.setPreferredSize(new Dimension(800, 600)); + + this.mainTable = getjTable(mainTable, null, columns, values); + this.addData(values); + this.rootPanel = new JPanel(new FlowLayout()); + this.sendButton = new JButton("传递"); + this.closeButton = new JButton("取消"); + + this.rootPanel.add(sendButton); + this.rootPanel.add(closeButton); + // this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(new JScrollPane(this.mainTable), BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + // this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + + // 添加监听 + public void createActionEvent() { + this.sendButton.addActionListener(this); + this.closeButton.addActionListener(this); + } + + /*** + * Jtable通用方法 + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(30); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames); + } + return tableModel; + } + + public void addData(Object[][] cellData) { + DefaultTableModel tableModel = (DefaultTableModel) this.mainTable + .getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter(this.getTableModel(null, this.columns, cellData)); + this.mainTable.setRowSorter(sorter); + for (int i = 0; i < cellData.length; i++) { + tableModel.addRow(cellData[i]); + } + // 表格数据不可修改 + this.mainTable.setEnabled(true); + // 更新表格 + this.mainTable.invalidate(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.sendButton)) { + try { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + StringBuffer messageString = new StringBuffer(); + for (int i = 0; i < this.mainTable.getRowCount(); i++) { + SendSAPProductRevBean sendSAPProductRevBean = new SendSAPProductRevBean(); + sendSAPProductRevBean.setMSGID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setBUSID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setTLGID("JT0001"); + sendSAPProductRevBean.setTLGNAME("维护生产版本接口"); + sendSAPProductRevBean.setDTSEND(sdf.format(new Date())); + sendSAPProductRevBean.setSENDER("TCM"); + sendSAPProductRevBean.setRECEIVER("SAP"); + sendSAPProductRevBean.setFREEUSE(""); + sendSAPProductRevBean.setMATNR(this.mainTable.getValueAt(i, 0) == null ? "":this.mainTable.getValueAt(i, 0).toString()); + sendSAPProductRevBean.setWERKS(this.mainTable.getValueAt(i, 1) == null ? "":this.mainTable.getValueAt(i, 1).toString()); + sendSAPProductRevBean.setVERID(this.mainTable.getValueAt(i, 2) == null ? "":this.mainTable.getValueAt(i, 2).toString()); + sendSAPProductRevBean.setTEXT1(this.mainTable.getValueAt(i, 3) == null ? "":this.mainTable.getValueAt(i, 3).toString()); + sendSAPProductRevBean.setADATU(this.mainTable.getValueAt(i, 4) == null ? "":this.mainTable.getValueAt(i, 4).toString()); + sendSAPProductRevBean.setBDATU(this.mainTable.getValueAt(i, 5) == null ? "":this.mainTable.getValueAt(i, 5).toString()); + sendSAPProductRevBean.setSTLAL(this.mainTable.getValueAt(i, 6) == null ? "":this.mainTable.getValueAt(i, 6).toString()); + sendSAPProductRevBean.setSTLAN(this.mainTable.getValueAt(i, 7) == null ? "":this.mainTable.getValueAt(i, 7).toString()); + sendSAPProductRevBean.setPLNNR(this.mainTable.getValueAt(i, 8) == null ? "":this.mainTable.getValueAt(i, 8).toString()); + sendSAPProductRevBean.setALNAL(this.mainTable.getValueAt(i, 9) == null ? "":this.mainTable.getValueAt(i, 9).toString()); + sendSAPProductRevBean.setMDV01(this.mainTable.getValueAt(i, 10) == null ? "":this.mainTable.getValueAt(i, 10).toString()); + sendSAPProductRevBean.setALORT(this.mainTable.getValueAt(i, 11) == null ? "":this.mainTable.getValueAt(i, 11).toString()); + sendSAPProductRevBean.setELPRO(this.mainTable.getValueAt(i, 12) == null ? "":this.mainTable.getValueAt(i, 12).toString()); + sendSAPProductRevBean.setKZ(this.mainTable.getValueAt(i, 13) == null ? "":this.mainTable.getValueAt(i, 13).toString()); + +// SI_TCM2SAP_C223_OUTServiceStub stub = new SI_TCM2SAP_C223_OUTServiceStub(); +// +// HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator(); +// +// List authSchemes = new ArrayList(); +// +// authSchemes.add(Authenticator.BASIC); +// +// basicAuth.setAuthSchemes(authSchemes); +// +// basicAuth.setUsername("chailian"); // Set your value +// +// basicAuth.setPassword("1q2w1Q2W!.@"); // Set your value +// +// basicAuth.setPreemptiveAuthentication(true); +// +//// Authenticator basicAuth = new Authenticator(); +//// basicAuth.setUsername("TCMCONN"); +//// basicAuth.setPassword("Zaq1xsw2"); +// stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, basicAuth); +// stub._getServiceClient().getOptions().setProperty(Configuration.CHARACTER_SET_ENCODING, "GBK"); +// stub._getServiceClient().getOptions().setTimeOutInMilliSeconds(300 * 1000); +// stub._getServiceClient().getOptions().setProperty(Configuration.HTTP_METHOD, +// HTTPConstants.HTTP_METHOD_POST); +// +// MSG_HDR_type0 mt_person = new MSG_HDR_type0(); +// mt_person.setMSGID(sendSAPProductRevBean.getMSGID()); +// mt_person.setBUSID(sendSAPProductRevBean.getBUSID()); +// mt_person.setTLGID(sendSAPProductRevBean.getTLGID()); +// mt_person.setLGNAME(sendSAPProductRevBean.getTLGNAME()); +// mt_person.setDTSEND(sendSAPProductRevBean.getDTSEND()); +// mt_person.setSENDER(sendSAPProductRevBean.getSENDER()); +// mt_person.setRECEIVER(sendSAPProductRevBean.getRECEIVER()); +// mt_person.setREEUSE(sendSAPProductRevBean.getFREEUSE()); +// MSG_BODY_type0 body_type0 = new MSG_BODY_type0(); +// HEADER_type0 type0 = new HEADER_type0(); +// type0.setMATNR(sendSAPProductRevBean.getMATNR()); +// type0.setWERKS(sendSAPProductRevBean.getWERKS()); +// type0.setVERID(sendSAPProductRevBean.getVERID()); +// type0.setTEXT1(sendSAPProductRevBean.getTEXT1()); +// type0.setADATU(sendSAPProductRevBean.getADATU()); +// type0.setBDATU(sendSAPProductRevBean.getBDATU()); +// type0.setSTLAL(sendSAPProductRevBean.getSTLAL()); +// type0.setSTLAN(sendSAPProductRevBean.getSTLAN()); +// type0.setPLNNR(sendSAPProductRevBean.getPLNNR()); +// type0.setALNAL(sendSAPProductRevBean.getALNAL()); +// type0.setMDV01(sendSAPProductRevBean.getMDV01()); +// type0.setALORT(sendSAPProductRevBean.getALORT()); +// type0.setELPRO(sendSAPProductRevBean.getELPRO()); +// type0.setKZ(sendSAPProductRevBean.getKZ()); +// +// body_type0.setHEADER(type0); +// +// // 调用接口 +// DT_TCM2SAP_C223 tcm2sap_CBSJQ = new DT_TCM2SAP_C223(); +// tcm2sap_CBSJQ.setMSG_HDR(mt_person); +// tcm2sap_CBSJQ.setMSG_BODY(body_type0); +// MT_TCM2SAP_C223 tcm2sap_CBSJQ2 = new MT_TCM2SAP_C223(); +// tcm2sap_CBSJQ2.setMT_TCM2SAP_C223(tcm2sap_CBSJQ); +// MT_SAP2TCM_C223 sap2tcm_CA21 = stub.SI_TCM2SAP_C223_OUT(tcm2sap_CBSJQ2); + + // 获取配置信息中的url + InputStream in = ScreenShotTest.class.getResourceAsStream("/toERP.properties"); + Properties p = new Properties(); + p.load(in); + String url = "http://mlapp.meiling.com/plmwebapi/sap/setinfo"; +// String url = p.getProperty("url"); + MLtoERPEntity mLtoERPEntity = new MLtoERPEntity(); + mLtoERPEntity.setInfotype("生产版本"); + mLtoERPEntity.setInfocode(session.getUser().getUserId()); + mLtoERPEntity.setInfoname(p.getProperty("infoname")); + mLtoERPEntity.setInfodesc(""); + List list1 = new ArrayList(); + List list2 = new ArrayList(); + + MLtoERPEntity2 field1 = new MLtoERPEntity2(); + field1.setField("MATNR"); + field1.setValue(sendSAPProductRevBean.getMATNR()); + list1.add(field1); + MLtoERPEntity2 field2 = new MLtoERPEntity2(); + field2.setField("WERKS"); + field2.setValue(sendSAPProductRevBean.getWERKS()); + list1.add(field2); + MLtoERPEntity2 field3 = new MLtoERPEntity2(); + field3.setField("VERID"); + field3.setValue(sendSAPProductRevBean.getVERID()); + list1.add(field3); + MLtoERPEntity2 field4 = new MLtoERPEntity2(); + field4.setField("TEXT1"); + field4.setValue(sendSAPProductRevBean.getTEXT1()); + list1.add(field4); + MLtoERPEntity2 field5 = new MLtoERPEntity2(); + field5.setField("ADATU"); + field5.setValue(sendSAPProductRevBean.getADATU()); + list1.add(field5); + MLtoERPEntity2 field6 = new MLtoERPEntity2(); + field6.setField("BDATU"); + field6.setValue(sendSAPProductRevBean.getBDATU()); + list1.add(field6); + MLtoERPEntity2 field7 = new MLtoERPEntity2(); + field7.setField("STLAL"); + field7.setValue(sendSAPProductRevBean.getSTLAL()); + list1.add(field7); + MLtoERPEntity2 field8 = new MLtoERPEntity2(); + field8.setField("STLAN"); + field8.setValue(sendSAPProductRevBean.getSTLAN()); + list1.add(field8); + MLtoERPEntity2 field9 = new MLtoERPEntity2(); + field9.setField("PLNNR"); + field9.setValue(sendSAPProductRevBean.getPLNNR()); + list1.add(field9); + MLtoERPEntity2 field10 = new MLtoERPEntity2(); + field10.setField("ALNAL"); + field10.setValue(sendSAPProductRevBean.getALNAL()); + list1.add(field10); + MLtoERPEntity2 field11 = new MLtoERPEntity2(); + field11.setField("MDV01"); + field11.setValue(sendSAPProductRevBean.getMDV01()); + list1.add(field11); + MLtoERPEntity2 field12 = new MLtoERPEntity2(); + field12.setField("ALORT"); + field12.setValue(sendSAPProductRevBean.getALORT()); + list1.add(field12); + MLtoERPEntity2 field13 = new MLtoERPEntity2(); + field13.setField("ELPRO"); + field13.setValue(sendSAPProductRevBean.getELPRO()); + list1.add(field13); + mLtoERPEntity.setData(list1); + mLtoERPEntity.setList(list2); + Gson gson = new Gson(); + String json = gson.toJson(mLtoERPEntity); + System.out.println(json); + String doPostResult = WebApiUtil.doPost(url, json); + MLRequestEntity resultEntity = gson.fromJson(doPostResult, MLRequestEntity.class); + String result = resultEntity.getResult(); + JSONObject fromObject = JSONObject.fromObject(result); + + System.out.println("当前数据库操作类型 UorI "+sendSAPProductRevBean.getKZ() + +"生产版本号"+sendSAPProductRevBean.getVERID()+"传递结果 SorE"+resultEntity.getErrcode()); + +// if(sap2tcm_CA21.getMT_SAP2TCM_C223().getSTATUS().equals("S") || sap2tcm_CA21.getMT_SAP2TCM_C223().getSTATUS().equals("E")) + if(resultEntity.getErrcode().equals("0") || resultEntity.getErrcode().equals("1")) + { + //将数据写入到表中 + InputStream input = null; + try { + input = new BufferedInputStream(getClass().getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVINSERTSQL"), UUID.randomUUID().toString().replace("-", ""), + sendSAPProductRevBean.getMSGID(),sendSAPProductRevBean.getBUSID(),sendSAPProductRevBean.getTLGID(),sendSAPProductRevBean.getTLGNAME(), + sendSAPProductRevBean.getDTSEND(),sendSAPProductRevBean.getSENDER(),sendSAPProductRevBean.getRECEIVER(),sendSAPProductRevBean.getFREEUSE(), + sendSAPProductRevBean.getMATNR(),sendSAPProductRevBean.getWERKS(),sendSAPProductRevBean.getVERID(),sendSAPProductRevBean.getTEXT1(), + sendSAPProductRevBean.getADATU(),sendSAPProductRevBean.getBDATU(),sendSAPProductRevBean.getSTLAL(),sendSAPProductRevBean.getSTLAN(), + sendSAPProductRevBean.getPLNNR(),sendSAPProductRevBean.getALNAL(),sendSAPProductRevBean.getMDV01(),sendSAPProductRevBean.getALORT(), + sendSAPProductRevBean.getELPRO(),resultEntity.getErrcode(),resultEntity.getErrmsg()); + if (sendSAPProductRevBean.getKZ().equals("U")) { + insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVUPDATESQL"), +// sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), +// sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getVERID(), +// sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), +// sendSAPProductRevBean.getBDATU(), //sendSAPProductRevBean.getSTLAL(), +// sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), +// sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), +// sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), + //sap2tcm_CA21.getMT_SAP2TCM_C223().getSTATUS(),sap2tcm_CA21.getMT_SAP2TCM_C223().getMESSAGE(), +// sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), +// sendSAPProductRevBean.getSTLAL()); + sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), + sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getVERID(), + sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), + sendSAPProductRevBean.getBDATU(), //sendSAPProductRevBean.getSTLAL(), + sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), + sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), + sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), + resultEntity.getErrcode(),resultEntity.getErrmsg(), + sendSAPProductRevBean.getSTLAL(), + sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), + sendSAPProductRevBean.getALNAL(),sendSAPProductRevBean.getVERID()); + } + System.out.println(insertSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception e2) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", MessageBox.ERROR); + e2.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + } + DbPool.freeAll(); + } + } + +// if (sap2tcm_CA21.getMT_SAP2TCM_C223().getMESSAGE() != null +// && !sap2tcm_CA21.getMT_SAP2TCM_C223().getMESSAGE().isEmpty()) { + if (resultEntity.getErrcode() != null + && !resultEntity.getErrcode().isEmpty()) { + if(resultEntity.getErrcode().equals("1")) + { + messageString.append("【物料代码】:"+fromObject.getString("MATNR").toString()); + messageString.append("【工厂】:"+fromObject.getString("WERKS").toString()); + messageString.append("【生产版本】:"+fromObject.getString("VERID").toString()); + messageString.append("【发送失败】:"+resultEntity.getErrmsg()); + messageString.append("\n"); + } + } + } + System.out.println(messageString); +// if(messageString.length() > 0) +// { +// MessageBox.post(messageString.toString(), "错误", MessageBox.ERROR); +// } +// else +// { +// MessageBox.post("发送成功!", "成功", MessageBox.INFORMATION); +// } + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + else if (source.equals(this.closeButton)) { + this.dispose(); + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevHandler.java new file mode 100644 index 0000000..e15d5c5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_14/GetProductRevHandler.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ML_14; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.ML_08.SendProductRevCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class GetProductRevHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + GetProductRevCommand command = new GetProductRevCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_15/CreateItemHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_15/CreateItemHandler.java new file mode 100644 index 0000000..2ddf7bc --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_15/CreateItemHandler.java @@ -0,0 +1,18 @@ +package com.connor.ml.tcm.ML_15; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +public class CreateItemHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String commandId = arg0.getCommand().getId(); + CreateNewBOHandler handler = new CreateNewBOHandler(commandId); + handler.execute(arg0); + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_15/CreateNewBOHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_15/CreateNewBOHandler.java new file mode 100644 index 0000000..d5f6bd1 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_15/CreateNewBOHandler.java @@ -0,0 +1,199 @@ +package com.connor.ml.tcm.ML_15; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExecutableExtension; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.handlers.HandlerUtil; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.SelectionHelper; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.ui.commands.Messages; +import com.teamcenter.rac.ui.commands.RACUICommandsActivator; +import com.teamcenter.rac.ui.commands.create.bo.NewBOModel; +import com.teamcenter.rac.ui.commands.create.bo.NewBOWizard; +import com.teamcenter.rac.util.SWTUIUtilities; +import com.teamcenter.rac.util.UIUtilities; +import com.teamcenter.rac.util.wizard.extension.BaseExternalWizardDialog; +import com.teamcenter.rac.util.wizard.extension.WizardExtensionHelper; + +/** + * Our sample handler extends AbstractHandler, an IHandler base class. + * + * @see org.eclipse.core.commands.IHandler + * @see org.eclipse.core.commands.AbstractHandler + */ +public class CreateNewBOHandler extends AbstractHandler implements + IExecutableExtension { + private String itemtype; + + public CreateNewBOHandler(String itemtype) { + this.itemtype = itemtype; + } + + private class CreateNewBOSWTDialog implements Runnable { + + public void run() { + NewBOWizard newbowizard = (NewBOWizard) getWizard(); + if (newbowizard == null) + newbowizard = new NewBOWizard(wizardId); + m_boModel.setSession(session); + m_boModel.reInitializeTransientData(); + newbowizard.setBOModel(m_boModel); + newbowizard.setShell(m_shell); + newbowizard.setParentFrame(AIFUtility.getActiveDesktop()); + newbowizard.setTargetArray(selectedCmps); + newbowizard.setCurrentSelection(m_currentSelection); + newbowizard.setWindowTitle(getWizardTitle()); + newbowizard.setRevisionFlag(m_revisionFlag); + newbowizard.setDefaultType(m_type); + m_boModel.setRevisionFlag(m_revisionFlag); + // newbowizard.setWizardId("123"); + Shell shell = UIUtilities.getCurrentModalShell(); + dialog = new BaseExternalWizardDialog(m_shell, newbowizard); + dialog.create(); + newbowizard.retrievePersistedDialogSettings(dialog); + newbowizard.setWizardDialog(dialog); + UIUtilities.setCurrentModalShell(dialog.getShell()); + dialog.open(); +// InterfaceAIFComponent[] aifComponent = m_boModel.getTargetArray(); +// if(aifComponent != null && aifComponent.length > 0) +// { +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.cme.mpp.MSEPerspective", +// aifComponent); +// } + dialog = null; + m_boModel = null; + UIUtilities.setCurrentModalShell(shell); + System.out.println("关闭"); + } + + private final Shell m_shell; + private boolean m_revisionFlag = false; + private final String m_type; + final CreateNewBOHandler this$0; + + private CreateNewBOSWTDialog(Shell shell, boolean flag, String s) { + super(); + this$0 = CreateNewBOHandler.this; + m_shell = shell; + m_revisionFlag = flag; + m_type = s; + } + + CreateNewBOSWTDialog(Shell shell, boolean flag, String s, + CreateNewBOSWTDialog createnewboswtdialog) { + this(shell, flag, s); + } + } + + public Object execute(ExecutionEvent executionevent) + throws ExecutionException { + if (executionevent == null) + throw new IllegalArgumentException("Event can't be null"); + boolean flag = false; + if (executionevent.getParameters() != null + && executionevent.getParameters().containsKey("selection")) { + Object obj = executionevent.getParameters().get("selection"); + if (obj instanceof InterfaceAIFComponent[]) { + selectedCmps = (InterfaceAIFComponent[]) obj; + m_currentSelection = new StructuredSelection(selectedCmps); + flag = true; + } + } + if (!flag) { + m_currentSelection = HandlerUtil + .getCurrentSelection(executionevent); + selectedCmps = SelectionHelper + .getTargetComponents(m_currentSelection); + } + m_boModel = getBOModel(); + try { + session = (TCSession) RACUICommandsActivator.getDefault() + .getSession(); + } catch (Exception _ex) { + session = (TCSession) AIFUtility.getDefaultSession(); + } + launchWizard(executionevent); + return null; + } + + public void setInitializationData( + IConfigurationElement iconfigurationelement, String s, Object obj) + throws CoreException { + } + + protected NewBOModel getBOModel() { + if (m_boModel == null) + m_boModel = new NewBOModel(this); + return m_boModel; + } + + public Wizard getWizard() { + if (wizardId == null || wizardId.length() == 0) + wizardId = "com.teamcenter.rac.ui.commands.create.bo.NewBOWizard"; + return WizardExtensionHelper.getWizard(wizardId); + } + + public String getWizardTitle() { + return Messages.getString("wizard.TITLE"); + } + + public void launchWizard() { + launchWizard(null); + } + + public void launchWizard(ExecutionEvent executionevent) { + boolean flag = false; + // String s = "RT4Item"; + if (executionevent != null && executionevent.getParameters() != null) { + if (executionevent.getParameters().containsKey("revisionFlag")) + flag = ((Boolean) executionevent.getParameters().get( + "revisionFlag")).booleanValue(); + // s = (String)executionevent.getParameters().get("objectType"); + if (executionevent.getParameters().containsKey("pasteRelation")) { + String s1 = (String) executionevent.getParameters().get( + "pasteRelation"); + if (s1 != null) { + String as[] = null; + as = s1.split(","); + m_boModel.setRelType(as[0]); + m_boModel.setPreAssignedRelType(as); + } + } + } + + + AIFDesktop aifdesktop = AIFUtility.getActiveDesktop(); + Shell shell = aifdesktop.getShell(); + if (shell != null) + // if(itemtype!=null) + SWTUIUtilities.asyncExec(new CreateNewBOSWTDialog(shell, flag, + itemtype, null)); + } + + protected void readDisplayParameters(NewBOWizard newbowizard, + WizardDialog wizarddialog) { + newbowizard.retrievePersistedDialogSettings(wizarddialog); + } + + protected InterfaceAIFComponent selectedCmps[]; + protected ISelection m_currentSelection; + protected String wizardId; + protected BaseExternalWizardDialog dialog; + protected TCSession session; + protected NewBOModel m_boModel; +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_16/PasteItemCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_16/PasteItemCommand.java new file mode 100644 index 0000000..9a107cb --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_16/PasteItemCommand.java @@ -0,0 +1,120 @@ +package com.connor.ml.tcm.ML_16; + +import java.util.ArrayList; +import java.util.Vector; + +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class PasteItemCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + + public PasteItemCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + protected void executeCommand() throws Exception { + // TODO Auto-generated method stub + //判断选中的是否为BOMLine + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + TCComponentItemRevision itemRevision = ((TCComponentBOMLine)comp).getItemRevision(); + + AIFClipboard aifclipboard = AIFPortal.getClipboard(); + Vector vec = aifclipboard.toVector(); + ArrayList itemRevisions = new ArrayList(); + for (int i = 0; i < vec.size(); i++) { + if(vec.get(i) instanceof TCComponentBOMLine) + { + itemRevisions.add(((TCComponentBOMLine)vec.get(i)).getItemRevision()); + } + } + recreateBom(itemRevision, itemRevisions, false); + ((TCComponentBOMLine)comp).refresh(); + super.executeCommand(); + } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev, ArrayList itemRevisionlists, + boolean isDelete) throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), topItemRev, null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e) { + // TODO: handle exception + try { + ((TCComponentBOMLine) children.getComponent()).cut(); + } catch (Exception e2) { + // TODO: handle exception + } + e.printStackTrace(); + } + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if (n_itemRevision != null) { + boolean isHave = false; + if (!isDelete) { + for (AIFComponentContext children : topline.getChildren()) { + if (n_itemRevision.getStringProperty("item_id") + .compareTo(children.getComponent().getProperty("bl_child_id")) == 0) { + isHave = true; + } + } + } + if (!isHave) { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if (topline.getBOMView() != null) { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_16/PasteItemHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_16/PasteItemHandler.java new file mode 100644 index 0000000..ab4ef30 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_16/PasteItemHandler.java @@ -0,0 +1,28 @@ +package com.connor.ml.tcm.ML_16; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class PasteItemHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + PasteItemCommand command = new PasteItemCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdCommand.java new file mode 100644 index 0000000..ce80fcd --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdCommand.java @@ -0,0 +1,163 @@ +package com.connor.ml.tcm.ML_17; + +import java.text.DecimalFormat; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class UpdateItemIdCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + + public UpdateItemIdCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + protected void executeCommand() throws Exception { + // TODO Auto-generated method stub + // 判断选中的是否为BOMLine + if (!(comp instanceof TCComponentBOMLine)) { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + TCComponentBOMLine topline = ((TCComponentBOMLine) comp); + + UpdateItemIdOperation operation=new UpdateItemIdOperation(session, topline); + session.queueOperation(operation); +// setMEOPId(topline); + +// super.executeCommand(); + } + + public void setMEOPId(TCComponentBOMLine topBomLine) throws Exception { + AIFComponentContext[] childrens = topBomLine.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = ((TCComponentBOMLine) children.getComponent()); + + TCComponentItem item = bomLine.getItem(); + if(item.getStringProperty("item_id").indexOf("-") > 0) + { + continue; + } + // 更新对象ID + String objectType = item.getProperty("object_type"); + System.out.println("objectType=======================" + objectType); + String itemId = ""; + switch (objectType) { + case "ML8_SpecOp": + case "专项工序": + String ml8_SpecOpPeriod = item.getStringProperty("ml8_SpecOpPeriod"); + String ml8_SpecOpCode = item.getStringProperty("ml8_SpecOpCode"); + String ml8_SpecOpNumber = item.getStringProperty("ml8_SpecOpNumber"); + + itemId = getGyRuleID(this.session, + String.format("%s-%s-%s", ml8_SpecOpPeriod, ml8_SpecOpCode, ml8_SpecOpNumber)); + + break; + case "ML8_StdOperation": + case "标准工序": + + String stdOpType = item.getStringProperty("ml8_StdOpType"); + String stdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String productType = item.getStringProperty("ml8_ProductType"); + String materialType = item.getStringProperty("ml8_MaterialType"); + String stdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(this.session, + String.format("%s-%s%s%s-%s", stdOpType, stdOpPeriod, productType, materialType, stdOpNumber)); + + break; + + case "ML8_DifOperation": + case "差异化工序": + + String ml8_StdOpType = item.getStringProperty("ml8_StdOpType"); + String ml8_StdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String ml8_ProductType = item.getStringProperty("ml8_ProductType"); + String ml8_MaterialType = item.getStringProperty("ml8_MaterialType"); + String ml8_StdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(this.session, String.format("%s-%s%s%s-%s", ml8_StdOpType, ml8_StdOpPeriod, + ml8_ProductType, ml8_MaterialType, ml8_StdOpNumber)); + + break; + default: + break; + } + if (!itemId.isEmpty()) { + item.lock(); + item.setProperty("item_id", itemId); + item.save(); + item.unlock(); + item.refresh(); + // return; + } + setMEOPId(bomLine); + } + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000000"); + String newID = oldItemID + "-000001"; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session.getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "-" + df.format(i); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getStdOpNumber(String itemID, int num) { + DecimalFormat df = new DecimalFormat("000"); + String newID = "010"; + // String idTemp = + try { + int i = 10; + while (itemID.compareTo(newID) != 0) { + i = i + 1; + newID = df.format(i); + } + newID = df.format(i + num); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdHandler.java new file mode 100644 index 0000000..d947c7b --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdHandler.java @@ -0,0 +1,28 @@ +package com.connor.ml.tcm.ML_17; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class UpdateItemIdHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + UpdateItemIdCommand command = new UpdateItemIdCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdOperation.java new file mode 100644 index 0000000..78a10b4 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_17/UpdateItemIdOperation.java @@ -0,0 +1,141 @@ +package com.connor.ml.tcm.ML_17; + +import java.sql.ResultSet; +import java.text.DecimalFormat; + +import com.connor.ml.tcm.util.DbPool; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class UpdateItemIdOperation extends AbstractAIFOperation{ + private TCSession session; + private TCComponentBOMLine topline; + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + setMEOPId(topline); + } + + public UpdateItemIdOperation(TCSession session,TCComponentBOMLine topline) { + this.session=session; + this.topline=topline; + } + + public void setMEOPId(TCComponentBOMLine topBomLine) throws Exception { + AIFComponentContext[] childrens = topBomLine.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = ((TCComponentBOMLine) children.getComponent()); + + TCComponentItem item = bomLine.getItem(); + if(item.getStringProperty("item_id").indexOf("-") > 0) + { + continue; + } + // 更新对象ID + String objectType = item.getProperty("object_type"); + System.out.println("objectType=======================" + objectType); + String itemId = ""; + switch (objectType) { + case "ML8_SpecOp": + case "专项工序": + String ml8_SpecOpPeriod = item.getStringProperty("ml8_SpecOpPeriod"); + String ml8_SpecOpCode = item.getStringProperty("ml8_SpecOpCode"); + String ml8_SpecOpNumber = item.getStringProperty("ml8_SpecOpNumber"); + + itemId = getGyRuleID(this.session, + String.format("%s-%s-%s", ml8_SpecOpPeriod, ml8_SpecOpCode, ml8_SpecOpNumber)); + + break; + case "ML8_StdOperation": + case "标准工序": + + String stdOpType = item.getStringProperty("ml8_StdOpType"); + String stdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String productType = item.getStringProperty("ml8_ProductType"); + String materialType = item.getStringProperty("ml8_MaterialType"); + String stdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(this.session, + String.format("%s-%s%s%s-%s", stdOpType, stdOpPeriod, productType, materialType, stdOpNumber)); + + break; + + case "ML8_DifOperation": + case "差异化工序": + + String ml8_StdOpType = item.getStringProperty("ml8_StdOpType"); + String ml8_StdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String ml8_ProductType = item.getStringProperty("ml8_ProductType"); + String ml8_MaterialType = item.getStringProperty("ml8_MaterialType"); + String ml8_StdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(this.session, String.format("%s-%s%s%s-%s", ml8_StdOpType, ml8_StdOpPeriod, + ml8_ProductType, ml8_MaterialType, ml8_StdOpNumber)); + + break; + default: + break; + } + if (!itemId.isEmpty()) { + item.lock(); + item.setProperty("item_id", itemId); + item.save(); + item.unlock(); + item.refresh(); + // return; + } + setMEOPId(bomLine); + } + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000000"); + String newID = oldItemID + "-000001"; + // String idTemp = + ResultSet rs2 = null; + String selectSql="select count(1) from PITEM a where a.pitem_id like '"; + selectSql=selectSql+oldItemID+"%'"; + try { + TCComponentItemType tccomponentitemtype = (TCComponentItemType) (session.getTypeComponent("Item")); +// +// tccomponentitemtype.getNewID(); + int i = 1; + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql); + if (rs2 != null) { + while (rs2.next()) { + i = rs2.getInt(1); + System.out.println("数据库查询结果"+i); + } + } + i=i+1; + +// int i = 1; + newID = oldItemID + "-" + df.format(i); + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "-" + df.format(i); + } + + + + DbPool.freeAll(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/BigDecimalUtils.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/BigDecimalUtils.java new file mode 100644 index 0000000..6561734 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/BigDecimalUtils.java @@ -0,0 +1,144 @@ +package com.connor.ml.tcm.ML_18; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.NumberFormat; + +public class BigDecimalUtils { + + public static final int MONEY_POINT = 2; // 货币保留两位小数 + + /** + * 格式化精度 + * + * @param v + * @param point + * 小数位数 + * @return double + */ + @SuppressWarnings("deprecation") + public static Double format(double v, int point) { + BigDecimal b = new BigDecimal(v); + return b.setScale(point, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * + * @param v + * @param point + * @return + */ + public static Double formatRoundUp(double v, int point) { + NumberFormat nf = NumberFormat.getInstance(); + nf.setRoundingMode(RoundingMode.HALF_UP);// 设置四舍五入 + nf.setMinimumFractionDigits(point);// 设置最小保留几位小数 + nf.setMaximumFractionDigits(point);// 设置最大保留几位小数 + return Double.valueOf(nf.format(v)); + } + + /** + * 格式化金额。带千位符 + * + * @param v + * @return + */ + public static String moneyFormat(Double v) { + DecimalFormat formater = new DecimalFormat(); + formater.setMaximumFractionDigits(2); + formater.setGroupingSize(3); + formater.setRoundingMode(RoundingMode.FLOOR); + return formater.format(v.doubleValue()); + } + + /** + * 带小数的显示小数。不带小数的显示整数 + * @param d + * @return + */ + public static String doubleTrans(Double d) { + if (Math.round(d) - d == 0) { + return String.valueOf((long) d.doubleValue()); + } + return String.valueOf(d); + } + + /** + * BigDecimal 相加 + * + * @param v1 + * @param v2 + * @return double + */ + public static Double add(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.add(n2).doubleValue(); + } + + /** + * BigDecimal 相减 + * + * @param v1 + * @param v2 + * @return double + */ + public static Double subtract(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.subtract(n2).doubleValue(); + } + + /** + * BigDecimal 相乘 + * + * @param v1 + * @param v2 + * @return double + */ + public static Double multiply(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.multiply(n2).doubleValue(); + } + + /** + * BigDecimal 相除 + * + * @param v1 + * @param v2 + * @return double + */ + @SuppressWarnings("deprecation") + public static Double divide(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.divide(n2, 10, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * 比较大小 小于0:v1 < v2 大于0:v1 > v2 等于0:v1 = v2 + * + * @param v1 + * @param v2 + * @return + */ + public static int compare(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.compareTo(n2); + } + + /** + * + * @param args + */ + public static void main(String[] args) { + // System.out.println(divide(1, 8)); + // System.out.println(format(multiply(3.55, 2.44),2)); + // System.out.println(divide(1.0, 3.0)); + // System.out.println(add(2.79, -3.0)); + System.out.println(doubleTrans(10000.0)); + } + +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/MoveRectangle.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/MoveRectangle.java new file mode 100644 index 0000000..d484846 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/MoveRectangle.java @@ -0,0 +1,100 @@ +package com.connor.ml.tcm.ML_18; +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class MoveRectangle extends Frame implements MouseMotionListener,MouseListener { + + private static final int WIDTH = 20; + private static final int HEIGHT = 30; + + private int x, y; + private boolean canMove; + private int dX, dY; + + public static void main(String[] args) { + // TODO Auto-generated method stub + new MoveRectangle().setVisible(true); + + } + + public MoveRectangle() { + x = 100; + y = 150; + canMove = false; + this.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent arg0) { + System.exit(0); + } + }); + this.addMouseMotionListener(this); + this.addMouseListener(this); + this.setSize(400, 300); + } + + @Override + public void paint(Graphics g) { + // TODO Auto-generated method stub + Color c = g.getColor(); + g.setColor(this.getBackground()); + g.fillRect(0, 0, this.getWidth(), this.getHeight()); + g.setColor(new Color(255, 0, 0)); + g.drawRect(x, y, WIDTH, HEIGHT); + g.setColor(c); + } + + @Override + public void mouseDragged(MouseEvent me) { + // TODO Auto-generated method stub + if (canMove) { + int mX = me.getX(); + int mY = me.getY(); + x = mX - dX; + y = mY - dY; + //repaint(); + paint(this.getGraphics()); + } + } + + @Override + public void mousePressed(MouseEvent me) { + // TODO Auto-generated method stub + if (me.getButton() == MouseEvent.BUTTON1) { + int mX = me.getX(); + int mY = me.getY(); + if (mX >= x && mX <= x + WIDTH && mY >= y && mY <= y + HEIGHT) { + dX = mX - x; + dY = mY - y; + canMove = true; + } + } + } + + @Override + public void mouseReleased(MouseEvent arg0) { + // TODO Auto-generated method stub + canMove = false; + } + + @Override + public void mouseMoved(MouseEvent me) { + } + + @Override + public void mouseClicked(MouseEvent arg0) { + } + + @Override + public void mouseEntered(MouseEvent arg0) { + } + + @Override + public void mouseExited(MouseEvent arg0) { + } + +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenShotTest.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenShotTest.java new file mode 100644 index 0000000..b600df7 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenShotTest.java @@ -0,0 +1,300 @@ +package com.connor.ml.tcm.ML_18; + +import java.awt.AWTException; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionAdapter; +import java.awt.image.BufferedImage; +import java.awt.image.RescaleOp; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Properties; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JToolBar; +import javax.swing.JWindow; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.filechooser.FileSystemView; + +import com.connor.ml.tcm.util.BigDecimalUtils; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + + +public class ScreenShotTest { + public static void main(String[] args) { + + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + try { + ScreenShotWindow ssw = new ScreenShotWindow(); + ssw.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + +} + +/** + * 截图窗口 + */ +class ScreenShotWindow extends JWindow { + private int orgx, orgy, endx, endy; + private BufferedImage image = null; + private BufferedImage tempImage = null; + private BufferedImage saveImage = null; + private TCComponentItemRevision rev; + private TCSession session; + private ToolsWindow tools = null; + + public ScreenShotWindow() { + super(); + } + + public ScreenShotWindow(TCSession session, TCComponentItemRevision rev) throws AWTException, IOException { + this.rev = rev; + this.session = session; + // 获取屏幕尺寸 + Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); + this.setBounds(0, 0, d.width, d.height); + + // 截取屏幕 + Robot robot = new Robot(); + image = robot.createScreenCapture(new Rectangle(0, 0, d.width, d.height)); + + // 获取配置信息中的截图比例 + InputStream in = ScreenShotTest.class.getResourceAsStream("/plm.properties"); + Properties p = new Properties(); + p.load(in); + + int w1 = Integer.parseInt(p.getProperty("IMAGE.WIDTH")); + int h1 = Integer.parseInt(p.getProperty("IMAGE.HEIGHT")); + + this.addMouseListener(new MouseAdapter() { + @Override + public void mousePressed(MouseEvent e) { + // 鼠标按下时记录结束点坐标,并隐藏操作窗口 + orgx = e.getX(); + orgy = e.getY(); + + if (tools != null) { + tools.setVisible(false); + } + } + + @Override + public void mouseReleased(MouseEvent e) { + // 鼠标松开时,显示操作窗口 + if (tools == null) { + tools = new ToolsWindow(ScreenShotWindow.this, e.getX(), e.getY()); + } else { + tools.setLocation(e.getX(), e.getY()); + } + tools.setVisible(true); + tools.toFront(); + } + }); + + this.addMouseMotionListener(new MouseMotionAdapter() { + + @Override + public void mouseDragged(MouseEvent e) { + // 鼠标拖动时,记录坐标并重绘窗口 + endx = e.getX(); + endy = e.getY(); + + // 临时图像,用于缓冲屏幕区域放置屏幕闪烁 + Image tempImage2 = createImage(ScreenShotWindow.this.getWidth(), ScreenShotWindow.this.getHeight()); + Graphics g = tempImage2.getGraphics(); + g.drawImage(tempImage, 0, 0, null); + int x = Math.min(orgx, endx);// 返回两个参数的较小值 + int y = Math.min(orgy, endy); + int width = Math.abs(endx - orgx) + 1;// math.abs(x) 返回x的绝对值 + Double m1 = BigDecimalUtils.multiply(width, h1); + int height = BigDecimalUtils.divide(m1, w1).intValue(); + // int height = Math.abs(endy - orgy) + 1; + + // 加上1防止width或height0 + g.setColor(Color.BLUE); + g.drawRect(x - 1, y - 1, width + 1, height + 1); + // 减1加1都了防止图片矩形框覆盖掉 + saveImage = image.getSubimage(x, y, width, height); + g.drawImage(saveImage, x, y, null); + + ScreenShotWindow.this.getGraphics().drawImage(tempImage2, 0, 0, ScreenShotWindow.this); + } + }); + } + + + @Override + public void paint(Graphics g) { + RescaleOp ro = new RescaleOp(0.8f, 0, null); + tempImage = ro.filter(image, null); + g.drawImage(tempImage, 0, 0, this); + } + + // 保存图像到文件 + public void saveImage() throws IOException { + try { + MethodUtil.openByPass(session); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + System.out.println("Width=" + saveImage.getWidth() + ",Height=" + saveImage.getHeight()); + JFileChooser jfc = new JFileChooser(); + jfc.setDialogTitle("保存"); + + // 文件过滤器,用户过滤可选择文件 + FileNameExtensionFilter filter = new FileNameExtensionFilter("PNG", "png"); + jfc.setFileFilter(filter); + + // 初始化一个默认文件(此文件会生成到桌面上) + SimpleDateFormat sdf = new SimpleDateFormat("yyyymmddHHmmss"); + String fileName = sdf.format(new Date()); + File filePath = FileSystemView.getFileSystemView().getHomeDirectory(); + File defaultFile = new File(filePath + File.separator + fileName + ".png"); + jfc.setSelectedFile(defaultFile); + + int flag = jfc.showSaveDialog(this); + if (flag == JFileChooser.APPROVE_OPTION) { + File file = jfc.getSelectedFile(); + String path = file.getPath(); + // 检查文件后缀,放置用户忘记输入后缀或者输入不正确的后缀 + if (!(path.endsWith(".png") || path.endsWith(".PNG"))) { + path += ".png"; + } + // 写入文件 + ImageIO.write(saveImage, "png", new File(path)); + TCComponentDataset mbDataset = createDataset(path,rev); + try { + rev.add("IMAN_specification",mbDataset); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }//数据集关系 + File deleteFile = new File(path); + if(deleteFile.exists()) { + deleteFile.delete(); + } + tools.dispose(); + this.setVisible(false); + //System.exit(0); + //MessageBox.post("创建成功","成功",MessageBox.INFORMATION); + } + + try { + MethodUtil.closeByPass(session); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + @SuppressWarnings("unused") + private TCComponentDataset createDataset(String fielPath,TCComponentItemRevision rev) { + TCComponentDataset mbDataset = null; + String[] path = new String[1]; + String[] ref_type = new String[1]; + try { + String name = rev.getStringProperty("object_name"); + System.out.println("rev_name===="+name); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + mbDataset = datasetType.create(name, "", "Image"); + ref_type[0] = "Image"; + path[0] = fielPath; + mbDataset.setFiles(path, ref_type); + + } catch (TCException e) { + e.printStackTrace(); + } + return mbDataset; + } + + public void closeWin() { + // TODO Auto-generated method stub + tools.dispose(); + this.setVisible(false); + } + +} + +/** + * 操作窗口 + */ +class ToolsWindow extends JWindow { + private ScreenShotWindow parent; + + public ToolsWindow(ScreenShotWindow parent, int x, int y) { + this.parent = parent; + this.init(); + this.setLocation(x, y); + this.pack(); + this.setVisible(true); + this.setPreferredSize(new Dimension(150, 20)); + } + + private void init() { + + this.setLayout(new BorderLayout()); + JToolBar toolBar = new JToolBar("Java 截图"); + + // 保存按钮 + // JButton saveButton = new JButton(new ImageIcon("icons/group_16.png")); + JButton saveButton = new JButton("save"); + // saveButton.setPreferredSize(new Dimension(80, 20)); + saveButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + new Runnable() { + public void run() { + try { + parent.saveImage(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + }.run(); + } + }); + toolBar.add(saveButton); + + // 关闭按钮 + JButton closeButton = new JButton("close"); + closeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + parent.closeWin(); + //System.exit(0); + } + }); + toolBar.add(closeButton); + + this.add(toolBar, BorderLayout.NORTH); + } + +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenshotCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenshotCommand.java new file mode 100644 index 0000000..f324759 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenshotCommand.java @@ -0,0 +1,99 @@ +package com.connor.ml.tcm.ML_18; + + +import java.awt.AWTException; +import java.awt.EventQueue; +import java.io.IOException; + +import org.eclipse.swt.widgets.Display; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ScreenshotCommand extends AbstractAIFCommand { + + private AbstractAIFApplication app; + private TCSession session; + private boolean hideTC; + private TCComponentItemRevision rev; + private static final String PREF_SCREENSHOT = "Connor_ScreenShot_Command"; + + public ScreenshotCommand(AbstractAIFApplication app, boolean actionInfo) { + // TODO Auto-generated constructor stub + this.app = app; + this.session = (TCSession) app.getSession(); + this.hideTC = actionInfo; + } + + @Override + protected void executeCommand() throws Exception { + // TODO Auto-generated method stub + //String cmd = session.getPreferenceService().getStringValue(PREF_SCREENSHOT); + //System.out.println("ScreenShot: "+cmd); + System.out.println("hideTC: "+hideTC); + // if("".equals(cmd)) { + // MessageBox.post("首选项"+PREF_SCREENSHOT+" 配置错误,请联系管理员!", + // "错误", MessageBox.ERROR); + // return; + // } + InterfaceAIFComponent target = app.getTargetComponent(); + if(target instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) target; + rev = line.getItemRevision(); + }else if(target instanceof TCComponentItemRevision) { + rev = (TCComponentItemRevision) target; + + }else { + MessageBox.post("请选择版本对象进行截图操作!!!", + "提示", MessageBox.INFORMATION); + return; + } + if(hideTC) { + Display.getDefault().syncExec(new Runnable() { + + @Override + public void run() { + // TODO Auto-generated method stub + AIFDesktop.getActiveDesktop().getShell().setMinimized(true); + } + }); + Thread.sleep(600); + } + + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + try { + ScreenShotWindow ssw = new ScreenShotWindow(session,rev); + System.out.println("开始截图"); + ssw.setVisible(true); + + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + +// if(hideTC) { +// Display.getDefault().syncExec(new Runnable() { +// +// @Override +// public void run() { +// // TODO Auto-generated method stub +// AIFDesktop.getActiveDesktop().getShell().setMaximized(true); +// } +// }); +// Thread.sleep(600); +// } + //Runtime.getRuntime().exec(cmd); + } +} + + diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenshotHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenshotHandler.java new file mode 100644 index 0000000..e05e5e3 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_18/ScreenshotHandler.java @@ -0,0 +1,35 @@ +package com.connor.ml.tcm.ML_18; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class ScreenshotHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + boolean actionInfo = false; + try { + String name = arg0.getCommand().getName(); + System.out.println("name==="+name); + if("外部截图".equals(name)) { + actionInfo = true; + }else { + actionInfo = false; + } + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + ScreenshotCommand command = new ScreenshotCommand(app,actionInfo); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_19/UpFileDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_19/UpFileDialog.java new file mode 100644 index 0000000..abc65e5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_19/UpFileDialog.java @@ -0,0 +1,204 @@ +package com.connor.ml.tcm.ML_19; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import com.connor.ml.tcm.bean.RealBean; +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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class UpFileDialog extends AbstractAIFDialog { + private TCSession session; + private InterfaceAIFComponent targetComp; + private JFileChooser jFileChooser; + private JTextField jt4 = new JTextField(20); + private JLabel jb4; + private JButton pBut; + private JButton okBut=new JButton("上传"); + private JButton celBut=new JButton("取消"); + private String UpFileStr="ML_UpFile";//首选项名称 + private List realbean=new ArrayList<>(); + private String type=""; + private File[] fs=null; + public UpFileDialog(TCSession arg0,InterfaceAIFComponent arg1){ + this.session = arg0; + this.targetComp = arg1; + } + + public void run(){ + if(targetComp == null){ + MessageBox.post("请选中文件夹或版本!!","错误", MessageBox.ERROR); + return; + } + type = targetComp.getType(); + System.out.println("tyep="+type); + if(type.equals("Folder")||type.contains("Revision")){ + getReal(); + init(); + }else{ + MessageBox.post("请选中文件夹或版本!!","错误", MessageBox.ERROR); + return; + } + } + + public void init(){ + FileSystemView fsv = FileSystemView.getFileSystemView(); + String deskPath = fsv.getHomeDirectory().getPath(); + setLayout(new PropertyLayout()); + jb4 = new JLabel(" 文件路径:"); + jt4.setText(deskPath); + pBut = new JButton("..."); + jFileChooser = new JFileChooser(); + this.jFileChooser.setCurrentDirectory(new File(deskPath)); + jFileChooser.setMultiSelectionEnabled(true); + add("1.1.left.top", jb4); + add("1.2.left.top", jt4); + add("1.3.left.top", pBut); + add("2.1.left.top", okBut); + add("2.2.left.top", celBut); + setVisible(true); + this.centerToScreen(); + this.pack(); + pBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + selectFileButtonEvent(); + } + }); + + okBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + System.out.println("开始上传"); + if(!jt4.getText().equals("")){ + String[] strs=jt4.getText().split(";"); + boolean is = true; + for(String str:strs){ + is = uploadfile(str); + if(!is){ + break; + } + } + if(is){ + MessageBox.post("上传完成!!","成功", MessageBox.INFORMATION); + } + setVisible(false); + } + } + }); + + celBut.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + setVisible(false); + } + }); + } + + public boolean uploadfile(String fathname){ + try { + String datType=""; + String toolType=""; + String realname=""; + for(RealBean bean:realbean){ + if(fathname.endsWith(bean.getHzm())){ + datType = bean.getDaType(); + toolType = bean.getToolType(); + realname = bean.getRealname(); + } + } + if((datType==null)||datType.equals("")){ + MessageBox.post("暂不支持该类型的文件上传!!!","提示", MessageBox.INFORMATION); + return false; + } + File file = new File(fathname); + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + TCComponentDataset dataset = datasetType.create(file.getName(), "", datType); + if(dataset == null){ + MessageBox.post("创建失败", "错误", MessageBox.ERROR); + return false; + } + dataset.setFiles(new String[]{fathname}, new String[]{toolType}); + if(type.equals("Folder")){ + System.out.println("文件夹关系:contents"); + ((TCComponent)targetComp).add("contents",dataset); + }else{ + System.out.println("版本关系:"+realname); + ((TCComponent)targetComp).add(realname,dataset); + } + return true; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + MessageBox.post("上传失败:"+e.getMessage(),"错误", MessageBox.ERROR); + return false; + } + + } + + private void getReal(){ + String[] names = session.getPreferenceService().getStringValues(UpFileStr); + if(names != null){ + for(int i=0;i mainLists = new ArrayList(); + private TCComponentBOMWindow bomwin; + public OpenWorkStepDialog(JTable mainTable,Object[][] center,TCComponentBOMWindow bomwin,TCSession session,TCComponentItemRevision target) { + //super(true); + this.mainTable = mainTable; + this.session = session; + this.oneValues = center; + this.bomwin = bomwin; + this.target = target; + init(); + selectParts(); + } + + + private void init() { + this.setTitle("工步打开"); + this.setSize(999, 666); + + JLabel leftLabel = new JLabel("工步:"); + Font font = new Font("新宋体", 1, 24); + leftLabel.setFont(font); + selectButton = new JButton("物料显示"); + selectButton.addActionListener(this); + this.leftTable = getjTable(leftTable, null, oneColumns, oneValues); + JPanel leftPanel = new JPanel(new BorderLayout()); + JPanel topPanel = new JPanel(); + topPanel.add(leftLabel); + //topPanel.add(selectButton); + leftPanel.add(BorderLayout.NORTH,topPanel); + leftPanel.add(BorderLayout.CENTER,new JScrollPane(leftTable)); + leftTable.setRowSelectionInterval(0,0);//表示选中第属一行 + leftTable.addMouseListener(this); + + JLabel rightLabel = new JLabel("工步结构:"); + rightLabel.setFont(font); + rightField = new JTextField(); + rightField.setPreferredSize(new Dimension(250,20)); + JPanel temp = new JPanel(); + temp.add(rightLabel); + temp.add(rightField); + //this.rightTable = getjTable(rightTable, null, rightColumns, rightValues); + twoTableModel = new DefaultTableModel(rightValues,rightColumns); + rightTable = new JTable(twoTableModel); + addButton = new JButton("+"); + celButton = new JButton("-"); + updateButton = new JButton("升版并修改"); + processButton = new JButton("提交工艺变更流程"); + addButton.addActionListener(this); + celButton.addActionListener(this); + updateButton.addActionListener(this); + processButton.addActionListener(this); + JPanel rightButtonPanel = new JPanel(new PropertyLayout()); + rightButtonPanel.add("1.1.center",addButton); + rightButtonPanel.add("2.1.center",celButton); + rightButtonPanel.add("3.1.center",updateButton); + rightButtonPanel.add("4.1.center",processButton); + + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.add(BorderLayout.NORTH,temp); + rightPanel.add(BorderLayout.CENTER,new JScrollPane(rightTable)); + rightPanel.add(BorderLayout.EAST,rightButtonPanel); + + this.setLayout(new BorderLayout()); + this.add(BorderLayout.WEST,leftPanel); + this.add(BorderLayout.CENTER,rightPanel); + + this.setLocationRelativeTo(null); + this.setVisible(true); + + } + + + + /*** + * Jtable通用方法 + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 150; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(30); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames); + } + return tableModel; + } + + public void addData(Object[][] cellData,String[] columns,JTable table) { + DefaultTableModel tableModel = (DefaultTableModel) table.getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter( + this.getTableModel(null, columns, cellData)); + table.setRowSorter(sorter); + for (int i = 0; i < cellData.length; i++) { + tableModel.addRow(cellData[i]); + } + // 表格数据不可修改 + //table.setEnabled(true); + // 更新表格 + table.invalidate(); + } + + + + @Override + public void actionPerformed(ActionEvent event) { + if (event.getSource() == this.selectButton) { + + } + else if(event.getSource() == this.processButton) { + try { +// int gbIndex = leftTable.getSelectedRow(); +// if(gbIndex == -1) { +// MessageBox.post("请选中工步!!!","错误", MessageBox.ERROR); +// return; +// } + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ML8_MCNotice"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + Date date = new Date(); + String head = "TCM-" + sdf.format(date) + "-"; + TCComponent[] search = session.search("零组件...", new String [] {"类型","零组件 ID"}, new String [] {"工艺变更通知单" ,head + "*"}); + DecimalFormat df = new DecimalFormat("000000"); + String newID = search[search.length - 1].getStringProperty("item_id"); + String[] split = newID.split("-"); + int end = Integer.parseInt(split[2]) + 1; + String id = head + df.format(end); + while(itemType.find(id) != null) { + end++; + id = head + df.format(end); + } + //id,版本,类型,名称,描述 + TCComponentItem newItem = + itemType.create(id,"A", "ML8_MCNotice", "变更工艺通知单", "", null); + for (int i = 0; i < leftTable.getRowCount(); i++) { + //TCComponentItemRevision afterRev = mainList.get(gbIndex); + String rev = leftTable.getValueAt(i, 2).toString(); + String id2 = leftTable.getValueAt(i, 1).toString(); + TCComponent[] search2 = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { id2 }); + TCComponentItem item = (TCComponentItem) search2[0]; + System.out.println("开始判断版本》》》》》》"+rev); + if (!"A".equals(rev)) { + System.out.println("开始挂载关系》》》》将"+item.getLatestItemRevision().getProperty("object_string") + +"挂载到"+newItem.getLatestItemRevision().getProperty("object_string")+"的ML8_GXBGH关系下"); + newItem.getLatestItemRevision().add("ML8_GXBGH", item.getLatestItemRevision()); + System.out.println("获取前一个版本》》》》"); + TCComponent[] relatedComponents = item.getRelatedComponents("revision_list"); + TCComponent beforeRev = relatedComponents[relatedComponents.length - 2]; + System.out.println("变更前对象:"+beforeRev.getProperty("object_sting")); + System.out.println("开始挂载关系》》》》将"+beforeRev.getProperty("object_string") + +"挂载到"+newItem.getLatestItemRevision().getProperty("object_string")+"的ML8_GXBGQ关系下"); + newItem.getLatestItemRevision().add("ML8_GXBGQ", beforeRev); + } + } + //拷贝选中对象(设计变更通知单) + newItem.getLatestItemRevision().add("ML8_RelatedECN", target); + //发起“624TCM_更改审批流程”流程,用新建对象 + //更改逻辑,创建流程需要获取组信息 + TCComponentGroup loginGroup = session.getUser().getLoginGroup(); + String stringProperty = loginGroup.getStringProperty("display_name"); + String[] value = session.getPreferenceService().getStringValues("ML_TCMGBBGFQLC"); + if(value == null || value.length == 1) { + MessageBox.post("首选项【ML_TCMGBBGFQLC】配置有误", "成功", MessageBox.ERROR); + return; + } + int num1 = 0; + for (int a = 0; a < value.length; a++) { + String[] split2 = value[a].split(";"); + String[] split3 = split2[1].split(","); + int num2 = 0; + for(int b=0;b map = new HashMap(); + for (int i = 0; i < rightTable.getRowCount(); i++) { + String id = rightTable.getValueAt(i, 1).toString(); + TCComponent[] search = session.search("零组件 ID", new String[] { "零组件 ID" },new String[] { id }); + if(search == null || search.length == 0) { + MessageBox.post(buffer + "这些id不存在对象,请重新检查后再添加!","错误", MessageBox.ERROR); + return; + } + else { + TCComponentItem item = (TCComponentItem) search[0]; + System.out.println("获取要添加的数量为:"+rightTable.getValueAt(i, 6).toString()); + map.put(item,rightTable.getValueAt(i, 6).toString()); + } + } + TCComponent[] search2 = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { id2 }); + TCComponentItem item = (TCComponentItem) search2[0]; + TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); + TCComponentItemRevision newItemRevision; + String status = leftTable.getValueAt(gbIndex, 4).toString(); + System.out.println("发布状态为:" + status); + if (status.equals("未发布")) { + //修改判断权限 + String property = latestItemRevision.getProperty("owning_user"); + String userName = session.getUser().getUserName(); + String userId = session.getUser().getUserId(); + System.out.println("当前用户:"+property); + System.out.println("当前user:"+userName); + System.out.println("当前userid:"+userId); + if(!property.contains(userName) && !property.contains(userId)) { + MessageBox.post("当前用户没有权限操作工步"+latestItemRevision.getProperty("object_string")+"对象","提示", MessageBox.ERROR); + return; + } + newItemRevision = latestItemRevision; + } else { + newItemRevision = latestItemRevision.saveAs(""); + } + //TCComponentItemRevision newItemRevision = latestItemRevision.saveAs(""); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(newItemRevision.getItem(), newItemRevision, null, null); + if(topLine.hasChildren()) { + AIFComponentContext[] children = topLine.getChildren(); + for (AIFComponentContext aifComponentContext : children) { + TCComponentBOMLine line = (TCComponentBOMLine) aifComponentContext.getComponent(); + line.cut(); + } + } + bomwin.save(); + int count = 0; + for(TCComponentItem key : map.keySet()) { + TCComponentBOMLine add = topLine.add(key, key.getLatestItemRevision(), null, + false, ""); + System.out.println("修改bom行"+add.getItemRevision().getProperty("object_string")+"的数量为:"+map.get(key)); + add.setStringProperty("bl_quantity", map.get(key)); + bomwin.save(); + count++; + } + //2023 10月8日修改 + //版本 + leftTable.setValueAt(newItemRevision.getStringProperty("item_revision_id"), gbIndex, 2); + //发布状态 + leftTable.setValueAt("未发布", gbIndex, 4); + //同步状态 + leftTable.setValueAt("已更新", gbIndex, 5); + //修改第一个窗口表格数据 + //循环获取主表格数据 + for(int i=0;i -1) { + selectParts(); + } + } + } + + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_20/WorkStepChangeDailog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_20/WorkStepChangeDailog.java new file mode 100644 index 0000000..3eb8790 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_20/WorkStepChangeDailog.java @@ -0,0 +1,1105 @@ +package com.connor.ml.tcm.ML_20; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.function.IntPredicate; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.osgi.framework.launch.Framework; + +import com.connor.ml.tcm.outfile.ML_01.DbomTransitionToEbomDialog; +import com.connor.ml.tcm.util.MethodUtil; +import com.connor.ml.tcm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.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.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCComponentBOPWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.schemas.internal.core._2011_06.ict.Array; + +import edu.emory.mathcs.backport.java.util.Arrays; + +public class WorkStepChangeDailog extends JFrame implements ActionListener{ + + /** + * + */ + private static final long serialVersionUID = 3251328284145342377L; + private static final TCComponent TCComponentItemRevision = null; + private AbstractAIFUIApplication app; + private TCComponent[] targets; + private TCSession session; + private TCComponentItemRevision target; + + private JPanel topPanel; + private JTable oneTable; + private String[] oneColumns = {"序号","物料编码","版本","名称","加工方式","加贸"}; + private Object[][] oneValues; + private JButton selectChangeButton; + + private JTable twoTable; + private String[] twoColumns = {"子物料R3码(原为)","物料名称","数量","子物料R3码(现改为)","物料名称","数量"}; + private Object[][] twoValues; + private JButton twoAddButton; + private JButton twoCelButton; + private JButton twoAnalysisButton; + + private JPanel centerPanel; + private JTable mainTable; + private String[] mainColumns = {"序号","产品代码","当前版本","名称","产品状态","创造者", + "关联的产品工艺","产品工艺版本","产品工艺名称","工步引用","工步版本","工步所有者","工步名称","工步状态","同步状态"}; + private JButton updateButton; + private JButton openWorkStepButton; + private JButton processButton; + private String[][] mainValues; + //excel文档导出的操作条件 + private Map> conditions; + //数据集所在版本的关系名称 + private final static String DATASET_RELATION = "IMAN_specification"; + + //引用的产品中的所有工步 + private ArrayList mainList = new ArrayList(); + //引用的产品中的工步id(防止重复) + private ArrayList ids = new ArrayList(); + + private TCComponentBOPWindow bopwin; + private TCComponentBOMWindow bomwin; + + //工步集合 + private String[] steps = {"ML8_Step","ML8_BJStep","ML8_PTStep","ML8_FPStep","ML8_XSStep","ML8_JBStep", + "ML8_TestStep","ML8_GLLJStep","ML8_HJStep","ML8_YSJStep","ML8_VPStep","ML8_JLStep"}; + + public WorkStepChangeDailog(AbstractAIFUIApplication app,TCComponent[] targets,TCComponentItemRevision target) { + //super(false); + this.app = app; + this.target = target; + this.targets = targets; + createWindow(); + oneValues = new String[targets.length][oneColumns.length]; + for (int i = 0; i < targets.length; i++) { + for (int j = 0; j < oneColumns.length; j++) { + try { + switch (j) { + case 0: + oneValues[i][j] = String.valueOf(i + 1); + break; + case 1: + oneValues[i][j] = targets[i].getStringProperty("item_id"); + break; + case 2: + oneValues[i][j] = targets[i].getStringProperty("item_revision_id"); + break; + case 3: + oneValues[i][j] = targets[i].getStringProperty("object_name"); + break; + case 4: + oneValues[i][j] = targets[i].getStringProperty("ml8_ProcessingMode"); + break; + case 5: + oneValues[i][j] = targets[i].getStringProperty("ml8_AddTrade"); + break; + } + } catch (TCException e) { + e.printStackTrace(); + } + + } + } + + this.session = (TCSession) app.getSession(); + try { + List childComponents = getChildComponents(target, "MSExcel", DATASET_RELATION); + if(childComponents==null||childComponents.size()==0) { + MessageBox.post("变更通知单版本下未找到EXCEL文件!","",MessageBox.INFORMATION); + return; + } + TCComponentDataset dataset = (TCComponentDataset) childComponents.get(0); + conditions = loadData(dataset); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + init(); + } + + private Map> loadData(TCComponentDataset dataset) throws TCException, IOException{ + Map> map = new HashMap>(); + TCComponentTcFile[] files = dataset.getTcFiles(); + File file = files[0].getFile(System.getProperty("java.io.tmpdir")); + String suffix = file.getAbsolutePath().substring(file.getAbsolutePath().lastIndexOf(".")+1); + FileInputStream input = new FileInputStream(file); + Workbook wb = null; + switch (suffix) { + case "xls": + wb = new HSSFWorkbook(input); + break; + case "xlsx": + wb = new XSSFWorkbook(input); + break; + default: + break; + } + Sheet sheet = wb.getSheet("BOM更改"); + int firstRow = sheet.getFirstRowNum(); + int lastRow = sheet.getLastRowNum(); + int startRow = lastRow; + System.out.println("开始提取表格信息"); + System.out.println("表格首行为:"+firstRow+",尾行为:"+lastRow); + for (int i = firstRow; i <= lastRow; i++) { + Row row = getRow(sheet, i); + Cell cell7 = getCell(row, 4); + String stringCellValue7 = getCellValue(cell7).trim(); + //获取父级id所在行数 + if(stringCellValue7!=null&&"R3码".equals(stringCellValue7)) { + startRow = i; + } + int t = startRow + 1; + System.out.println("数据从"+t+"行开始获取"); + if(i > startRow) { + //判断 结束位置 + Cell cell3 = getCell(row, 3); + String stringCellValue3 = getCellValue(cell3); + if(stringCellValue3!=null&&stringCellValue3.trim().length()>0)break; + List tempList = new ArrayList(); + if(stringCellValue7!=null&&stringCellValue7.trim().length()>0) { + String key = stringCellValue7; + do { + String [] tempArr = new String[6]; + tempArr[0] = getCellValue(getCell(row, 6)).trim(); + tempArr[1] = getCellValue(getCell(row, 7)).trim(); + tempArr[2] = getCellValue(getCell(row, 8)).trim(); + tempArr[3] = getCellValue(getCell(row, 9)).trim(); + tempArr[4] = getCellValue(getCell(row, 10)).trim(); + tempArr[5] = getCellValue(getCell(row, 11)).trim(); +// tempArr[1] = getCell(row, 21).getStringCellValue()!=null?getCell(row, 21).getStringCellValue():""; +// tempArr[2] = getCell(row, 25).getStringCellValue()!=null?getCell(row, 25).getStringCellValue():""; +// tempArr[3] = getCell(row, 27).getStringCellValue()!=null?getCell(row, 27).getStringCellValue():""; +// tempArr[4] = getCell(row, 32).getStringCellValue()!=null?getCell(row, 32).getStringCellValue():""; +// tempArr[5] = getCell(row, 36).getStringCellValue()!=null?getCell(row, 36).getStringCellValue():""; + if(!tempArr[0].equals(""))tempList.add(tempArr); + i++; + row = getRow(sheet, i); + cell7 = getCell(row, 4); + stringCellValue7 = getCellValue(cell7).trim(); + }while(stringCellValue7==null||"".equals(stringCellValue7)); + map.put(key, tempList); + System.out.println("================="); + System.out.println("map添加key:"+key); + for(String[] s:tempList) { + System.out.println("--------"); + for(String str:s) { + System.out.println(str); + } + System.out.println("--------"); + } + System.out.println("================="); + i--; + } + } + } + return map; + } + + public Row getRow(Sheet sheet,int i) { + Row row = sheet.getRow(i); + if(row==null)row = sheet.createRow(i); + return row; + } + public Cell getCell(Row row,int i) { + Cell cell = row.getCell(i); + if(cell==null)cell = row.createCell(i); + return cell; + } + + public String getCellValue(Cell c) { + if (c == null) { + return ""; + } + String value = ""; + if (c.getCellType() == CellType.NUMERIC.getCode()) { + DecimalFormat df = new DecimalFormat("0"); + String whatYourWant = df.format(c.getNumericCellValue()); + return whatYourWant; + } + switch (c.getCellType()) { + case HSSFCell.CELL_TYPE_NUMERIC:// 数字 + value = (c.getNumericCellValue() + "").split("\\.")[0]; + break; + case HSSFCell.CELL_TYPE_STRING:// 字符串 + value = c.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_BOOLEAN:// boolean + value = c.getBooleanCellValue() + ""; + break; + case HSSFCell.CELL_TYPE_FORMULA:// 公式 + value = c.getCellFormula() + ""; + break; + case HSSFCell.CELL_TYPE_BLANK:// 空值 + value = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + value = "非法字符"; + break; + default: + value = "未知类型"; + break; + } + return value; + } + + public void run() { + init(); + } + + private void init() { + this.setTitle("工艺变更"); + this.setSize(new Dimension(1500,899)); + + JPanel onePanel = new JPanel(new BorderLayout()); + JLabel oneLabel = new JLabel("父级物料编号:"); + Font font = new Font("新宋体", 1, 24); + oneLabel.setFont(font); + this.oneTable = getjTable(oneTable, null, oneColumns, oneValues); + selectChangeButton = new JButton("查找"); + JPanel oneButtonPanel = new JPanel(new PropertyLayout()); + oneButtonPanel.add("1.1.center",selectChangeButton); + onePanel.add(BorderLayout.NORTH,oneLabel); + onePanel.add(BorderLayout.CENTER,new JScrollPane(oneTable)); + //onePanel.add(BorderLayout.EAST,oneButtonPanel); + + JPanel twoPanel = new JPanel(new BorderLayout()); + JLabel twoLabel = new JLabel("更改内容:"); + twoLabel.setFont(font); + this.twoTable = getjTable(twoTable, null, twoColumns, twoValues); + twoAddButton = new JButton("+"); + twoCelButton = new JButton("-"); + twoAnalysisButton = new JButton("影响分析"); + oneTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + + @Override + public void valueChanged(ListSelectionEvent e) { + // TODO Auto-generated method stub + int row = oneTable.getSelectedRow(); + if(row!=-1) { + TCComponentItemRevision revision = (com.teamcenter.rac.kernel.TCComponentItemRevision) targets[row]; +// TCComponentItemRevision revision = mainList.get(row); + try { + System.out.println("选中行id:"+revision.getStringProperty("item_id")); + if(conditions.containsKey(revision.getStringProperty("item_id"))) { + System.out.println("提取文档信息到条件表格"); + List list = conditions.get(revision.getStringProperty("item_id")); + String [][] data = new String[list.size()][6]; + System.out.println("list.size="+list.size()); + for(int i = 0;i sorter = new TableRowSorter(partsTable.getModel()); + //partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } +// } + return partsTable; + } + + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames); + } + return tableModel; + } + + public void addData(Object[][] cellData,String[] columns,JTable table) { + DefaultTableModel tableModel = (DefaultTableModel) table.getModel(); + tableModel.setRowCount(0); + RowSorter sorter = new TableRowSorter( + this.getTableModel(null, columns, cellData)); + //table.setRowSorter(sorter); + for (int i = 0; i < cellData.length; i++) { + tableModel.addRow(cellData[i]); + } + // 表格数据不可修改 + //table.setEnabled(true); + // 更新表格 + table.invalidate(); + } + @Override + public void actionPerformed(ActionEvent event) { + if(event.getSource() == this.twoAddButton) { + DefaultTableModel tableModel = (DefaultTableModel) this.twoTable.getModel(); + tableModel.addRow(new String[] {}); + }else if(event.getSource() == this.twoCelButton) { + int selectedRow = twoTable.getSelectedRow();//获得选中行的索引 + if(selectedRow!= -1) //是否存在选中行 + { + DefaultTableModel tableModel = (DefaultTableModel) this.twoTable.getModel(); + tableModel.removeRow(selectedRow); //删除行 + } + }else if(event.getSource() == this.twoAnalysisButton) { + new Thread() { + @Override + public void run() { + ProgressBarThread thread = new ProgressBarThread("查询中", "查询中..."); + thread.start(); + mainList.clear(); + ids.clear(); + int oneIndex = oneTable.getSelectedRow(); + int twoIndex = twoTable.getSelectedRow(); + String changeId = twoTable.getValueAt(twoIndex, 0).toString(); + try { + System.out.println("当前选中对象为:" + targets[oneIndex].toString()); + ArrayList topList = new ArrayList(); + getTopItem(targets[oneIndex],false,topList); + System.out.println("得到的数据长度为:" + topList.size()); + //得到右边更改内容的上一级(所有的工步类型) + ArrayList gbList = new ArrayList(); + + TCComponent[] search = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {changeId}); + if(search == null || search.length == 0) { + MessageBox.post(changeId + "该ID在tc中未找到对象", "提示", MessageBox.ERROR); + return; + } + TCComponentItemRevision changeRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + TCComponent[] whereReferenced = changeRev.whereUsed((short)0); + ArrayList tccomponents = new ArrayList(); + for(TCComponent reContext : whereReferenced) { +// InterfaceAIFComponent component = reContext.getComponent(); +// if(component instanceof TCComponent) { + tccomponents.add((TCComponent)reContext); +// } + } + //TCComponent[] whereUsed = changeRev.whereUsed(TCComponentItemRevision.WHERE_USED_ALL); + TCComponent[] whereUsed = (TCComponent[]) tccomponents.toArray(new TCComponent[0]); + for(TCComponent tcComponent : whereUsed) { + if(tcComponent.getStringProperty("object_name")!=null) { + System.out.println("更改内容id引用:"+tcComponent.getStringProperty("object_name")); + } + } + Map> revsMap = new HashMap<>(); + List asList = Arrays.asList(steps); + for (int i = 0; i < whereUsed.length; i++) { + + if(whereUsed[i].getType().contains("Step")) { + TCComponentItemRevision rev = (TCComponentItemRevision) whereUsed[i]; + TCComponentItemRevision latestItemRevision = rev.getItem().getLatestItemRevision(); + gbList.add(latestItemRevision); + ArrayList gbForGyList = new ArrayList(); + getTopGYItem(latestItemRevision, gbForGyList,gbList); + revsMap.put(latestItemRevision, gbForGyList); + } + } + //得到数据的集合 + int index = 1; + System.out.println("revsMap==>"+revsMap.toString()); + System.out.println("gbList==>"+gbList.toString()); + ArrayList> dataList = new ArrayList>(); + for (int i = 0; i < gbList.size(); i++) { + //工艺对象 + TCComponentItemRevision gbRevision = gbList.get(i); + List lists = revsMap.get(gbRevision); + if(lists.size()==0) { + continue; + } + TCComponentItemRevision gyRevision = lists.get(0).getItem().getLatestItemRevision(); + //产品对象 + TCComponent[] components = gyRevision.getRelatedComponents("IMAN_METarget"); +// gbRevision = null; +// try { +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// continue; +// } + String gbId = gbRevision.getStringProperty("item_id"); + for (TCComponent cpRevision : components) { + //符合条件 + System.out.println("cpRevision==>"+cpRevision.toString()); + if(topList.contains(cpRevision) && !ids.contains(gbId)) { + System.out.println("gbId==>"+gbId); + TCComponentItemRevision revision = gyRevision.getItem().getLatestItemRevision();//工艺 + TCComponentItemRevision latestItemRevision = ((TCComponentItemRevision) cpRevision);//产品 + ArrayList list = new ArrayList(); + list.add(String.valueOf(index)); + list.add(latestItemRevision.getStringProperty("item_id")); + list.add(latestItemRevision.getStringProperty("item_revision_id")); + list.add(latestItemRevision.getStringProperty("object_name")); + //删除制造厂 产线列(改为隐藏这两列) + //list.add(latestItemRevision.getTCProperty("ml8_Factory").getDisplayableValue()); + //list.add(latestItemRevision.getStringProperty("ml8_Line")); + if(latestItemRevision.getProperty("release_status_list") == "" || latestItemRevision.getProperty("release_status_list") == null) { + list.add("未发布"); + }else { + list.add(latestItemRevision.getProperty("release_status_list")); + } + String userName = latestItemRevision.getReferenceProperty("owning_user") + .getStringProperty("user_name"); + list.add(userName); + list.add(revision.getStringProperty("item_id")); + list.add(revision.getStringProperty("item_revision_id")); + list.add(revision.getStringProperty("object_name")); + //工步属性 + list.add(gbId); + String status = gbRevision.getProperty("release_status_list"); + System.out.println("发布状态为 :" + status); + list.add(gbRevision.getStringProperty("item_revision_id")); + //添加工步所有者 + list.add(gbRevision.getProperty("owning_user")); + list.add(gbRevision.getStringProperty("object_name")); + list.add(status == "" ? "未发布" : "已发布"); + /** + * 判断工步对象发布状态,若已发布,则判断其版本属性更改单号(ml8_changeNO), + * 若其属性值与当前选择的设计更改单的ID一致,则显示“已更新”,若是该属性没有值,或属性值与当前设计更改单的ID不一致,则为未更新。 + 若工步未发布,则根据更改单号属性值进行判断,若值和当前设计更改单的ID一致,则为已更新,若属性值不一致或没有值,则为未更新。 + */ + String changeNo = gbRevision.getStringProperty("ml8_changeNO"); + list.add(target.getStringProperty("item_id").equals(changeNo)? "已更新" :"未更新"); + dataList.add(list); + ids.add(gbId); + mainList.add(gbRevision); + index++; + break; + } + } + } + System.out.println("dataList==>"+dataList.toString()); + if(dataList.size()==0) { + thread.setBool(true); + MessageBox.post("影响分析查询结果为空。","提示",2); + } + mainValues = new String[dataList.size()][]; + for (int i = 0; i < dataList.size(); i++) { + mainValues[i] = new String[dataList.get(i).size()]; + for (int j = 0; j < dataList.get(i).size(); j++) { + mainValues[i][j] = dataList.get(i).get(j); + } + } + addData(mainValues,mainColumns,mainTable); + mainTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 禁用自动调整列宽 + TableColumnModel columnModel = mainTable.getColumnModel(); + for (int column = 0; column < mainTable.getColumnCount(); column++) { + TableColumn tableColumn = columnModel.getColumn(column); + int preferredWidth = tableColumn.getMinWidth(); + int maxWidth = tableColumn.getMaxWidth(); + + for (int row = 0; row < mainTable.getRowCount(); row++) { + TableCellRenderer cellRenderer = mainTable.getCellRenderer(row, column); + Component c = mainTable.prepareRenderer(cellRenderer, row, column); + int width = c.getPreferredSize().width + mainTable.getIntercellSpacing().width; + preferredWidth = Math.max(preferredWidth, width); + + // 如果列宽度超过最大值,则使用最大值 + if (preferredWidth >= maxWidth) { + preferredWidth = maxWidth; + break; + } + } + + tableColumn.setPreferredWidth(preferredWidth); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + thread.setBool(true); + } + } + }.start(); + + } else if (event.getSource() == this.updateButton) { + // 在引用的产品窗口中,用户多选对象后,点击升版并同步按钮, + // 如果工步状态为已发布,则进行升版;若未发布,则直接修改。 + // 在同步完成之后,将当前设计更改单对象的ID,填写到自动同步的MBOM的属性更改单号(ml8_changeNO)内 + try { + int[] selectedRows = mainTable.getSelectedRows(); + int[] twoRows = twoTable.getSelectedRows(); + ArrayList> dealList = new ArrayList>(); + ArrayList> dealItemList = new ArrayList>(); + for (int i : twoRows) { + System.out.println("当前选中的更改内容行为" + (i + 1)); + String r3OldId = twoTable.getValueAt(i, 0) == null ? "" :twoTable.getValueAt(i, 0).toString(); + String reNewId = twoTable.getValueAt(i, 3).toString(); + String r3OldCount = twoTable.getValueAt(i, 2).toString(); + String r3NewCount = twoTable.getValueAt(i, 5).toString(); + String way = "";// 新增,替换,删除 + if(r3OldId.equals(reNewId)) { + if(r3NewCount.equals("0")) + way = "删除"; + else + way = "新增"; + }else { + way = "替换"; + } +// String way = twoTable.getValueAt(i, 0).toString();// 新增,替换,删除 +// String r3OldId = twoTable.getValueAt(i, 1) == null ? "" :twoTable.getValueAt(i, 1).toString(); +// String reNewId = twoTable.getValueAt(i, 4).toString(); +// String r3OldCount = twoTable.getValueAt(i, 3).toString(); +// String r3NewCount = twoTable.getValueAt(i, 6).toString(); + TCComponent[] oldSearch = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { r3OldId }); + TCComponent[] newSearch = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] { reNewId }); + if (oldSearch == null || oldSearch.length == 0) { + MessageBox.post("ID为:" + r3OldId + "的对象在TC中不存在", "错误", MessageBox.ERROR); + return; + } + if (newSearch == null || newSearch.length == 0) { + MessageBox.post("ID为:" + reNewId + "的对象在TC中不存在", "错误", MessageBox.ERROR); + return; + } + ArrayList list = new ArrayList(); + list.add(way); + list.add(r3OldId); + list.add(reNewId); + list.add(r3OldCount); + list.add(r3NewCount); + dealList.add(list); + TCComponentItem oldItem = (TCComponentItem) oldSearch[0]; + TCComponentItem newItem = (TCComponentItem) newSearch[0]; + ArrayList itemList = new ArrayList(); + itemList.add(oldItem); + itemList.add(newItem); + dealItemList.add(itemList); + } + String mess = ""; + for (int index : selectedRows) { + System.out.println("当前选中引用行为:" + index); + TCComponentItemRevision revision = mainList.get(index); + TCComponentItemRevision center; + System.out.println("判断前:当前对象为:" + revision.getItem().getLatestItemRevision() + "====== 发布状态为:" + mainTable.getValueAt(index, 13).toString()); + if (mainTable.getValueAt(index, 13).toString().equals("未发布")) { + //修改判断权限 + String property = revision.getItem().getLatestItemRevision().getProperty("owning_user"); + String userName = session.getUser().getUserName(); + String userId = session.getUser().getUserId(); + System.out.println("当前用户:"+property); + System.out.println("当前user:"+userName); + System.out.println("当前userid:"+userId); + if(!property.contains(userName) && !property.contains(userId)) { + mess+=revision.getItem().getLatestItemRevision().getProperty("object_string")+" "; + continue; + } + center = revision.getItem().getLatestItemRevision(); + } else { + center = revision.saveAs(""); + mainValues[index][10] = center.getStringProperty("item_revision_id"); + mainValues[index][13] = "未发布"; + } + mainValues[index][14] = "已更新"; + System.out.println("判断后:当前对象为:" + center + "====== 发布状态为:" + mainTable.getValueAt(index, 13).toString()); + MethodUtil.openByPass(session); + try { + center.setStringProperty("ml8_changeNO", target.getStringProperty("item_id")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + MethodUtil.closeByPass(session); + } + TCComponentBOMLine topLine = bomwin.setWindowTopLine(center.getItem(), center, null, null); + AIFComponentContext[] children = topLine.getChildren(); + for (int i = 0; i < dealList.size(); i++) { + ArrayList list = dealList.get(i); + ArrayList list2 = dealItemList.get(i); + String way = list.get(0); + String r3OldId = list.get(1); + String reNewId = list.get(2); + String r3OldCount = list.get(3); + String r3NewCount = list.get(4); + switch (way) { + case "增加": + case "新增": + /** + * 程序根据子物料R3码(原为)中的id,在工步下找到该对象,再根据子物料R3码(现改为)的数量, + * 修改原数量,若子物料R3码(原为)的数量为0,则在工步下新增该对象 + */ + if (r3OldCount.isEmpty() || r3OldCount.equals("0")) { + System.out.println("增加时:开始修改数量;数量改为:" + r3NewCount); + TCComponentBOMLine add = topLine.add(list2.get(0), list2.get(0).getLatestItemRevision(), null, false, ""); + add.setStringProperty("bl_quantity", r3NewCount); + bomwin.save(); + } else { + if (!r3NewCount.isEmpty() && !r3NewCount.equals("0")) { + for (AIFComponentContext context : children) { + TCComponentBOMLine bomline = (TCComponentBOMLine) context.getComponent(); + String bomId = bomline.getStringProperty("bl_item_item_id"); + if (r3OldId.equals(bomId)) { + System.out.println("增加时:开始修改数量;数量改为:" + r3NewCount); + bomline.setStringProperty("bl_quantity", r3NewCount); + bomwin.save(); + break; + } + else { + + } + } + } + } + break; + case "替换": + // 程序根据子物料R3码(原为)中的id,在工步下找到该对象,再根据子物料R3码(现改为)中的id和数量,替换原对象 + for (AIFComponentContext context : children) { + TCComponentBOMLine bomline = (TCComponentBOMLine) context.getComponent(); + String bomId = bomline.getStringProperty("bl_item_item_id"); + if (r3OldId.equals(bomId)) { + System.out.println("替换时:开始替换对象"); + bomline.cut(); + TCComponentBOMLine add = topLine.add(list2.get(1), list2.get(1).getLatestItemRevision(), null, + false, ""); + add.setStringProperty("bl_quantity", r3NewCount); + bomwin.save(); + } + } + break; + case "删除": + if (r3NewCount.isEmpty() || r3NewCount.equals("0")) { + for (AIFComponentContext context : children) { + TCComponentBOMLine bomline = (TCComponentBOMLine) context.getComponent(); + String bomId = bomline.getStringProperty("bl_item_item_id"); + if (r3OldId.equals(bomId)) { + System.out.println("删除时:开始删除对象"); + bomline.cut(); + bomwin.save(); + } + } + } + break; + default: + break; + } + } + } + + //更新表中的值 + addData(mainValues,mainColumns,mainTable); + if("".equals(mess)) { + MessageBox.post("升版并同步执行成功!!!", "成功", MessageBox.INFORMATION); + }else { + MessageBox.post("工步"+mess+"没有权限修改,其余升版并同步执行成功", "提示", MessageBox.INFORMATION); + } + + } catch (Exception e) { + MessageBox.post(e.getMessage(), "异常", MessageBox.ERROR); + e.printStackTrace(); + } + }else if(event.getSource() == this.processButton) { + /*提交工艺变更流程 + * (5)程序自动创建工艺变更通知单(ML8_MCNotice),并检查同步状态为已更新的MBOM对象, + * 若此工步为A版,则不需要将其拷贝至工艺变更通知单下, + * 若不为A版,则将此版本拷贝至工艺变更通知单的变更后关系下,并且其上一版对象, + * 拷贝至工艺变更通知单的变更后关系下,再将设计变更通知单(ML8_CNoticeRevision) + * 版本对象以设计变更通知单关系(ML8_RelatedECN)拷贝至工艺变更通知单下, + * 之后程序调用624TCM_更改审批流程,将该工艺变更通知单作为流程目标并发起流程。 + */ + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ML8_MCNotice"); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + Date date = new Date(); + String head = "TCM-" + sdf.format(date)+"-"; + TCComponent[] search = session.search("零组件...", new String [] {"类型","零组件 ID"}, new String [] {"工艺变更通知单" ,head + "*"}); + DecimalFormat df = new DecimalFormat("000000"); + String newID = search[search.length - 1].getStringProperty("item_id"); + String[] split = newID.split("-"); + int end = Integer.parseInt(split[2]) + 1; + String id = head + df.format(end); + while(itemType.find(id) != null) { + end++; + id = head + df.format(end); + } + //id,版本,类型,名称,描述 + TCComponentItem newItem = + itemType.create(id,"A", "ML8_MCNotice", "变更工艺通知单", "", null); + MethodUtil.openByPass(session); + try { + int[] selectedRow = mainTable.getSelectedRows(); + for(int i=0;i topList) throws TCException { + ArrayList tccomponents = new ArrayList(); + TCComponent[] whereReferenced = com.whereUsed((short)0); + for(TCComponent reContext : whereReferenced) { +// InterfaceAIFComponent component = reContext.getComponent(); +// if(component instanceof TCComponent) { + tccomponents.add((TCComponent)reContext); +// } + } + //TCComponent[] whereUsed = com.whereUsed(TCComponent.WHERE_USED_ALL); + + TCComponent[] whereUsed = (TCComponent[]) tccomponents.toArray(new TCComponent[0]); + for (TCComponent component2 : whereUsed) { + String type = component2.getType(); + if(one.equals(type) || two.equals(type)) { + if(component2.getProperty("object_name")!=null) { + System.out.println(com.getProperty("object_string")+"通过引用关系找到bom顶层:"+component2.getProperty("object_string")); + } + topList.add((TCComponentItemRevision) component2); + } + if(four.equals(type) || five.equals(type)) { + getTopItem(component2,condition,topList); + } + } + } + + /** + * 通过工步找到顶层的产品工艺 + * @param com + * @param topList + * @throws TCException + */ + private void getTopGYItem(TCComponent com ,ArrayList topList,ArrayList gbList) throws TCException { + ArrayList tccomponents = new ArrayList(); + TCComponent[] whereReferenced = com.whereUsed((short)0); + for(TCComponent reContext : whereReferenced) { +// InterfaceAIFComponent component = reContext.getComponent(); +// if(component instanceof TCComponent) { + tccomponents.add((TCComponent)reContext); +// } + } + //TCComponent[] whereUsed = com.whereUsed(TCComponent.WHERE_USED_ALL); + TCComponent[] whereUsed = (TCComponent[]) tccomponents.toArray(new TCComponent[0]); + for (TCComponent component2 : whereUsed) { + String type = component2.getType(); + if(three.equals(type)) { + if(component2.getStringProperty("object_name")!=null) { + System.out.println("通过工步"+com.getStringProperty("object_name")+"找到顶层的产品工艺:"+component2.getStringProperty("object_name")); + } +// gbList.add((TCComponentItemRevision)com); + topList.add((TCComponentItemRevision) component2); + } + else { + getTopGYItem(component2,topList,gbList); + } + } + } + + /** + * 得到工艺BOM下面有更改内容的所选对象(根据子物料R3码(原为)的id,在产品工艺中找到引用(BOM关系)该物料的工步) + * @param changeId + * @param topLine + * @param datasMap + * @param topId 顶层产品的ID + * @throws TCException + */ + private void getStepDatas(String changeId,TCComponentBOPLine topLine,HashMap datasMap,String topId) throws TCException { + AIFComponentContext[] children = topLine.getChildren(); + if(children != null && children.length > 0) { + for (AIFComponentContext aifComponentContext : children) { + TCComponentBOPLine childLine = (TCComponentBOPLine) aifComponentContext.getComponent(); + String type = childLine.getTCProperty("bl_item_object_type").getDisplayableValue(); + if(type.contains("工步")) { + AIFComponentContext[] children2 = childLine.getChildren(); + if(children2 != null && children2.length > 0) { + for (AIFComponentContext aifComponentContext2 : children2) { + TCComponentBOPLine part = (TCComponentBOPLine) aifComponentContext2.getComponent(); + String id = part.getItem().getStringProperty("item_id"); + String stepId = childLine.getStringProperty("bl_item_item_id"); + if(id.equals(changeId) && !ids.contains(stepId)) { + ids.add(stepId); + datasMap.put(stepId + "@@@" + topId , childLine.getItem().getLatestItemRevision()); + mainList.add(childLine.getItem().getLatestItemRevision()); + } + } + } + } + getStepDatas(changeId,childLine,datasMap,topId); + + } + } + } + + private void createWindow() { + try { + TCSession session = (TCSession) app.getSession(); + TCTypeService service = session.getTypeService(); + TCComponentBOPWindowType winType = (TCComponentBOPWindowType) service.getTypeComponent("BOPWindow"); + TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + this.bopwin = winType.createBOPWindow(null); + this.bomwin = bomWinType.create(null); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public static List getChildComponents(TCComponent rev, String dsType, String rel) throws Exception { + if (rev == null) { + return null; + } + rev.refresh(); + List res = new ArrayList(); + TCComponent[] kids = rev.getRelatedComponents(rel); + for (TCComponent c : kids) { + if (c.getType().equals(dsType)) { + res.add(c); + } + } + return res; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_20/WorkStepChangeHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_20/WorkStepChangeHandler.java new file mode 100644 index 0000000..1578f39 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_20/WorkStepChangeHandler.java @@ -0,0 +1,66 @@ +package com.connor.ml.tcm.ML_20; + +import java.text.DecimalFormat; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.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.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.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class WorkStepChangeHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + TCSession session = (TCSession) app.getSession(); + + if(!"ML8_CNoticeRevision".equals(targetComponent.getType())) { + MessageBox.post("请选中'设计变更通知单版本对象'!!!","错误", MessageBox.ERROR); + return null; + } + else { + TCComponentItemRevision rev = (TCComponentItemRevision) targetComponent; + try { + TCComponent[] relatedComponent = rev.getRelatedComponents("ML8_GXBGH"); + if(relatedComponent == null || relatedComponent.length == 0) { + MessageBox.post("该对象的变更后关系下没有数据!!!","错误", MessageBox.ERROR); + } + else { + WorkStepChangeDailog dialog = new WorkStepChangeDailog(app, relatedComponent,rev); + //new Thread(dialog).start(); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + return null; + } + + public void delete_recycleID(TCUserService userService,String itemID) { + // Object[] params = { counterName, itemID }; + if ((itemID == null) || (itemID.length() == 0)) { + return; + } + itemID = itemID.replace(" ", "").trim(); + Object[] params = { itemID }; + try { + userService.call("delete_recycleID", params); + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_21/GySopHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_21/GySopHandler.java new file mode 100644 index 0000000..360a1a1 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_21/GySopHandler.java @@ -0,0 +1,65 @@ +package com.connor.ml.tcm.ML_21; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.outfile.ML_02.GXZYZDSCommand; +import com.connor.ml.tcm.outfile.ML_03.GWZYZDSCommand; +import com.connor.ml.tcm.outfile.ML_09.CPGYSOPCommand; +import com.connor.ml.tcm.outfile.ML_10.CXGYSOPCommand; +//import com.connor.ml.tcm.outfile.ML_02.GXZYZDSCommand; +//import com.connor.ml.tcm.outfile.ML_03.GWZYZDSCommand; +//import com.connor.ml.tcm.outfile.ML_09.CPGYSOPCommand; +//import com.connor.ml.tcm.outfile.ML_10.CXGYSOPCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class GySopHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp = app.getTargetComponent(); + try { + if((comp instanceof TCComponentBOMLine) && ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_ProdProcess")) { + try { + GXZYZDSCommand command = new GXZYZDSCommand(app.getTargetComponent(),session,false);//工序 + command.executeModal(); + + CPGYSOPCommand command2 = new CPGYSOPCommand(app.getTargetComponent(),session);//产品 + command2.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } + else if((comp instanceof TCComponentBOMLine) && ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_PlantBOP")) { + try { + GWZYZDSCommand command = new GWZYZDSCommand(app.getTargetComponent(),session); //工位 + command.executeModal(); + + CXGYSOPCommand command2 = new CXGYSOPCommand(app.getTargetComponent(),session);//产线 + command2.executeModal(); + } catch (Exception e) { + e.printStackTrace(); + } + } + else { + MessageBox.post("请选中正确的对象(产品总装工艺对象、美菱工厂BOP对象)!", "提示", MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_21/GySopOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_21/GySopOperation.java new file mode 100644 index 0000000..447b775 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_21/GySopOperation.java @@ -0,0 +1,26 @@ +package com.connor.ml.tcm.ML_21; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; + +public class GySopOperation extends AbstractAIFOperation{ + + private int status;//1代表产品总装工艺对象、2代表美菱工厂BOP对象 + + public GySopOperation(InterfaceAIFComponent targetComponent,int status) { + this.status = status; + } + + @Override + public void executeOperation() throws Exception { + if(status == 1) { + + } + else if(status == 2) { + + } + + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/GBbean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/GBbean.java new file mode 100644 index 0000000..0c1c4af --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/GBbean.java @@ -0,0 +1,32 @@ +package com.connor.ml.tcm.ML_22; + +public class GBbean { + private String gbmc; + private String czms; + private String gxbz; + public GBbean(String gbmc, String czms, String gxbz) { + super(); + this.gbmc = gbmc; + this.czms = czms; + this.gxbz = gxbz; + } + public String getGbmc() { + return gbmc; + } + public void setGbmc(String gbmc) { + this.gbmc = gbmc; + } + public String getCzms() { + return czms; + } + public void setCzms(String czms) { + this.czms = czms; + } + public String getGxbz() { + return gxbz; + } + public void setGxbz(String gxbz) { + this.gxbz = gxbz; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/InsertPDFHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/InsertPDFHandler.java new file mode 100644 index 0000000..b9000f8 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/InsertPDFHandler.java @@ -0,0 +1,67 @@ +package com.connor.ml.tcm.ML_22; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.outfile.ML_02.GXZYZDSCommand; +import com.connor.ml.tcm.outfile.ML_03.GWZYZDSCommand; +import com.connor.ml.tcm.outfile.ML_09.CPGYSOPCommand; +import com.connor.ml.tcm.outfile.ML_10.CXGYSOPCommand; +//import com.connor.ml.tcm.outfile.ML_02.GXZYZDSCommand; +//import com.connor.ml.tcm.outfile.ML_03.GWZYZDSCommand; +//import com.connor.ml.tcm.outfile.ML_09.CPGYSOPCommand; +//import com.connor.ml.tcm.outfile.ML_10.CXGYSOPCommand; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.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 InsertPDFHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp = app.getTargetComponent(); + try { + if((comp instanceof TCComponentItemRevision)) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + String type = comp.getType(); + System.out.println("type===="+type); + if("ML8_StdOperationRevision".equals(type) || "ML8_DifOperationRevision".equals(type) + ||"ML8_SpecOpRevision".equals(type)) { + InsertPDFOperation operation = new InsertPDFOperation(rev, session); + session.queueOperation(operation); + } + }else if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine)comp; + TCComponentItem item = line.getItem(); + System.out.println("itemName===="+item.getStringProperty("object_name")); + String type =item.getType(); + System.out.println("type===="+type); + if("ML8_StdOperation".equals(type) || "ML8_DifOperation".equals(type) + ||"ML8_SpecOp".equals(type)) { + TCComponentItemRevision rev = item.getLatestItemRevision(); + InsertPDFOperation operation = new InsertPDFOperation(rev, session); + session.queueOperation(operation); + } + } + else { + MessageBox.post("请选中正确的对象(工序版本对象或者工序BOMLine对象)!", "提示", MessageBox.INFORMATION); + return null; + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/InsertPDFOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/InsertPDFOperation.java new file mode 100644 index 0000000..55cd287 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ML_22/InsertPDFOperation.java @@ -0,0 +1,333 @@ +package com.connor.ml.tcm.ML_22; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.io.File; +import java.io.FileOutputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import javax.swing.JPanel; + +import com.lowagie.text.pdf.BaseFont; +import com.lowagie.text.pdf.PdfContentByte; +import com.lowagie.text.pdf.PdfReader; +import com.lowagie.text.pdf.PdfStamper; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class InsertPDFOperation extends AbstractAIFOperation{ + + private TCComponentItemRevision rev; + private TCSession session; + public InsertPDFOperation(TCComponentItemRevision rev,TCSession session) { + this.rev = rev; + this.session = session; + } + + @Override + public void executeOperation() throws Exception { + TCComponent[] pdfs = rev.getRelatedComponents("ML8_3Dpdf"); + for (int i = 0; i < pdfs.length; i++) { + TCComponent[] releases = pdfs[i].getRelatedComponents("release_status_list"); + if(releases != null && releases.length > 0) { + MessageBox.post("已存在发布的3Dpdf,无法重新生成!!!", "提示", MessageBox.INFORMATION); + return; + }else { + rev.remove("ML8_3Dpdf", pdfs[i]); + pdfs[i].delete(); + rev.refresh(); + } + } + String gxName = rev.getStringProperty("object_name"); + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentBOMLine newLine = view.setWindowTopLine(rev.getItem(), rev, null, null); + List gbList = new ArrayList(); + List wlList = new ArrayList(); + try { + getGBItemAndWLItem(newLine,gbList,wlList); + String pdfUID = session.getPreferenceService().getStringValue("ML_OPOutPdfTemplate"); + TCComponentDataset pdfDataset = (TCComponentDataset)session.stringToComponent(pdfUID); + File[] files = pdfDataset.getFiles(""); + String path = files[0].getAbsolutePath(); + String path2 = path.replace(".pdf", "1.pdf"); + System.out.println("生成pdf路劲====="+path2); + insertPDF(path,path2,gxName,gbList,wlList); + TCComponentDataset dataset = createDataset(gxName +"_3DPDF"); + String as2[] = {"PDF_Reference"}; + String as1[] = {path2}; + dataset.setFiles(as1, as2); + rev.add("ML8_3Dpdf", dataset); + rev.refresh(); + File file2 = new File(path2); + File file = new File(path); + file.delete(); + file2.delete(); + MessageBox.post("3DPDF插入成功,请在版本下查看!!!", "提示", MessageBox.INFORMATION); + } catch (Exception e) { + e.printStackTrace(); + // TODO: handle exception + } + + + } + private TCComponentDataset createDataset(String name) { + TCComponentDataset mbDataset = null; + String type = "PDF"; + try { + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + mbDataset = datasetType.create(name, "", type); + } catch (TCException e) { + e.printStackTrace(); + } + return mbDataset; + } + private static void insertPDF(String path,String path2, String gxName ,List gbList, List wlList) { + // TODO Auto-generated method stub + try { + System.out.println("=====开始签字====="); + + PdfReader reader = new PdfReader(path); + + FileOutputStream ous = new FileOutputStream(path2); + PdfStamper stamper = new PdfStamper(reader, ous); + BaseFont base = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", true); + float x1 = 60.0F; + float y1 = 340.0F; + float x2 = 460.0F; + float y2= 340.0F; + PdfContentByte content = stamper.getUnderContent(1); + content.beginText(); + content.setColorFill(Color.BLACK); + content.setFontAndSize(base, 15.0F); + content.setTextRise(15.0F); + content.setTextMatrix(x1, y1); + // content.setTextMatrix(Float.valueOf(812.0F).floatValue(), + // Float.valueOf(-13.0F).floatValue()); + content.showText(gxName); + content.endText(); + for (int i = 0; i < gbList.size(); i++) { + GBbean gBbean = gbList.get(i); + // content.setTextMatrix(Float.valueOf(812.0F).floatValue(), + // Float.valueOf(-13.0F).floatValue()); + String val = "工步"+(i+1)+gBbean.getGbmc()+ ":" +gBbean.getCzms(); + List list = list2map(val,370); + for (int j = 0; j < list.size(); j++) { + y1 = y1 - 20.0F; + content.beginText(); + content.setColorFill(Color.BLACK); + content.setFontAndSize(base, 12.0F); + content.setTextRise(12.0F); + content.setTextMatrix(x1, y1); + content.showText(list.get(j)); + content.endText(); + } + String val1 = "工艺标准:"+gBbean.getGxbz(); + List list1 = list2map(val1,370); + for (int j = 0; j < list1.size(); j++) { + y1 = y1 - 20.0F; + content.beginText(); + content.setColorFill(Color.BLACK); + content.setFontAndSize(base, 12.0F); + content.setTextRise(12.0F); + content.setTextMatrix(x1, y1); + // content.setTextMatrix(Float.valueOf(812.0F).floatValue(), + // Float.valueOf(-13.0F).floatValue()); + content.showText(list1.get(j)); + content.endText(); + } + } + for (int i = 0; i < wlList.size(); i++) { + content.beginText(); + content.setColorFill(Color.BLACK); + content.setFontAndSize(base, 12.0F); + content.setTextRise(12.0F); + content.setTextMatrix(x2, y2); + // content.setTextMatrix(Float.valueOf(812.0F).floatValue(), + // Float.valueOf(-13.0F).floatValue()); + content.showText(wlList.get(i)); + content.endText(); + y2 = y2 - 15.0F; + } + stamper.close(); + ous.flush(); + ous.close(); + reader.close(); + System.out.println("=====签字结束====="); + } catch (Exception e) { + e.printStackTrace(); + } + + } + public static List list2map(String str, int width) { + List list2 = new ArrayList(); + Font font = new Font("宋体", Font.PLAIN, 12); + FontMetrics fm = sun.font.FontDesignMetrics.getMetrics(font); +// Font font = new Font("宋体", Font.PLAIN, 12); +// Graphics g = new JPanel().getGraphics(); // 可以是任意的 Graphics 对象 +// FontMetrics fm = g.getFontMetrics(font); + + String tmp_str = ""; + int tmp_width = 0; + int tmp_pic_width = 0; + Pattern pattern = Pattern.compile("w{1}(\\+)?(\\-)?(\\d+\\.\\d+)|(\\d+)"); + + String value = str; + + + + int index = 0; + + for (int j = 0; j < value.length(); j++) { + tmp_str = tmp_str+value.charAt(j); + + //System.out.println("tmp_str:"+tmp_str); + + //System.out.println("tmp width="+((fm.stringWidth(tmp_str)+tmp_pic_width)-tmp_width)); + + if(((fm.stringWidth(tmp_str)+tmp_pic_width)-tmp_width)>=width) + { + //如果有数字、规格、公差等字符时,需要在同一行输出 + int len = tmp_str.length(); + Matcher matcherBall = pattern.matcher(tmp_str); + boolean flag = false; + while (matcherBall.find()) + { + + //System.out.println("matcherBall.find"); + + int beginIndex = matcherBall.start(); + int endIndex = matcherBall.end(); + + + + if(endIndex==len) + { + //判断下一个值 + if(j gbList = new ArrayList(); +// gbList.add(new GBbean("工步名称1","选取对应型号冷藏内衬,检查内衬是否合格,胆口朝上摆放至皮带线上","工艺标注1")); +// gbList.add(new GBbean("工步名称2","操作描述2","工艺标注2")); +// gbList.add(new GBbean("工步名称3","操作描述3","工艺标注3")); +// gbList.add(new GBbean("工步名称4","操作描述4","工艺标注4")); +// gbList.add(new GBbean("工步名称5","操作描述5","工艺标注5")); +// gbList.add(new GBbean("工步名称6","操作描述6","工艺标注6")); +// List wlList = new ArrayList(); +// wlList.add("测试物料1"); +// wlList.add("测试物料2"); +// wlList.add("测试物料3"); +// wlList.add("测试物料4"); +// wlList.add("测试物料5"); +// wlList.add("测试物料6"); +// insertPDF(path,path2,gxName,gbList,wlList); +// } + private void getGBItemAndWLItem(TCComponentBOMLine newLine, List gbList, + List wlList) { + // TODO Auto-generated method stub + try { + AIFComponentContext[] childs = newLine.getChildren(); + for (int i = 0; i < childs.length; i++) { + InterfaceAIFComponent childComp = childs[i].getComponent(); + if(childComp instanceof TCComponentBOMLine) { + TCComponentBOMLine childLine = (TCComponentBOMLine) childComp; + TCComponentItemRevision childRev = childLine.getItemRevision(); + String type = childRev.getType(); + System.out.println("type===="+type); + if("ML8_StepRevision".equals(type) || "ML8_BJStepRevision".equals(type) || + "ML8_PTStepRevision".equals(type) || "ML8_FPStepRevision".equals(type) || + "ML8_XSStepRevision".equals(type) || "ML8_JBStepRevision".equals(type) || + "ML8_TestStepRevision".equals(type) || "ML8_GLLJStepRevision".equals(type) || + "ML8_HJStepRevision".equals(type) || "ML8_YSJStepRevision".equals(type) || + "ML8_VPStepRevision".equals(type) || "ML8_JLStepRevision".equals(type)) { + String gbmc = childRev.getStringProperty("object_name"); + String czms = childRev.getStringProperty("object_desc"); + String gxbz = childRev.getStringProperty("ml8_ProcessStandard"); + GBbean bean = new GBbean(gbmc,czms, gxbz); + gbList.add(bean); + AIFComponentContext[] wlChilds = childLine.getChildren(); + for (AIFComponentContext wlChild : wlChilds) { + InterfaceAIFComponent wlChildComp = wlChild.getComponent(); + if(wlChildComp instanceof TCComponentBOMLine) { + TCComponentBOMLine wlChildLine = (TCComponentBOMLine) wlChildComp; + TCComponentItemRevision wlRev = wlChildLine.getItemRevision(); + String wlType = wlRev.getType(); + System.out.println("wlType===="+wlType); + if("ML8_PartRevision".equals(wlType)) { + String wlName = wlRev.getStringProperty("object_name"); + wlList.add(wlName); + } + } + } + } + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/CheckHeaderCellRenderer.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/CheckHeaderCellRenderer.java new file mode 100644 index 0000000..d0427da --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/CheckHeaderCellRenderer.java @@ -0,0 +1,72 @@ +package com.connor.ml.tcm.OrderBOMTB; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; + +public class CheckHeaderCellRenderer implements TableCellRenderer { + DefaultTableModel tableModel; + JTableHeader tableHeader; + final JCheckBox selectBox; + + public CheckHeaderCellRenderer(final JTable table) { + this.tableModel = (DefaultTableModel) table.getModel(); + this.tableHeader = table.getTableHeader(); + selectBox = new JCheckBox(tableModel.getColumnName(0)); + selectBox.setSelected(false); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + // 获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == 0) { + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); +// tableModel.selectAllOrNull(value); + tableHeader.repaint(); + if(value) { + for(int i=0;i textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header = new String[] {"全选","生产订单号","产品代码","物料编码","产品名称","同步时间","生产计划号", + "批次号","工厂","ERP班组编码"}; + protected DefaultTableModel tm_part; + public DeleteOrdFram(TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + initUI(); + } +// private String sqlString = "delete ML_CREATEORDERBOM where STATUS='2' and PRODUCTID=? and MATERIALNO=? " +// + "and OBJECTNAME=? and PRODPLANO=? and BATCHNO=?" +// + " and FACTORY=? and REPCODE=? and PRODORDERO=?"; + private String sqlString = "delete ML_CREATEORDERBOM where STATUS='2' and PRODORDERO=? and PRODUCTID=? and MATERIALNO=? " + + "and OBJECTNAME=? and PRODPLANO=? and BATCHNO=?" + + " and FACTORY=? and REPCODE=?"; + private void initUI() { + // TODO Auto-generated method stub + try { + this.setTitle("批量删除订单BOM"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel,BorderLayout.NORTH); + this.add(pane,BorderLayout.CENTER); + this.add(btnPanel,BorderLayout.SOUTH); + + + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(1200,600)); + this.validate(); + this.setVisible(true); +// this.setAlwaysOnTop(true); + + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + // 添加监听 + public void createActionEvent() { + this.btnQry.addActionListener(this); +// this.readQry.addActionListener(this); + this.btnDis.addActionListener(this); + this.btnOk.addActionListener(this); + + } + private List compList = new ArrayList(); + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+"+source); + if(source.equals(this.btnQry)) { + + + new Thread() { + @Override + public void run() { + compList.clear(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm:ss"); +// TCComponent[] search = session.search("订单BOM查询", +// new String[] { "ml8_ProdPlanNo","早于","晚于"}, +// new String[] {cpdmField.getText(),simpleDateFormat.format(endButton.getDate()), +// simpleDateFormat.format(startButton.getDate())}); +// ConnorUtils.getDate2String(, startButton.getDate()), +// ConnorUtils.getDate2String(new SimpleDateFormat("yyyy-M-dd 23:59"), endButton.getDate() +// System.out.println(dateString); + try { + +// String[] fields = new String[] { "ml8_ProductID","ml8_MaterialNo","ml8_ProdOrderNo", +// "ml8_BatchNo","ml8_ProdPlanNo","ml8_Factory","ml8_ERPCode","早于","晚于"}; + ArrayList valueList = new ArrayList(); + ArrayList fieldList = new ArrayList(); + String[] fiels = new String[] { "ml8_ProductID","ml8_MaterialNo","ml8_ProdOrderNo", + "ml8_BatchNo","ml8_ProdPlanNo","ml8_Factory","ml8_ERPCode"}; + for (int i = 0; i < fiels.length; i++) { + String text = textMap.get(fiels[i]).getText(); + if(text != null && !text.isEmpty()) { + fieldList.add(fiels[i]); + valueList.add(text); + } + } + + if(endButton.getDate()!=null) { + valueList.add(simpleDateFormat.format(endButton.getDate()).toString()); + fieldList.add("早于"); + } + if(startButton.getDate()!=null) { + valueList.add(simpleDateFormat.format(startButton.getDate()).toString()); + fieldList.add("晚于"); + } + System.out.println("size================="+valueList.size()); + + + //测试 + String[] str1 = (String[])fieldList.toArray(new String[fieldList.size()]); + String[] str2 = (String[])valueList.toArray(new String[valueList.size()]); + String str11 = ""; + String str22 = ""; + for (int i = 0; i < str1.length; i++) { + str11=str11+str1[i]+","; + } + System.out.println("11111111111111111111111111================="+str11); + for (int i = 0; i < str2.length; i++) { + str22=str22+str2[i]+","; + } + System.out.println("11111111111111111111111111================="+str22); + + + + //查询 + TCComponent[] search = session.search("订单BOM查询", + (String[])fieldList.toArray(new String[fieldList.size()]), + (String[])valueList.toArray(new String[valueList.size()])); + + System.out.println("search.length-----------------------"+search.length); + for(int t=map.getRowCount()-1;t>=0;t--) { + map.removeRow(t); + } + List arrList = Arrays.asList(search); + compList = new ArrayList<>(arrList); + for(TCComponent component:search) { + TCComponentItem tcComponent = (TCComponentItem) component; + TCComponentItemRevision latestItemRevision = tcComponent.getLatestItemRevision(); + String[] properties = latestItemRevision.getProperties( + new String[] {"ml8_ProdOrderNo","ml8_ProductID","ml8_MaterialNo","object_name" + ,"last_mod_date","ml8_ProdPlanNo" + ,"ml8_BatchNo","ml8_Factory","ml8_ERPCode"}); + List list = new ArrayList(); + list.add("0"); + list.addAll(Arrays.asList(properties)); + map.addRow(list.toArray()); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }.start(); + }else if(this.btnDis.equals(source)){ + this.dispose(); + }else if(source.equals(this.btnOk)) { + String message = ""; + DbPool.getConnection(); + try { + List deList = new ArrayList(); + List de2List = new ArrayList(); + ArrayList selectRow = new ArrayList(); + for(int ind=0;ind() { + @Override + public int compare(Integer o1, Integer o2) { + if(o1>o2) return 1; + else if(o1= 0; i--) { + compList.remove(selectRow.get(i)); + map.removeRow(selectRow.get(i)); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + message = e1.getMessage(); + }finally { + DbPool.freeAll(); + } + //compList.clear(); + if(message.equals("")) { + MessageBox.post("删除完成","提示",2); + }else { + MessageBox.post("删除失败\n"+message,"提示",2); + } + + + } + + } + private JButton btnOk; + private JButton btnDis; + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + btnOk = new JButton("确定"); + btnDis = new JButton("取消"); + topPanel.add("1.1.center",btnOk); + + topPanel.add("1.2.center",btnDis); + return topPanel; + } + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private DateButton startButton; + private DateButton endButton; + private JButton btnQry; + private JTextField cpdmField; + //查询部分 + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); +// topPanel.add("1.1.left.center",field); + topPanel.setBorder(BorderFactory.createTitledBorder("查询ERP订单BOM")); +// btnQry = new JButton("查询"); +// +// topPanel.add("1.1.left.center",new JLabel("生产订单号:")); +// cpdmField = new JTextField(15); +// topPanel.add("1.2.left.center",cpdmField); +// startButton = new DateButton(dateFormat); +// endButton = new DateButton(dateFormat); +// topPanel.add("1.3.left.center",new JLabel("从ERP同步订单BOM的时间范围:")); +// topPanel.add("1.4.left.center",startButton); +// topPanel.add("1.5.left.center",new JLabel("~")); +// topPanel.add("1.6.left.center",endButton); +// topPanel.add("1.7.left.center",btnQry); + topPanel.add("1.1.left.center",new JLabel(" ")); + topPanel.add("2.1.left.center",getJLabel("产品代码:")); + JTextField cpdmField = new JTextField(15); + topPanel.add("2.2.left.center",cpdmField); + textMap.put("ml8_ProductID", cpdmField); + topPanel.add("2.3.left.center",getJLabel("物料编码:")); + JTextField wlbmField = new JTextField(15); + topPanel.add("2.4.left.center",wlbmField); + textMap.put("ml8_MaterialNo", wlbmField); + + topPanel.add("2.5.left.center",getJLabel("生产订单号:")); + JTextField ddhField = new JTextField(15); + topPanel.add("2.6.left.center",ddhField); + textMap.put("ml8_ProdOrderNo", ddhField); + + topPanel.add("3.1.left.center",getJLabel("批次号:")); + JTextField pcField = new JTextField(15); + topPanel.add("3.2.left.center",pcField); + textMap.put("ml8_BatchNo", pcField); + topPanel.add("3.3.left.center",getJLabel("生产计划号:")); + JTextField scjhhField = new JTextField(15); + topPanel.add("3.4.left.center",scjhhField); + textMap.put("ml8_ProdPlanNo", scjhhField); + + + topPanel.add("4.1.left.center",getJLabel("工厂:")); + JTextField gcField = new JTextField(15); + topPanel.add("4.2.left.center",gcField); + textMap.put("ml8_Factory", gcField); + topPanel.add("4.3.left.center",getJLabel("ERP班组编码:")); + JTextField erpbmField = new JTextField(15); + topPanel.add("4.4.left.center",erpbmField); + textMap.put("ml8_ERPCode", erpbmField); + btnQry = new JButton("查询"); + + + + startButton = new DateButton(dateFormat); + endButton = new DateButton(dateFormat); + startButton.setDate("未设置日期"); + endButton.setDate("未设置日期"); +// startButton.set + topPanel.add("3.5.left.center",getJLabel("时间晚于:")); + topPanel.add("3.6.left.center",startButton); + topPanel.add("4.5.left.center",getJLabel("时间早于:")); + topPanel.add("4.6.left.center",endButton); + topPanel.add("5.1.left.center",btnQry); + return topPanel; + } + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getJTable(null, null, header, null); + table.setRowHeight(30); + table.setPreferredSize(new Dimension(1200,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 设置表格的自动调整模式为关闭自动调整 + table.getColumnModel().getColumn(0).setPreferredWidth(50); + table.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); + int selectedRow = table.rowAtPoint(e.getPoint()); +// System.out.println("selectColumn==>"+selectColumn); + if(selectColumn != 0) + { + return; + }else { + Object valueAt = table.getValueAt(selectedRow, selectColumn); + if(valueAt.toString().equals("1")) { + table.setValueAt("0", selectedRow, selectColumn); + }else { + table.setValueAt("1", selectedRow, selectColumn); + } + } + } + }); + JScrollPane pane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + pane.setPreferredSize(new Dimension(1200,400)); + pane.setViewportView(table);//为scrollPane指定显示对象为table + return pane; + } + private DefaultTableModel map; + public JTable getJTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 150; +// int totleLen = 1000; + if (partsTable == null) { + map = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + partsTable = new JTable(map) ; + + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); +// Adapter1 adapter = new Adapter1(partsTable); + partsTable.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(partsTable)); +// setDefaultRenderer(new CheckHeaderCellRenderer(table)); + + partsTable.setRowHeight(30); + // //设置显示器渲染 + partsTable.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(partsTable)); +// partsTable.setDefaultRenderer(Object.class, renderer); + partsTable.getTableHeader().setReorderingAllowed(false); +// if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } + } + + //++ + return partsTable; + } + private JLabel getJLabel(String name) { + JLabel label = new JLabel(name); + label.setPreferredSize(new Dimension(100, 30)); + return label; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteOrdHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteOrdHandler.java new file mode 100644 index 0000000..9a355dc --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteOrdHandler.java @@ -0,0 +1,35 @@ +package com.connor.ml.tcm.OrderBOMTB; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class DeleteOrdHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + new Thread() { + @Override + public void run() { + + new DeleteOrdFram(session); + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteTechFram.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteTechFram.java new file mode 100644 index 0000000..a4bb873 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteTechFram.java @@ -0,0 +1,1108 @@ +package com.connor.ml.tcm.OrderBOMTB; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.BorderFactory; +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.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; + +import com.connor.ml.tcm.util.ProgressBarThread; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.ServiceData; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentGroup; +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.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentTask; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.rac.core.DataManagementService; + +import cn.net.connor.ml.plm.exportExcel.TCUtil; +import cn.net.connor.ml.plm.tcm.KUtil; + +public class DeleteTechFram extends JFrame implements ActionListener{ + + private Map textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header = new String[] {"全选","ID","名称","类型","所有者","创建者部门"}; + protected DefaultTableModel tm_part; + private String[] techQuerys; + private HashMap> typeQueryMap; + private ArrayList typeList = new ArrayList(); + private JComboBox dxlx; + private String query = ""; + private String errorCode = ""; + public DeleteTechFram(TCSession session) { + // TODO Auto-generated constructor stub + techQuerys = session.getPreferenceService().getStringValues("CONNOR_Tech_Query"); + if(techQuerys == null || techQuerys.length <= 0) { + System.out.println("请配置首选项 CONNOR_Tech_Query"); + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "请配置首选项 CONNOR_Tech_Query", "错误", 1); + return; + } + this.session = session; + initUI(); + } + + private void initUI() { + // TODO Auto-generated method stub + //获取 类型和查询构建器的map 并且 获取所有类型 + typeQueryMap = getTypeQuery(techQuerys); + + try { + this.setTitle("删除工艺"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel,BorderLayout.NORTH); + this.add(pane,BorderLayout.CENTER); + this.add(btnPanel,BorderLayout.SOUTH); + + + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(900,600)); + this.validate(); + this.setVisible(true); +// this.setAlwaysOnTop(true); + + } catch (Exception e) { + e.printStackTrace(); + return; + } + } + // 添加监听 + public void createActionEvent() { + this.btnQry.addActionListener(this); +// this.readQry.addActionListener(this); + this.btnDis.addActionListener(this); + this.btnOk.addActionListener(this); + + } + private List compList = new ArrayList(); + private TCComponentItem tcItem; + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+"+source); + if(source.equals(this.btnQry)) { + ProgressBarThread thread = new ProgressBarThread("查询中", "查询中..."); + thread.start(); + compList.clear(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-M-dd HH:mm:ss"); + try { + + //获取所选的查询 + String selectedItem = (String)dxlx.getSelectedItem(); + if(selectedItem != null && !selectedItem.isEmpty()) { + query = typeQueryMap.get(selectedItem).get(1); + + }else { + MessageBox.post("请选择:对象类型!!","提示",2); + thread.setBool(true); + return; + } + TCComponent[] search = null; + System.out.println("query-------------======"+query); + if(query.equals("删除工步查询All")) { + ArrayList valueList = new ArrayList(); + ArrayList fieldList = new ArrayList(); + String[] fiels = new String[] { "名称","ID","姓名","部门名称","模板"}; + String[] fielsButton = new String[] { "mc","id","syz","cjzbm","mb"}; + for (int i = 0; i < fielsButton.length; i++) { + String text = textMap.get(fielsButton[i]).getText(); + if(text != null && !text.isEmpty()) { + fieldList.add(fiels[i]); + valueList.add(text); + } + } + + + if(selectedItem != null && !selectedItem.isEmpty()) { + fieldList.add("类型"); + valueList.add(selectedItem); + } + + if(cjrqdy.getDate()!=null) { + valueList.add(simpleDateFormat.format(cjrqdy.getDate()).toString()); + fieldList.add("创建日期大于"); + } + if(cjrqxy.getDate()!=null) { + valueList.add(simpleDateFormat.format(cjrqxy.getDate()).toString()); + fieldList.add("创建日期小于"); + } + if(xgrqdy.getDate()!=null) { + valueList.add(simpleDateFormat.format(xgrqdy.getDate()).toString()); + fieldList.add("修改日期大于"); + } + if(xgrqxy.getDate()!=null) { + valueList.add(simpleDateFormat.format(xgrqxy.getDate()).toString()); + fieldList.add("修改日期小于"); + } + + //测试 + String[] str1 = (String[])fieldList.toArray(new String[fieldList.size()]); + String[] str2 = (String[])valueList.toArray(new String[valueList.size()]); + String str11 = ""; + String str22 = ""; + for (int i = 0; i < str1.length; i++) { + str11=str11+str1[i]+","; + } + System.out.println("11111111111111111111111111================="+str11); + for (int i = 0; i < str2.length; i++) { + str22=str22+str2[i]+","; + } + System.out.println("11111111111111111111111111================="+str22); + //查询 + search = session.search(query, + (String[])fieldList.toArray(new String[fieldList.size()]), + (String[])valueList.toArray(new String[valueList.size()])); + + System.out.println("-------search.count----------"+search.length); + }else if(query.equals("删除查询All")){ + ArrayList valueList = new ArrayList(); + ArrayList fieldList = new ArrayList(); + String[] fiels = new String[] { "名称","ID","姓名","部门名称","模板"}; + String[] fielsButton = new String[] { "mc","id","syz","cjzbm","mb"}; + for (int i = 0; i < fielsButton.length; i++) { + String text = textMap.get(fielsButton[i]).getText(); + if(text != null && !text.isEmpty()) { + fieldList.add(fiels[i]); + valueList.add(text); + } + } + + + if(selectedItem != null && !selectedItem.isEmpty()) { + fieldList.add("类型"); + valueList.add(selectedItem); + } + + if(cjrqdy.getDate()!=null) { + valueList.add(simpleDateFormat.format(cjrqdy.getDate()).toString()); + fieldList.add("创建日期大于"); + } + if(cjrqxy.getDate()!=null) { + valueList.add(simpleDateFormat.format(cjrqxy.getDate()).toString()); + fieldList.add("创建日期小于"); + } + if(xgrqdy.getDate()!=null) { + valueList.add(simpleDateFormat.format(xgrqdy.getDate()).toString()); + fieldList.add("修改日期大于"); + } + if(xgrqxy.getDate()!=null) { + valueList.add(simpleDateFormat.format(xgrqxy.getDate()).toString()); + fieldList.add("修改日期小于"); + } + + //测试 + String[] str1 = (String[])fieldList.toArray(new String[fieldList.size()]); + String[] str2 = (String[])valueList.toArray(new String[valueList.size()]); + String str11 = ""; + String str22 = ""; + for (int i = 0; i < str1.length; i++) { + str11=str11+str1[i]+","; + } + System.out.println("11111111111111111111111111================="+str11); + for (int i = 0; i < str2.length; i++) { + str22=str22+str2[i]+","; + } + System.out.println("11111111111111111111111111================="+str22); + //查询 + search = session.search(query, + (String[])fieldList.toArray(new String[fieldList.size()]), + (String[])valueList.toArray(new String[valueList.size()])); + + System.out.println("-------search.count----------"+search.length); + } + + for(int t=map.getRowCount()-1;t>=0;t--) { + map.removeRow(t); + } + if(null != search && search.length > 0) { + List arrList = Arrays.asList(search); + compList = new ArrayList<>(arrList); + for(TCComponent component:search) { + TCComponentItem tcComponent = (TCComponentItem) component; +// TCComponentItemRevision latestItemRevision = tcComponent.getLatestItemRevision(); + String[] properties = component.getProperties( + new String[] {"item_id","object_name","object_type","owning_user" + ,"owning_group"}); + List list = new ArrayList(); + list.add("0"); + list.addAll(Arrays.asList(properties)); + map.addRow(list.toArray()); + } + thread.setBool(true); + }else { + thread.setBool(true); + MessageBox.post("未查询到数据","提示",2); + } + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + }else if(this.btnDis.equals(source)){ + this.dispose(); + }else if(source.equals(this.btnOk)) { + ProgressBarThread thread = null; + ArrayList deleteIdList = new ArrayList(); + try { + KUtil.setByPass(true); + //装行的数组 + ArrayList lineList = new ArrayList(); + //装被删除id + for(int ind=0;ind deItemList = new ArrayList(); + DataManagementService service = DataManagementService.getService(session); + + if(tcItem.getType().equals("ML8_Step")) { + //删除item + thread = new ProgressBarThread("删除中", "删除中..."); + thread.start(); + gbDeleteItem(tcItem, deItemList, service,null); + lineList.add(ind); + deleteIdList.add(tcItem.getStringProperty("item_id")); + }else { + MessageBox.post("该工步不可删除!","提示",2); + return; + } + + }else {//---------------------------------删除工艺、工序 删除自身未发布状态对象,管理员账号可删除所有对象 + //判断是不是管理员 + Boolean isDelete = false; + TCComponentGroup group = session.getCurrentGroup(); + //管理员可以任意删除 + System.out.println("group.toDisplayString()==========="+group.toDisplayString()); + if(group.toDisplayString().equals("dba")) { + isDelete = true; + }else { + + //不是管理员 删除自身未发布状态对象 + String owner = map.getValueAt(ind, 4).toString();//所有者 + //判断所以者列是否为空 + System.out.println("owner==========="+owner); + if(owner != null || !owner.isEmpty()) { + //判断所有者是否为登录者 + String userId = session.getUser().getUserId(); + System.out.println("userId==========="+userId); + if(owner.contains(userId)) { + //判断是否发布 + String isRelease = tcItem.getLatestItemRevision().getStringProperty("release_status_list"); + if(isRelease != null && isRelease.length() > 0) { + MessageBox.post("工艺已发布无法删除!","提示",2); + return; + }else { + isDelete = true; + } + }else { + MessageBox.post("工艺所有者不是该用户无法删除!","提示",2); + return; + } + + }else { + MessageBox.post("所有者列为空无法删除!","提示",2); + return; + } + } + if(isDelete) { + //打开要删除的工艺 + //System.out.println("打开要删除的工艺"); +// com.teamcenter.rac.common.Activator.getDefault() +// .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); +// com.teamcenter.rac.common.Activator.getDefault().openComponents( +// "com.teamcenter.rac.cme.mpp.MSEPerspective", +// new InterfaceAIFComponent[] { tcItem }); + thread = new ProgressBarThread("删除中", "删除中..."); + thread.start(); + List deItemList = new ArrayList(); + DataManagementService service = DataManagementService.getService(session); + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine topLine = view.setWindowTopLine(tcItem, tcItem.getLatestItemRevision(), null, null); + dgDeleteTech(tcItem,deItemList, service, topLine,view); + + //删除已删除的table 和 complist + deleteIdList.add(tcItem.getStringProperty("item_id")); + lineList.add(ind); + } + + } + } + + } + //删除对应complist 和 table + if(lineList.size() > 0) { + Collections.reverse(lineList); //从后开始删 + //测试 + System.out.println("lineList.size========================="+lineList.size()); + for (int i = 0; i < lineList.size(); i++) { + System.out.println("=================="+lineList.get(i)); + } + + for (int i = 0; i < lineList.size(); i++) { + compList.remove(lineList.get(i)); + map.removeRow(lineList.get(i)); + } + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + if(thread != null) { + thread.setBool(true); + } + //通过id查询删除的工艺 如果工艺还在就删除失败 + TCComponent[] search = null; + + String tempStr=""; + for (int i = 0; i < deleteIdList.size(); i++) { + tempStr+=deleteIdList.get(i)+";"; + } + String subTempStr = tempStr.substring(0, tempStr.length()-1); + try { + search = session.search("零组件 ID", new String[] { "零组件 ID" }, new String[] {subTempStr}); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if(search != null && search.length > 0) { + MessageBox.post("删除失败\n"+errorCode,"提示",2); + }else { + MessageBox.post("删除完成","提示",2); + } + KUtil.setByPass(false); + } + + + + } + + } + private JButton btnOk; + private JButton btnDis; + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + btnOk = new JButton("确定"); + btnDis = new JButton("取消"); + topPanel.add("1.1.center",btnOk); + + topPanel.add("1.2.center",btnDis); + return topPanel; + } + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ///发布日期 + private DateButton fbrq; + //创建日期大于 + private DateButton cjrqdy; + //创建日期小于 + private DateButton cjrqxy; + //修改日期大于 + private DateButton xgrqdy; + //修改日期小于 + private DateButton xgrqxy; + private JButton btnQry; + //查询部分 + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); +// topPanel.add("1.1.left.center",field); + topPanel.setBorder(BorderFactory.createTitledBorder("查询工艺")); + + //名称 + topPanel.add("1.1.left.center",getJLabel("名称:")); + JTextField mc = new JTextField(15); + topPanel.add("1.2.left.center",mc); + textMap.put("mc", mc); + + //ID + topPanel.add("1.3.left.center",getJLabel("ID:")); + JTextField id = new JTextField(15); + topPanel.add("1.4.left.center",id); + textMap.put("id", id); + +// //版本 +// topPanel.add("1.5.left.center",getJLabel("版本:")); +// JTextField bb = new JTextField(15); +// topPanel.add("1.6.left.center",bb); +// textMap.put("bb", bb); + + //发布状态 + topPanel.add("1.5.left.center",getJLabel("所有者:")); + JTextField syz = new JTextField(15); + topPanel.add("1.6.left.center",syz); + textMap.put("syz", syz); + + //创建者部门 + topPanel.add("2.1.left.center",getJLabel("创建者部门:")); + JTextField cjzbm = new JTextField(15); + topPanel.add("2.2.left.center",cjzbm); + textMap.put("cjzbm", cjzbm); + + + + + + //模板 + topPanel.add("2.3.left.center",getJLabel("模板:")); + JTextField mb = new JTextField(15); + topPanel.add("2.4.left.center",mb); + textMap.put("mb", mb); + +// //发布状态 +// topPanel.add("2.5.left.center",getJLabel("发布状态:")); +// JTextField fbzt = new JTextField(15); +// topPanel.add("2.6.left.center",fbzt); +// textMap.put("fbzt", fbzt); + + //对象类型 + topPanel.add("2.5.left.center",getJLabel("对象类型:")); + dxlx = new JComboBox(); + + for (int i = 0; i < typeList.size(); i++) { + dxlx.addItem(typeList.get(i)); + } + dxlx.setSelectedIndex(-1); + topPanel.add("2.6.left.center",dxlx); +// textMap.put("dxlx", dxlx); + + + + + fbrq = new DateButton(dateFormat); + cjrqdy = new DateButton(dateFormat); + cjrqxy = new DateButton(dateFormat); + xgrqdy = new DateButton(dateFormat); + xgrqxy = new DateButton(dateFormat); + fbrq.setDate("未设置日期"); + cjrqdy.setDate("未设置日期"); + cjrqxy.setDate("未设置日期"); + xgrqdy.setDate("未设置日期"); + xgrqxy.setDate("未设置日期"); +// startButton.set +// topPanel.add("4.5.left.center",getJLabel("发布日期:")); +// topPanel.add("4.6.left.center",fbrq); + topPanel.add("3.1.left.center",getJLabel("创建日期大于:")); + topPanel.add("3.2.left.center",cjrqdy); + //加JLabel 12 + //topPanel.add("5.3.left.center",new JLabel(" ")); + topPanel.add("4.1.left.center",getJLabel("创建日期小于:")); + topPanel.add("4.2.left.center",cjrqxy); + //加JLabel 13 + // topPanel.add("4.5.left.center",new JLabel(" ")); + topPanel.add("3.3.left.center",getJLabel("修改日期大于:")); + topPanel.add("3.4.left.center",xgrqdy); + //加JLabel 15 + // topPanel.add("5.6.left.center",new JLabel(" ")); + topPanel.add("4.3.left.center",getJLabel("修改日期小于:")); + topPanel.add("4.4.left.center",xgrqxy); + + btnQry = new JButton("查询"); + topPanel.add("5.1.left.center",btnQry); + return topPanel; + } + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getJTable(null, null, header, null); + table.setRowHeight(30); +// table.setPreferredSize(new Dimension(1200,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 设置表格的自动调整模式为关闭自动调整 + table.getColumnModel().getColumn(0).setPreferredWidth(50); + table.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); + int selectedRow = table.rowAtPoint(e.getPoint()); +// System.out.println("selectColumn==>"+selectColumn); + if(selectColumn != 0) + { + return; + }else { + Object valueAt = table.getValueAt(selectedRow, selectColumn); + if(valueAt.toString().equals("1")) { + table.setValueAt("0", selectedRow, selectColumn); + }else { + table.setValueAt("1", selectedRow, selectColumn); + } + } + } + }); + JScrollPane pane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + pane.setPreferredSize(new Dimension(900,400)); + pane.setViewportView(table);//为scrollPane指定显示对象为table + return pane; + } + private DefaultTableModel map; + public JTable getJTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 150; +// int totleLen = 1000; + if (partsTable == null) { + map = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + partsTable = new JTable(map) ; + + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); +// Adapter1 adapter = new Adapter1(partsTable); + partsTable.getTableHeader().setDefaultRenderer(new CheckHeaderCellRenderer(partsTable)); +// setDefaultRenderer(new CheckHeaderCellRenderer(table)); + + partsTable.setRowHeight(30); + // //设置显示器渲染 + partsTable.getColumnModel().getColumn(0).setCellRenderer(new TableCellCheckboxRenderer(partsTable)); +// partsTable.setDefaultRenderer(Object.class, renderer); + partsTable.getTableHeader().setReorderingAllowed(false); +// if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); +// } else { +// partsTable.setAutoResizeMode(1); +// } + } + + //++ + return partsTable; + } + private JLabel getJLabel(String name) { + JLabel label = new JLabel(name); + label.setPreferredSize(new Dimension(100, 30)); + return label; + } + + public HashMap> getTypeQuery(String[] typeQuery) { + HashMap> map = new HashMap>(); + for (int i = 0; i < typeQuery.length; i++) { + String[] values = typeQuery[i].split("-"); + ArrayList tempList = new ArrayList(); + if(values != null && values.length == 3){ + tempList.add(values[0]); + tempList.add(values[2]); + map.put(values[1], tempList); + typeList.add(values[1]); + } + } + return map; + } + + public void deleteItem(TCComponentItem tcItem,List deItemList,DataManagementService service,TCComponentBOMWindow zView) throws Exception { + try { + System.out.println("item开始"); + //获取对象下所有版本 + System.out.println("tcItem======================="+tcItem); + if(tcItem == null) { + return; + } + TCComponent[] revs = tcItem.getReferenceListProperty("revision_list"); + + //循环版本 + System.out.println("revs.length==========================="+revs.length); + for (int i = 0; i < revs.length; i++) { + List deTaskReference = new ArrayList(); + + TCComponentItemRevision tcRevision = (TCComponentItemRevision) revs[i]; + String revisionId = tcRevision.getStringProperty("item_id"); + System.out.println("对象revisionId==========================="+revisionId); + //循环删除引用 + AIFComponentContext[] whereReferenced = tcRevision.whereReferenced(); + System.out.println("whereReferenced.length==========================="+whereReferenced.length); + for (int j = 0; j < whereReferenced.length; j++) { + InterfaceAIFComponent component = whereReferenced[j].getComponent(); + + //判断是否父级 或者 前版本 + if( component instanceof TCComponentItemType) { + TCComponentItem referenceItem = (TCComponentItem) component; + String itemId = referenceItem.getStringProperty("item_id"); + if(itemId.equals(revisionId)) { + continue; + } + } + + //工作流 + String referenceType = component.getType(); + System.out.println("type============"+referenceType); + if(referenceType.equals("EPMTask")) { + //if(component instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask)component; + AIFComponentContext[] taskReferenced = task.whereReferenced(); + if(taskReferenced.length > 0) { + if(taskReferenced[0].getComponent().getType().equals("Job")) { + deTaskReference.add((TCComponentProcess)taskReferenced[0].getComponent()); + } + } + //task.delete(); +// deTaskReference.add((TCComponentTask)component); +// System.out.println("000000000000000000000000000000000"); + } + //物料被Newstuff Folder引用 剪切 + if(referenceType.equals("Newstuff Folder")) { + //if(component instanceof TCComponentTask) { + TCComponentFolder newStuffFolder = (TCComponentFolder)component; + if(null != newStuffFolder) { + newStuffFolder.cutOperation("contents", new TCComponent[] { tcRevision}); + } + } +// System.out.println("deTaskReference.size=============="+deTaskReference.size()); +// //删除工作流对象 +// ServiceData deTaskReferenceObject = service.deleteObjects(deTaskReference.toArray(new TCComponent[] {})); +// KUtil.throwServiceDataError(deTaskReferenceObject); + //关系:得到对象然后通过关系名称剪切 + try { + if(component instanceof TCComponentItemRevision) { + //剪切 + + TCComponentItemRevision ReferenceRevision = (TCComponentItemRevision)component; + TCComponent relatedComponent = ReferenceRevision.getRelatedComponent("IMAN_based_on"); + System.out.println("relatedComponent==========================="+relatedComponent); + if(null != relatedComponent) { + ReferenceRevision.cutOperation("IMAN_based_on", new TCComponent[] { tcRevision}); + } + } + } catch (Exception e) { + // TODO: handle exception + } + } + //删除工作流对象 + System.out.println("deTaskReference.size=============="+deTaskReference.size()); + ServiceData deTaskReferenceObject = service.deleteObjects(deTaskReference.toArray(new TCComponent[] {})); + KUtil.throwServiceDataError(deTaskReferenceObject); + deTaskReference.clear(); + + + //循环bom删除 使用 + TCComponent[] whereUsed = tcRevision.whereUsed((short)0); + for (int j = 0; j < whereUsed.length; j++) { + + TCComponentType type = whereUsed[j].getTypeComponent(); + if(type instanceof TCComponentItemType) { + //判断是否父级 + TCComponentItem userItem = (TCComponentItem)whereUsed[j]; + String itemId = userItem.getStringProperty("item_id"); + if(itemId.equals(revisionId)) { + continue; + } + }else if(type instanceof TCComponentItemRevisionType) { + TCComponentItemRevision userRevision = (TCComponentItemRevision)whereUsed[j]; + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine topLine = view.setWindowTopLine(userRevision.getItem(), userRevision, null, null); + topLine.lock(); + AIFComponentContext[] childrens = topLine.getChildren(); + for (int k = 0; k < childrens.length; k++) { + InterfaceAIFComponent comp = childrens[k].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; + String bomItemId = line.getStringProperty("bl_item_item_id"); + if(bomItemId != null && bomItemId.equals(revisionId)) { + topLine.remove("", line); + } + } + } + topLine.save(); + topLine.unlock(); + view.save(); + view.close(); + } + + } + + } + + //删除item的引用 + List itemDeTaskReference = new ArrayList(); + AIFComponentContext[] itemWhereReferenced = tcItem.whereReferenced(); + System.out.println("item_whereReferenced.length==========================="+itemWhereReferenced.length); + for (int j = 0; j < itemWhereReferenced.length; j++) { + InterfaceAIFComponent component = itemWhereReferenced[j].getComponent(); + //工作流 + String referenceType = component.getType(); + System.out.println("type============"+referenceType); +// if(referenceType.equals("EPMTask")) { + if(referenceType.equals("EPMTask")) { + //if(component instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask)component; + System.out.println("task==============="+task.getName()); + AIFComponentContext[] taskReferenced = task.whereReferenced(); + System.out.println("taskReferenced.length=============="+taskReferenced.length); + if(taskReferenced.length > 0) { + if(taskReferenced[0].getComponent().getType().equals("Job")) { + itemDeTaskReference.add((TCComponentProcess)taskReferenced[0].getComponent()); + } + } + } + //物料被Newstuff Folder引用 剪切 + if(referenceType.equals("Newstuff Folder")) { + //if(component instanceof TCComponentTask) { + TCComponentFolder newStuffFolder = (TCComponentFolder)component; + if(null != newStuffFolder) { + newStuffFolder.cutOperation("contents", new TCComponent[] { tcItem}); + } + } + } + System.out.println("deTaskReference.size=============="+itemDeTaskReference.size()); + //删除工作流对象 + ServiceData deTaskReferenceObject = service.deleteObjects(itemDeTaskReference.toArray(new TCComponent[] {})); + KUtil.throwServiceDataError(deTaskReferenceObject); + itemDeTaskReference.clear(); + + //删除item的 使用 + TCComponent[] itemWhereUsed = tcItem.whereUsed((short)0); + for (int z = 0; z < itemWhereUsed.length; z++) { + TCComponentItemRevision userRevision = (TCComponentItemRevision)itemWhereUsed[z]; + String itemId = tcItem.getStringProperty("item_id"); + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine topLine = view.setWindowTopLine(userRevision.getItem(), userRevision, null, null); + topLine.lock(); + AIFComponentContext[] childrens = topLine.getChildren(); + for (int k = 0; k < childrens.length; k++) { + InterfaceAIFComponent comp = childrens[k].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; + String bomItemId = line.getStringProperty("bl_item_item_id"); + if(bomItemId != null && bomItemId.equals(itemId)) { + topLine.remove("", line); + } + } + } + topLine.save(); + topLine.unlock(); + view.save(); + view.close(); + } + //执行删除item + tcItem.refresh(); + //tcItem.delete(); + deItemList.add(tcItem); + if(zView != null) { + zView.close(); + } + ServiceData deItemListObject = service.deleteObjects(deItemList.toArray(new TCComponent[] {})); + KUtil.throwServiceDataError(deItemListObject); + deItemList.clear(); + System.out.println("item完成"); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + errorCode+="ID:"+tcItem.getStringProperty("item_id")+" 的对象存在非正常引用关系,请手动删除引用后再继续执行删除工艺!\n"; + } + } + + //递归删除工艺 + public void dgDeleteTech(TCComponentItem item,List deItemList,DataManagementService service,TCComponentBOMLine topLine,TCComponentBOMWindow view) { + + try { + AIFComponentContext[] childrens = topLine.getChildren(); + for (int k = 0; k < childrens.length; k++) { + InterfaceAIFComponent comp = childrens[k].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; +// String type = line.getStringProperty("fnd0bl_line_object_type"); + String type = line.getItem().getType(); + boolean hasChildren = line.hasChildren(); + TCComponentItem tempItem = line.getItem(); + //判断是否有子 并且类型不是 ML8_PartRevision,ML8_RawMaterialRevision + if(hasChildren) { + //特定工序、工步不删 工步下的ML8_Part 和 ML8_RawMaterial不删 + if(type.equals("ML8_Part") || type.equals("ML8_RawMaterial") || type.equals("ML8_DifOperation") || type.equals("ML8_SpecOp") || type.equals("ML8_BJStep") || type.equals("ML8_PTStep") || type.equals("ML8_FPStep") || type.equals("ML8_XSStep") || type.equals("ML8_JBStep")|| type.equals("ML8_TestStep") || type.equals("ML8_GLLJStep") || type.equals("ML8_HJStep") || type.equals("ML8_YSJStep") || type.equals("ML8_VPStep") || type.equals("ML8_GZStep") || type.equals("ML8_JLStep")) { + + }else { + dgDeleteTech(null,deItemList, service, line,null); + } + } + //从后开始删除 + try { + + if(type.equals("ML8_Part") || type.equals("ML8_RawMaterial") || type.equals("ML8_DifOperation") || type.equals("ML8_SpecOp") || type.equals("ML8_BJStep") || type.equals("ML8_PTStep") || type.equals("ML8_FPStep") || type.equals("ML8_XSStep") || type.equals("ML8_JBStep")|| type.equals("ML8_TestStep") || type.equals("ML8_GLLJStep") || type.equals("ML8_HJStep") || type.equals("ML8_YSJStep") || type.equals("ML8_VPStep") || type.equals("ML8_GZStep") || type.equals("ML8_JLStep")) { + + }else { + if(tempItem != null) { + System.out.println("删除的type========和ID=========="+type+"============"+tempItem.getStringProperty("item_id")); + deleteItem(tempItem, deItemList, service,null); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + } + } + //删除item + try { + deleteItem(item, deItemList, service,view); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return; + } + } + + //删除工步 + public void gbDeleteItem(TCComponentItem tcItem,List deItemList,DataManagementService service,TCComponentBOMWindow zView) throws Exception { + try { + //获取对象下所有版本 + TCComponent[] revs = tcItem.getReferenceListProperty("revision_list"); + //循环版本 + System.out.println("revs.length==========================="+revs.length); + for (int i = 0; i < revs.length; i++) { + List deTaskReference = new ArrayList(); + + TCComponentItemRevision tcRevision = (TCComponentItemRevision) revs[i]; + String revisionId = tcRevision.getStringProperty("item_id"); + System.out.println("revisionId==========================="+revisionId); + //循环删除引用 + AIFComponentContext[] whereReferenced = tcRevision.whereReferenced(); + System.out.println("whereReferenced.length==========================="+whereReferenced.length); + for (int j = 0; j < whereReferenced.length; j++) { + InterfaceAIFComponent component = whereReferenced[j].getComponent(); + + //判断是否父级 或者 前版本 + if( component instanceof TCComponentItemType) { + TCComponentItem referenceItem = (TCComponentItem) component; + String itemId = referenceItem.getStringProperty("item_id"); + if(itemId.equals(revisionId)) { + continue; + } + } + + //工作流 + String referenceType = component.getType(); + System.out.println("type============"+referenceType); + if(referenceType.equals("EPMTask")) { + //if(component instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask)component; + System.out.println("task==============="+task.getName()); + AIFComponentContext[] taskReferenced = task.whereReferenced(); + System.out.println("taskReferenced.length=============="+taskReferenced.length); + if(taskReferenced.length > 0) { + if(taskReferenced[0].getComponent().getType().equals("Job")) { + deTaskReference.add((TCComponentProcess)taskReferenced[0].getComponent()); + } + } + //task.delete(); +// deTaskReference.add((TCComponentTask)component); +// System.out.println("000000000000000000000000000000000"); + } +// System.out.println("deTaskReference.size=============="+deTaskReference.size()); +// //删除工作流对象 +// ServiceData deTaskReferenceObject = service.deleteObjects(deTaskReference.toArray(new TCComponent[] {})); +// KUtil.throwServiceDataError(deTaskReferenceObject); + //关系:得到对象然后通过关系名称剪切 + if(component instanceof TCComponentItemRevision) { + //剪切 + + TCComponentItemRevision ReferenceRevision = (TCComponentItemRevision)component; + TCComponent relatedComponent = ReferenceRevision.getRelatedComponent("IMAN_based_on"); + System.out.println("relatedComponent==========================="+relatedComponent); + if(null != relatedComponent) { + ReferenceRevision.cutOperation("IMAN_based_on", new TCComponent[] { tcRevision}); + } + } + } + //删除工作流对象 + System.out.println("deTaskReference.size=============="+deTaskReference.size()); + ServiceData deTaskReferenceObject = service.deleteObjects(deTaskReference.toArray(new TCComponent[] {})); + KUtil.throwServiceDataError(deTaskReferenceObject); + deTaskReference.clear(); + + + //循环bom删除 使用 + TCComponent[] whereUsed = tcRevision.whereUsed((short)0); + for (int j = 0; j < whereUsed.length; j++) { + + TCComponentType type = whereUsed[j].getTypeComponent(); + if(type instanceof TCComponentItemType) { + //判断是否父级 + TCComponentItem userItem = (TCComponentItem)whereUsed[j]; + String itemId = userItem.getStringProperty("item_id"); + if(itemId.equals(revisionId)) { + continue; + } + }else if(type instanceof TCComponentItemRevisionType) { + TCComponentItemRevision userRevision = (TCComponentItemRevision)whereUsed[j]; + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine topLine = view.setWindowTopLine(userRevision.getItem(), userRevision, null, null); + topLine.lock(); + AIFComponentContext[] childrens = topLine.getChildren(); + for (int k = 0; k < childrens.length; k++) { + InterfaceAIFComponent comp = childrens[k].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; + String bomItemId = line.getStringProperty("bl_item_item_id"); + if(bomItemId.equals(revisionId)) { + topLine.remove("", line); + } + } + } + topLine.save(); + topLine.unlock(); + view.save(); + view.close(); + } + + } + + } + + //删除item的引用 + List itemDeTaskReference = new ArrayList(); + AIFComponentContext[] itemWhereReferenced = tcItem.whereReferenced(); + System.out.println("item_whereReferenced.length==========================="+itemWhereReferenced.length); + for (int j = 0; j < itemWhereReferenced.length; j++) { + InterfaceAIFComponent component = itemWhereReferenced[j].getComponent(); + //工作流 + String referenceType = component.getType(); + System.out.println("type============"+referenceType); +// if(referenceType.equals("EPMTask")) { + if(referenceType.equals("EPMTask")) { + //if(component instanceof TCComponentTask) { + TCComponentTask task = (TCComponentTask)component; + System.out.println("task==============="+task.getName()); + AIFComponentContext[] taskReferenced = task.whereReferenced(); + System.out.println("taskReferenced.length=============="+taskReferenced.length); + if(taskReferenced.length > 0) { + if(taskReferenced[0].getComponent().getType().equals("Job")) { + itemDeTaskReference.add((TCComponentProcess)taskReferenced[0].getComponent()); + } + } + } + } + System.out.println("deTaskReference.size=============="+itemDeTaskReference.size()); + //删除工作流对象 + ServiceData deTaskReferenceObject = service.deleteObjects(itemDeTaskReference.toArray(new TCComponent[] {})); + KUtil.throwServiceDataError(deTaskReferenceObject); + itemDeTaskReference.clear(); + + //删除item的 使用 + TCComponent[] itemWhereUsed = tcItem.whereUsed((short)0); + for (int z = 0; z < itemWhereUsed.length; z++) { + TCComponentItemRevision userRevision = (TCComponentItemRevision)itemWhereUsed[z]; + String itemId = tcItem.getStringProperty("item_id"); + TCComponentBOMWindowType viewType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = viewType.create(null); + TCComponentBOMLine topLine = view.setWindowTopLine(userRevision.getItem(), userRevision, null, null); + topLine.lock(); + AIFComponentContext[] childrens = topLine.getChildren(); + for (int k = 0; k < childrens.length; k++) { + InterfaceAIFComponent comp = childrens[k].getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine line = (TCComponentBOMLine) comp; + String bomItemId = line.getStringProperty("bl_item_item_id"); + if(bomItemId.equals(itemId)) { + topLine.remove("", line); + } + } + } + topLine.save(); + topLine.unlock(); + view.save(); + view.close(); + } + //执行删除item + tcItem.refresh(); + //tcItem.delete(); + deItemList.add(tcItem); + if(zView != null) { + zView.close(); + } + ServiceData deItemListObject = service.deleteObjects(deItemList.toArray(new TCComponent[] {})); + KUtil.throwServiceDataError(deItemListObject); + deItemList.clear(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + errorCode+="ID:"+tcItem.getStringProperty("item_id")+" 的对象存在非正常引用关系,请手动删除引用后再继续执行删除操作!\n"; + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteTechHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteTechHandler.java new file mode 100644 index 0000000..78095ac --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/DeleteTechHandler.java @@ -0,0 +1,35 @@ +package com.connor.ml.tcm.OrderBOMTB; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class DeleteTechHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + new Thread() { + @Override + public void run() { + + new DeleteTechFram(session); + + } + }.start(); + + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/JTreeTable.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/JTreeTable.java new file mode 100644 index 0000000..7175701 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/JTreeTable.java @@ -0,0 +1,87 @@ +package com.connor.ml.tcm.OrderBOMTB; + +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.jdesktop.swingx.JXTreeTable; + +public class JTreeTable extends JXTreeTable { + + + private List isNotEditableRow; + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + public JTreeTable(JTreeTableModel testTreeTableModel) { + // TODO Auto-generated constructor stub + super(testTreeTableModel); + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + return true;//super.isCellEditable(arg0, arg1); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + // TODO Auto-generated method stub + //if(isNotEditableRow.contains(row) && column == 2) + + + return cellEditor; + //return super.getCellEditor(row, column); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub +// if((this.getValueAt(row, 1) != null && column == 1) || column == 7 ||column == 8 ) +// { +// if(this.getValueAt(row, column).equals("")){ +// return super.getCellRenderer(row, column); +// } +// return checkboxRenderer; +// } +// else +// { + return super.getCellRenderer(row, column); +// } + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/JTreeTableModel.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/JTreeTableModel.java new file mode 100644 index 0000000..db57379 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/JTreeTableModel.java @@ -0,0 +1,102 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.OrderBOMTB; +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; + + +/** + * + * @author vearn + */ +public class JTreeTableModel extends DefaultTreeTableModel { + + private String[] _names = { "订单BOM","数量", "度量单位"}; + + + private List isNotEditableRow; + + + + public JTreeTableModel(TreeTableNode node) { + super(node); + } + + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + /** + * 列的数量 + */ + @Override + public int getColumnCount() { + return _names.length; + } + + /** + * 表头显示的内容 + */ + @Override + public String getColumnName(int column) { + return _names[column]; + } + + /** + * 返回在单元格中显示的Object + */ + @Override + public Object getValueAt(Object node, int column) { + Object value = null; + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node; + Object o = mutableNode.getUserObject(); + if (o != null && o instanceof OrderBean) { + OrderBean bean = (OrderBean) o; + switch (column) { + case 0: + value = bean.getMatnrNo()+"-"+bean.getName(); + break; + case 1: + value = bean.getBl_quantity(); + break; + case 2: + value = bean.getUom(); + break; + } + } + } + return value; + } + + /** + * 设置所有单元格都不能编辑 + * + * @param the node (i.e. row) for which editing is to be determined + * @param the column for which editing is to be determined + * @return false + */ + @Override + public boolean isCellEditable(Object node, int column) { + //if(column == 5) + //{ + return true; + //} + //else + //{ + // return false; + //} + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/OrderBOMDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/OrderBOMDialog.java new file mode 100644 index 0000000..90bfb81 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/OrderBOMTB/OrderBOMDialog.java @@ -0,0 +1,971 @@ +package com.connor.ml.tcm.OrderBOMTB; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.RowSorter; +import javax.swing.border.EmptyBorder; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.connor.ml.tcm.util.ProgressBarThread; +import com.itextpdf.text.pdf.PdfStructTreeController.returnType; +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.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; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.ml.plm.sendBomSap.DbPool; +import cn.net.connor.ml.plm.tcm.KUtil; +import com.teamcenter.services.rac.cad.StructureManagementService; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.AttributesInfo; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructureInfo; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructurePref; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.CreateOrUpdateRelativeStructureResponse; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelOccInfo; +import com.teamcenter.services.rac.cad._2007_01.StructureManagement.RelativeStructureChildInfo; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateIn; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateInput; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateOut; +import com.teamcenter.services.rac.core._2008_06.DataManagement.CreateResponse; +import com.teamcenter.soaictstubs.ICCTReservationService; +import com.teamcenter.services.rac.core.DataManagementService; +public class OrderBOMDialog extends JFrame implements ActionListener{ + + private Map textMap = new HashMap<>(); + private TCSession session; + private JTable table; + private String[] header = new String[] {"产品代码","物料编码","物料名称","生产计划号", + "批次号","工厂","ERP班组编码","生产订单号"}; + protected DefaultTableModel tm_part; + private Boolean isBomQuery = false; +// private TCTextService textService; + public OrderBOMDialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; +// textService = session.getTextService(); + initUI(); + } + private Map uomTags = new HashMap(); + public void initUI() { + // TODO Auto-generated method stub + try { + TCComponentType typeComponent = session.getTypeComponent("UnitOfMeasure"); + TCComponent[] extent = typeComponent.extent(); + for(int t=0;t"+uid); + uomTags.put(extent[t].getStringProperty("symbol"), extent[t]); + } + + this.setTitle("同步订单BOM"); + this.setLayout(new BorderLayout()); + + JPanel topPanel = getTopPanel(); + + JScrollPane pane = getTablePanel(); + pane.setBorder(BorderFactory.createTitledBorder("")); +// JPanel btnPanel = getRightPanel(); + JPanel btnPanel = getBtnPanel(); + + this.add(topPanel,BorderLayout.NORTH); + this.add(pane,BorderLayout.CENTER); + this.add(btnPanel,BorderLayout.SOUTH); + JScrollPane tablePanelRight = getTablePanelRight(new DefaultMutableTreeTableNode()); + tablePanelRight.setBorder(BorderFactory.createTitledBorder("")); + comp = tablePanelRight; +// this.setB + this.add(tablePanelRight,BorderLayout.EAST); + +// this.setAlwaysOnTop(rootPaneCheckingEnabled); + this.createActionEvent(); + this.pack(); + this.setPreferredSize(new Dimension(1200,500)); + this.validate(); + this.setVisible(true); +// this.setAlwaysOnTop(true); + + } catch (Exception e) { + e.printStackTrace(); + return; + } + + } + + private JButton btnQry; + private JButton readQry; + private JScrollPane comp; + private JButton createdQry; + private JButton btnOk; + private JButton btnDis; + private JPanel getBtnPanel() { + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + btnOk = new JButton("确定"); + btnDis = new JButton("取消"); + topPanel.add("1.1.center",btnOk); + + topPanel.add("1.2.center",btnDis); + return topPanel; + } + private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private DateButton startButton; + private DateButton endButton; + //查询部分 + private JPanel getTopPanel() { + // TODO Auto-generated method stub + JPanel topPanel = new JPanel(); + topPanel.setLayout(new PropertyLayout()); + topPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); + JLabel field = new JLabel("查询ERP订单BOM"); + topPanel.add("1.1.left.center",new JLabel(" ")); + + topPanel.add("2.1.left.center",getJLabel("产品代码:")); + JTextField cpdmField = new JTextField(15); + topPanel.add("2.2.left.center",cpdmField); + textMap.put("PRODUCTID", cpdmField); + topPanel.add("2.3.left.center",getJLabel("物料编码:")); + JTextField wlbmField = new JTextField(15); + topPanel.add("2.4.left.center",wlbmField); + textMap.put("MATERIALNO", wlbmField); + + topPanel.add("3.1.left.center",getJLabel("批次号:")); + JTextField pcField = new JTextField(15); + topPanel.add("3.2.left.center",pcField); + textMap.put("BATCHNO", pcField); + topPanel.add("3.3.left.center",getJLabel("生产计划号:")); + JTextField scjhhField = new JTextField(15); + topPanel.add("3.4.left.center",scjhhField); + textMap.put("PRODPLANO", scjhhField); + + + topPanel.add("4.1.left.center",getJLabel("工厂:")); + JTextField gcField = new JTextField(15); + topPanel.add("4.2.left.center",gcField); + textMap.put("FACTORY", gcField); + topPanel.add("4.3.left.center",getJLabel("ERP班组编码:")); + JTextField erpbmField = new JTextField(15); + topPanel.add("4.4.left.center",erpbmField); + textMap.put("REPCODE", erpbmField); + btnQry = new JButton("查询"); + + topPanel.add("2.5.left.center",getJLabel("生产订单号:")); + JTextField ddhField = new JTextField(15); + topPanel.add("2.6.left.center",ddhField); + textMap.put("PRODORDERO", ddhField); + + startButton = new DateButton(dateFormat); + endButton = new DateButton(dateFormat); + startButton.setDate("未设置日期"); + endButton.setDate("未设置日期"); +// startButton.set + topPanel.add("3.5.left.center",getJLabel("时间晚于:")); + topPanel.add("3.6.left.center",startButton); + topPanel.add("4.5.left.center",getJLabel("时间早于:")); + topPanel.add("4.6.left.center",endButton); + + readQry = new JButton("查看BOM->"); + topPanel.add("5.1.left.center",btnQry); + topPanel.add("5.2.left.center",readQry); + + topPanel.add("5.3.left.center",new JLabel("")); + createdQry = new JButton("查询已创建"); + topPanel.add("5.4.left.center",createdQry); + return topPanel; + } + private JLabel getJLabel(String name) { + JLabel label = new JLabel(name); + label.setPreferredSize(new Dimension(100, 30)); + return label; + } + // 添加监听 + public void createActionEvent() { + this.btnQry.addActionListener(this); + this.readQry.addActionListener(this); + this.btnDis.addActionListener(this); + this.btnOk.addActionListener(this); + this.createdQry.addActionListener(this); + //增加双击打开bom视图 + this.table.addMouseListener(new MouseListener() { + + @Override + public void mouseReleased(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mousePressed(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent var1) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseClicked(MouseEvent var1) { + // TODO Auto-generated method stub + //双击打开BOM视图 单机dialog打开视图 + if (var1.getClickCount() == 2) { + TCComponentItem item = null; + //查询条件 + ArrayList fieldList = new ArrayList(); + ArrayList valueList = new ArrayList(); + String[] fields = new String[] { "ml8_ProductID","ml8_MaterialNo","","ml8_ProdPlanNo", + "ml8_BatchNo","ml8_Factory","ml8_ERPCode","ml8_ProdOrderNo"}; + for (int j = 0; j < 8; j++) { + if(j == 2) { + continue; + }else { + String str = (String)table.getValueAt(table.getSelectedRow(), j); + //不为空 + if(str != null && !str.equals("")) { + fieldList.add(fields[j]); + valueList.add(str); + } + } + } + TCComponent[] search = null; + try { + search = session.search("订单BOM查询", + (String[])fieldList.toArray(new String[fieldList.size()]), + (String[])valueList.toArray(new String[valueList.size()])); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(search == null || search.length == 0) { + MessageBox.post("订单BOM未创建或者创建的订单BOM被删除!","提示",2); + return; + }else { + item = (TCComponentItem) search[0]; + } + //打开创建的item + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.cme.mpp.MSEPerspective", new InterfaceAIFComponent[] { item }); + }else if(var1.getClickCount() == 1) { + lookBom(table.getSelectedRow()); + } + + } + }); + } + + private Integer num = 0; + + private DefaultMutableTreeTableNode topNode; + private String sqlString = "SELECT * FROM ML_CREATEORDERBOM WHERE NO = (SELECT MAX(NO)" + + " FROM ML_CREATEORDERBOM where PRODUCTID=? and MATERIALNO=? and OBJECTNAME=? and PRODPLANO=? and BATCHNO=?" + + " and FACTORY=? and REPCODE=? and PRODORDERO=?)"; + private String sqlString2 = "update ML_CREATEORDERBOM set STATUS='2' where PRODUCTID=? and MATERIALNO=? " + + "and OBJECTNAME=? and PRODPLANO=? and BATCHNO=?" + + " and FACTORY=? and REPCODE=? and PRODORDERO=?"; + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + Object source = e.getSource(); + System.out.println("source==>+"+source); + if(source.equals(this.btnQry)) { + isBomQuery = false; + //查询增加进度条 + ProgressBarThread thread = new ProgressBarThread("查询中", "查询中..."); + thread.start(); + for(int i=tm_part.getRowCount()-1;i>=0;i--) { + tm_part.removeRow(i); + } + + DbPool.getConnection(); + try { + StringBuilder insertSql = new StringBuilder("select DISTINCT PRODUCTID,MATERIALNO,OBJECTNAME," + + "PRODPLANO,BATCHNO,FACTORY,REPCODE,PRODORDERO from ML_CREATEORDERBOM where STATUS = '0' "); + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for(String prop : textMap.keySet()) + { + String text = textMap.get(prop).getText(); + if(text!=null && !text.isEmpty()) { + //insertSql.append(" and ").append(prop).append(" = '").append(text).append("'"); + //查询多个产品代码 + insertSql.append(getSql(text, prop)); + } + } + if(startButton.getDate()!=null) { + insertSql.append(" and CREATE_DATE>='").append(sf.format(startButton.getDate())).append("'"); + } + if(endButton.getDate()!=null) { + insertSql.append(" and CREATE_DATE<='").append(sf.format(endButton.getDate())).append("'"); + } + System.out.println(insertSql.toString()); + ResultSet rs = DbPool.read(insertSql.toString()); +// List<> + while (rs.next()) { + + tm_part.addRow(new String[] {rs.getString("PRODUCTID"), + rs.getString("MATERIALNO"),rs.getString("OBJECTNAME"),rs.getString("PRODPLANO") + ,rs.getString("BATCHNO"),rs.getString("FACTORY"),rs.getString("REPCODE") + ,rs.getString("PRODORDERO")}); + } + + } catch (Exception ex) { + // TODO: handle exception + ex.printStackTrace(); + } finally { + DbPool.freeAll(); + } + thread.setBool(true); + }else if(source.equals(this.createdQry)) { + isBomQuery = true; + //查询增加进度条 + ProgressBarThread thread = new ProgressBarThread("查询中", "查询中..."); + thread.start(); + for(int i=tm_part.getRowCount()-1;i>=0;i--) { + tm_part.removeRow(i); + } + + DbPool.getConnection(); + try { + StringBuilder insertSql = new StringBuilder("select DISTINCT PRODUCTID,MATERIALNO,OBJECTNAME," + + "PRODPLANO,BATCHNO,FACTORY,REPCODE,PRODORDERO from ML_CREATEORDERBOM where STATUS = '2' "); + SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + for(String prop : textMap.keySet()) + { + String text = textMap.get(prop).getText(); + if(text!=null && !text.isEmpty()) { + //insertSql.append(" and ").append(prop).append(" = '").append(text).append("'"); + //查询多个产品代码 + insertSql.append(getSql(text, prop)); + } + } + if(startButton.getDate()!=null) { + insertSql.append(" and CREATE_DATE>='").append(sf.format(startButton.getDate())).append("'"); + } + if(endButton.getDate()!=null) { + insertSql.append(" and CREATE_DATE<='").append(sf.format(endButton.getDate())).append("'"); + } + System.out.println(insertSql.toString()); + ResultSet rs = DbPool.read(insertSql.toString()); +// List<> + while (rs.next()) { + + tm_part.addRow(new String[] {rs.getString("PRODUCTID"), + rs.getString("MATERIALNO"),rs.getString("OBJECTNAME"),rs.getString("PRODPLANO") + ,rs.getString("BATCHNO"),rs.getString("FACTORY"),rs.getString("REPCODE") + ,rs.getString("PRODORDERO")}); + } + + } catch (Exception ex) { + // TODO: handle exception + ex.printStackTrace(); + } finally { + DbPool.freeAll(); + } + thread.setBool(true); + }else if(source.equals(this.readQry)) { + DbPool.getConnection(); + int ind = table.getSelectedRow(); + if(comp!=null) { + this.remove(comp); + } + + try { + ResultSet rs = DbPool.read(sqlString, + new String[] {(String)table.getValueAt(ind, 0),(String)table.getValueAt(ind, 1), + (String)table.getValueAt(ind, 2),(String)table.getValueAt(ind, 3) + ,(String)table.getValueAt(ind, 4),(String)table.getValueAt(ind, 5), + (String)table.getValueAt(ind, 6),(String)table.getValueAt(ind, 7)}); + if (rs.next()) { + + String json = rs.getString("JSON"); + int no = rs.getInt("NO"); + System.out.println(no); +// num = no; + JSONObject parseObject = JSON.parseObject(json); + + String materialNo = parseObject.getString("ml8_MaterialNo"); + String pName = parseObject.getString("object_name"); + JSONArray childItems = parseObject.getJSONArray("childItems"); + + OrderBean nodeBean = new OrderBean(); + nodeBean.setMatnrNo("顶层"); + DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); + OrderBean nodeBean2 = new OrderBean(); + nodeBean2.setMatnrNo(materialNo); + nodeBean2.setName(pName); +// nodeBean2.setUom(pName); + DefaultMutableTreeTableNode topNode = new DefaultMutableTreeTableNode(nodeBean2); + rootNode.add(topNode); + for(int i=0;i cIList = new ArrayList(); + //查询是否存在订单BOM对象 + TCComponentItemType itemType = null; + TCComponentItemRevision latestItemRevision = null; + TCComponentItem item = null; + //查询条件 + ArrayList fieldList = new ArrayList(); + ArrayList valueList = new ArrayList(); + String[] fields = new String[] { "ml8_ProductID","ml8_MaterialNo","","ml8_ProdPlanNo", + "ml8_BatchNo","ml8_Factory","ml8_ERPCode","ml8_ProdOrderNo"}; + for (int j = 0; j < 8; j++) { + if(j == 2) { + continue; + }else { + String str = (String)table.getValueAt(inds[i], j); + //不为空 + if(str != null && !str.equals("")) { + fieldList.add(fields[j]); + valueList.add(str); + } + } + } + //测试输出 +// String[] a = (String[])fieldList.toArray(new String[fieldList.size()]); +// String[] b = (String[])valueList.toArray(new String[valueList.size()]); +// String as = ""; +// String bs = ""; +// for (int j = 0; j < a.length; j++) { +// as = as+a[j]+","; +// } +// for (int j = 0; j < b.length; j++) { +// bs = bs+b[j]+","; +// } +// System.out.println("======================"+as); +// System.out.println("======================"+bs); + TCComponent[] search = session.search("订单BOM查询", + (String[])fieldList.toArray(new String[fieldList.size()]), + (String[])valueList.toArray(new String[valueList.size()])); + System.out.println("========================================"+search.length); + //已创建bom中 给提示 跟用户确认是否需要创建 + if(isBomQuery) { + if(search == null || search.length == 0) { + thread.setBool(true); + int sl = JOptionPane.showOptionDialog(null, "订单BOM被删除,是否重新生成?", "",-1, + 3, null, (Object[]) new String[] { "是", "否" }, "否"); + if(sl == 1) { + //thread.setBool(true); +// thread.stop(); +// thread.interrupt(); + //thread.destroy(); + System.out.println("1111111"); + return; + } + thread.setBool(false); + itemType = (TCComponentItemType) session.getTypeComponent("ML8_OrdMBOMItem"); + item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), + "ML8_OrdMBOMItem", (String)table.getValueAt(inds[i], 2), "", null); + latestItemRevision = item.getLatestItemRevision(); + Map map = new HashMap(); + map.put("ml8_ProductID", (String)table.getValueAt(inds[i], 0)); + map.put("ml8_MaterialNo", (String)table.getValueAt(inds[i], 1)); + map.put("ml8_ProdPlanNo", (String)table.getValueAt(inds[i], 3)); + map.put("ml8_BatchNo", (String)table.getValueAt(inds[i], 4)); + map.put("ml8_Factory", (String)table.getValueAt(inds[i], 5)); + map.put("ml8_ERPCode", (String)table.getValueAt(inds[i], 6)); + map.put("ml8_ProdOrderNo", (String)table.getValueAt(inds[i], 7)); + latestItemRevision.setProperties(map); + session.getUser().getNewStuffFolder().add("contents", item); + }else { + thread.setBool(true); + int sl = JOptionPane.showOptionDialog(null, "订单BOM已存在,是否重新生成?", "",-1, + 3, null, (Object[]) new String[] { "是", "否" }, "否"); + if(sl == 1) { + + + //thread.setBool(true); +// thread.stop(); +// thread.interrupt(); + //thread.destroy(); + System.out.println("11111111"); + return; + } + thread.setBool(false); + item =(TCComponentItem)search[0]; + latestItemRevision = item.getLatestItemRevision(); + } + + }else { + if(search == null || search.length == 0) { + itemType = (TCComponentItemType) session.getTypeComponent("ML8_OrdMBOMItem"); + item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), + "ML8_OrdMBOMItem", (String)table.getValueAt(inds[i], 2), "", null); + latestItemRevision = item.getLatestItemRevision(); + Map map = new HashMap(); + map.put("ml8_ProductID", (String)table.getValueAt(inds[i], 0)); + map.put("ml8_MaterialNo", (String)table.getValueAt(inds[i], 1)); + map.put("ml8_ProdPlanNo", (String)table.getValueAt(inds[i], 3)); + map.put("ml8_BatchNo", (String)table.getValueAt(inds[i], 4)); + map.put("ml8_Factory", (String)table.getValueAt(inds[i], 5)); + map.put("ml8_ERPCode", (String)table.getValueAt(inds[i], 6)); + map.put("ml8_ProdOrderNo", (String)table.getValueAt(inds[i], 7)); + latestItemRevision.setProperties(map); + session.getUser().getNewStuffFolder().add("contents", item); + }else { + item =(TCComponentItem)search[0]; + latestItemRevision = item.getLatestItemRevision(); + } + } + + + itemId = itemId+latestItemRevision.getProperty("item_id")+","; + List numList = new ArrayList(); + itemType = (TCComponentItemType) session.getTypeComponent("ML8_OrdItem"); + + //修改 2023年9月12日,修改逻辑创建时只创建顶层BOM,将json数据存在txt中,放在版本表单下 + Boolean flagBoolean = false; + if(flagBoolean) { + for(int t=0;t revPropMap = new HashMap<>(); + revPropMap.put("object_name", name); + revPropMap.put("ml8_MaterialNo", userObject.getMatnrNo()); + CreateInput revInput = new CreateInput(); + Map revInfoMap = new HashMap<>(); + revInfoMap.put("revision", new CreateInput[] { revInput }); + revInput.boName = "ML8_OrdItemRevision"; //ML8_OrdItemRevision + revInput.stringProps = revPropMap; + + numList.add(userObject.getBl_quantity()); + CreateInput itemInput = new CreateInput(); + itemInput.boName = "ML8_OrdItem"; + Map itemPropMap = new HashMap<>(); + itemPropMap.put("item_id", itemType.getNewID()); + itemPropMap.put("object_name", name); +// System.out.println("userObject.getUom()==>"+userObject.getUom()); +// itemPropMap.put("uom_tag", userObject.getUom()); + itemInput.compoundCreateInput = revInfoMap; + //item.getProperty("object_name") + " " + parent.getEbTeRe(); + itemInput.stringProps = itemPropMap; + + Map itemPropMapTag = new HashMap<>(); + if(userObject.getUom()!=null && uomTags.containsKey(userObject.getUom())){ + itemPropMapTag.put("uom_tag", uomTags.get(userObject.getUom())); + itemInput.tagProps = itemPropMapTag; + } + + + CreateIn cI = new CreateIn(); + cI.clientId = "CreateItem"; + cI.data = itemInput; + cIList.add(cI); + } + + DataManagementService service = DataManagementService.getService(session); + CreateResponse resp = service.createObjects(cIList.toArray(new CreateIn[cIList.size()])); + + ICCTReservationService reservationService = new ICCTReservationService( + session.getSoaConnection()); + + TCComponent[] strustRevs = latestItemRevision.getReferenceListProperty("structure_revisions"); + if(strustRevs!=null && strustRevs.length>0) { + reservationService.reserve(new String[] {strustRevs[0].getUid()}, "true", "true", (short) 2); + } + + KUtil.throwServiceDataError(resp.serviceData); + CreateOut[] cOs = resp.output; + System.out.println("创建成功的对象:"+cOs.length); + int seq = 0; + List childInfos = new ArrayList<>(); + for (int j = 0, len = cOs.length; j < len; j++) { + for (TCComponent s : cOs[j].objects) { + if (s instanceof TCComponentItem) { + TCComponentItemRevision latestItemRevision2 = ((TCComponentItem)s).getLatestItemRevision(); + RelativeStructureChildInfo childInfo = new RelativeStructureChildInfo(); + RelOccInfo occInfo = new RelOccInfo(); + AttributesInfo attr = new AttributesInfo(); + attr.name = "bl_quantity"; +// int num = POIUtil.getIntValue(childs.get(i).getEbQty()); +// num = num == 0 ? 1 : num; + attr.value = numList.get(seq) + ""; + AttributesInfo attr1 = new AttributesInfo(); + attr1.name = "bl_sequence_no"; + attr1.value = (seq + 1) * 10 + ""; + seq = seq+1; + occInfo.attrsToSet = new AttributesInfo[] { attr, attr1 }; + childInfo.child = latestItemRevision2; + childInfo.occInfo = occInfo; + childInfos.add(childInfo); + } + } + + } + CreateOrUpdateRelativeStructureInfo srtuctInfo = new CreateOrUpdateRelativeStructureInfo(); + srtuctInfo.childInfo = childInfos.toArray(new RelativeStructureChildInfo[] {}); + srtuctInfo.parent = latestItemRevision; + srtuctInfo.precise = false; + CreateOrUpdateRelativeStructurePref sPref = new CreateOrUpdateRelativeStructurePref(); +// System.out.println("srtuctInfos==>"+srtuctInfos.size()); + CreateOrUpdateRelativeStructureResponse respStr; + StructureManagementService service2 = StructureManagementService.getService(session); + respStr = service2.createOrUpdateRelativeStructure( new CreateOrUpdateRelativeStructureInfo[] {srtuctInfo}, + "view", true, sPref); + KUtil.throwServiceDataError(respStr.serviceData); + + if(strustRevs!=null && strustRevs.length>0) { + reservationService.unReserve(new String[] {strustRevs[0].getUid()}, false); + } + + DbPool.getConnection(); + try { + DbPool.write(sqlString2,new String[] {(String)table.getValueAt(inds[i], 0),(String)table.getValueAt(inds[i], 1), + (String)table.getValueAt(inds[i], 2),(String)table.getValueAt(inds[i], 3) + ,(String)table.getValueAt(inds[i], 4),(String)table.getValueAt(inds[i], 5), + (String)table.getValueAt(inds[i], 6),(String)table.getValueAt(inds[i], 7)}); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + }finally { + DbPool.freeAll(); + } + }else { + DbPool.getConnection(); + int ind = table.getSelectedRow(); + try { + ResultSet rs = DbPool.read(sqlString, + new String[] {(String)table.getValueAt(ind, 0),(String)table.getValueAt(ind, 1), + (String)table.getValueAt(ind, 2),(String)table.getValueAt(ind, 3) + ,(String)table.getValueAt(ind, 4),(String)table.getValueAt(ind, 5), + (String)table.getValueAt(ind, 6),(String)table.getValueAt(ind, 7)}); + if (rs.next()) { + String json = rs.getString("JSON"); + try { + String url = "C:\\Users\\Administrator\\AppData\\Local\\Temp\\JSONTXT\\"+itemId+".txt"; + File file = new File(url); + // 检查文件夹是否存在,如果不存在则创建 + File folder = file.getParentFile(); + if (!folder.exists()) { + if (folder.mkdirs()) { + System.out.println("文件夹创建成功"); + } else { + System.out.println("文件夹创建失败"); + } + } + // 检查文件是否存在,如果不存在则创建 + if (!file.exists()) { + if (file.createNewFile()) { + System.out.println("文件创建成功"); + } else { + System.out.println("文件创建失败"); + } + } + FileWriter writer = new FileWriter(file); + writer.write(json); + writer.close(); + + //开始挂载文件夹 + String pref = "Text"; + String as1[] = {url}; + String as2[] = {pref}; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session.getTypeComponent("Text"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create("bomJson", "JSON", "Text"); + tccomponentDataset.setFiles(as1, as2); + latestItemRevision.add("IMAN_specification",tccomponentDataset); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + } catch (Exception ex) { + // TODO: handle exception + ex.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } + + +// MessageBox.post("同步完成","提示",2); + + //打开创建的item + if(inds.length == 1 && item != null) { + com.teamcenter.rac.common.Activator.getDefault() + .openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); + com.teamcenter.rac.common.Activator.getDefault().openComponents( + "com.teamcenter.rac.cme.mpp.MSEPerspective", new InterfaceAIFComponent[] { item }); + } + + } + thread.setBool(true); + MessageBox.post("同步完成,订单BOM对象ID:"+itemId+"新建对象已加到newstuff文件夹下.","提示",2); + }catch (Exception ex) { + ex.printStackTrace(); + // TODO: handle exception + thread.setBool(true); + MessageBox.post("同步出错:"+ex.getMessage(),"提示",2); + } + + //查询顶层订单BOM对象 +// TCComponent[] search = +// session.search("零组件...", new String [] {"类型","零组件 ID"}, new String [] {"工艺变更通知单" ,head + "-*"}); + + + } + + } + + + private JScrollPane getTablePanel() { + // TODO Auto-generated method stub + table = getjTable(null, null, header, null); + table.setRowHeight(30); +// table.setPreferredSize(new Dimension(1500,400)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 设置表格的自动调整模式为关闭自动调整 +// table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//设置JTable的列宽随着列表内容的大小进行调整 +// table.setPreferredSize(new Dimension(1200,400)); + JScrollPane pane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + pane.setPreferredSize(new Dimension(750,400)); + pane.setViewportView(table);//为scrollPane指定显示对象为table + return pane; + } + private JScrollPane getTablePanelRight(DefaultMutableTreeTableNode topNode) { + // TODO Auto-generated method stub + JTreeTable table2 = getJTreeTable(null, null, header, null,topNode); + table2.setRowHeight(30); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);//设置JTable的列宽随着列表内容的大小进行调整 + JScrollPane pane = new JScrollPane(table2); + pane.setPreferredSize(new Dimension(450,400)); + table2.expandAll(); + return pane; + } + /*** + * Jtable通用方法 + * + * @param partsTable + * @param dtm + * @param titleNames + * @param values + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { +// int simpleLen = 100; +// int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(this.getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + partsTable.getTableHeader().setReorderingAllowed(false); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + for (int i = 0; i < titleNames.length; i++) { + if(i==2) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(200); + }else { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(120); + } + + } + + } + return partsTable; + } + public DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + tm_part = null; + if (dtm == null) { + tm_part = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + + return tm_part; + } + public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames, + Object[][] values,DefaultMutableTreeTableNode rootNode) { + if (partsTable == null) { + JTreeTableModel map = new JTreeTableModel(rootNode); + partsTable = new JTreeTable(map); + partsTable.getTableHeader().setReorderingAllowed(false); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + + partsTable.getColumnModel().getColumn(0).setPreferredWidth(400); // 设置第一列宽度 + partsTable.setHighlighters(HighlighterFactory.createAlternateStriping()); + } + return partsTable; + } + + private void lookBom(int ind) { + DbPool.getConnection(); + if(comp!=null) { + this.remove(comp); + } + + try { + ResultSet rs = DbPool.read(sqlString, + new String[] {(String)table.getValueAt(ind, 0),(String)table.getValueAt(ind, 1), + (String)table.getValueAt(ind, 2),(String)table.getValueAt(ind, 3) + ,(String)table.getValueAt(ind, 4),(String)table.getValueAt(ind, 5), + (String)table.getValueAt(ind, 6),(String)table.getValueAt(ind, 7)}); + if (rs.next()) { + + String json = rs.getString("JSON"); + int no = rs.getInt("NO"); + System.out.println(no); +// num = no; + JSONObject parseObject = JSON.parseObject(json); + + String materialNo = parseObject.getString("ml8_MaterialNo"); + String pName = parseObject.getString("object_name"); + JSONArray childItems = parseObject.getJSONArray("childItems"); + + OrderBean nodeBean = new OrderBean(); + nodeBean.setMatnrNo("顶层"); + DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); + OrderBean nodeBean2 = new OrderBean(); + nodeBean2.setMatnrNo(materialNo); + nodeBean2.setName(pName); +// nodeBean2.setUom(pName); + DefaultMutableTreeTableNode topNode = new DefaultMutableTreeTableNode(nodeBean2); + rootNode.add(topNode); + for(int i=0;i processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + //private TestTreeTableModel tableModel; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + + } + public TableCellCheckboxRenderer(final JTable table) { + } + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 +// this.setBorderPainted(true); + + if(value != null) + { + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/ComboBoxItemBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/ComboBoxItemBean.java new file mode 100644 index 0000000..64f883c --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/ComboBoxItemBean.java @@ -0,0 +1,33 @@ +package com.connor.ml.tcm.bean; + +public class ComboBoxItemBean { + + private String key; + private String value; + + public ComboBoxItemBean(String key, String value) { + super(); + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/CreatePropBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/CreatePropBean.java new file mode 100644 index 0000000..5c27882 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/CreatePropBean.java @@ -0,0 +1,44 @@ +package com.connor.ml.tcm.bean; + +import com.teamcenter.rac.kernel.TCPropertyDescriptor; + +public class CreatePropBean { + + private String displayName; + private String name; + private String value; + private TCPropertyDescriptor descriptor; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public TCPropertyDescriptor getDescriptor() { + return descriptor; + } + + public void setDescriptor(TCPropertyDescriptor descriptor) { + this.descriptor = descriptor; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/DoubleBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/DoubleBean.java new file mode 100644 index 0000000..93e1dc2 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/DoubleBean.java @@ -0,0 +1,14 @@ +package com.connor.ml.tcm.bean; + +public class DoubleBean { + private Double value = new Double(0); + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/ItemBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/ItemBean.java new file mode 100644 index 0000000..d3ea87c --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/ItemBean.java @@ -0,0 +1,130 @@ +package com.connor.ml.tcm.bean; + +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; + +public class ItemBean { + private TCComponentItem item; + private String itemID;// 零组件ID + private String revID;// 版本ID + private String name;// 名称 + private String unitDis;// 单位显示 + private String unit;// 单位 + private String typeDis;// 类型显示 + private String type;// 类型 + private Map itemProps;// 零组件属性 + private Map revProps;// 版本属性 + private Map formProps;// 版本表单属性 + private TCComponentFolder folder; + + public TCComponentFolder getFolder() { + return folder; + } + + public void setFolder(TCComponentFolder folder) { + this.folder = folder; + } + + public String getTypeDis() { + return typeDis; + } + + public void setTypeDis(String typeDis) { + this.typeDis = typeDis; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnitDis() { + return unitDis; + } + + public void setUnitDis(String unitDis) { + this.unitDis = unitDis; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public TCComponentItem getItem() { + return item; + } + + public void setItem(TCComponentItem item) { + this.item = item; + } + + // ---------------------------------------------------- + public String getItemID() { + return itemID; + } + + public void setItemID(String itemID) { + this.itemID = itemID; + } + + public String getRevID() { + return revID; + } + + public void setRevID(String revID) { + this.revID = revID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getItemProps() { + return itemProps; + } + + public void setItemProps(Map itemProps) { + this.itemProps = itemProps; + } + + public Map getRevProps() { + return revProps; + } + + public void setRevProps(Map revProps) { + this.revProps = revProps; + } + + public Map getFormProps() { + return formProps; + } + + public void setFormProps(Map formProps) { + + this.formProps = formProps; + } + + @Override + public String toString() { + return "TMom001DeriveItemBean [itemID=" + itemID + ", revID=" + revID + + ", name=" + name + ", itemProps=" + itemProps + ", revProps=" + + revProps + ", formProps=" + formProps + "]"; + + } + + // ------------------------------ + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/LOVBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/LOVBean.java new file mode 100644 index 0000000..bd792df --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/LOVBean.java @@ -0,0 +1,38 @@ +package com.connor.ml.tcm.bean; + +public class LOVBean { + private String displayName; + private String realName; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public LOVBean(String displayName, String realName) { + super(); + this.displayName = displayName; + this.realName = realName; + } + + public LOVBean() { + super(); + } + + @Override + public String toString() { + return displayName; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/NodeBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/NodeBean.java new file mode 100644 index 0000000..e3d82c4 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/NodeBean.java @@ -0,0 +1,73 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.bean; + +import java.util.Random; + +import com.teamcenter.rac.kernel.TCComponentItem; + +/** + * + * @author vearn + */ +public class NodeBean { + + private String ebom;//EBOM对象信息 + private String refreshStatus;//发布状态 + private String projectTeam;//替代项目组 + private String num;//数量 + private String mbomId;//对象ID + private String mbomName;//对象名称 + private String isHave;//ID在系统中是否存在 + private TCComponentItem item;//EBOM对象 + public String getEbom() { + return ebom; + } + public void setEbom(String ebom) { + this.ebom = ebom; + } + public String getRefreshStatus() { + return refreshStatus; + } + public void setRefreshStatus(String refreshStatus) { + this.refreshStatus = refreshStatus; + } + public String getProjectTeam() { + return projectTeam; + } + public void setProjectTeam(String projectTeam) { + this.projectTeam = projectTeam; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + public String getMbomId() { + return mbomId; + } + public void setMbomId(String mbomId) { + this.mbomId = mbomId; + } + public String getMbomName() { + return mbomName; + } + public void setMbomName(String mbomName) { + this.mbomName = mbomName; + } + public String getIsHave() { + return isHave; + } + public void setIsHave(String isHave) { + this.isHave = isHave; + } + public TCComponentItem getItem() { + return item; + } + public void setItem(TCComponentItem item) { + this.item = item; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/PropExplictBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/PropExplictBean.java new file mode 100644 index 0000000..41fabee --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/PropExplictBean.java @@ -0,0 +1,25 @@ +package com.connor.ml.tcm.bean; + +import java.util.List; + +public class PropExplictBean { + private String Type = ""; + private List PropList; + + public String getType() { + return Type; + } + + public void setType(String type) { + Type = type; + } + + public List getPropList() { + return PropList; + } + + public void setPropList(List propList) { + PropList = propList; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/RealBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/RealBean.java new file mode 100644 index 0000000..fd83031 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/RealBean.java @@ -0,0 +1,40 @@ +package com.connor.ml.tcm.bean; + +public class RealBean { + private String hzm; + private String daType; + private String toolType; + private String realname; + public String getHzm() { + return hzm; + } + public void setHzm(String hzm) { + this.hzm = hzm; + } + public String getDaType() { + return daType; + } + public void setDaType(String daType) { + this.daType = daType; + } + public String getToolType() { + return toolType; + } + public void setToolType(String toolType) { + this.toolType = toolType; + } + + public String getRealname() { + return realname; + } + public void setRealname(String realname) { + this.realname = realname; + } + @Override + public String toString() { + return "RealBean [hzm=" + hzm + ", daType=" + daType + ", toolType=" + + toolType + ", realname=" + realname + "]"; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendOABean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendOABean.java new file mode 100644 index 0000000..11ae40a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendOABean.java @@ -0,0 +1,51 @@ +package com.connor.ml.tcm.bean; + +import java.util.ArrayList; +import java.util.List; + +public class SendOABean { + + private String infotype = ""; + private String infocode = ""; + private String infoname = ""; + private List data = new ArrayList(); + private List list = new ArrayList(); + private List file = new ArrayList(); + + public String getInfotype() { + return infotype; + } + public void setInfotype(String infotype) { + this.infotype = infotype; + } + public String getInfocode() { + return infocode; + } + public void setInfocode(String infocode) { + this.infocode = infocode; + } + public String getInfoname() { + return infoname; + } + public void setInfoname(String infoname) { + this.infoname = infoname; + } + public List getData() { + return data; + } + public void setData(List data) { + this.data = data; + } + public List getList() { + return list; + } + public void setList(List list) { + this.list = list; + } + public List getFile() { + return file; + } + public void setFile(List file) { + this.file = file; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendOAPropertyBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendOAPropertyBean.java new file mode 100644 index 0000000..901cdc6 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendOAPropertyBean.java @@ -0,0 +1,20 @@ +package com.connor.ml.tcm.bean; + +public class SendOAPropertyBean { + + private String field = ""; + private String value = ""; + + public String getField() { + return field; + } + public void setField(String field) { + this.field = field; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendSAPProcessBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendSAPProcessBean.java new file mode 100644 index 0000000..8349860 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendSAPProcessBean.java @@ -0,0 +1,250 @@ +package com.connor.ml.tcm.bean; + +public class SendSAPProcessBean { + private String TYPE; + private String GROUPNAME; + private String MSGID; + private String BUSID; + private String TLGID; + private String TLGNAME; + private String DTSEND; + private String SENDER; + private String RECEIVER; + private String FREEUSE; + private String MATNR; + private String WERKS; + private String PLNNR; + private String PLNAL; + private String DATUV; + private String VERWE; + private String STATU; + private String VORNR; + private String STEUS; + private String ARBPL; + private String LTXA1; + private String BMSCH; + private String VGW01; + private String VGE01; + private String VGW02; + private String VGE02; + private String VGW03; + private String VGE03; + private String VGW04; + private String VGE04; + private String VGW05; + private String VGE05; + private String KZ; + private String STATUS; + private String MESSAGE; + + public String getTYPE() { + return TYPE; + } + public void setTYPE(String tYPE) { + TYPE = tYPE; + } + public String getGROUPNAME() { + return GROUPNAME; + } + public void setGROUPNAME(String gROUPNAME) { + GROUPNAME = gROUPNAME; + } + public String getMSGID() { + return MSGID; + } + public void setMSGID(String mSGID) { + MSGID = mSGID; + } + public String getBUSID() { + return BUSID; + } + public void setBUSID(String bUSID) { + BUSID = bUSID; + } + public String getTLGID() { + return TLGID; + } + public void setTLGID(String tLGID) { + TLGID = tLGID; + } + public String getTLGNAME() { + return TLGNAME; + } + public void setTLGNAME(String tLGNAME) { + TLGNAME = tLGNAME; + } + public String getDTSEND() { + return DTSEND; + } + public void setDTSEND(String dTSEND) { + DTSEND = dTSEND; + } + public String getSENDER() { + return SENDER; + } + public void setSENDER(String sENDER) { + SENDER = sENDER; + } + public String getRECEIVER() { + return RECEIVER; + } + public void setRECEIVER(String rECEIVER) { + RECEIVER = rECEIVER; + } + public String getFREEUSE() { + return FREEUSE; + } + public void setFREEUSE(String fREEUSE) { + FREEUSE = fREEUSE; + } + public String getMATNR() { + return MATNR; + } + public void setMATNR(String mATNR) { + MATNR = mATNR; + } + public String getWERKS() { + return WERKS; + } + public void setWERKS(String wERKS) { + WERKS = wERKS; + } + public String getPLNNR() { + return PLNNR; + } + public void setPLNNR(String pLNNR) { + PLNNR = pLNNR; + } + public String getPLNAL() { + return PLNAL; + } + public void setPLNAL(String pLNAL) { + PLNAL = pLNAL; + } + public String getDATUV() { + return DATUV; + } + public void setDATUV(String dATUV) { + DATUV = dATUV; + } + public String getVERWE() { + return VERWE; + } + public void setVERWE(String vERWE) { + VERWE = vERWE; + } + public String getSTATU() { + return STATU; + } + public void setSTATU(String sTATU) { + STATU = sTATU; + } + public String getVORNR() { + return VORNR; + } + public void setVORNR(String vORNR) { + VORNR = vORNR; + } + public String getSTEUS() { + return STEUS; + } + public void setSTEUS(String sTEUS) { + STEUS = sTEUS; + } + public String getARBPL() { + return ARBPL; + } + public void setARBPL(String aRBPL) { + ARBPL = aRBPL; + } + public String getLTXA1() { + return LTXA1; + } + public void setLTXA1(String lTXA1) { + LTXA1 = lTXA1; + } + public String getBMSCH() { + return BMSCH; + } + public void setBMSCH(String bMSCH) { + BMSCH = bMSCH; + } + public String getVGW01() { + return VGW01; + } + public void setVGW01(String vGW01) { + VGW01 = vGW01; + } + public String getVGE01() { + return VGE01; + } + public void setVGE01(String vGE01) { + VGE01 = vGE01; + } + public String getVGW02() { + return VGW02; + } + public void setVGW02(String vGW02) { + VGW02 = vGW02; + } + public String getVGE02() { + return VGE02; + } + public void setVGE02(String vGE02) { + VGE02 = vGE02; + } + public String getVGW03() { + return VGW03; + } + public void setVGW03(String vGW03) { + VGW03 = vGW03; + } + public String getVGE03() { + return VGE03; + } + public void setVGE03(String vGE03) { + VGE03 = vGE03; + } + public String getVGW04() { + return VGW04; + } + public void setVGW04(String vGW04) { + VGW04 = vGW04; + } + public String getVGE04() { + return VGE04; + } + public void setVGE04(String vGE04) { + VGE04 = vGE04; + } + public String getVGW05() { + return VGW05; + } + public void setVGW05(String vGW05) { + VGW05 = vGW05; + } + public String getVGE05() { + return VGE05; + } + public void setVGE05(String vGE05) { + VGE05 = vGE05; + } + public String getKZ() { + return KZ; + } + public void setKZ(String kZ) { + KZ = kZ; + } + public String getSTATUS() { + return STATUS; + } + public void setSTATUS(String sTATUS) { + STATUS = sTATUS; + } + public String getMESSAGE() { + return MESSAGE; + } + public void setMESSAGE(String mESSAGE) { + MESSAGE = mESSAGE; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendSAPProductRevBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendSAPProductRevBean.java new file mode 100644 index 0000000..e5e1246 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/bean/SendSAPProductRevBean.java @@ -0,0 +1,175 @@ +package com.connor.ml.tcm.bean; + +public class SendSAPProductRevBean { + private String MSGID = ""; + private String BUSID = ""; + private String TLGID = ""; + private String TLGNAME = ""; + private String DTSEND = ""; + private String SENDER = ""; + private String RECEIVER = ""; + private String FREEUSE = ""; + private String MATNR = ""; + private String WERKS = ""; + private String VERID = ""; + private String TEXT1 = ""; + private String ADATU = ""; + private String BDATU = ""; + private String STLAL = ""; + private String STLAN = ""; + private String PLNNR = ""; + private String ALNAL = ""; + private String MDV01 = ""; + private String ALORT = ""; + private String ELPRO = ""; + private String KZ = ""; + public String getMSGID() { + return MSGID; + } + public void setMSGID(String mSGID) { + MSGID = mSGID; + } + public String getBUSID() { + return BUSID; + } + public void setBUSID(String bUSID) { + BUSID = bUSID; + } + public String getTLGID() { + return TLGID; + } + public void setTLGID(String tLGID) { + TLGID = tLGID; + } + public String getTLGNAME() { + return TLGNAME; + } + public void setTLGNAME(String tLGNAME) { + TLGNAME = tLGNAME; + } + public String getDTSEND() { + return DTSEND; + } + public void setDTSEND(String dTSEND) { + DTSEND = dTSEND; + } + public String getSENDER() { + return SENDER; + } + public void setSENDER(String sENDER) { + SENDER = sENDER; + } + public String getRECEIVER() { + return RECEIVER; + } + public void setRECEIVER(String rECEIVER) { + RECEIVER = rECEIVER; + } + public String getFREEUSE() { + return FREEUSE; + } + public void setFREEUSE(String fREEUSE) { + FREEUSE = fREEUSE; + } + public String getMATNR() { + return MATNR; + } + public void setMATNR(String mATNR) { + MATNR = mATNR; + } + public String getWERKS() { + return WERKS; + } + public void setWERKS(String wERKS) { + WERKS = wERKS; + } + public String getVERID() { + return VERID; + } + public void setVERID(String vERID) { + VERID = vERID; + } + public String getTEXT1() { + return TEXT1; + } + public void setTEXT1(String tEXT1) { + TEXT1 = tEXT1; + } + public String getADATU() { + return ADATU; + } + public void setADATU(String aDATU) { + ADATU = aDATU; + } + public String getBDATU() { + return BDATU; + } + public void setBDATU(String bDATU) { + BDATU = bDATU; + } + public String getSTLAL() { + return STLAL; + } + public void setSTLAL(String sTLAL) { + STLAL = sTLAL; + } + public String getSTLAN() { + return STLAN; + } + public void setSTLAN(String sTLAN) { + STLAN = sTLAN; + } + public String getPLNNR() { + return PLNNR; + } + public void setPLNNR(String pLNNR) { + PLNNR = pLNNR; + } + public String getALNAL() { + return ALNAL; + } + public void setALNAL(String aLNAL) { + ALNAL = aLNAL; + } + public String getMDV01() { + return MDV01; + } + public void setMDV01(String mDV01) { + MDV01 = mDV01; + } + public String getALORT() { + return ALORT; + } + public void setALORT(String aLORT) { + ALORT = aLORT; + } + public String getELPRO() { + return ELPRO; + } + public void setELPRO(String eLPRO) { + ELPRO = eLPRO; + } + public String getKZ() { + return KZ; + } + public void setKZ(String kZ) { + KZ = kZ; + } + @Override + public String toString() { + return "SendSAPProductRevBean [MSGID=" + MSGID + ", BUSID=" + BUSID + ", TLGID=" + TLGID + ", TLGNAME=" + + TLGNAME + ", DTSEND=" + DTSEND + ", SENDER=" + SENDER + ", RECEIVER=" + RECEIVER + ", FREEUSE=" + + FREEUSE + ", MATNR=" + MATNR + ", WERKS=" + WERKS + ", VERID=" + VERID + ", TEXT1=" + TEXT1 + + ", ADATU=" + ADATU + ", BDATU=" + BDATU + ", STLAL=" + STLAL + ", STLAN=" + STLAN + ", PLNNR=" + PLNNR + + ", ALNAL=" + ALNAL + ", MDV01=" + MDV01 + ", ALORT=" + ALORT + ", ELPRO=" + ELPRO + ", KZ=" + KZ + + ", getMSGID()=" + getMSGID() + ", getBUSID()=" + getBUSID() + ", getTLGID()=" + getTLGID() + + ", getTLGNAME()=" + getTLGNAME() + ", getDTSEND()=" + getDTSEND() + ", getSENDER()=" + getSENDER() + + ", getRECEIVER()=" + getRECEIVER() + ", getFREEUSE()=" + getFREEUSE() + ", getMATNR()=" + getMATNR() + + ", getWERKS()=" + getWERKS() + ", getVERID()=" + getVERID() + ", getTEXT1()=" + getTEXT1() + + ", getADATU()=" + getADATU() + ", getBDATU()=" + getBDATU() + ", getSTLAL()=" + getSTLAL() + + ", getSTLAN()=" + getSTLAN() + ", getPLNNR()=" + getPLNNR() + ", getALNAL()=" + getALNAL() + + ", getMDV01()=" + getMDV01() + ", getALORT()=" + getALORT() + ", getELPRO()=" + getELPRO() + + ", getKZ()=" + getKZ() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + + super.toString() + "]"; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/changeBlocc/ChangeHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/changeBlocc/ChangeHandler.java new file mode 100644 index 0000000..81147d4 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/changeBlocc/ChangeHandler.java @@ -0,0 +1,80 @@ +package com.connor.ml.tcm.changeBlocc; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.turntobop.SelectBOPLine; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class ChangeHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String id = AIFUtility.getCurrentPerspectiveDef().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + + try { + + new Thread() { + @Override + public void run() { +// SelectBOPLine dialogBopLine=new SelectBOPLine(bomBopLine,session); + InterfaceAIFComponent target = app.getTargetComponent(); + if(target instanceof TCComponentBOPLine) { + TCComponentBOPLine bomBopLine=(TCComponentBOPLine)target; + + changeType(bomBopLine); + + } + } + }.start(); + + + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + + return null; + } + + private void changeType(TCComponentBOMLine bomBopLine) { + // TODO Auto-generated method stub + try { + AIFComponentContext[] children = bomBopLine.getChildren(); + + for(AIFComponentContext context:children) { + + TCComponentBOMLine component = (TCComponentBOMLine) context.getComponent(); + TCComponentItem itemRevision = component.getItem(); + if(itemRevision.getType().equals("ML8_Station")) { + component.setStringProperty("bl_occ_type", "MEWorkArea"); + component.save(); + } + + changeType(component); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/checkMBOM/CheckMBOMHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/checkMBOM/CheckMBOMHandler.java new file mode 100644 index 0000000..fd6e03f --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/checkMBOM/CheckMBOMHandler.java @@ -0,0 +1,59 @@ +package com.connor.ml.tcm.checkMBOM; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.sun.mail.handlers.message_rfc822; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class CheckMBOMHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + for(InterfaceAIFComponent comp:targetComponents) { + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + try { + String ml8_Factory = rev.getStringProperty("ml8_Factory"); + String ml8_Line = rev.getStringProperty("ml8_Line"); + if(ml8_Factory==null||ml8_Line==null||ml8_Factory.trim().equals("")||ml8_Line.trim().equals("")) { + MessageBox.post("当前对象不为MBOM!","",MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine topLine = (TCComponentBOMLine)comp; + try { + TCComponentItemRevision rev = topLine.getItemRevision(); + String ml8_Factory = rev.getStringProperty("ml8_Factory"); + String ml8_Line = rev.getStringProperty("ml8_Line"); + if(ml8_Factory==null||ml8_Line==null||ml8_Factory.trim().equals("")||ml8_Line.trim().equals("")) { + MessageBox.post("当前对象不为MBOM!","",MessageBox.INFORMATION); + return null; + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + session.queueOperation(new CheckMBOMOperation(app,session)); + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/checkMBOM/CheckMBOMOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/checkMBOM/CheckMBOMOperation.java new file mode 100644 index 0000000..f56b498 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/checkMBOM/CheckMBOMOperation.java @@ -0,0 +1,180 @@ +package com.connor.ml.tcm.checkMBOM; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingConstants; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class CheckMBOMOperation extends AbstractAIFOperation{ + + private AbstractAIFUIApplication app; + private TCSession session; + private StringBuffer checkResult; + private TCComponentBOMWindow bomwin; + + public CheckMBOMOperation() { + + } + + public CheckMBOMOperation(AbstractAIFUIApplication app, TCSession session) { + this.app = app; + this.session = session; + checkResult = new StringBuffer(""); + this.bomwin = createBOMWindow(); + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在校验......"); + dia.setVisible(true); + boolean flag = true; + try { + flag = check(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (flag) { + dia.setVisible(false); + }else { + dia.setVisible(false); + MessageBox.post(checkResult.toString(), "", MessageBox.INFORMATION); + } + }; + }.start(); + } + + private boolean check() throws TCException{ + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + for(InterfaceAIFComponent comp: targetComponents) { + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + String top_ml8_Factory = rev.getStringProperty("ml8_Factory"); + String top_ml8_Line = rev.getStringProperty("ml8_Line"); + System.out.println("首行的ml8_Factory为:"+top_ml8_Factory+",ml8_Line为:"+top_ml8_Line); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(rev.getItem(), rev, null, null); + checkChild(topLine,top_ml8_Factory,top_ml8_Line); + }else if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine topLine = (TCComponentBOMLine)comp; + TCComponentItemRevision rev = topLine.getItemRevision(); + String top_ml8_Factory = rev.getStringProperty("ml8_Factory"); + String top_ml8_Line = rev.getStringProperty("ml8_Line"); + System.out.println("首行的ml8_Factory为:"+top_ml8_Factory+",ml8_Line为:"+top_ml8_Line); + checkChild(topLine,top_ml8_Factory,top_ml8_Line); + } + } + if(checkResult.toString().equals("")) { + return true; + }else { + return false; + } + } + + private void checkChild(TCComponentBOMLine topLine,String top_ml8_Factory, String top_ml8_Line) throws TCException { + AIFComponentContext[] children = topLine.getChildren(); + for(AIFComponentContext con:children) { + TCComponentBOMLine childLine = (TCComponentBOMLine)con.getComponent(); + TCComponentItemRevision rev = childLine.getItemRevision(); + String ml8_ProcessingMode = rev.getStringProperty("ml8_ProcessingMode");//加工方式 + String ml8_AddTrade = rev.getStringProperty("ml8_AddTrade");//加贸 + System.out.println(rev.toString()+"的ml8_ProcessingMode为:"+ml8_ProcessingMode+",ml8_AddTrade为:"+ml8_AddTrade); + if(ml8_ProcessingMode==null)ml8_ProcessingMode = ""; + if(ml8_AddTrade == null)ml8_AddTrade = ""; + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + String ml8_Factory = rev.getStringProperty("ml8_Factory"); + String ml8_Line = rev.getStringProperty("ml8_Line"); + System.out.println(rev.toString()+"的ml8_Factory为:"+ml8_Factory+",ml8_Line为:"+ml8_Line); + if(ml8_Factory==null||ml8_Line==null||ml8_Factory.trim().equals("")||ml8_Line.trim().equals("")) { + if(checkResult.toString().equals("")) { + checkResult.append(rev.getStringProperty("item_id")+rev.getStringProperty("object_name")+"工厂、产线为空!"); + }else { + checkResult.append("\n").append(rev.getStringProperty("item_id")+rev.getStringProperty("object_name")+"工厂、产线为空!"); + } + }else { + + if(!ml8_Factory.equals(top_ml8_Factory)||!ml8_Line.equals(top_ml8_Line)) { + if(checkResult.toString().equals("")) { + checkResult.append(rev.getStringProperty("item_id")+rev.getStringProperty("object_name")+"工厂、产线不一致!"); + }else { + checkResult.append("\n").append(rev.getStringProperty("item_id")+rev.getStringProperty("object_name")+"工厂、产线不一致!"); + } + } + + } + } + + //递归 + if(childLine.getChildrenCount()>0) + checkChild(childLine,top_ml8_Factory,top_ml8_Line); + + } + } + + private TCComponentBOMWindow createBOMWindow() { + TCComponentBOMWindow window=null; + try { + TCSession session = (TCSession) app.getSession(); + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + window = winType.create(null); + } catch (TCException e) { + e.printStackTrace(); + } + return window; + } + + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/CloneProcessDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/CloneProcessDialog.java new file mode 100644 index 0000000..7c015ca --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/CloneProcessDialog.java @@ -0,0 +1,301 @@ +package com.connor.ml.tcm.cloneProcess; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.apache.http.client.HttpClient; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class CloneProcessDialog extends AbstractAIFDialog{ + + private TCSession session; + private JTextField textField; + private JTextField textField2; + private String revUid; + public CloneProcessDialog(TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + //this.bop = bop; + + init(); + } + private List revList = new ArrayList(); + private void init() { + // TODO Auto-generated method stub + this.setLayout(new PropertyLayout()); + this.setPreferredSize(new Dimension(650, 300)); + + JPanel btnPanel1 = new JPanel(); + JLabel drawingtype = new JLabel("克隆选项:"); + JAutoCompleteComboBox lineComBox = new JAutoCompleteComboBox(new String[] {}); + lineComBox.addItem(""); + lineComBox.addItem("克隆产品工艺"); + lineComBox.addItem("克隆产品BOP"); + + btnPanel1.add("1.1.left.top", drawingtype); + btnPanel1.add("1.2.left.top", lineComBox); + + drawingtype.setPreferredSize(new Dimension (120,30)); + + JPanel btnPanel2 = new JPanel(); + JLabel moudleId = new JLabel("模板ID:"); + + textField=new JTextField(); + moudleId.setPreferredSize(new Dimension (120,30)); + + textField.setPreferredSize(new Dimension (200,30)); + + JButton jButton=new JButton("分类查找"); + + jButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + new Thread() { + @Override + public void run() { + //revList.clear(); + G4MDialog classDialog = new G4MDialog("人本集团", null,revList, session); + + TCComponentItemRevision rev = revList.get(0); + try { + + revUid = rev.getUid(); + textField.setText(rev.getStringProperty("item_id")); + textField2.setText(rev.getStringProperty("object_name")); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }.start(); + } + }); + btnPanel2.add("1.1.left.top", moudleId); + btnPanel2.add("1.2.left.top", textField); + btnPanel2.add("1.3.left.top", jButton); + + JPanel btnPanel3 = new JPanel(); + JAutoCompleteComboBox lineComBox2 = new JAutoCompleteComboBox(new String[] {}); + lineComBox.setPreferredSize(new Dimension (200,30)); + lineComBox2.setPreferredSize(new Dimension (200,30)); + JLabel cloneRule = new JLabel("克隆规则:"); + cloneRule.setPreferredSize(new Dimension (120,30)); + + lineComBox2.addItem(""); + lineComBox2.addItem("带物料克隆"); + lineComBox2.addItem("过滤物料克隆"); + btnPanel3.add("1.1.left.top", cloneRule); + btnPanel3.add("1.2.left.top", lineComBox2); + + JPanel btnPanel4 = new JPanel(); + JLabel moudleName = new JLabel("新建工艺名称:"); + + textField2=new JTextField(); + + moudleName.setPreferredSize(new Dimension (120,30)); + textField2.setPreferredSize(new Dimension (200,30)); + btnPanel4.add("1.1.left.top", moudleName); + btnPanel4.add("1.2.left.top", textField2); + + JPanel btnPanel5 = new JPanel(); + JButton jButton1=new JButton("确定"); + JButton jButton2=new JButton("取消"); + jButton2.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + + + jButton1.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + String selectedItem =(String) lineComBox.getSelectedItem(); + String cloneRule=""; + String moudleID=textField.getText(); + String moudleName=textField2.getText(); + + + + try { + + if(revList.size()==0 && !moudleID.equals("")) { + TCComponentItem itemById = getItemById(moudleID.trim()); + TCComponentItemRevision latestItemRevision = itemById.getLatestItemRevision(); + revList.add(latestItemRevision); + } + + TCComponentUser user = session.getUser(); + String uid = user.getUid(); + TCComponentGroup group = session.getGroup(); + String uid2 = group.getUid(); + TCPreferenceService service = session.getPreferenceService(); + String values = service.getStringValue("ML_CloneUrl"); + + TCComponentItemRevision moudleRev = revList.get(0); + String moudleUid = moudleRev.getUid(); + TCComponentItemRevision revision =(TCComponentItemRevision) session.stringToComponent(moudleUid); + + TCComponentItem item = revision.getItem(); + String type = item.getType(); + + String newID=""; + if(selectedItem.equals("克隆产品工艺")) { + + if(type.equals("ML8_ProdProcess") || type.equals("ML8_StdProcess") ||type.equals("ML8_SpecProcess")) { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(type); + newID = itemType.getNewID(); + }else { + MessageBox.post("所选模板不为产品工艺类型","提示",2); + } + + String string =(String) lineComBox2.getSelectedItem(); + + if(string.equals("带物料克隆")) { + cloneRule="Process.Template.Mapping_Consumes"; + }else if (string.equals("过滤物料克隆")) { + cloneRule="Process.Template.Ignoring_Consumes"; + }else if (string.equals("")) { + MessageBox.post("请选择克隆规则","提示",2); + return; + } + String paramString=newID+";"+moudleName+";"+moudleUid+";"+cloneRule+";"+uid+";"+uid2+";"+user.getUserId(); + WebApiUtil.httpSapRequest(values+"/connor/Clone/modifyName","POST", + paramString,1); + MessageBox.post("克隆正在进行中,完成后会以企业微信进行通知","提示",2); + // cloneRule= + }else if (selectedItem.equals("克隆产品BOP")) { + + if(type.equals("ML8_PlantBOP") ) { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ML8_PlantBOP");// + newID = itemType.getNewID(); + System.out.println(newID+"newID"); + TCComponentItem create = itemType.create(newID, itemType.getNewRev(null), + "ML8_PlantBOP", moudleName, "", null);// + TCComponentItemRevision newRev = create.getLatestItemRevision(); + String newUid = newRev.getUid(); + cloneRule="PlantBOPTemplate"; + System.out.println("moudleUid"+moudleUid+"newUid"+newUid); + String paramString=newUid+";"+moudleName+";"+moudleUid+";PlantBOPTemplate;"+uid+";"+uid2+";"+user.getUserId();; + WebApiUtil.httpSapRequest(values+"/connor/Clone/modifyName","POST", + paramString,1); + + MessageBox.post("克隆正在进行中,完成后会以企业微信进行通知","提示",2); + }else { + MessageBox.post("所选模板不为工厂BOP","提示",2); + return; + } + + revList.clear(); + + }else if (selectedItem.equals("")) { + MessageBox.post("请选择克隆选项","提示",2); + return; + } + + + System.out.println(cloneRule+"moudleID"+moudleID+"moudleName"+moudleName); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); + btnPanel5.add("1.1.left.top", jButton1); + btnPanel5.add("1.3.left.top", jButton2); + + this.add("1.1.left.top", btnPanel1); + this.add("2.1.left.top", btnPanel2); + this.add("3.1.left.top", btnPanel3); + this.add("4.1.left.top", btnPanel4); + this.add("4.2.left.top", btnPanel5); + + this.setVisible(true); + this.centerToScreen(); + this.pack(); + this.setResizable(false); + this.setBounds(5, 5, 5, 5); + this.centerToScreen(); + this.showDialog(); +// btnPanel1.add("1.3.left.top", checkBox2); +// btnPanel1.add("1.4.left.top", checkBox3); + } + + private TCComponentItem getItemById(String itemId) throws Exception { + // TODO Auto-generated method stub + String queryName = "Item ID"; + String[] keys = new String[]{getText(session, "ItemID")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); + int len = res.length; + if (len == 0) { + return null; + } else if (len > 1) { + return (TCComponentItem) res[0]; + } else { + return (TCComponentItem) res[0]; + } + } + + public static String getText(TCSession session, String str) throws Exception { + if (isEmpty(str)) { + return str; + } else { + String res = session.getTextService().getTextValue(str); + return !isEmpty(res) ? res : str; + } + }public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + public static TCComponent[] query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + System.out.println("null"+queryName); + } else { + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + return null; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/CloneProcessHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/CloneProcessHandler.java new file mode 100644 index 0000000..b30592a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/CloneProcessHandler.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.cloneProcess; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class CloneProcessHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + + CloneProcessDialog dialog = new CloneProcessDialog(session); + new Thread(dialog).start(); + + return null; + } + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/G4MDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/G4MDialog.java new file mode 100644 index 0000000..187ac6d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/G4MDialog.java @@ -0,0 +1,210 @@ +package com.connor.ml.tcm.cloneProcess; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JPanel; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.classification.common.AbstractG4MApplication; +import com.teamcenter.rac.classification.common.G4MApplicationPanel; +import com.teamcenter.rac.classification.common.G4MUserAppContext; +import com.teamcenter.rac.classification.common.table.G4MTable; +import com.teamcenter.rac.classification.icm.ICMApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +@SuppressWarnings("serial") +public class G4MDialog extends AbstractAIFDialog { + + private JButton b_ok; + private JButton b_cel; + private ICMApplication app; + private MyG4MContext m_context; + protected TCComponentICO ico; + private String expandClass; + private List revList; + InterfaceAIFComponent iaf; + + public String moudleID; + public String moudleName; + TCComponentForm form; + TCSession session; + // public G4MDialog(String expandClass, InterfaceAIFComponent iaf, QZjsbjdBean jsbjdBean, TCSession session, TCComponentForm form) { + // super(AIFDesktop.getActiveDesktop(), true); + // this.jsbjdBean=jsbjdBean; + // this.expandClass = expandClass; + // this.iaf = iaf; + // this.session=session; + // this.form=form; + // try { + // this.app = new ICMApplication(); + // this.m_context = new MyG4MContext(app, "k0"); + // } catch (Exception e) { + // e.printStackTrace(); + // } + // initUI(); + // } + public G4MDialog(String expandClass, InterfaceAIFComponent iaf,List revList, TCSession session) { + super(AIFDesktop.getActiveDesktop(), true); + this.expandClass = expandClass; + this.iaf = iaf; + this.revList = revList; + this.session=session; + try { + this.app = new ICMApplication(); + this.m_context = new MyG4MContext(app, "k0"); + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + showDialog(); + } + + @Override + public void run() { + showDialog(); + } + + private void initUI() { + this.setTitle("选择克隆模板"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(1000, 600)); + this.setMinimumSize(new Dimension(640, 480)); + MyG4MPanel panel = new MyG4MPanel(null); + try { + m_context.openComponent(iaf); + panel.initialize(m_context); + this.add(BorderLayout.CENTER, panel); + m_context.getTree().expandToClass(expandClass); + // new Thread(m_context.getClassificationDialog()).start(); + } catch (Exception e) { + e.printStackTrace(); + } + // panel.open(iaf); + this.add(BorderLayout.SOUTH, initBtnPanel()); + addListeners(); + } + + private void addListeners() { + b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + G4MTable table = m_context.getTablePane().getG4MTable(); + List list = null; + if (table != null) { + ISelection sel = table.getSelection(); + if (sel != null && sel instanceof StructuredSelection) { + list = ((StructuredSelection) sel).toList(); + + } + } + if (list == null || list.size() == 0) { + MessageBox.post("请选择要使用的对象", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "请选择要使用的对象"); + return; + } + if (list.size() > 1) { + MessageBox.post("请选择单行数据", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "请选择单行数据"); + return; + } + Object target = list.get(0); + if (target != null && target instanceof TCComponentICO) { + ico = (TCComponentICO) target; + moudleID=ico.getId(); + + System.out.println(" ico.getClassId()=====" + ico.getId()); + TCComponentItemRevision rev = (TCComponentItemRevision) ico.getClassifiedObject(); + revList.clear(); + revList.add(rev); + + try { + moudleName=rev.getStringProperty("object_name"); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } +// MessageBox.post("图纸引用成功!!!", "成功", MessageBox.INFORMATION); + dispose(); + } else { + MessageBox.post("选择的数据不是ICO对象", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "选择的数据不是ICO对象"); + return; + } + } + }); + b_cel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + + + private JPanel initBtnPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 25, 5)); + this.b_ok = new JButton("确定"); + this.b_cel = new JButton("取消"); + panel.add(b_ok); + panel.add(b_cel); + return panel; + } + + public class MyG4MContext extends G4MUserAppContext { + + public MyG4MContext(AbstractAIFUIApplication paramAbstractAIFUIApplication, String paramString) + throws Exception { + super(paramAbstractAIFUIApplication, paramString); + } + + @Override + public void setBusy(String paramString) { + } + + @Override + public void setIdle(String paramString) { + } + + } + + public class MyG4MPanel extends G4MApplicationPanel { + + public MyG4MPanel(AbstractG4MApplication paramAbstractG4MApplication) { + super(paramAbstractG4MApplication); + } + + @Override + public void closeSignaled() { + try { + m_context.clear(); + } catch (Exception e) { + e.printStackTrace(); + } + // m_context.openComponent(iaf); + } + + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/JAutoCompleteComboBox.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/JAutoCompleteComboBox.java new file mode 100644 index 0000000..5a8a147 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/JAutoCompleteComboBox.java @@ -0,0 +1,160 @@ +package com.connor.ml.tcm.cloneProcess; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +@SuppressWarnings({ "serial", "rawtypes", "unchecked" }) +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +@SuppressWarnings({"rawtypes"}) +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + @SuppressWarnings("unused") + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + @SuppressWarnings({ "unchecked", "unused" }) + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + @SuppressWarnings("unchecked") + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + // v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/WebApiUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/WebApiUtil.java new file mode 100644 index 0000000..f0dfcfe --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/cloneProcess/WebApiUtil.java @@ -0,0 +1,431 @@ +package com.connor.ml.tcm.cloneProcess; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.ConnectException; +import java.net.HttpURLConnection; +import java.net.SocketTimeoutException; +import java.net.URL; +//import javax.servlet.http.HttpServletRequest; + +import org.apache.http.*; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.ConnectTimeoutException; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; + +import java.net.URI; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; +import java.net.URLConnection; +import java.net.UnknownHostException; +import java.security.SecureRandom; +import java.security.cert.CertificateException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Base64.Encoder; +import java.util.Iterator; +import java.util.List; +//import java.util.*; +import java.util.Map; + + + + +/** + * Title: + * @version 1.0 + * @author 叶友德 + * 修订记录:yeyoude 2018-11-23创建; + * Copyright: Copyright (c) 2018 宏发电声 + */ +@SuppressWarnings("deprecation") +public class WebApiUtil { + + + /** + * post请求 + * @param url + * @param param + * @return + * @throws Exception + */ + public static String doPost(String url, String param) throws Exception { + + System.out.println("开始发送请求"); + System.out.println("url="+url); + HttpClient client = new DefaultHttpClient(); + client.getParams().setParameter("http.connection.timeout", Integer.valueOf(10000)); + client.getParams().setParameter("http.socket.timeout", Integer.valueOf(20000)); + HttpPost postmeth = new HttpPost(url); + StringEntity stringEntity = new StringEntity(param, "UTF-8"); +// stringEntity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, +// "application/json")); + postmeth.setEntity(stringEntity); // post请求参数 param可以在请求之前进行json转换 + postmeth.setHeader("Content-Type", "application/json;charset=utf-8"); +// postmeth.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + try { + + HttpResponse statueCode = client.execute(postmeth); + + System.out.println(statueCode.getStatusLine());// 状态码 200成功 500服务器内部报错这个时候要看服务端的报错日志 404 路径错误 + + String response = paseResponse(statueCode); + + return response; + } catch (ConnectTimeoutException cte) { + System.out.println("请求通信【"+ url + "】时连接超时,堆栈轨迹如下"+ cte.getStackTrace()); + } catch (SocketTimeoutException ste) { + System.out.println("请求通信【"+ url + "】时读取超时,堆栈轨迹如下"+ ste.getStackTrace()); + } catch (Exception e) { + System.out.println("请求通信【"+ url + "】时偶遇异常,堆栈轨迹如下"+ e.getStackTrace()); + } finally { + client.getConnectionManager().shutdown(); + } + return null; + } + private static String paseResponse(HttpResponse response) { + + HttpEntity entity = response.getEntity(); + + String charset = EntityUtils.getContentCharSet(entity); + + String body = null; + try { + body = EntityUtils.toString(entity); + + } catch (ParseException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + + return body; + } + + + public static String doPost(String url, Map params){ + BufferedReader in = null; + try { + // 定义 HttpClient + HttpClient client = new DefaultHttpClient(); + // 实例化 HTTP 方法 + HttpPost request = new HttpPost(); + request.setURI(new URI(url)); + //设置参数 + List nvps = new ArrayList(); + for (Iterator iter = params.keySet().iterator(); iter.hasNext();) { + String name = (String) iter.next(); + String value = String.valueOf(params.get(name)); + nvps.add(new BasicNameValuePair(name, value)); + System.out.println(name +"-"+value); + } + request.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); + HttpResponse response = client.execute(request); + int code = response.getStatusLine().getStatusCode(); + System.out.println(code); + if(code == 200){ //请求成功 + in = new BufferedReader(new InputStreamReader(response.getEntity().getContent(),"utf-8")); + StringBuffer sb = new StringBuffer(""); + String line = ""; + String NL = System.getProperty("line.separator"); + while ((line = in.readLine()) != null) { + sb.append(line + NL); + } + in.close(); + return sb.toString(); + }else{ // + System.out.println("状态码:" + code); + return null; + } + }catch(Exception e){ + e.printStackTrace(); + return null; + } + } + + public JSONObject httpPostRequest(String param,String url,String token){ + JSONObject jsonObject = new JSONObject(); + try (final CloseableHttpClient httpClient = HttpClients.createDefault()) { + final HttpPost httpPost = new HttpPost(url); + JSONObject jsonString = JSON.parseObject(param); + //设置请求体参数 + StringEntity entity = new StringEntity(param); + entity.setContentEncoding("utf-8"); + httpPost.setEntity(entity); + //设置请求头部 + httpPost.setHeader("Content-Type", "application/json"); + if(token != null && !"".equals(token)){ + httpPost.setHeader("Authorization",token); + } + //执行请求,返回请求响应 + try (final CloseableHttpResponse response = httpClient.execute(httpPost)) { + //请求返回状态码 + int statusCode = response.getStatusLine().getStatusCode(); + //请求成功 + if (statusCode == HttpStatus.SC_OK && statusCode <= HttpStatus.SC_TEMPORARY_REDIRECT) { + //取出响应体 +// final HttpEntity entity2 = response.getEntity(); +// //从响应体中解析出token +// String responseBody = EntityUtils.toString(entity2, "utf-8"); +// jsonObject = JSONObject.parseObject(responseBody); + //token = jsonObject.getString("access_token"); + } else { + //请求失败 + throw new ClientProtocolException("请求失败,响应码为:" + statusCode); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return jsonObject; + } + + public static void main(String[] args) { + httpSapRequest("http://localhost:8080/connor/Clone/modifyName","POST","RGnJoBG$ZxyzTA;cloneTest;wqvJI9kSZxyzTA;PlantBOPTemplate",1); + } + + /** + * 1.发起http请求并获取结果 + * @param requestUrl请求地址 + * @param requestMethod请求方式(GET、POST) + * @param outputStr提交的数据 + * @return JSONObject(通过JSONObject.get(key)的方式获取json对象的属性值) + */ + public static JSONObject httpRequest(String requestUrl, String requestMethod, String outputStr) { + return httpRequest(requestUrl, requestMethod, outputStr, "UTF-8"); + } + public static JSONObject httpSapRequest(String requestUrl, String requestMethod, String outputStr,int i) { + return httpRequest(requestUrl, requestMethod, outputStr, "UTF-8",1); + } + public static JSONObject httpRequest(String requestUrl, String requestMethod, String outputStr, String charsetName,int i) { + JSONObject jsonObject = null; + StringBuffer buffer = new StringBuffer(); + URLConnection conn = null; + OutputStream out = null; + BufferedReader in = null; + try { +// URL url = new URL(requestUrl);//创建URL +// HttpURLConnection conn = (HttpURLConnection) url.openConnection();//建立连接 +// conn.setRequestMethod(requestMethod); +// conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); +// conn.setRequestProperty("connection", "keep-alive"); +// conn.setUseCaches(false);//设置不要缓存 +// conn.setDoOutput(true); +// conn.setDoInput(true); +// conn.setInstanceFollowRedirects(true); + //System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2"); +// String username = "HF_PLM"; +// String password = "123sdfHJH%^&"; + System.out.println(1); + Encoder encoder = Base64.getEncoder(); +// String encoding = new String(encoder.encode(new String(username+":"+password).getBytes())); + URL url = new URL(requestUrl); // 创建URL + conn = url.openConnection(); // 建立连接 + ((HttpURLConnection)conn).setRequestMethod(requestMethod); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("connection", "keep-alive"); +// conn.setRequestProperty( "Authorization","Basic "+encoding); + conn.setUseCaches(false);// 设置不要缓存 + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setConnectTimeout(30000); + conn.setReadTimeout(1000); + ((HttpURLConnection)conn).setInstanceFollowRedirects(false); //禁止跳转 + + //https请求免验证 + if (conn instanceof HttpsURLConnection) { + //logger.info("http ssl request."); + //SSLContext sslContext = SSLContext.getInstance("SSL", "TLSv1.1"); + //sslContext.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new SecureRandom()); + //((HttpsURLConnection)conn).setSSLSocketFactory(sslContext.getSocketFactory()); +// ((HttpsURLConnection)conn).setSSLSocketFactory(new TLSSocketConnectionFactory()); + //((HttpsURLConnection)conn).setHostnameVerifier(new TrustAnyHostnameVerifier()); + } + conn.connect(); + // 当有数据需要提交时 + if (null != outputStr) { + OutputStream outputStream = conn.getOutputStream(); + outputStream.write(outputStr.getBytes("UTF-8"));// 注意编码格式,防止中文乱码 + outputStream.close(); + } + + // 将返回的输入流转换成字符串 + InputStream inputStream = conn.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, charsetName); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + String str = null; + while ((str = bufferedReader.readLine()) != null) { + buffer.append(str); + } + bufferedReader.close(); + inputStreamReader.close(); + // 释放资源 + inputStream.close(); + inputStream = null; + //conn.disconnect(); +// System.out.println(buffer.toString()); +// jsonObject = JsonUtil.toJSONObject(buffer.toString()); + } catch (java.net.SocketTimeoutException ce) { + System.out.println("不等待接口返回结果"); + } catch (Exception e) { + e.printStackTrace(); + } + return jsonObject; + } + + /** + * 1.发起http请求并获取结果 + * @param requestUrl请求地址 + * @param requestMethod请求方式(GET、POST) + * @param outputStr提交的数据 + * @param charsetName 接收数据的编码(UTF-8,GBK) + * @return JSONObject(通过JSONObject.get(key)的方式获取json对象的属性值) + */ + public static JSONObject httpRequest(String requestUrl, String requestMethod, String outputStr, String charsetName) { + JSONObject jsonObject = null; + StringBuffer buffer = new StringBuffer(); + URLConnection conn = null; + OutputStream out = null; + BufferedReader in = null; + try { +// URL url = new URL(requestUrl);//创建URL +// HttpURLConnection conn = (HttpURLConnection) url.openConnection();//建立连接 +// conn.setRequestMethod(requestMethod); +// conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); +// conn.setRequestProperty("connection", "keep-alive"); +// conn.setUseCaches(false);//设置不要缓存 +// conn.setDoOutput(true); +// conn.setDoInput(true); +// conn.setInstanceFollowRedirects(true); +// //System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2"); +// String username = "HF_TEST"; +// String password = "abc123456"; +// Encoder encoder = Base64.getEncoder(); +// String encoding = new String(encoder.encode(new String(username+":"+password).getBytes())); + URL url = new URL(requestUrl); // 创建URL + conn = url.openConnection(); // 建立连接 + ((HttpURLConnection)conn).setRequestMethod(requestMethod); + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8"); + conn.setRequestProperty("connection", "keep-alive"); +// conn.setRequestProperty( "Authorization","Basic "+encoding); + conn.setUseCaches(false);// 设置不要缓存 + conn.setDoOutput(true); + conn.setDoInput(true); + conn.setConnectTimeout(30000); + conn.setReadTimeout(30000); + ((HttpURLConnection)conn).setInstanceFollowRedirects(false); //禁止跳转 + + //https请求免验证 + if (conn instanceof HttpsURLConnection) { + //logger.info("http ssl request."); + //SSLContext sslContext = SSLContext.getInstance("SSL", "TLSv1.1"); + //sslContext.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new SecureRandom()); + //((HttpsURLConnection)conn).setSSLSocketFactory(sslContext.getSocketFactory()); +// ((HttpsURLConnection)conn).setSSLSocketFactory(new TLSSocketConnectionFactory()); + //((HttpsURLConnection)conn).setHostnameVerifier(new TrustAnyHostnameVerifier()); + } + conn.connect(); + // 当有数据需要提交时 + if (null != outputStr) { + OutputStream outputStream = conn.getOutputStream(); + outputStream.write(outputStr.getBytes("UTF-8"));// 注意编码格式,防止中文乱码 + outputStream.close(); + } + + // 将返回的输入流转换成字符串 + InputStream inputStream = conn.getInputStream(); + InputStreamReader inputStreamReader = new InputStreamReader(inputStream, charsetName); + BufferedReader bufferedReader = new BufferedReader(inputStreamReader); + + String str = null; + while ((str = bufferedReader.readLine()) != null) { + buffer.append(str); + } + bufferedReader.close(); + inputStreamReader.close(); + // 释放资源 + inputStream.close(); + inputStream = null; + //conn.disconnect(); +// jsonObject = JsonUtil.toJSONObject(buffer.toString()); + } catch (ConnectException ce) { + ce.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return jsonObject; + } + + /**接收http请求,并获取结果JSONObject*/ +// public static JSONObject getHttpRequest(HttpServletRequest request) { +// StringBuffer buffer = new StringBuffer(); +// try { +// // 将返回的输入流转换成字符串 +// InputStream inputStream = request.getInputStream(); +// InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "UTF-8"); +// BufferedReader bufferedReader = new BufferedReader(inputStreamReader); +// String str = null; +// while ((str = bufferedReader.readLine()) != null) { +// buffer.append(str); +// } +// bufferedReader.close(); +// inputStreamReader.close(); +// // 释放资源 +// inputStream.close(); +// inputStream = null; +// +// } catch (ConnectException ce) { +// ce.printStackTrace(); +// } catch (Exception e) { +// e.printStackTrace(); +// } +//// JSONObject jsonObject = JsonUtil.toJSONObject(buffer.toString()); +// return null; +// } + + // 实现一个X509TrustManager接口,用于绕过验证 + private static class TrustAnyTrustManager implements X509TrustManager { + public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { + + } + + public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { + + } + + public X509Certificate[] getAcceptedIssuers() { + return new X509Certificate[] {}; + } + } + + //效验服务器主机名的合法性 + private static class TrustAnyHostnameVerifier implements HostnameVerifier { + public boolean verify(String hostname, SSLSession session) { + return true; + } + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeDialog.java new file mode 100644 index 0000000..0feeb2e --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeDialog.java @@ -0,0 +1,127 @@ +package com.connor.ml.tcm.export_worktime; + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class ExportWorktimeDialog extends AbstractAIFDialog implements ActionListener{ + + private AbstractAIFUIApplication app; + private TCSession session; + private final static String ML_EXPORT_WORKTIME = "ML_export_worktime"; + private Map gcjgMap = new HashMap();//首选项配置的工厂结构(名称,id) + private JPanel mainPanel; + private JComboBox gcjgBox;//工厂结构下拉框 + private List revs; + private JButton okButton; + private JButton cancelButton; + + public ExportWorktimeDialog() { + + } + + public ExportWorktimeDialog(AbstractAIFUIApplication app, TCSession session,List revs) { + this.app = app; + this.session = session; + this.revs = revs; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + init(); + }catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + } + + public void init() { + String[] values = session.getPreferenceService().getStringValues(ML_EXPORT_WORKTIME); + gcjgBox = new JComboBox(); + if(values!=null&&values.length>0) { + for(String s:values) { + String[] split = s.split("[|]"); + gcjgMap.put(split[0], split[1]); + gcjgBox.addItem(split[0]); + } + }else { + MessageBox.post("请联系管理员配置"+ML_EXPORT_WORKTIME+"首选项!!","",MessageBox.INFORMATION); + return; + } + + mainPanel = new JPanel(new BorderLayout()); + JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.CENTER)); + okButton = new JButton("确定"); + cancelButton = new JButton("取消"); + + okButton.addActionListener(this); + cancelButton.addActionListener(this); + + panel1.add(new JLabel("工厂结构")); + panel1.add(gcjgBox); + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + buttonPanel.add(okButton); + buttonPanel.add(cancelButton); + + mainPanel.add(panel1,BorderLayout.CENTER); + mainPanel.add(buttonPanel,BorderLayout.SOUTH); + mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));//设置外边距 + //设置组件间距 + BorderLayout mainPanelLayout = (BorderLayout)mainPanel.getLayout(); + mainPanelLayout.setHgap(10); + FlowLayout panel1Layout = (FlowLayout)panel1.getLayout(); + panel1Layout.setHgap(30); + FlowLayout buttonPanelLayout = (FlowLayout)buttonPanel.getLayout(); + buttonPanelLayout.setHgap(30); + + add(mainPanel); + setTitle("工时报表"); + pack(); +// setAlwaysOnTop(true); + setLocationRelativeTo(null); + setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if(source.equals(okButton)) { + String string = gcjgBox.getSelectedItem().toString(); + String id = gcjgMap.get(string); + if(id==null||!gcjgMap.containsKey(string)) { + MessageBox.post(ML_EXPORT_WORKTIME+"首选项配置错误!","",MessageBox.INFORMATION); + return; + } + ExportWorktimeOperation operation = new ExportWorktimeOperation(app, session,revs,id,gcjgBox.getSelectedItem().toString()); + session.queueOperation(operation); + dispose(); + }else if(source.equals(cancelButton)) { + dispose(); + } + + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeHandler.java new file mode 100644 index 0000000..305125a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeHandler.java @@ -0,0 +1,62 @@ +package com.connor.ml.tcm.export_worktime; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.axis2.databinding.types.soapencoding.Array; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +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 ExportWorktimeHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + List revs = new ArrayList(); + for(InterfaceAIFComponent comp: targetComponents) { + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + String type = rev.getType(); + if(!type.equals("ML8_PlantBOPRevision")) { + MessageBox.post("请选择美菱工厂BOP版本进行报表输出!","",MessageBox.INFORMATION); + return null; + }else { + revs.add(rev); + } + }else if(comp instanceof TCComponentBOPLine) { + TCComponentBOPLine bopLine = (TCComponentBOPLine)comp; + try { + TCComponentItemRevision rev = bopLine.getItemRevision(); + String type = rev.getType(); + if(!type.equals("ML8_PlantBOPRevision")) { + MessageBox.post("请选择美菱工厂BOP版本进行报表输出!","",MessageBox.INFORMATION); + return null; + }else { + revs.add(rev); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + ExportWorktimeDialog dialog = new ExportWorktimeDialog(app,session,revs); + new Thread(dialog).start(); + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeOperation.java new file mode 100644 index 0000000..e292c20 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/export_worktime/ExportWorktimeOperation.java @@ -0,0 +1,368 @@ +package com.connor.ml.tcm.export_worktime; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingConstants; + +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.ibm.icu.math.BigDecimal; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCComponentBOPWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class ExportWorktimeOperation extends AbstractAIFOperation { + + private AbstractAIFUIApplication app; + private TCSession session; + private String errInfo; + private TCComponentBOPWindow bopwin; + private List revs; + private String gcjgId;// 工厂结构id + private String name; + private boolean iscancel = false; + private final static String[] gbType = { "ML8_StepRevision", "ML8_BJStepRevision", "ML8_PTStepRevision", + "ML8_FPStepRevision", "ML8_XSStepRevision", "ML8_JBStepRevision", "ML8_TestStepRevision", + "ML8_GLLJStepRevision", "ML8_HJStepRevision", "ML8_YSJStepRevision", "ML8_VPStepRevision", + "ML8_GZStepRevision", "ML8_JLStepRevision" };// 工步类型 + + public ExportWorktimeOperation() { + + } + + public ExportWorktimeOperation(AbstractAIFUIApplication app, TCSession session, List revs, + String gcjgId, String name) { + this.app = app; + this.session = session; + errInfo = ""; + this.bopwin = createBOPWindow(); + this.revs = revs; + this.gcjgId = gcjgId; + this.name = name; + } + + public String getErrInfo() { + return errInfo; + } + + public void setErrInfo(String errInfo) { + this.errInfo = errInfo; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在导出......"); + dia.setVisible(true); + boolean flag = false; + try { + flag = export(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if (iscancel) + return; + if (flag) { + dia.setVisible(false); + MessageBox.post("导出成功!", "", MessageBox.INFORMATION); + } else { + dia.setVisible(false); + MessageBox.post(errInfo + "导出失败!", "", MessageBox.INFORMATION); + } + }; + }.start(); + } + + private boolean export() throws TCException { + List> gcjgList = new ArrayList>(); + List gbTypeList = new ArrayList(Arrays.asList(gbType)); + List gwList = new ArrayList();// 工位名称 + int gwNum = 0;// 工位数量 + System.out.println("开始获取数据"); + try { + for (TCComponentItemRevision rev : revs) { + gwNum = 0; + TCComponent[] meTargets = rev.getRelatedComponents("IMAN_METarget"); + System.out.println(rev.toString() + "的制造目标数量:" + meTargets.length); + if (meTargets.length != 1) + continue; + String metargetId = meTargets[0].getStringProperty("item_id"); + // 遍历工厂结构 + TCComponent[] gcjgItems = queryItemById(gcjgId); + if (gcjgItems == null || gcjgItems.length < 1) { + setErrInfo(errInfo + "未找到id为" + gcjgId + "的工厂结构对象!"); + return false; + } + TCComponentItem item = (TCComponentItem) gcjgItems[0]; + TCComponentItemRevision revision = item.getLatestItemRevision(); + TCComponentBOPLine topLine = (TCComponentBOPLine) bopwin.setWindowTopLine(item, revision, null, null); + Map map = new HashMap();// (工位名称,id) + Map map2 = new HashMap();//(工位名称,工时) + List sortList = new ArrayList();// 工位先后顺序 + map.put("工位", metargetId); + map2.put("工位", metargetId); + AIFComponentContext[] children; + // 获取工厂结构下工位数据 + getStationRev(gwList, metargetId, topLine, map, sortList,map2); + + topLine = (TCComponentBOPLine) bopwin.setWindowTopLine(rev.getItem(), rev, null, null); + // 获取报表数据 + getData(gbTypeList, topLine, map, sortList,map2); + gcjgList.add(map2); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return false; + } finally { + if (!bopwin.isWindowClosed()) { + bopwin.setClearCacheOnClose(true); + bopwin.close(); + } + } + + System.out.println("开始导出报表"); + if (!exportToExcelX(gcjgList, gwList)) + return false; + return true; + } + + private void getData(List gbTypeList, TCComponentBOPLine topLine, Map map, + List sortList, Map map2) throws TCException { + AIFComponentContext[] children; + children = topLine.getChildren(); + if (children != null && children.length > 0) { + boolean hasStation = false; + String object_name = ""; + for (AIFComponentContext con : children) { + TCComponentBOPLine childLine = (TCComponentBOPLine) con.getComponent(); + AIFComponentContext[] children2 = childLine.getChildren(); + if (children2 != null && children2.length > 0) { + getData(gbTypeList, childLine, map, sortList,map2); + } + TCComponentItemRevision childRev = childLine.getItemRevision(); + object_name = childRev.getStringProperty("object_name"); + String type = childRev.getType(); + System.out.println("当前类型:" + type); + System.out.println("当前目标名称:" + object_name); + if (type.equals("ML8_StationRevision") && sortList.contains(object_name)) { + String itemId = map.get(object_name); + System.out.println("当前id:" + childRev.getStringProperty("item_id")); + System.out.println("工厂结构工位的id:" + itemId); + if (itemId.equals(childRev.getStringProperty("item_id"))) {// 判断工位id相同 + hasStation = true; + break; + } + } + object_name = ""; + } + if (hasStation) { + System.out.println(object_name + "存在"); + BigDecimal num = new BigDecimal("0"); + for (AIFComponentContext con : children) { + TCComponentBOPLine childLine = (TCComponentBOPLine) con.getComponent(); +// TCComponentItemRevision childRev = childLine.getItemRevision(); + System.out.println("当前类型:" + childLine.getItemRevision().getType()); + if (gbTypeList.contains(childLine.getItemRevision().getType())) { + String bl_me_duration_time = Double.toString(childLine.getDoubleProperty("bl_me_duration_time")); + System.out.println(childLine.toString() + "获取到bl_me_duration_time为:" + bl_me_duration_time); + if (bl_me_duration_time == null || bl_me_duration_time.trim().equals("")) + bl_me_duration_time = "0"; + num = num.add(new BigDecimal(bl_me_duration_time)); + } + ; + map2.put(object_name, num.toString()); + System.out.println("设置" + object_name + "的工时为:" + num); + } + } + + } + } + + private void getStationRev(List gwList, String metargetId, TCComponentBOPLine topLine, + Map map, List sortList, Map map2) throws TCException { + AIFComponentContext[] children = topLine.getChildren(); + if (children != null && children.length > 0) { + System.out.println("工厂结构下的对象数量:" + children.length); + for (AIFComponentContext con : children) { + TCComponentBOPLine childLine = (TCComponentBOPLine) con.getComponent(); + TCComponentItemRevision childRev = childLine.getItemRevision(); + String type = childRev.getType(); + System.out.println("当前目标类型:" + type); + if (type.equals("ML8_StationRevision")) { + String object_name = childRev.getStringProperty("object_name"); + String item_id = childRev.getStringProperty("item_id"); + System.out.println("添加工位:" + object_name); + map.put(object_name, item_id); + map2.put(object_name, "0"); + if(!sortList.contains(object_name)) + sortList.add(object_name); + if(!gwList.contains(object_name)) + gwList.add(object_name); + } + AIFComponentContext[] children2 = childLine.getChildren(); + if (children2 != null && children2.length > 0) { + + getStationRev(gwList, metargetId, childLine, map, sortList, map2); + } + } + } + } + + private boolean exportToExcelX(List> list, List gwList) { + JFileChooser fs = new JFileChooser(); + fs.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fs.setDialogTitle("导出报表"); + if (fs.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {// 判断是否点了确定 + String path = fs.getSelectedFile().getAbsolutePath(); + XSSFWorkbook workbook = new XSSFWorkbook(); + XSSFSheet sheet = workbook.createSheet(); + for (int i = 0; i < gwList.size() + 1; i++) { + + XSSFRow row = sheet.getRow(i); + if (row == null) + row = sheet.createRow(i); + if (i == 0) { + for (int j = 0; j < list.size() + 1; j++) { + if (j == 0) {// 第一行第一列 + XSSFCell cell = row.getCell(j); + if (cell == null) + cell = row.createCell(j); + cell.setCellValue("工位"); + } else { + String targetId = list.get(j - 1).get("工位"); + XSSFCell cell = row.getCell(j); + if (cell == null) + cell = row.createCell(j); + cell.setCellValue(targetId); + } + } + } else { + for (int j = 0; j < list.size() + 1; j++) { + if (j == 0) {// 其他行第一列 + XSSFCell cell = row.getCell(j); + if (cell == null) + cell = row.createCell(j); + cell.setCellValue(gwList.get(i - 1)); + } else { + XSSFCell cell = row.getCell(j); + if (cell == null) + cell = row.createCell(j); + cell.setCellValue(list.get(j - 1).get(gwList.get(i - 1))); + + } + } + } + + } + FileOutputStream outputStream; + try { + System.out.println("生成文件路径:" + path + name + "-工时报表.xlsx"); + outputStream = new FileOutputStream(new File(path + File.separator + name + "-工时报表.xlsx")); + workbook.write(outputStream); + outputStream.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } else { + iscancel = true; + } + + return true; + } + + private TCComponentBOPWindow createBOPWindow() { + TCComponentBOPWindow window = null; + try { + TCSession session = (TCSession) app.getSession(); + TCTypeService service = session.getTypeService(); + TCComponentBOPWindowType winType = (TCComponentBOPWindowType) service.getTypeComponent("BOPWindow"); + window = winType.createBOPWindow(null); + } catch (TCException e) { + e.printStackTrace(); + } + return window; + } + + private TCComponent[] queryItemById(String id) throws TCException { + String queryName = "Item..."; + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + throw new TCException("没有找到查询"); + } + String idField = session.getTextService().getTextValue("ItemID"); + String searchID = id; + TCComponent[] searchResult = query.execute(new String[] { idField }, new String[] { searchID }); + return searchResult; + } + + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/knowledgeBase/knowledgeBaseCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/knowledgeBase/knowledgeBaseCommand.java new file mode 100644 index 0000000..581c5f6 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/knowledgeBase/knowledgeBaseCommand.java @@ -0,0 +1,53 @@ +package com.connor.ml.tcm.knowledgeBase; + +import java.util.ArrayList; +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.bean.NodeBean; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.cme.bvr.connect.pasteduplicate.PasteDuplicateOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + +public class knowledgeBaseCommand extends AbstractAIFCommand { + + private TCSession session; + + private TCComponent procLine ; + public knowledgeBaseCommand(TCSession session) { + // TODO Auto-generated constructor stub + this.session = session; + } + + @Override + public void executeModal() throws Exception { + + String puid = session.getPreferenceService().getStringValue("Meling_TCMKnowledgeBase_Puid"); + if (puid == null || puid.length() < 1) { + MessageBox.post("请检查首选项:Meling_TCMKnowledgeBase_Puid,是否配置。", "错误", MessageBox.ERROR); + return; + } + TCComponent comp = session.stringToComponent(puid); + if(comp==null) { + MessageBox.post("未找到配置的文件夹,请检查首选项:Meling_TCMKnowledgeBase_Puid,是否配置正确。", "错误", MessageBox.ERROR); + return; + } + 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[] { comp }); + + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/knowledgeBase/knowledgeBaseHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/knowledgeBase/knowledgeBaseHandler.java new file mode 100644 index 0000000..dc80903 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/knowledgeBase/knowledgeBaseHandler.java @@ -0,0 +1,28 @@ +package com.connor.ml.tcm.knowledgeBase; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class knowledgeBaseHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + knowledgeBaseCommand command = new knowledgeBaseCommand(session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ls/lsOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ls/lsOperation.java new file mode 100644 index 0000000..a7963bf --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ls/lsOperation.java @@ -0,0 +1,141 @@ +package com.connor.ml.tcm.ls; + +import java.util.HashMap; +import java.util.Map; + +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCClassificationService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSProperty; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.kernel.ics.ICSSearchResult; + +public class lsOperation extends AbstractAIFOperation{ + + private Map lineEroCodeMap=new HashMap(); + private TCSession session; + private InterfaceAIFComponent[] targetComponents; + public lsOperation(InterfaceAIFComponent[] targetComponents, TCSession session2) { + // TODO Auto-generated constructor stub + this.session=session2; + this.targetComponents=targetComponents; + + } + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + MethodUtil.openByPass(session); + try { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem find = itemType.find("890054701-I010-E"); + TCComponentItemRevision latestItemRevision = find.getLatestItemRevision(); + latestItemRevision.setStringProperty("ml8_LineCode", "J"); + latestItemRevision.setStringProperty("ml8_ERPCode", "J"); + latestItemRevision.setStringProperty("ml8_Line", "J"); + latestItemRevision.setStringProperty("ml8_Factory", "I010"); + MethodUtil.closeByPass(session); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + MethodUtil.closeByPass(session); + } +// TCClassificationService classificationService = session +// .getClassificationService(); +// ICSSearchResult[] results = classificationService.searchICOs( +// "组计数器字典", null, 0); +// for (int j = 0; j < results.length ; j++) { +// String ERPCode = ""; +// String line = ""; +// +// String groupNo = ""; +// String lineName = ""; +//// String classERPCode = ""; +// String classFactory = ""; +// String icoUID = results[j].getIcoUid(); +// TCComponentICO ico = (TCComponentICO) session +// .stringToComponent(icoUID); +// ico.getClassifiedObject(); +// ICSProperty[] icsProps = ico.getICSProperties(true); +// +// ICSPropertyDescription[] icsDs = ico +// .getICSPropertyDescriptors(); +// +// for (ICSPropertyDescription icsD : icsDs) { +// String value = ""; +// for (ICSProperty icsProperty : icsProps) { +// if (icsProperty.getId() == icsD.getId()) { +// value = icsProperty.getValue(); +// } +// } +// if (icsD.getName().compareTo("ERP班组编码") == 0) { +// ERPCode = value; +// } +// if (icsD.getName().compareTo("产线") == 0) { +// line = value; +// } +// if (icsD.getName().compareTo("产线代码") == 0) { +// lineName = value; +// } +// if (icsD.getName().compareTo("工厂") == 0) { +// classFactory = value; +// } +// } +// String keyString=classFactory+"line"+line; +// System.out.println(keyString + "result"+lineName + "=" + ERPCode); +// if(!lineEroCodeMap.containsKey(keyString)) { +// lineEroCodeMap.put(keyString, lineName + "=" + ERPCode); +// } +// } +// +// for(InterfaceAIFComponent component:targetComponents) { +// TCComponentItemRevision bomBopLine=(TCComponentItemRevision)component; +// +// ChangeMessage(bomBopLine); +// +// } + + } + private void ChangeMessage(TCComponentItemRevision bomBopLine) throws TCException { + // TODO Auto-generated method stub + + String item_id = bomBopLine.getStringProperty("item_id"); + String[] split = item_id.split("-"); + if(split.length==3) { + + String factoryString=split[1]; + String lineString=split[2]; + if(lineEroCodeMap.containsKey(factoryString+"line"+lineString)) { + String result = lineEroCodeMap.get(factoryString+"line"+lineString); + + if(result.indexOf("=") > 0) + { + String lineCode = result.split("=")[0]; + String erpCode = result.split("=")[1]; + + bomBopLine.setStringProperty("ml8_LineCode", lineCode); + bomBopLine.setStringProperty("ml8_ERPCode", erpCode); + } + } + + } + TCComponent[] referenceListProperty = bomBopLine.getReferenceListProperty("ps_children"); + for(TCComponent conComponent:referenceListProperty) { + if(conComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision revision=(TCComponentItemRevision)conComponent; + ChangeMessage(revision); + } + } + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/ls/lshandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/ls/lshandler.java new file mode 100644 index 0000000..3c3b479 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/ls/lshandler.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.ls; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + +public class lshandler extends AbstractHandler { + + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + + lsOperation operation=new lsOperation(targetComponents,session); + session.queueOperation(operation); + + + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/ExcelUtil07.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/ExcelUtil07.java new file mode 100644 index 0000000..0f083ac --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/ExcelUtil07.java @@ -0,0 +1,2547 @@ +//package com.connor.ml.tcm.metarialChange; +// +//import java.awt.Graphics; +//import java.awt.GraphicsConfiguration; +//import java.awt.GraphicsDevice; +//import java.awt.GraphicsEnvironment; +//import java.awt.HeadlessException; +//import java.awt.Image; +//import java.awt.Transparency; +//import java.awt.image.BufferedImage; +//import java.io.ByteArrayOutputStream; +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileNotFoundException; +//import java.io.FileOutputStream; +//import java.io.IOException; +//import java.io.InputStream; +//import java.text.DecimalFormat; +//import java.text.SimpleDateFormat; +//import java.util.ArrayList; +//import java.util.Date; +//import java.util.HashMap; +//import java.util.Iterator; +//import java.util.LinkedHashMap; +//import java.util.List; +//import java.util.Map; +// +//import javax.imageio.ImageIO; +//import javax.swing.ImageIcon; +//import javax.swing.tree.DefaultMutableTreeNode; +// +//import org.apache.poi.hssf.usermodel.HSSFWorkbook; +//import org.apache.poi.ss.usermodel.Cell; +//import org.apache.poi.ss.usermodel.CellValue; +//import org.apache.poi.ss.usermodel.DateUtil; +//import org.apache.poi.ss.usermodel.Name; +//import org.apache.poi.ss.usermodel.Row; +//import org.apache.poi.ss.usermodel.Sheet; +//import org.apache.poi.ss.usermodel.Workbook; +//import org.apache.poi.ss.util.AreaReference; +//import org.apache.poi.ss.util.CellRangeAddress; +//import org.apache.poi.ss.util.CellReference; +//import org.apache.poi.xssf.usermodel.XSSFCell; +//import org.apache.poi.xssf.usermodel.XSSFCellStyle; +//import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +//import org.apache.poi.xssf.usermodel.XSSFDrawing; +//import org.apache.poi.xssf.usermodel.XSSFFont; +//import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +//import org.apache.poi.xssf.usermodel.XSSFName; +//import org.apache.poi.xssf.usermodel.XSSFRichTextString; +//import org.apache.poi.xssf.usermodel.XSSFRow; +//import org.apache.poi.xssf.usermodel.XSSFSheet; +//import org.apache.poi.xssf.usermodel.XSSFWorkbook; +// +//import com.teamcenter.rac.aif.kernel.AIFComponentContext; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentDataset; +//import com.teamcenter.rac.kernel.TCComponentDatasetType; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCComponentTcFile; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCProperty; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.FileUtility; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.schemas.core._2020_01.datamanagement.GetIdContextsInput; +// +///** +// * Excel Toolling +// * +// * @author hub 2015-09-06 +// */ +//public class ExcelUtil07 { +// // private static Registry reg = Registry.getRegistry(this); +// // private static XSSFSheet sheet; +// // private static final int MY_ROWS = 46; +// private static Map map = new HashMap(); +// private static final String EXCEL_XLS = "xls"; +// private static final String EXCEL_XLSX = "xlsx"; +// +// /** +// * 读取EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readExcel(File excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < col_count; i++) { +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// line_msg.add(value); +// } +// lines_msg.add(line_msg); +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取控制计划EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readControlPlanExcel(File excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// int startRow = 1; +// // 获取合并单元格 +// Map regionCellMap = getRegionCell(sheet); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = startRow; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < 18; i++) { +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// if (value == null || value.equals("")) { +// line_msg.add(getRegionValue(workBook, sheet, j, i)); +// } else { +// line_msg.add(value); +// } +// } +// // 行号 +// line_msg.add(((Integer) (j - startRow)).toString()); +// // 合并单元格 +// line_msg.add(toControlPlanRegionCell(regionCellMap, j)); +// if (line_msg.get(0) != null) { +// lines_msg.add(line_msg); +// } +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取委托内容EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readEntrustingContentExcel(File excel_file) +// throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List> lines_msg = new ArrayList>(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// int startRow = 0; +// // 获取合并单元格 +// Map regionCellMap = getEntrustingContentRegionCell(sheet); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// System.out.println(" SHEET COL COUNT " + col_count); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// System.out.println(" SHEET ROW COUNT " + row_count); +// for (int j = startRow; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// List line_msg = new ArrayList(); +// for (int i = 0; i < 3; i++) { +// String value = getStringCellValue(evaluator, row.getCell((short) i)); +// if (value == null || value.equals("")) { +// line_msg.add(getRegionValue(workBook, sheet, j, i)); +// } else { +// line_msg.add(value); +// } +// } +// // 合并单元格 +// line_msg.add(toEntrustingContentRegionCell(regionCellMap, j)); +// if (line_msg.get(0) != null) { +// lines_msg.add(line_msg); +// } +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// public static void main(String[] args) { +// try { +// List> strList = readExcel(new File("F:\\Connor(项目管理)\\东睦项目\\东睦系统\\控制计划\\生产控制计划模板3.xlsx")); +// for (List list : strList) { +// for (String str : list) { +// System.out.print(str + "|"); +// } +// System.out.println(); +// } +// +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public void writeSignName(String intExcelFilePath, String outExcelFilePath, String signName, String msgValue, +// int sheetIndex, int rowIndex, int cellIndex) throws IOException { +// // 输出文件的路径 +// FileOutputStream outPut = new FileOutputStream(new File(outExcelFilePath)); +// // 输入文件的路径 +// FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); +// XSSFWorkbook wb = new XSSFWorkbook(inPut); +// wb.getName(""); +// AreaReference[] areaR2 = AreaReference.generateContiguous(wb.getName("").getRefersToFormula()); +// AreaReference areaR = null; +// CellReference[] cellR = areaR.getAllReferencedCells(); +// cellR[0].getSheetName();// s +// cellR[0].getCol();// +// cellR[0].getRow();// +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFSheet sheet = wb.getSheetAt(sheetIndex); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(cellIndex); +// String value = getStringCellValue(evaluator, cell); +// if (value.startsWith(signName)) { +// value = value.substring(0, signName.length()); +// } +// cell.setCellValue(value + msgValue); +// wb.write(outPut); +// inPut.close(); +// outPut.close(); +// } +// +// /*** +// * 写入到EXCEL数据 (写入单种数据) +// * +// * @param xls_write_Address +// * @param beanListAll +// * @param sheetnames +// * @throws IOException +// */ +// /* +// * public void writeExcel(String xls_write_Address, String path, +// * List beanListAll, int index) throws IOException { +// * FileOutputStream output = new FileOutputStream(new File(path)); // 读取的文件路径 +// * FileInputStream input = new FileInputStream(new File(xls_write_Address)); +// * XSSFWorkbook wb = new XSSFWorkbook(input);// (new XSSFSheet sheet = +// * wb.getSheetAt(0); for (int i = 0; i < beanListAll.size(); i++) { +// * JFomPasteBean bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat +// * = false; if ((i + 3) > sheet.getLastRowNum()) { row = sheet.createRow(i + 3); +// * isCreat = true; } else { row = sheet.getRow(i + 3); isCreat = false; } +// * +// * for (int cols = 0; cols < 7; cols++) { XSSFCell cell = null; if (isCreat) { +// * cell = row.createCell(cols); } else { cell = row.getCell(cols); } +// * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { +// * +// * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: +// * cell.setCellValue(bean.getProductName());// 写入内容 break; case 2: // +// * cell.setCellValue(bean.getPicturePath());// 写入内容 insertPicture(wb, sheet, +// * bean.getPicturePath(), (short) 2, (i + 3)); break; case 3: +// * cell.setCellValue(bean.getDatasetName());// 写入内容 break; case 4: +// * cell.setCellValue(bean.getItemRevisionId());// 写入内容 break; case 5: +// * cell.setCellValue("");// 写入内容 +// * +// * break; case 6: // cell.setCellType(XSSFCell.CELL_TYPE_);// 文本格式 +// * cell.setCellValue(bean.getReleaseDateStr());// 写入内容 break; +// * +// * } } } // } wb.write(output); output.close(); input.close(); +// * System.out.println("-------WRITE EXCEL OVER-------"); } +// */ +// /** +// * 获取单个的命名单元格的内容 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static String getNamedCellValue(XSSFWorkbook wb, String cellName) throws IOException { +// String value = null; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return ""; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(colIndex); +// value = getStringCellValue(evaluator, cell); +// } +// } +// } +// return value; +// } +// +// /** +// * 设置单个的命名单元格的内容 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static void setNamedCellValue(XSSFWorkbook wb, String cellName, String cellValue) throws IOException { +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFCell cell = row.getCell(colIndex); +// cell.setCellValue(cellValue); +// } +// } +// } +// } +// } +// +// /** +// * 插入图片到指定的单元格中 +// * +// * @param wb +// * @param sheet1 +// * @param picPath +// * @param colIndex +// * @param rowIndex +// */ +// public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, ImageIcon imageIcon, String cellName, +// int columns, int rows) { +// +// // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray +// try { +// if (imageIcon == null) { +// return; +// } +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// ImageIO.write(toBufferedImage(imageIcon.getImage()), "jpg", byteArrayOut); +// // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); +// // anchor主要用于设置图片的属性 +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, +// (short) (colIndex + columns), rowIndex + rows); +// //anchor.setAnchorType(3); +// // 插入图片 +// patriarch.createPicture(anchor, +// wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); +// } +// } +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } +// +// /** +// * 将Image转BufferedImage +// * +// * @param image +// * @return +// */ +// public static BufferedImage toBufferedImage(Image image) { +// if (image instanceof BufferedImage) { +// return (BufferedImage) image; +// } +// +// // This code ensures that all the pixels in the image are loaded +// image = new ImageIcon(image).getImage(); +// +// // Determine if the image has transparent pixels; for this method's +// // implementation, see e661 Determining If an Image Has Transparent Pixels +// // boolean hasAlpha = hasAlpha(image); +// +// // Create a buffered image with a format that's compatible with the screen +// BufferedImage bimage = null; +// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); +// try { +// // Determine the type of transparency of the new buffered image +// int transparency = Transparency.OPAQUE; +// /* +// * if (hasAlpha) { transparency = Transparency.BITMASK; } +// */ +// +// // Create the buffered image +// GraphicsDevice gs = ge.getDefaultScreenDevice(); +// GraphicsConfiguration gc = gs.getDefaultConfiguration(); +// bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); +// } catch (HeadlessException e) { +// // The system does not have a screen +// } +// +// if (bimage == null) { +// // Create a buffered image using the default color model +// int type = BufferedImage.TYPE_INT_RGB; +// // int type = BufferedImage.TYPE_3BYTE_BGR;//by wang +// /* +// * if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } +// */ +// bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); +// } +// +// // Copy image to buffered image +// Graphics g = bimage.createGraphics(); +// +// // Paint the image onto the buffered image +// g.drawImage(image, 0, 0, null); +// g.dispose(); +// +// return bimage; +// } +// +// /*** +// * 写入到EXCEL数据 (写入单种数据) +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @throws IOException +// */ +// public void writeExcel(String xls_write_Address, ArrayList ls, String[] sheetnames) throws IOException { +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFWorkbook wb = new XSSFWorkbook();// (new +// // BufferedInputStream(output)); +// for (int sn = 0; sn < ls.size(); sn++) { +// XSSFSheet sheet = wb.createSheet(String.valueOf(sn)); +// wb.setSheetName(sn, sheetnames[sn]); +// ArrayList ls2 = ls.get(sn); +// for (int i = 0; i < ls2.size(); i++) { +// XSSFRow row = sheet.createRow(i); +// String[] s = ls2.get(i); +// for (int cols = 0; cols < s.length; cols++) { +// XSSFCell cell = row.createCell(cols); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// cell.setCellValue(s[cols]);// 写入内容 +// } +// } +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// /** +// * 根据单元格的名字来找到单元格的内容 +// * +// * @param inputFilePath +// * @param cellName +// * @return +// */ +// public static List getExcelNamedCellValue(String inputFilePath, String[] cellNames) { +// List valueList = new ArrayList(); +// if (!new File(inputFilePath).exists()) { +// for (int i = 0; i < cellNames.length; i++) +// valueList.add(""); +// return valueList; +// } +// try { +// FileInputStream is = new FileInputStream(new File(inputFilePath)); +// XSSFWorkbook wb = new XSSFWorkbook(is); +// for (String name : cellNames) +// valueList.add(getNamedCellValue(wb, name)); +// is.close(); +// } catch (FileNotFoundException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } catch (IOException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return valueList; +// } +// +// /** +// * 针对工程变更的信息写入 +// * +// * @param xls_write_Address +// * @param ls +// * @throws IOException +// */ +// /* +// * public static void writeExcel(String outPath, InputStream input, +// * List beanListAll) throws IOException { +// * +// * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 +// * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new +// * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow +// * = 2; for (int i = 0; i < beanListAll.size(); i++) { JFomProjectChangeBean +// * bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat = false; if +// * ((i + startRow) > sheet.getLastRowNum()) { row = sheet.createRow(i + +// * startRow); isCreat = true; } else { row = sheet.getRow(i + startRow); isCreat +// * = false; } +// * +// * for (int cols = 0; cols < 12; cols++) { XSSFCell cell = null; if (isCreat) { +// * cell = row.createCell(cols); } else { cell = row.getCell(cols); } +// * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { +// * +// * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: +// * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: +// * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: +// * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: +// * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: +// * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: +// * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: +// * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: +// * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: +// * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: +// * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// 写入内容 +// * break; } } } // } wb.write(output); output.close(); input.close(); +// * System.out.println("-------WRITE EXCEL OVER-------"); } +// */ +// /** +// * 设置单元格 +// * +// * @param row1 +// * @param index +// * @param str +// */ +// public static void setCellValue(XSSFRow row1, int index, String str) { +// XSSFCell cell = row1.getCell(index); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING); +// cell.setCellValue(str); +// } +// +// /** +// * 设置单元格 +// * +// * @param row1 +// * @param index +// * @param str +// */ +// public static void setCellValue(Row row1, int index, String str) { +// Cell cell = row1.getCell(index); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING); +// cell.setCellValue(str); +// } +// +// /** +// * 针对工程变更的信息写入 +// * +// * @param xls_write_Address +// * @param ls +// * @throws IOException +// */ +// /* +// * public static void writeExcelBomExport(String outPath, InputStream input, +// * List beanListAll, JFomBomExportProjBean projBean) throws +// * IOException { +// * +// * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 +// * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new +// * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow +// * = 4; if (projBean != null) { XSSFRow row1 = sheet.getRow(0); +// * setCellValue(row1, 11, projBean.getPROJ_NAME()); setCellValue(row1, 14, +// * projBean.getPROJ_MODE()); setCellValue(row1, 16, projBean.getPRODUCT_LIFE()); +// * row1 = sheet.getRow(1); setCellValue(row1, 11, projBean.getPROJ_CUSTOMER()); +// * setCellValue(row1, 14, projBean.getPROJ_MEMBER()); } for (int i = 0; i < +// * beanListAll.size(); i++) { JFomBomExportBean bean = beanListAll.get(i); +// * XSSFRow row = null; Boolean isCreat = false; if ((i + startRow) > +// * sheet.getLastRowNum()) { row = sheet.createRow(i + startRow); isCreat = true; +// * } else { row = sheet.getRow(i + startRow); isCreat = false; } +// * +// * for (int cols = 0; cols < 22; cols++) { XSSFCell cell = null; if (isCreat) { +// * cell = row.createCell(cols); } else { cell = row.getCell(cols); } +// * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 int indexStr = +// * bean.getIndexStr(); if (cols == (indexStr + 1)) { +// * cell.setCellValue(JFomUtil.JF3_INDEX_STR);// 写入内容 } +// * +// * switch (cols) { +// * +// * case 0: cell.setCellValue(bean.getIndexExt());// 写入内容 break; case 7: +// * cell.setCellValue(bean.getWlNumber());// 写入内容 break; case 8: +// * cell.setCellValue(bean.getMPS()); break; case 9: +// * cell.setCellValue(bean.getCustomerNo()); break; case 10: +// * cell.setCellValue(bean.getWlName()); break; case 11: +// * cell.setCellValue(bean.getK3code()); break; case 12: insertPicture(wb, sheet, +// * bean.getPicturePath(), (short) 14, i + startRow); break; case 13: +// * cell.setCellValue(bean.getMaterialName()); break; case 14: +// * cell.setCellValue(bean.getMaterialSize()); break; case 15: +// * cell.setCellValue(bean.getMaterialStander()); break; case 16: +// * cell.setCellValue(bean.getMaterialPark()); break; case 17: +// * cell.setCellValue(bean.getJingzhong()); break; case 18: +// * cell.setCellValue(bean.getMaozhong()); break; case 19: +// * cell.setCellValue(bean.getGongyi()); break; case 20: +// * cell.setCellValue(bean.getGongyingshang()); break; default: break; } } } // } +// * wb.write(output); output.close(); input.close(); +// * System.out.println("-------WRITE EXCEL OVER-------"); } +// */ +// public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, String picPath, short colIndex, int rowIndex) { +// +// // FileOutputStream fileOut = null; +// BufferedImage bufferImg = null; +// // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray +// try { +// if (!new File(picPath).exists()) { +// return; +// } +// String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, picPath.length()); +// ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); +// System.out.println(picPath); +// bufferImg = ImageIO.read(new File(picPath)); +// ImageIO.write(bufferImg, dexStr, byteArrayOut); +// // XSSFWorkbook wb = new XSSFWorkbook(); +// // XSSFSheet sheet1 = wb.createSheet("test picture"); +// // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) +// XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); +// // anchor主要用于设置图片的属性 +// XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, +// (short) (colIndex + 1), rowIndex + 1); +// //anchor.setAnchorType(3); +// // 插入图片 +// patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); +// +// } catch (Exception e) { +// e.printStackTrace(); +// } +// +// } +// +// /** +// * 移除合并的单元格 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, +// * check_index+12+check_rows, 0, 0)); +// * +// * @param startRow +// * @param endRow +// * @return +// */ +// public static boolean removeMergen(XSSFSheet sheet, int startRow, int endRow) { +// boolean isOK = false; +// int count = sheet.getNumMergedRegions(); +// for (int i = 0; i < count; i++) { +// CellRangeAddress address = sheet.getMergedRegion(i); +// System.out.println(address.getFirstRow() + "|" + address.getLastRow()); +// if (address.getFirstRow() == startRow && address.getLastRow() == endRow) { +// sheet.removeMergedRegion(i); +// isOK = true; +// break; +// } +// } +// return isOK; +// } +// +// /** +// * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, +// * check_index+12+check_rows, 0, 0)); +// * +// * @param startRow +// * @param endRow +// * @return +// */ +// public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { +// boolean isOK = false; +// if (rows.length > 0 && columns.length > 0) { +// sheet.addMergedRegion( +// new CellRangeAddress(rows[0], rows[rows.length - 1], columns[0], columns[columns.length - 1])); +// isOK = true; +// } +// return isOK; +// } +// +// /** +// * 截取字符串 +// * +// * @param inStr +// * @return +// */ +// public static String changeStringToInt(String inStr) { +// int index = inStr.indexOf("."); +// System.out.println(index); +// String outStr = null; +// if (index != -1) { +// +// outStr = inStr.substring(0, index); +// } else { +// outStr = inStr; +// +// } +// // System.out.println(outStr); +// return outStr; +// } +// +// /** +// * 截取一定长度的字符串 +// * +// * @param inStr +// * @param inLen +// * @return +// */ +// public static String changeStringToInt(String inStr, int inLen) { +// int index = inStr.indexOf("."); +// inLen++; +// System.out.println(index); +// String outStr = null; +// if (index != -1 && (inStr.length() - index) >= inLen) { +// +// outStr = inStr.substring(0, index + inLen); +// } else { +// outStr = inStr; +// +// } +// // System.out.println(outStr); +// return outStr; +// } +// +// /** +// * 将float转换成保留两位的字符串 +// * +// * @param f 需要转换的float数 +// * @return +// */ +// public static String changeFloatToStr(float f) { +// DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. +// String str = decimalFormat.format(f);// format 返回的是字符串 +// return str; +// } +// +// /** +// * 将字符串转换成int +// * +// * @param str +// * @return +// */ +// public static float changeStrToFloat(String str) { +// float temp_int = 0; +// try { +// temp_int = Float.parseFloat(str.trim()); +// return temp_int; +// } catch (NumberFormatException e) { +// System.out.println(e.getMessage()); +// return -1; +// } +// } +// +// /** +// * 设置formual的时候用来替换原有的单元格号到新的单元格号 +// * +// * @param originStr +// * @param subStr +// * @param index +// * @param index2 +// * @return +// */ +// public static String replaceSubString(String originStr, String subStr, int index, int index2) { +// StringBuffer sbO = new StringBuffer(); +// sbO.append(subStr); +// sbO.append(index); +// StringBuffer sbR = new StringBuffer(); +// sbR.append(subStr); +// sbR.append(index2); +// String resultStr = originStr.replace(sbO.toString(), sbR.toString()); +// return resultStr; +// } +// +// /** +// * 读取EXCEL信息 +// * +// * @param String excel_file +// * @return List> 返回信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List> readExcel(String excel_file) throws FileNotFoundException, IOException { +// if (excel_file == null) { +// return null; +// } +// File file = new File(excel_file); +// // 获取EXCEL数据的具体逻辑的函数 +// return readExcel(file); +// } +// +// public static String combinationString(String s) { +// String result = ""; +// List sList = new ArrayList(); +// List sList2 = new ArrayList(); +// if (s.indexOf("&") > -1) { +// String[] ss = s.split("&"); +// if (ss[0].indexOf("/") > -1) { +// String[] sss = ss[0].split("/"); +// for (int i = 0; i < sss.length; i++) { +// sList.add(sss[i]); +// } +// } else { +// sList.add(ss[0]); +// } +// if (ss[1].indexOf("/") > -1) { +// String[] sss = ss[1].split("/"); +// for (int i = 0; i < sss.length; i++) { +// sList2.add(sss[i]); +// } +// } else { +// sList2.add(ss[1]); +// } +// +// if (sList.size() == sList2.size()) { +// StringBuffer sb = new StringBuffer(); +// for (int i = 0; i < sList.size(); i++) { +// sb.append(sList.get(i) + "/" + sList2.get(i) + "&"); +// } +// if (sb != null && sb.length() != 0) { +// result = sb.substring(0, sb.length() - 1); +// } +// } +// } +// return result; +// +// } +// +// /** +// * 读取控制计划信息 +// * +// * @param String excel_file +// * @return List> 返回信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static Map> readExcel(String excel_file, String cellName) +// throws FileNotFoundException, IOException { +// if (excel_file == null) { +// return null; +// } +// File file = new File(excel_file); +// XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file)); +// Map> result = new LinkedHashMap>(); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(xwb); +// XSSFSheet sheet = xwb.getSheetAt(0); +// XSSFRow row; +// String cell; +// for (int i = sheet.getFirstRowNum(); i < sheet.getPhysicalNumberOfRows(); i = i + 2) { +// +// row = sheet.getRow(i); +// if (getRegionValue(xwb, sheet, i, 1).toString().equals(cellName)) { +// List rowValue = new ArrayList(); +// int lastRow = getRegionIndex(sheet, i, 1, cellName); +// for (int j = row.getFirstCellNum(); j < row.getLastCellNum(); j++) { +// if (j == 10) { +// continue; +// } +// if ((row.getCell(j) == null || row.getCell(j).toString().equals("")) && i <= lastRow) { +// String s = getRegionValue(xwb, sheet, i, j); +// if (s == null) { +// cell = ""; +// } else { +// if (j == 9) { +// if (row.getCell(10) != null && !row.getCell(10).toString().equals("")) { +// s = s + "/" + sheet.getRow(i - 1).getCell(10).toString() + "/" +// + row.getCell(10).toString(); +// } +// } +// cell = s; +// } +// } else { +// cell = getStringCellValue(evaluator, row.getCell(j)); +// } +// System.out.print(cell + ","); +// rowValue.add(cell); +// } +// result.put((int) Float.parseFloat(rowValue.get(3)), rowValue); +// } +// System.out.println("**********************"); +// } +// return result; +// } +// +// /** +// * 获取单个的命名单元格的位置 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int[] getNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int[] index = new int[2]; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return null; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) { +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// index[0] = cellR.getCol(); +// index[1] = cellR.getRow(); +// // colIndex = cellR.getCol(); +// // rowIndex = cellR.getRow(); +// } +// } +// } +// } +// return index; +// } +// +// /** +// * 获取单个的命名单元格的列 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int getNamedColumnIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int index = -1; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } +// +// /** +// * 获取合并单元格内容 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String getRegionValue(XSSFWorkbook workbook, XSSFSheet sheet, int rowIndex, int cellIndex) { +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// if (rowIndex <= lastRowNum && rowIndex >= rowNum && cellIndex <= lastColIndex && cellIndex >= colIndex) { +// return getStringCellValue(evaluator, sheet.getRow(rowNum).getCell((short) colIndex)); +// } +// } +// return null; +// } +// +// /** +// * 获取EXCEL合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static Map getRegionCell(XSSFSheet sheet) { +// Map regionCellMap = new HashMap(); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (rowNum >= 13) { +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// // 行集合 +// int[] rows = new int[lastRowNum - (rowNum - 1)]; +// // 列集合 +// for (int j = 0; j < rows.length; j++) { +// rows[j] = rowNum + j; +// } +// int[] columns = new int[lastColIndex - (colIndex - 1)]; +// for (int j = 0; j < columns.length; j++) { +// columns[j] = colIndex + j + 1; +// } +// regionCellMap.put(rows, columns); +// } +// } +// return regionCellMap; +// } +// +// /** +// * 获取EXCEL合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static Map getEntrustingContentRegionCell(XSSFSheet sheet) { +// Map regionCellMap = new HashMap(); +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (rowNum >= 0) { +// // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); +// // 行集合 +// int[] rows = new int[lastRowNum - (rowNum - 1)]; +// // 列集合 +// for (int j = 0; j < rows.length; j++) { +// rows[j] = rowNum + j; +// } +// int[] columns = new int[lastColIndex - (colIndex - 1)]; +// for (int j = 0; j < columns.length; j++) { +// columns[j] = colIndex + j + 1; +// } +// regionCellMap.put(rows, columns); +// } +// } +// return regionCellMap; +// } +// +// /** +// * 转换为控制计划合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String toControlPlanRegionCell(Map regionCell, int row) { +// Iterator> it = regionCell.entrySet().iterator(); +// StringBuffer sb = new StringBuffer(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k] - 13); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k]); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == row) { +// sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) +// + "-"); +// } +// } +// if (sb.length() > 0) { +// return sb.toString().substring(0, sb.length() - 1); +// } else { +// return ""; +// } +// } +// +// /** +// * 转换为委托内容合并单元格 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @return +// */ +// public static String toEntrustingContentRegionCell(Map regionCell, int row) { +// Iterator> it = regionCell.entrySet().iterator(); +// StringBuffer sb = new StringBuffer(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// StringBuffer rowSb = new StringBuffer(); +// StringBuffer columnSb = new StringBuffer(); +// for (int k = 0; k < entry.getKey().length; k++) { +// rowSb.append(entry.getKey()[k]); +// rowSb.append(","); +// } +// for (int k = 0; k < entry.getValue().length; k++) { +// columnSb.append(entry.getValue()[k] - 1); +// columnSb.append(","); +// } +// if (entry.getKey()[0] == row) { +// sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) +// + "-"); +// } +// } +// if (sb.length() > 0) { +// return sb.toString().substring(0, sb.length() - 1); +// } else { +// return ""; +// } +// } +// +// /** +// * 设置单元格中指定字体的样式 +// * +// * @param wb +// * @param s 内容 +// * @param firstIndex 起始位置 +// * @param lastIndex 结束位置 +// * @param fontSize 字体大小 +// * @param FontName 字体样式 +// * @return +// */ +// public static XSSFRichTextString setCellFont(XSSFWorkbook wb, String s, int firstIndex, int lastIndex, int fontSize, +// String FontName) { +// XSSFRichTextString ts = new XSSFRichTextString(s); +// XSSFFont font1 = (XSSFFont) wb.createFont(); +// font1.setFontHeightInPoints((short) 8); // 字体高度 +// font1.setFontName("宋体"); // 字体 +// // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 +// XSSFFont font = (XSSFFont) wb.createFont(); +// font.setFontHeightInPoints((short) fontSize); // 字体高度 +// font.setFontName(FontName); // 字体 +// // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 +// ts.applyFont(firstIndex, lastIndex, font); +// ts.applyFont(lastIndex, ts.length(), font1); +// return ts; +// } +// +// /** +// * 获取单元格大小 +// * +// * @param sheet +// * @param rowIndex +// * @param cellIndex +// * @param cellValue +// */ +// public static int getRegionIndex(XSSFSheet sheet, int rowIndex, int cellIndex, String cellValue) { +// int lastRow = 0; +// for (int i = 0; i < sheet.getNumMergedRegions(); i++) { +// CellRangeAddress region = sheet.getMergedRegion(i); +// int colIndex = region.getFirstColumn(); +// int lastColIndex = region.getLastColumn(); +// int rowNum = region.getFirstRow(); +// int lastRowNum = region.getLastRow(); +// if (sheet.getRow(rowNum).getCell(colIndex).toString().equals(cellValue)) { +// lastRow = lastRowNum; +// } +// } +// return lastRow; +// } +// +// /** +// * 获取单元格数据内容为字符串类型的数据 +// * +// * @param cell Excel单元格 +// * @return String 单元格数据内容 +// */ +// private static String getStringCellValue(XSSFFormulaEvaluator evaluator, XSSFCell cell) { +// if (cell == null) { +// return ""; +// } +// String strCell = ""; +// switch (cell.getCellType()) { +// case XSSFCell.CELL_TYPE_STRING: +// strCell = cell.getStringCellValue(); +// break; +// case XSSFCell.CELL_TYPE_NUMERIC: +// // strCell = cell.getStringCellValue(); +// if (DateUtil.isCellDateFormatted(cell)) { +// SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); +// Date date = cell.getDateCellValue(); +// if (date != null) +// strCell = sdf.format(date); +// } else { +// +// strCell = "" + cell.getNumericCellValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// break; +// case XSSFCell.CELL_TYPE_BOOLEAN: +// strCell = String.valueOf(cell.getBooleanCellValue()); +// break; +// case XSSFCell.CELL_TYPE_BLANK: +// strCell = ""; +// break; +// case XSSFCell.CELL_TYPE_ERROR: +// strCell = String.valueOf(cell.getErrorCellValue()); +// break; +// case XSSFCell.CELL_TYPE_FORMULA: +// CellValue value = evaluator.evaluate(cell); +// try { +// strCell = value.getStringValue(); +// if (strCell == null) { +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// } catch (Exception e) { +// +// strCell = "" + value.getNumberValue(); +// if (strCell.endsWith(".0")) { +// strCell = strCell.substring(0, strCell.indexOf(".0")); +// } +// } +// break; +// +// default: +// strCell = ""; +// break; +// } +// if (strCell.equals("") || strCell == null) { +// return ""; +// } +// // System.out.println(" === Type =" + cell.getCellType() + " Value =" + +// // strCell); +// return strCell; +// } +// +// /** +// * 插入行数 +// * +// * @param starRow +// * @param rows +// */ +// public static void insertRow(XSSFSheet sheet, int starRow, int rows) { +// XSSFRow sourceRow = sheet.getRow(starRow); +// sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); +// for (int i = 0; i < rows; i++) { +// XSSFRow targetRow = null; +// XSSFCell sourceCell = null; +// XSSFCell targetCell = null; +// short m; +// targetRow = sheet.createRow(starRow + 1); +// targetRow.setHeight(sourceRow.getHeight()); +// System.out.println(sourceRow.getLastCellNum()); +// for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { +// System.out.println(m); +// sourceCell = sourceRow.getCell(m); +// targetCell = targetRow.createCell(m); +// targetCell.setCellStyle(sourceCell.getCellStyle()); +// targetCell.setCellType(sourceCell.getCellType()); +// } +// } +// } +// +// /*** +// * 向sheet中插入一行 +// * +// * @param sheet +// * @param startRow +// * @param rows +// * @return +// */ +// public static XSSFSheet insertRows(XSSFSheet sheet, int startRow, int rows) { +// XSSFRow sourceRow = sheet.getRow(startRow); +// sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); +// for (int i = 0; i < rows; i++) { +// XSSFRow targetRow = null; +// XSSFCell sourceCell = null; +// XSSFCell targetCell = null; +// short m; +// targetRow = sheet.createRow(startRow + 1); +// targetRow.setHeight(sourceRow.getHeight()); +// System.out.println(sourceRow.getLastCellNum()); +// for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { +// System.out.println(m); +// sourceCell = sourceRow.getCell(m); +// targetCell = targetRow.createCell(m); +// targetCell.setCellStyle(sourceCell.getCellStyle()); +// targetCell.setCellType(sourceCell.getCellType()); +// } +// } +// return sheet; +// } +// +// /** +// * 检查单元格内容是否是数字 +// * +// * @param value +// * @return +// */ +// public static boolean CheckCellValueIsNumber(String value) { +// boolean is_ok = false; +// if (value.equals("")) { +// return false; +// } +// try { +// Float.parseFloat(value); +// } catch (NumberFormatException e) { +// e.printStackTrace(); +// System.out.println("===>" + value); +// is_ok = true; +// } +// return is_ok; +// } +// +//// /** +//// * 拼接麦格纳的联系人和联系电话 +//// * +//// * @param persion +//// * @param phone +//// * @return +//// */ +//// public static String connectPhoneAndPersion(String persion, String phone) { +//// StringBuffer persionPhoneSb = new StringBuffer(); +//// if (persion != null && phone != null) { +//// +//// String[] persions = null; +//// String[] phones = null; +//// if (persion.contains("、")) { +//// persions = persion.split("、"); +//// } else if (persion.contains("\\/")) { +//// persions = persion.split("\\/"); +//// } else if (persion.contains(",")) { +//// persions = persion.split(","); +//// } else { +//// persions = new String[] { persion }; +//// } +//// +//// if (phone.contains("、")) { +//// phones = phone.split("、"); +//// } else if (phone.contains("\\/")) { +//// phones = phone.split("\\/"); +//// } else if (phone.contains(",")) { +//// phones = phone.split(","); +//// } else { +//// phones = new String[] { phone }; +//// } +//// +//// if (persions != null && phones != null) { +//// int persionCount = persions.length; +//// int phonesCount = phones.length; +//// if (persionCount == phonesCount) { +//// for (int i = 0; i < persionCount; i++) { +//// persionPhoneSb.append(persions[i]).append("/") +//// .append(phones[i]).append(" "); +//// +//// } +//// } +//// } +//// } +//// +//// return persionPhoneSb.toString(); +//// } +// +// /*** +// * 输出成形作业指导书 +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @param row_num +// * @param col_num +// * @throws IOException +// * +// */ +// public static void writeExcelForCX(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFCellStyle style = wb.createCellStyle(); +//// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +//// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +//// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +//// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet sheet = wb.getSheetAt(0); +// sheet.setForceFormulaRecalculation(true); +// if (ls != null) +// for (int i = 0; i < ls.size(); i++) { +// if (i % 27 == 0 && i != 0) { +// row_num += 11; +// } +// XSSFRow row = sheet.getRow(i + row_num - 1); +// ArrayList ls2 = ls.get(i); +// for (int cols = 0; cols < ls2.size(); cols++) { +// XSSFCell cell = row.getCell(cols + col_num - 1); +// if (cell == null) { +// cell = row.createCell(cols + col_num - 1); +// } +//// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// cell.setCellStyle(style);// 添加边框 +// if (cols + col_num == 9) { +// String cpgc = ls2.get(cols); +// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +// System.out.println("strs.length=>" + strs.length); +// if (cpgc != null && cpgc != "") { +// if (!" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue( +// setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// } else +// cell.setCellValue(ls2.get(cols));// 写入内容 +// } +// +// } +// else +// MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// /** +// * 输出整形作业指导书 +// * +// * @param string +// * @param is +// * @param zx +// * @param strings +// * @param i +// * @param j +// */ +// public static void writeExcelForZX(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// XSSFCellStyle style = wb.createCellStyle(); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet sheet = wb.getSheetAt(0); +// for (int i = 0; i < ls.size(); i++) { +// if (i % 30 == 0 && i != 0) { +// row_num += 10; +// } +// XSSFRow row = sheet.getRow(i + row_num - 1); +// ArrayList ls2 = ls.get(i); +// for (int cols = 0; cols < ls2.size(); cols++) { +// XSSFCell cell = null; +// if (cols == ls2.size() - 1) +// cell = row.getCell(cols + col_num - 1); +// else +// cell = row.getCell(cols + col_num - 1); +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +//// cell.setCellStyle(style);// 添加边框 +// if (cols + col_num == 11) { +// String cpgc = ls2.get(cols); +// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +// System.out.println("strs.length=>" + strs.length); +// if (cpgc != null && cpgc != "") { +// if (!" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// } else +// cell.setCellValue(ls2.get(cols));// 写入内容 +// } +// +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// } +// +// /** +// * 输出烧结作业指导书 +// * +// * @param string +// * @param is +// * @param zx +// * @param strings +// * @param i +// * @param j +// */ +// public static void writeExcelForSJ(String xls_write_Address, File file, ArrayList> ls, +// List productNameList24, List productNameList18) throws IOException { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +//// writeExcelWithOneCellName(wb, "生产设备", rb3_jqsb); +// XSSFCellStyle style = wb.createCellStyle(); +// XSSFFont font = wb.createFont(); +// font.setFontHeightInPoints((short) 8); +// style.setFont(font); +// XSSFSheet s = wb.getSheetAt(0); +// s.setForceFormulaRecalculation(true); +// if (productNameList24 != null) { +// setNamedCellValue(wb, "二十四寸", +// productNameList24.toString().substring(1, productNameList24.toString().length() - 1)); +// } +// if (productNameList18 != null) { +// setNamedCellValue(wb, "十八寸", +// productNameList18.toString().substring(1, productNameList18.toString().length() - 1)); +// } +// int[] indexs = getNamedCellIndex(wb, "设备"); +// int startRow = indexs[1] + 1; +// int startColumn = indexs[0]; +// for (int i = 0; i < productNameList24.size(); i++) { +// +// Row r = s.getRow(startRow + i); +// setCellValue(r, startColumn, productNameList24.get(i)); +// } +// for (int i = 0; i < productNameList18.size(); i++) { +// Row r = s.getRow(startRow + productNameList24.size() + i); +// setCellValue(r, startColumn, productNameList18.get(i)); +// } +// +// int row_num = 0; +// int t = 0; +// for (int i = 0; i < ls.size(); i++) { +// if (t % 12 == 0 && i != 0) { +// t = 0; +// row_num += 29; +// } +// +// ArrayList ls2 = ls.get(i); +// System.out.println("SJ_data.size===============>" + ls2.size()); +// System.out.println("SJ_data====================>" + ls2.toString()); +// for (int j = 0; j < ls2.size() + 1; j++) { +// int namedCellIdx = wb.getNameIndex("head" + String.valueOf(j + 1)); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// CellReference[] crefs = arefs[0].getAllReferencedCells(); +// for (int k = 0; k < crefs.length; k++) { +// Row r = s.getRow(crefs[k].getRow() + row_num + 1); +// Cell c = r.getCell(crefs[k].getCol()); +// if (j == 2) { +// toSpecial(j, wb, c, ls2); +// } else if (namedCellIdx != wb.getNameIndex("head7")) +// c.setCellValue(ls2.get(j)); +// else +// c.setCellValue("√"); +// } +// } +// +// } +// t++; +// row_num++; +// } +// wb.write(output); +// output.close(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// +// } +// +// // 20181220-ReinhartEdit +// /*** +// * 输出热处理作业指导书 +// * +// * @param xls_write_Address +// * @param ls +// * @param sheetnames +// * @param row_num +// * @param col_num +// * @throws IOException +// * +// */ +// public static void writeExcelForRCL(String xls_write_Address, File file, ArrayList> ls, +// int row_num, int col_num) throws IOException { +// // InputStream is = new FileInputStream(file); +// // XSSFWorkbook wb = new XSSFWorkbook(is);// (new +// // is.close(); +// // FileOutputStream output = new FileOutputStream(new File( +// // xls_write_Address)); // 读取的文件路径 +// +// // XSSFCellStyle style = wb.createCellStyle(); +// // MessageBox.post("In Processing", "Step", MessageBox.WARNING); +// +// // MessageBox.post(xls_write_Address, "Step", MessageBox.WARNING); +// +// // 读取Excel文档 +// // File finalXlsxFile = new File("D:/NBTM热处理工艺指导书.xlsx"); +// File finalXlsxFile = new File(xls_write_Address); +// Workbook workBook = getWorkbok(finalXlsxFile); +// // sheet 对应一个工作页 +// Sheet getSheet = workBook.getSheetAt(0); +// +//// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +//// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +//// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +//// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); +// // XSSFFont font = wb.createFont(); +// /// font.setFontHeightInPoints((short) 8); +// // style.setFont(font); +// +// if (ls != null) { +// +// int rowNumber = getSheet.getLastRowNum(); // 第一行从0开始算 +// System.out.println("原始数据总行数:" + ls.size()); +// +// // 先把模板文件内容清空了 +// for (int i = 0; i < 10; i++) { +// Row row = getSheet.getRow(i + 26); +// +// if (row == null) { +// row = getSheet.createRow(i + 26); +// } +// try { +// Cell Itemcell = row.getCell(2); +// if (Itemcell == null) { +// Itemcell = row.createCell(2); +// } +// Itemcell.setCellValue("");// 写入内容 +// +// Cell Valuecell = row.getCell(6); +// if (Valuecell == null) { +// Valuecell = row.createCell(6); +// } +// Valuecell.setCellValue("");// 写入内容 +// +// Cell Processcell = row.getCell(10); +// if (Processcell == null) { +// Processcell = row.createCell(10); +// } +// Processcell.setCellValue("");// 写入内容 +// +// Cell Doublecell = row.getCell(14); +// if (Doublecell == null) { +// Doublecell = row.createCell(14); +// } +// Doublecell.setCellValue("");// 写入内容 +// +// } catch (Exception ex) { +// System.out.println(ex.toString()); +// MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); +// +// return; +// } +// +// } +// // System.out.println("先把模板文件内容清空了" ); +// +// // 先把模板文件内容清空了 +// // 写入参数数据 +// // System.out.println(ls.size()); +// for (int i = 0; i < ls.size(); i++) { +// +// System.out.println("写入实际数据!"); +// Row row = getSheet.getRow(i + 26); +// +// if (row == null) { +// row = getSheet.createRow(i + 26); +// } +// +// ArrayList ls2 = ls.get(i); +// // System.out.println(ls2.get(i)); +// // MessageBox.post(ls2.get(0), "Step", MessageBox.WARNING); +// +// try { +// +// Cell Itemcell = row.getCell(2); +// if (Itemcell == null) { +// Itemcell = row.createCell(2); +// } +// System.out.println(ls2.get(1)); +// Itemcell.setCellValue(ls2.get(1));// 写入内容 +// +// Cell Valuecell = row.getCell(6); +// if (Valuecell == null) { +// Valuecell = row.createCell(6); +// } +// System.out.println(ls2.get(2)); +// Valuecell.setCellValue(ls2.get(2));// 写入内容 +// +// Cell Processcell = row.getCell(10); +// if (Processcell == null) { +// Processcell = row.createCell(10); +// } +// System.out.println(ls2.get(3)); +// Processcell.setCellValue(ls2.get(3));// 写入内容 +// +// Cell Doublecell = row.getCell(14); +// if (Doublecell == null) { +// Doublecell = row.createCell(14); +// } +// System.out.println(ls2.get(4)); +// Doublecell.setCellValue(ls2.get(4));// 写入内容 +// +// } catch (Exception ex) { +// System.out.println(ex.toString()); +// MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); +// +// return; +// } +// +// } +// // 写入参数数据 +// +// // FileOutputStream output = new FileOutputStream("D:/MY热处理工艺指导书.xlsx"); // +// // 读取的文件路径 +// FileOutputStream output = new FileOutputStream(xls_write_Address); // 读取的文件路径 +// +// workBook.write(output); +// // wb.write(output); +// +// if (output != null) { +// output.flush(); +// output.close(); +// } +// +// // System.out.println("Start output data to Excel end!!!!!"); +// // MessageBox.post(" output data to Excel end!!!!!", "Step", +// // MessageBox.WARNING); +// +// } else { +// MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); +// } +// +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// public static void toSpecial(int cols, XSSFWorkbook wb, Cell cell, ArrayList cell_Date) { +// String cpgc = cell_Date.get(cols); +//// System.out.println(cpgc); +// String[] strs = cpgc.split("special"); +//// System.out.println(strs.length); +// if (cpgc != null || cpgc != "") { +// if (!"null".equals(strs[1]) && !" ".equals(strs[1])) { +// String special = strs[1]; +// if (special.indexOf("|") <= 0) { +// if ("产品/过程/规格/公差".equals(special.split("-")[0])) { +// int index = Integer.valueOf(special.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// +// } else { +// String[] tstxs = special.split("\\|"); +// for (String str : tstxs) { +// if ("产品/过程/规格/公差".equals(str.split("-")[0])) { +// int index = Integer.valueOf(str.split("-")[1]); +// if (strs[0] != null && strs[0] != "") { +// cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); +// } +// } +// } +// } +// } else { +// // 直接写入strs[0] +// cell.setCellValue(strs[0]); +// } +// } +// +// } +// +// public static void writeExcelWithOneCellName(XSSFWorkbook wb, String cellName, String value) { +// +// int namedCellIdx = wb.getNameIndex(cellName); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// for (int j = 0; j < crefs.length; j++) { +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// c.setCellValue(value); +// } +// } +// } +// } +// +// /** +// * 将对象属性值写入到Excel中 +// * +// * @param output +// * @param file +// * @param cellName +// * @param cellValue +// */ +// public static void writeExcelWithCellName(File file, String fileOutUrl, Map map, int code, +// String meop_name) { +// try { +// InputStream is = new FileInputStream(file); +// Workbook wb = new XSSFWorkbook(is);// retrieve workbook +// is.close(); +// FileOutputStream output = new FileOutputStream(new File(fileOutUrl)); +// boolean is_first = true; +// for (String key : map.keySet()) { +// if (is_first && "产品代号".equals(key) && (code == 3 || code == 4 || code == 5)) { +// int a1CellIndex = wb.getNameIndex("head"); +// if (a1CellIndex != -1) { +// Name a1NameCell = wb.getNameAt(a1CellIndex); +// AreaReference[] a1ARF = AreaReference.generateContiguous(a1NameCell.getRefersToFormula()); +// CellReference[] a1CRF = a1ARF[0].getAllReferencedCells(); +// Sheet s = wb.getSheet(a1CRF[0].getSheetName()); +// Row r = s.getRow(a1CRF[0].getRow()); +// Cell c = r.getCell(a1CRF[0].getCol()); +// System.out.println(key + ":" + c.getStringCellValue()); +// c.setCellValue(c.getStringCellValue() + map.get(key)); +// is_first = false; +// } +// } +// +// if ("工艺流程".equals(key)) { +// SetFont(wb, map.get(key), meop_name); +// } +// +// else { +// +// int namedCellIdx = wb.getNameIndex(key); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// +// for (int j = 0; j < crefs.length; j++) { +// +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// if (code == 2) { +// c.setCellValue(map.get(key).split("/")[0]); +// } else +// c.setCellValue(map.get(key)); +// } +// } +// } +// } +// } +// wb.write(output); +// output.close(); +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// /** +// * 设置str1中str2的字体 +// * +// * @param wb +// * @param str1 +// * @param str2 +// * @throws IOException +// */ +// private static void SetFont(Workbook wb, String str1, String str2) throws IOException { +// int index = 0; +// int start_index = 0; +// int end_index = str1.length(); +// String meop_name = str2.split("/")[0]; +// if (str1.indexOf("成形") != -1) +// start_index = str1.indexOf("成形"); +// if (str1.lastIndexOf("包装") != -1) +// end_index = str1.lastIndexOf("包装") + 2; +// str1 = str1.substring(start_index, end_index); +// while ((index = str1.indexOf(meop_name, index)) != -1) { +// int next_index = index + meop_name.length(); +// boolean begin = index - 1 < 0 || str1.charAt(index - 1) == '-'; +// boolean end = next_index > str1.length() || next_index + 1 > str1.length() ? true +// : str1.charAt(next_index) == '-'; +// if (begin && end) +// break; +// else +// index = index + meop_name.length(); +// } +// XSSFRichTextString ts = new XSSFRichTextString(str1); +// XSSFFont font1 = (XSSFFont) wb.createFont(); +// font1.setFontHeightInPoints((short) 10); // 字体高度 +// font1.setFontName("仿宋"); // 字体 +// XSSFFont font = (XSSFFont) wb.createFont(); +// font.setFontHeightInPoints((short) 12); // 字体高度 +// font.setFontName("仿宋"); +// ts.applyFont(index, index + meop_name.length(), font); +// ts.applyFont(index + meop_name.length(), ts.length(), font1); +//// XSSFFont font = (XSSFFont) wb.createFont(); +//// +//// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); +//// ts.applyFont(index, index+str2.length(), font); +// int namedCellIdx = wb.getNameIndex("工艺流程"); +// if (namedCellIdx != -1) { +// Name aNamedCell = wb.getNameAt(namedCellIdx); +// AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); +// for (int i = 0; i < arefs.length; i++) { +// CellReference[] crefs = arefs[i].getAllReferencedCells(); +// for (int j = 0; j < crefs.length; j++) { +// Sheet s = wb.getSheet(crefs[j].getSheetName()); +// Row r = s.getRow(crefs[j].getRow()); +// Cell c = r.getCell(crefs[j].getCol()); +// c.setCellValue(ts); +// } +// } +// } +// } +// +// /** +// * 添加命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param tcResource 文件的物理路径 +// * @param relationType 关系名称 +// * @param fileName 文件名 +// */ +// public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, +// String fileName, String relationType, String excelType, boolean isDelete) { +// try { +// String as1[] = { tcResource };// 文件的物理路径 +// String as2[] = { "excel" }; +// String as3[] = { excelType }; +// String as4[] = { "Plain" }; +// TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session +// .getTypeComponent("Dataset"); +// TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); +// tccomponentDataset.setFiles(as1, as3, as4, as2); +// AIFComponentContext[] zyzdsChildrens = item.getChildren(); +// TCComponentItemRevision zyzdsRev = item; +// for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { +// if (excelType.equals(zyzdsChildren.getComponent().getType())) { +// TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); +// if (dateSet.getStringProperty("object_name").equals(fileName)) { +// dateSet.delete(); +// zyzdsRev.remove(relationType, dateSet); +// } +// } +// } +// item.add(relationType, tccomponentDataset); +// if (isDelete) { +// new File(tcResource).delete(); +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// /** +// * 获取命名的引用返回所有对象 +// * +// * @param session +// * @param item 对象的版本 +// * @param relationType 关系名称 +// */ +// public static TCComponentDataset[] getComponentToDatasets(TCSession session, TCComponentItemRevision item, +// String relationType) { +// try { +// TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); +// TCComponentDataset[] Childrens = new TCComponentDataset[zyzdsChildrens.length]; +// if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { +// return null; +// } +// for (int ii = 0; ii < zyzdsChildrens.length; ii++) { +// +// if (zyzdsChildrens[ii] instanceof TCComponentDataset) { +// // +// +// Childrens[ii] = (TCComponentDataset) zyzdsChildrens[ii]; +// +// // +// } +// +//// +// +// } +// +// return Childrens; +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * 获取命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param relationType 关系名称 +// */ +// +// public static TCComponentDataset getComponentToDataset(TCSession session, TCComponentItemRevision item, +// String relationType) { +// try { +// TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); +// if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { +// return null; +// } +// for (TCComponent zyzdsChildren : zyzdsChildrens) { +// +// return (TCComponentDataset) zyzdsChildren; +//// +// +// } +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * 获取命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param relationType 关系名称 +// */ +// public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, +// String relationType, String fileType) { +// try { +// TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); +// if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { +// return null; +// } +// for (TCComponent zyzdsChildren : zyzdsChildrens) { +// if (fileType.equals(zyzdsChildren.getType())) { +// return (TCComponentDataset) zyzdsChildren; +//// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +//// return tcFile[0].getFmsFile(); +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * 获取命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param relationType 关系名称 +// */ +// public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, +// String fileType) { +// try { +// TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); +// if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { +// return null; +// } +// for (TCComponent zyzdsChildren : zyzdsChildrens) { +// if (fileType.equals(zyzdsChildren.getType())) { +// TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * 获取合并单元格 +// * +// * @param value 值 +// * @param startIndex 起始行 +// * @return +// */ +// public static void getCombineRow(String value, int startIndex) { +// // TODO Auto-generated method stub +// String[] sombines = null; +// if (value != null && !value.equals("")) { +// if (value.indexOf("-") >= 0) { +// sombines = value.split("-"); +// } else { +// sombines = new String[] { value }; +// } +// } +// for (int j = 0; j < sombines.length; j++) { +// if (sombines[j].indexOf("/") >= 0) { +// int[] row; +// int[] cloumn; +// String[] cells = sombines[j].split("/"); +// if (cells[0].indexOf(",") >= 0) { +// String[] rows = cells[0].split(","); +// row = new int[rows.length]; +// for (int k = 0; k < rows.length; k++) { +// row[k] = Integer.parseInt(rows[k]) + startIndex; +// } +// } else { +// row = new int[] { Integer.parseInt(cells[0]) + startIndex }; +// } +// if (cells[1].indexOf(",") >= 0) { +// String[] cloumns = cells[1].split(","); +// cloumn = new int[cloumns.length]; +// for (int k = 0; k < cloumns.length; k++) { +// cloumn[k] = Integer.parseInt(cloumns[k]) - 1; +// } +// } else { +// cloumn = new int[] { Integer.parseInt(cells[1]) - 1 }; +// } +// map.put(row, cloumn); +// } +// } +// } +// +// /** +// * 获取单个的命名单元格的列 +// * +// * @param wb +// * @param cellName +// * @return +// * @throws IOException +// */ +// public static int getOneNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { +// int index = -1; +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); +// XSSFName name = wb.getName(cellName); +// if (name == null) { +// return -1; +// } +// AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); +// if (areaRs != null) +// for (AreaReference areaR : areaRs) { +// CellReference[] cellRs = areaR.getAllReferencedCells(); +// if (cellRs != null) { +// for (CellReference cellR : cellRs) { +// String sheetName = cellR.getSheetName(); +// short colIndex = cellR.getCol(); +// int rowIndex = cellR.getRow(); +// XSSFSheet sheet = wb.getSheet(sheetName); +// XSSFRow row = sheet.getRow(rowIndex); +// return colIndex; +// } +// } +// } +// return index; +// } +// +// /** +// * 改变数据集的命名引用 +// * +// * @param tccomponentDataset +// * @param quote +// * @param type +// * @param path +// * @throws TCException +// */ +// public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) +// throws TCException { +// String myPath[] = { path }; +// String myQuote[] = { quote };// 引用"excel" +// String myType[] = { type };// 类型"MSExcelX" +// String myPlain[] = { "Plain" }; +// +// // 删除数据集的引用 +// deleDateSetRef(tccomponentDataset); +// // 数据集的替换 +// tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote); +// +// } +// +// /** +// * 删除数据集的命名引用 +// * +// * @param dataset +// * @throws TCException +// */ +// private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { +// +// TCComponentTcFile[] tcFiles = dataset.getTcFiles(); +// for (int i = 0; i < tcFiles.length; i++) { +// // 得到数据集的引用类型 +// String str_temp = getNamedRefType(dataset, tcFiles[i]); +// // 删除引用 +// dataset.removeNamedReference(str_temp); +// } +// +// } +// +// /** +// * 得到数据集的引用类型 +// * +// * @param datasetComponent +// * @param tccomponent +// * @return +// * @throws TCException +// */ +// private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) +// throws TCException { +// String s; +// s = ""; +// TCProperty tcproperty; +// TCProperty tcproperty1; +// TCComponent atccomponent[]; +// String as[]; +// int i; +// int j; +// int k; +// try { +// tcproperty = datasetComponent.getTCProperty("ref_list"); +// tcproperty1 = datasetComponent.getTCProperty("ref_names"); +// if (tcproperty == null || tcproperty1 == null) +// return s; +// } catch (TCException tcexception) { +// return s; +// } +// atccomponent = tcproperty.getReferenceValueArray(); +// as = tcproperty1.getStringValueArray(); +// if (atccomponent == null || as == null) +// return s; +// i = atccomponent.length; +// if (i != as.length) +// return s; +// j = -1; +// k = 0; +// do { +// if (k >= i) +// break; +// if (tccomponent == atccomponent[k]) { +// j = k; +// break; +// } +// k++; +// } while (true); +// if (j != -1) +// s = as[j]; +// return s; +// } +// +// /** +// * 下载文件 +// * +// * @param comps +// * @return +// * @throws TCException +// * @throws IOException +// */ +// public static String downLoadFile(TCComponentDataset dateSet, String compType) throws TCException, IOException { +// String value = ""; +// String tempPath = System.getenv("TEMP"); +// // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); +// if (tempPath == null) { +// tempPath = ""; +// } else if (!tempPath.endsWith("\\")) { +// tempPath = tempPath + "\\"; +// } +// SimpleDateFormat sdf = new SimpleDateFormat("yyyymmdd"); +// TCComponentTcFile[] tcFiles = dateSet.getTcFiles(); +// File file = null; +// if (tcFiles != null) { +// file = tcFiles[0].getFmsFile(); +// String fileName = file.getName(); +// String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); +// fileName = tempPath + sdf.format(new Date()) + fileDix; +// File dirFile = new File(fileName); +// FileUtility.copyFile(file, dirFile); +//// if (compType.equals("MSExcelX")) { +//// this.excelDataset = (TCComponentDataset) comp; +//// } +// return fileName; +// } +// return value; +// } +// +// public static void setFlowChart(Map valueMap, File file) { +// // TODO Auto-generated method stub +// file.setWritable(true); +// try { +// InputStream is = new FileInputStream(file); +// XSSFWorkbook wb = new XSSFWorkbook(is);// ( +// XSSFSheet sheet = wb.getSheetAt(0); +// +// Iterator> it = valueMap.entrySet().iterator(); +// while (it.hasNext()) { +// Map.Entry entry = it.next(); +// setNamedCellValue(wb, entry.getKey(), entry.getValue()); +// } +// FileOutputStream output = new FileOutputStream(file); +// wb.write(output); +// output.close(); +// is.close(); +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// // file.setReadOnly(); +// System.out.println("-------WRITE EXCEL OVER-------"); +// } +// +// public static Workbook getWorkbok(File file) throws IOException { +// Workbook wb = null; +// FileInputStream in = new FileInputStream(file); +// System.out.println(file.getName()); +// +// if (file.getName().endsWith(EXCEL_XLS)) { // Excel 2003 +// wb = new HSSFWorkbook(in); +// } else if (file.getName().endsWith(EXCEL_XLSX)) { // Excel 2007/2010 +// System.out.println("OK"); +// wb = new XSSFWorkbook(in); +// } +// return wb; +// } +// +// /** +// * 读取EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static List readExcelByEntrustment(File excel_file, String type) +// throws FileNotFoundException, IOException { +// if (excel_file == null || !excel_file.exists()) { +// return null; +// } +// // 用来返回的所有的行的信息 +// List lines_msg = new ArrayList(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// boolean isSelectType = false;// 判断是否找到指定的类型 +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// if (row == null) { +// isSelectType = false; +// continue; +// } +// // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); +// if (getStringCellValue(evaluator, row.getCell((short) 0)) == null +// || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { +// isSelectType = false; +// } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { +// isSelectType = true; +// if (row.getCell((short) 2) != null) { +// String value = getStringCellValue(evaluator, row.getCell((short) 1)); +// lines_msg.add(value); +// } +// } else { +// continue; +// } +// +// } +// // insertRow(sheet,4,1); +// return lines_msg; +// } +// +// /** +// * 读取EXCEL表 +// * +// * @param File excel_file +// * @return List> 返回的信息 +// * @throws IOException +// * @throws FileNotFoundException +// */ +// public static DefaultMutableTreeNode readExcelNodeByEntrustment(File excel_file, String type) +// throws FileNotFoundException, IOException { +// DefaultMutableTreeNode node = new DefaultMutableTreeNode("应用领域"); +// if (excel_file == null || !excel_file.exists()) { +// return node; +// } +// // 用来返回的所有的行的信息 +// //List lines_msg = new ArrayList(); +// XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); +// XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); +// XSSFSheet sheet = workBook.getSheetAt(0); +// XSSFRow title_row = sheet.getRow(0); +// +// // 得到列的数目 +// int col_count = title_row.getPhysicalNumberOfCells(); +// // 得到行的数目 +// int row_count = sheet.getLastRowNum(); +// boolean isSelectType = false;// 判断是否找到指定的类型 +// String no1 = ""; +// String no2 = ""; +// DefaultMutableTreeNode no1Node = null; +// DefaultMutableTreeNode no2Node = null; +// for (int j = 0; j < row_count + 1; j++) { +// // 用来返回单行的信息 +// XSSFRow row = sheet.getRow(j); +// if (row == null) { +// isSelectType = false; +// continue; +// } +// // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); +// if (getStringCellValue(evaluator, row.getCell((short) 0)) == null +// || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { +// isSelectType = false; +// } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { +// isSelectType = true; +// if (row.getCell((short) 4) != null) { +// String value1 = getStringCellValue(evaluator, row.getCell((short) 1)); +// String value2 = getStringCellValue(evaluator, row.getCell((short) 2)); +// //String value = getStringCellValue(evaluator, row.getCell((short) 3)); +// String value4 = getStringCellValue(evaluator, row.getCell((short) 4)); +// if(!value1.isEmpty() && value1.compareTo(no1) != 0) +// { +// no1Node = new DefaultMutableTreeNode(value1); +// node.add(no1Node); +// no2Node = new DefaultMutableTreeNode(value2); +// no1Node.add(no2Node); +// } +// else if(!value2.isEmpty() && value2.compareTo(no2) != 0) { +// no2Node = new DefaultMutableTreeNode(value2); +// no1Node.add(no2Node); +// } +// +// no2Node.add(new DefaultMutableTreeNode(value4)); +// +// //lines_msg.add(value); +// } +// } else { +// continue; +// } +// +// } +// // insertRow(sheet,4,1); +// return node; +// } +// +// //去除工序号最后的流水 +// public static String getID(String ID) { +// if(ID.indexOf("-")>-1) { +// String[] iDs=ID.split("-"); +// String id=""; +// for(int i=0;i> JobDatas=new ArrayList>(); +// private String ProductCode=""; +// private String ProductType=""; +// private boolean isMEOP=false; +// private ListerrorList=new ArrayList(); +// public GXZYZDSCommand(InterfaceAIFComponent comp, TCSession session,boolean isMEOP) { +// // TODO Auto-generated constructor stub +// this.comp = comp; +// this.session = session; +// this.isMEOP=isMEOP; +// } +// +// @Override +// public void executeModal() throws Exception { +// // TODO Auto-generated method stub +// //获取选中的对象 +// +// BomLine = (TCComponentBOMLine) comp; +// +// //从选中目标逐层分解类型:工序则生成指导书,工艺就继续分解 +// if(isMEOP) { +// getMeopValues(BomLine); +// } +// +// +// //非工序的错误信息统一打印 +// if(errorList.size()>0) { +// String errorMessage=""; +// for(int i=0;i-1) { +// getOP(bomLine); +// }else if(bomLine.getItem().getType().indexOf("Op")>-1) { +// getMeopValues(bomLine); +// } +// } +// } +// +// //获取工序数据 +// public void getMeopValues(TCComponentBOMLine MEOP) throws TCException, IOException { +// List> WorkStepDatas=new ArrayList>();//工步数据 +// List> MaterialDatas=new ArrayList>();//物料数据 +// List> FrockDatas=new ArrayList>();//工装数据 +// Tree02 jobTree=new Tree02(); +// jobTree.setProductCode(ProductCode); +// jobTree.setProductType(ProductType); +// +// TCComponentBOMLine MEOPBomLine=MEOP; +// //jobTree.setItemID(MEOPBomLine.getItemRevision().getStringProperty("item_id"));//工序编号 +// jobTree.setItemID(ExcelUtil07.getID(MEOPBomLine.getItemRevision().getStringProperty("item_id")));//工序编号 +// jobTree.setName(MEOPBomLine.getItemRevision().getStringProperty("object_name"));//工序名称 +// jobTree.setTime(String.valueOf(MEOPBomLine.getDoubleProperty("bl_me_work_time")));//标准时间 +// +// +//// MessageBox.post(MEOPBomLine.getItem().getType(),"cuowu",MessageBox.ERROR); +// +// //获取工序下工步 +// TCComponent[] WorkStep=MEOPBomLine.getReferenceListProperty("Mfg0sub_elements"); +// +// if(WorkStep==null||WorkStep.length==0) { +// //选中的对象不是工序的话就要将报错信息统一打出 +// if(((TCComponentBOMLine)comp).getItem().getType().equals("ML8_StdOperation")|| +// ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_DifOperation")|| +// ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_SpecOp")) { +// MessageBox.post("工序:"+MEOPBomLine.getStringProperty("bl_line_name")+"下没有内容。","错误",MessageBox.ERROR); +// }else { +// errorList.add(MEOPBomLine.getStringProperty("bl_line_name")); +// } +// +// } +// if(MEOPBomLine.getItemRevision().getProperty("release_status_list") != ""){ +// MessageBox.post("工序:"+MEOPBomLine.getStringProperty("bl_line_name")+"已发布,无法生成工序作业指导书。","错误",MessageBox.ERROR); +// }else{ +// int frockNo=0; +// for(int j=0;j WorkStepData=new ArrayList(); +// TCComponentBOMLine WorkStepLine=(TCComponentBOMLine)WorkStep[j]; +// //获取操作图片先生成图片待插入后再删除 +// boolean isExist=true; +// //WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("IMAN_specification"));//操作图片 +// WorkStepData.add(String.valueOf(j+1)); +// if(WorkStepLine.getItemRevision().getReferenceListProperty("IMAN_specification").length!=0) { +// TCComponent[] sssComponents=WorkStepLine.getItemRevision().getReferenceListProperty("IMAN_specification"); +// for(TCComponent num:sssComponents) { +// if(num.getType().equals("Image")) { +// WorkStepData.add(copyImage(num, String.valueOf(j+1))); +// isExist=false; +// break; +// } +// } +// } +// if(isExist)WorkStepData.add(""); +// //WorkStepData.add("C:\\美菱导出测试\\测试图.png");//图片 +// WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("object_name"));//工步名称 +// WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("object_desc"));//描述 +// WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("ml8_ProcessStandard"));//工艺标准 +// WorkStepData.add(String.valueOf(WorkStepLine.getDoubleProperty("bl_me_work_time")));//工时 +// WorkStepDatas.add(WorkStepData); +// +// //获取工步下的事例,提取工装和物料的数据 +// AIFComponentContext[] WorkStepExample=WorkStepLine.getChildren(); +// for(int k=0;k MaterialData=new ArrayList(); +// MaterialData.add((exampleBomLine.getItemRevision().getStringProperty("item_id")).split("-")[0]); +// MaterialData.add(exampleBomLine.getItemRevision().getStringProperty("object_name")); +// MaterialData.add(exampleBomLine.getItemRevision().getStringProperty("ml8_FigureNum")); +// MaterialData.add(exampleBomLine.getStringProperty("bl_quantity"));//统计数量 +// MaterialDatas.add(MaterialData); +// } +// //工装类型 +// if(exampleBomLine.getStringProperty("bl_occ_type").equals("METool")) { +// List FrockData=new ArrayList(); +// FrockData.add(exampleBomLine.getItemRevision().getStringProperty("item_id")); +// FrockData.add(exampleBomLine.getItemRevision().getStringProperty("object_name")); +// FrockDatas.add(FrockData); +// } +// +// } +// } +// +// //合并工装数量 +// if(FrockDatas!=null) { +// Map frockMapNo=new HashMap(); +// Map frockMapName=new HashMap(); +// List listValuefrock=new ArrayList(); +// for(int m=0;m FrockData=new ArrayList(); +// FrockData.add(String.valueOf(n+1)); +// FrockData.add(listValuefrock.get(n)); +// FrockData.add(frockMapName.get(listValuefrock.get(n))); +// //FrockData.add(String.valueOf(frockMapNo.get(listValuefrock.get(n))));//数量不用显示 +// FrockDatas.add(FrockData); +// } +// } +// +// +// //合并物料数量 +// if(MaterialDatas!=null) { +// Map materialMapNo=new HashMap(); +// Map materialMapName=new HashMap(); +// Map materialMapTh=new HashMap();//图号 +// List listValue=new ArrayList(); +// for(int m=0;m MaterialData=new ArrayList(); +// MaterialData.add(listValue.get(n)); +// MaterialData.add(materialMapName.get(listValue.get(n))); +// MaterialData.add(materialMapTh.get(listValue.get(n))); +// MaterialData.add(String.valueOf(materialMapNo.get(listValue.get(n)))); +// MaterialDatas.add(MaterialData); +// } +// +// } +// +// jobTree.setWorkStep(WorkStepDatas); +// jobTree.setFrock(FrockDatas); +// jobTree.setMaterial(MaterialDatas); +// +// System.out.println("工序ID:"+jobTree.getItemID()); +// System.out.println("工序名称:"+jobTree.getName()); +// System.out.println("产品代号:"+jobTree.getProductCode()); +// System.out.println("产品型号:"+jobTree.getProductType()); +// System.out.println("标准时间:"+jobTree.getTime()); +// System.out.println("工装数据:"+jobTree.getFrock().toString()); +// System.out.println("物料数据:"+jobTree.getMaterial().toString()); +// System.out.println("工步数据:"+jobTree.getWorkStep().toString()); +// +// +// //每个工序生成一棵树 +// +// GXZYZDSDialog gxzyzdsDialog=new GXZYZDSDialog(comp,session,jobTree,MEOPBomLine.getItem()); +// } +// } +// +// +// +// //通过图片获取对象复制图片 +// public String copyImage(TCComponent ttComponent,String name) throws TCException { +// TCComponentDataset Dataset; +// TCComponentTcFile picFile; +// Dataset=(TCComponentDataset) ttComponent; +// TCComponentTcFile[] tcFile; +// tcFile =Dataset.getTcFiles(); +// picFile=tcFile[0]; +// MethodUtil.CopyPic(picFile.getFmsFile(),System.getenv("TEMP") + "\\"+name); +// return System.getenv("TEMP") + "\\"+name; +// } +//} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/GXZYZDSDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/GXZYZDSDialog.java new file mode 100644 index 0000000..480a9b8 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/GXZYZDSDialog.java @@ -0,0 +1,521 @@ +//package com.connor.ml.tcm.metarialChange; +// +//import java.awt.BorderLayout; +//import java.awt.Dimension; +//import java.awt.FlowLayout; +//import java.awt.Font; +//import java.awt.Robot; +//import java.awt.event.ActionEvent; +//import java.awt.event.ActionListener; +//import java.awt.event.KeyEvent; +//import java.awt.event.MouseEvent; +//import java.awt.event.MouseListener; +//import java.awt.image.BufferedImage; +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileOutputStream; +//import java.io.IOException; +//import java.lang.reflect.Method; +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.List; +//import java.util.Map; +// +//import javax.imageio.ImageIO; +//import javax.swing.JButton; +//import javax.swing.JLabel; +//import javax.swing.JPanel; +//import javax.swing.JScrollPane; +//import javax.swing.ListSelectionModel; +//import javax.swing.table.DefaultTableModel; +//import javax.swing.tree.TreePath; +// +//import org.apache.poi.ss.usermodel.Cell; +//import org.apache.poi.xssf.usermodel.XSSFCell; +//import org.apache.poi.xssf.usermodel.XSSFWorkbook; +//import org.jdesktop.swingx.decorator.HighlighterFactory; +//import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +// +//import com.itextpdf.text.pdf.codec.Base64.InputStream; +//import com.spire.xls.CellStyle; +//import com.spire.xls.ExcelPicture; +//import com.spire.xls.ExcelVersion; +//import com.spire.xls.Workbook; +//import com.spire.xls.Worksheet; +//import com.spire.xls.core.INameRanges; +//import com.spire.xls.core.IXLSRange; +//import com.teamcenter.rac.aif.AbstractAIFDialog; +//import com.teamcenter.rac.aif.kernel.AIFComponentContext; +//import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentBOMLine; +//import com.teamcenter.rac.kernel.TCComponentBOMWindow; +//import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +//import com.teamcenter.rac.kernel.TCComponentDataset; +//import com.teamcenter.rac.kernel.TCComponentDatasetType; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCComponentItemType; +//import com.teamcenter.rac.kernel.TCComponentTcFile; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.schemas.internal.core._2008_06.dispatchermanagement.InsertDatasetVersionArgs; +//import com.teamcenter.soa.client.model.Lov.Style; +//import com.teamcenter.soa.exceptions.NotLoadedException; +// +//public class GXZYZDSDialog extends AbstractAIFDialog implements ActionListener { +// +// private TCSession session; +// private InterfaceAIFComponent comp; +// +// private List> WorkStepDatas=new ArrayList>();//工步 +// private List> MaterialDatas=new ArrayList>();//物料 +// private List> FrockDatas=new ArrayList>();//工装 +// private Tree02 tree; +// private TCComponentItem target; +// private String outPathString =System.getenv("TEMP") + "\\";//导出路径 +// private String nameString=""; +// private CellStyle cellStyle; +// private double RowHeight=20; +// public GXZYZDSDialog(InterfaceAIFComponent comp, TCSession session,Tree02 tree,TCComponentItem target) throws IOException { +// // TODO Auto-generated constructor stub +// super(false); +// this.session = session; +// this.comp = comp; +// this.tree=tree; +// this.target=target; +// nameString=tree.getItemID()+tree.getName(); +// init(); +// } +// +// private void init() throws IOException { +// //创建Workbook对象 +// Workbook wb = new Workbook(); +// File file1 = null; +// file1=MethodUtil.getFile(session, "工序作业指导书", "MSExcelX"); +// FileInputStream input1 = new FileInputStream(file1); +// wb.loadFromHtml(input1); +// //加载一个测试文档 +// //wb.loadFromFile("C:\\美菱导出测试\\作业指导书.xlsx"); +// //MessageBox.post(outPathString,"错误",MessageBox.ERROR); +// //获取第一个工作表 +// Worksheet sheet = wb.getWorksheets().get(0); +// sheet.setName(nameString+"工序作业指导书"); +// +//// +//// //获取全局命名区域 +//// //获取局部命名区域(对局部命名区域进行相关操作) +//// INameRanges namedRange1 = wb.getNameRanges(); +//// IXLSRange ddd=namedRange1.get(4).getRefersToRange(); +//// System.out.println(ddd.getColumn()); +//// namedRange1.get(0).setRefersToRange(sheet.getCellRange("A24")); +// +// String Formula1 = "=IF(ml8_Design=\"\",\"\",ml8_Design)";//编制 +// String Formula2 = "=IF(ml8_Examine=\"\",\"\",ml8_Examine)";//审核 +// String Formula3 = "=IF(ml8_Standardization=\"\",\"\",ml8_Standardization)";//会签 +// String Formula4 = "=IF(ml8_Approval=\"\",\"\",ml8_Approval)";//批准 +// +// +// +// //获取行高 +// RowHeight=sheet.getRowHeight(5); +// +// ExcelPicture pic1 = sheet.getPictures().get(1); +// BufferedImage loImage1 = pic1.getPicture(); +// ImageIO.write(loImage1,"jpg",new File(outPathString+"图标1.jpg")); +// ExcelPicture pic2 = sheet.getPictures().get(2); +// BufferedImage loImage2 = pic2.getPicture(); +// ImageIO.write(loImage2,"jpg",new File(outPathString+"图标2.jpg")); +// ExcelPicture pic3 = sheet.getPictures().get(3); +// BufferedImage loImage3 = pic3.getPicture(); +// ImageIO.write(loImage3,"jpg",new File(outPathString+"图标3.jpg")); +// +// +// //判断一共复制多少表格 +// WorkStepDatas=tree.getWorkStep(); +// MaterialDatas=tree.getMaterial(); +// FrockDatas=tree.getFrock(); +// int num=0; +// if(WorkStepDatas.size()>0) { +// num=(int) Math.ceil((double)WorkStepDatas.size()/6); +// if((int) Math.ceil((double)MaterialDatas.size()/10)>num) { +// num=(int) Math.ceil((double)MaterialDatas.size()/10); +// } +// if((int) Math.ceil((double)FrockDatas.size()/5)>num) { +// num=(int) Math.ceil((double)FrockDatas.size()/5); +// } +// }else { +// num=1; +// } +// +// //在工作表内复制单元格区域 +// for(int i=1;i WorkStepData=new ArrayList(); +// WorkStepData=WorkStepDatas.get(i-1); +// int startRow=flag*29+1;//开始行 +// if(i%6!=0) { +// switch (i%6) { +// case 1: +// InsertWorkStepData(sheet,startRow,4,1,WorkStepData); +// break; +// case 2: +// InsertWorkStepData(sheet,startRow,9,1,WorkStepData); +// break; +// case 3: +// InsertWorkStepData(sheet,startRow,14,1,WorkStepData); +// break; +// case 4: +// InsertWorkStepData(sheet,startRow,4,17,WorkStepData); +// break; +// case 5: +// InsertWorkStepData(sheet,startRow,9,17,WorkStepData); +// break; +// default: +// break; +// } +// }else { +// InsertWorkStepData(sheet,startRow,14,17,WorkStepData); +// flag++; +// } +// } +// flag=0; +// //插入物料 +// for(int i=1;i<=MaterialDatas.size();i++) { +// List MaterialData=new ArrayList(); +// MaterialData=MaterialDatas.get(i-1); +// int startRow=flag*29+1;//开始行 +// if(i%10!=0) { +// switch (i%10) { +// case 1: +// InsertMaterialData(sheet,startRow,21,1,MaterialData); +// break; +// case 2: +// InsertMaterialData(sheet,startRow,22,1,MaterialData); +// break; +// case 3: +// InsertMaterialData(sheet,startRow,23,1,MaterialData); +// break; +// case 4: +// InsertMaterialData(sheet,startRow,24,1,MaterialData); +// break; +// case 5: +// InsertMaterialData(sheet,startRow,25,1,MaterialData); +// break; +// case 6: +// InsertMaterialData(sheet,startRow,21,11,MaterialData); +// break; +// case 7: +// InsertMaterialData(sheet,startRow,22,11,MaterialData); +// break; +// case 8: +// InsertMaterialData(sheet,startRow,23,11,MaterialData); +// break; +// case 9: +// InsertMaterialData(sheet,startRow,24,11,MaterialData); +// break; +// default: +// break; +// } +// }else { +// InsertMaterialData(sheet,startRow,25,11,MaterialData); +// flag++; +// } +// } +// flag=0; +// //插入工装 +// for(int i=1;i<=FrockDatas.size();i++) { +// List FrockData=new ArrayList(); +// FrockData=FrockDatas.get(i-1); +// int startRow=flag*29+1;//开始行 +// if(i%5!=0) { +// switch (i%5) { +// case 1: +// InsertFrockData(sheet,startRow,21,21,FrockData); +// break; +// case 2: +// InsertFrockData(sheet,startRow,22,21,FrockData); +// break; +// case 3: +// InsertFrockData(sheet,startRow,23,21,FrockData); +// break; +// case 4: +// InsertFrockData(sheet,startRow,24,21,FrockData); +// break; +// default: +// break; +// } +// }else { +// InsertFrockData(sheet,startRow,25,21,FrockData); +// flag++; +// } +// } +// +// +//// //插入公式 +//// int PenultimateRow2=sheet.getLastRow()-1;//倒数第二行行数 +//// System.out.println("复制后的倒数第二行行数=======>"+PenultimateRow2); +//// if(PenultimateRow2!=PenultimateRow) { +//// if(formatCell1!=null) { +//// sheet.getCellRange(PenultimateRow2,4).setFormula(formatCell1); +//// } +//// if(formatCell2!=null) { +//// sheet.getCellRange(PenultimateRow2,11).setFormula(formatCell2); +//// } +//// if(formatCell3!=null) { +//// sheet.getCellRange(PenultimateRow2,20).setFormula(formatCell3); +//// } +//// if(formatCell4!=null) { +//// sheet.getCellRange(PenultimateRow2,28).setFormula(formatCell4); +//// } +//// } +// +// +// wb.saveToFile(outPathString+nameString+"工序作业指导书.xlsx"); +// Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());//删除有水印的最后一页 +// sheetRemove.remove(); +// wb.saveToFile(outPathString+nameString+"工序作业指导书.xlsx"); +// try { +// if(MethodUtil.getExcelToItem(session,this.target.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX",nameString+"工序作业指导书") != null) { +// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,this.target.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX",nameString+"工序作业指导书"), "excel", "MSExcelX", outPathString+nameString+"工序作业指导书.xlsx"); +// }else { +// MethodUtil.setExcelToItem(session,this.target.getLatestItemRevision(),outPathString+nameString+"工序作业指导书.xlsx",nameString+"工序作业指导书","IMAN_specification", +// "MSExcelX", true); +// +// } +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// if(new File(outPathString+nameString+"工序作业指导书.xlsx").exists()) { +// new File(outPathString+nameString+"工序作业指导书.xlsx").delete(); +// } +// } +// +// +// //创建表格 +// public void copyTable(Worksheet sheet, int startRow,int endRow) throws IOException { +// String s1="A".concat(String.valueOf(startRow)); +// String s2=":AF".concat(String.valueOf(endRow)); +// sheet.copy(sheet.getCellRange("A1:AF28"),sheet.getCellRange( +// s1.concat(s2)),true); +// //合并单元格 +// sheet.getRange().get("A".concat(String.valueOf(startRow)).concat(":G".concat(String.valueOf(startRow+1)))).merge(); +// sheet.getRange().get("H".concat(String.valueOf(startRow)).concat(":AB".concat(String.valueOf(startRow+1)))).merge(); +// sheet.getRange().get("AC".concat(String.valueOf(startRow)).concat(":AF".concat(String.valueOf(startRow)))).merge(); +// sheet.getRange().get("AC".concat(String.valueOf(startRow+1)).concat(":AF".concat(String.valueOf(startRow+1)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+2)).concat(":B".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("C".concat(String.valueOf(startRow+2)).concat(":G".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("H".concat(String.valueOf(startRow+2)).concat(":I".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("J".concat(String.valueOf(startRow+2)).concat(":N".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("o".concat(String.valueOf(startRow+2)).concat(":P".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+2)).concat(":U".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("V".concat(String.valueOf(startRow+2)).concat(":W".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("X".concat(String.valueOf(startRow+2)).concat(":AB".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("AC".concat(String.valueOf(startRow+2)).concat(":AD".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("AE".concat(String.valueOf(startRow+2)).concat(":AF".concat(String.valueOf(startRow+2)))).merge(); +// sheet.getRange().get("B".concat(String.valueOf(startRow+3)).concat(":H".concat(String.valueOf(startRow+3)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+3)).concat(":L".concat(String.valueOf(startRow+3)))).merge(); +// sheet.getRange().get("M".concat(String.valueOf(startRow+3)).concat(":O".concat(String.valueOf(startRow+3)))).merge(); +// sheet.getRange().get("R".concat(String.valueOf(startRow+3)).concat(":X".concat(String.valueOf(startRow+3)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+3)).concat(":AB".concat(String.valueOf(startRow+3)))).merge(); +// sheet.getRange().get("AC".concat(String.valueOf(startRow+3)).concat(":AE".concat(String.valueOf(startRow+3)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+4)).concat(":A".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("B".concat(String.valueOf(startRow+4)).concat(":H".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+4)).concat(":L".concat(String.valueOf(startRow+4)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+5)).concat(":L".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("M".concat(String.valueOf(startRow+4)).concat(":O".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("P".concat(String.valueOf(startRow+4)).concat(":P".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+4)).concat(":Q".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("R".concat(String.valueOf(startRow+4)).concat(":X".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+4)).concat(":AB".concat(String.valueOf(startRow+4)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+5)).concat(":AB".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("AC".concat(String.valueOf(startRow+4)).concat(":AE".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("AF".concat(String.valueOf(startRow+4)).concat(":AF".concat(String.valueOf(startRow+8)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+9)).concat(":A".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("B".concat(String.valueOf(startRow+9)).concat(":H".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+9)).concat(":L".concat(String.valueOf(startRow+9)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+10)).concat(":L".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("M".concat(String.valueOf(startRow+9)).concat(":O".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("P".concat(String.valueOf(startRow+9)).concat(":P".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+9)).concat(":Q".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("R".concat(String.valueOf(startRow+9)).concat(":X".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+9)).concat(":AB".concat(String.valueOf(startRow+9)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+10)).concat(":AB".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("AC".concat(String.valueOf(startRow+9)).concat(":AE".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("AF".concat(String.valueOf(startRow+9)).concat(":AF".concat(String.valueOf(startRow+13)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+14)).concat(":A".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("B".concat(String.valueOf(startRow+14)).concat(":H".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+14)).concat(":L".concat(String.valueOf(startRow+14)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+15)).concat(":L".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("M".concat(String.valueOf(startRow+14)).concat(":O".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("P".concat(String.valueOf(startRow+14)).concat(":P".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+14)).concat(":Q".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("R".concat(String.valueOf(startRow+14)).concat(":X".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+14)).concat(":AB".concat(String.valueOf(startRow+14)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+15)).concat(":AB".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("AC".concat(String.valueOf(startRow+14)).concat(":AE".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("AF".concat(String.valueOf(startRow+14)).concat(":AF".concat(String.valueOf(startRow+18)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+19)).concat(":T".concat(String.valueOf(startRow+19)))).merge(); +// sheet.getRange().get("U".concat(String.valueOf(startRow+19)).concat(":Y".concat(String.valueOf(startRow+19)))).merge(); +// sheet.getRange().get("Z".concat(String.valueOf(startRow+19)).concat(":AF".concat(String.valueOf(startRow+19)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+20)).concat(":C".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("D".concat(String.valueOf(startRow+20)).concat(":F".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("G".concat(String.valueOf(startRow+20)).concat(":I".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("K".concat(String.valueOf(startRow+20)).concat(":M".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("N".concat(String.valueOf(startRow+20)).concat(":P".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+20)).concat(":S".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("V".concat(String.valueOf(startRow+20)).concat(":W".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("X".concat(String.valueOf(startRow+20)).concat(":Y".concat(String.valueOf(startRow+20)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+21)).concat(":C".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("D".concat(String.valueOf(startRow+21)).concat(":F".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("G".concat(String.valueOf(startRow+21)).concat(":I".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("K".concat(String.valueOf(startRow+21)).concat(":M".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("N".concat(String.valueOf(startRow+21)).concat(":P".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+21)).concat(":S".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("V".concat(String.valueOf(startRow+21)).concat(":W".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("X".concat(String.valueOf(startRow+21)).concat(":Y".concat(String.valueOf(startRow+21)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+22)).concat(":C".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("D".concat(String.valueOf(startRow+22)).concat(":F".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("G".concat(String.valueOf(startRow+22)).concat(":I".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("K".concat(String.valueOf(startRow+22)).concat(":M".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("N".concat(String.valueOf(startRow+22)).concat(":P".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+22)).concat(":S".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("V".concat(String.valueOf(startRow+22)).concat(":W".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("X".concat(String.valueOf(startRow+22)).concat(":Y".concat(String.valueOf(startRow+22)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+23)).concat(":C".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("D".concat(String.valueOf(startRow+23)).concat(":F".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("G".concat(String.valueOf(startRow+23)).concat(":I".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("K".concat(String.valueOf(startRow+23)).concat(":M".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("N".concat(String.valueOf(startRow+23)).concat(":P".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+23)).concat(":S".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("V".concat(String.valueOf(startRow+23)).concat(":W".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("X".concat(String.valueOf(startRow+23)).concat(":Y".concat(String.valueOf(startRow+23)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+24)).concat(":C".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("D".concat(String.valueOf(startRow+24)).concat(":F".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("G".concat(String.valueOf(startRow+24)).concat(":I".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("K".concat(String.valueOf(startRow+24)).concat(":M".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("N".concat(String.valueOf(startRow+24)).concat(":P".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+24)).concat(":S".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("V".concat(String.valueOf(startRow+24)).concat(":W".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("X".concat(String.valueOf(startRow+24)).concat(":Y".concat(String.valueOf(startRow+24)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+25)).concat(":C".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("D".concat(String.valueOf(startRow+25)).concat(":F".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("G".concat(String.valueOf(startRow+25)).concat(":I".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("K".concat(String.valueOf(startRow+25)).concat(":M".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("N".concat(String.valueOf(startRow+25)).concat(":P".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+25)).concat(":S".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("V".concat(String.valueOf(startRow+25)).concat(":W".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("X".concat(String.valueOf(startRow+25)).concat(":Y".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("Z".concat(String.valueOf(startRow+20)).concat(":AF".concat(String.valueOf(startRow+25)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+26)).concat(":C".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("D".concat(String.valueOf(startRow+26)).concat(":H".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("I".concat(String.valueOf(startRow+26)).concat(":K".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("L".concat(String.valueOf(startRow+26)).concat(":P".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("Q".concat(String.valueOf(startRow+26)).concat(":S".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("T".concat(String.valueOf(startRow+26)).concat(":X".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("Y".concat(String.valueOf(startRow+26)).concat(":AA".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("AB".concat(String.valueOf(startRow+26)).concat(":AF".concat(String.valueOf(startRow+26)))).merge(); +// sheet.getRange().get("A".concat(String.valueOf(startRow+27)).concat(":AF".concat(String.valueOf(startRow+27)))).merge(); +// +// +// for(int i=4;i<19;i++) { +// sheet.setRowHeight(startRow+i,RowHeight); +// } +// //sheet.getRange().get("".concat(String.valueOf(startRow+)).concat(":".concat(String.valueOf(startRow+)))).merge(); +// //插入图片 +// MethodUtil.InsertTitlePicture(sheet,outPathString+"图标1.jpg",new int[] {startRow,startRow+1}, +// new int[] {1,2,3,4,5,6,7},false ,0,0); +// MethodUtil.InsertTitlePicture(sheet,outPathString+"图标2.jpg",new int[] {startRow}, +// new int[] {29,30,31,32},false ,0,0); +// MethodUtil.InsertTitlePicture(sheet,outPathString+"图标3.jpg",new int[] {startRow+27},new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14, +// 15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32},false ,0,0); +//// ExcelPicture pic1 = sheet.getPictures().add(startRow, 1,outPathString+"图标1.jpg"); +//// pic1.setWidth(290); +//// pic1.setHeight(75); +//// ExcelPicture pic2 = sheet.getPictures().add(startRow, 29,outPathString+"图标2.jpg"); +//// pic2.setWidth(155); +//// pic2.setHeight(43); +//// ExcelPicture pic3 = sheet.getPictures().add(startRow+27, 1,outPathString+"图标3.jpg"); +//// pic3.setWidth(1350); +//// pic3.setHeight(25); +// } +// //工步插入数据 +// public void InsertWorkStepData(Worksheet sheet,int startRow,int row,int column,List dataList) throws IOException { +// sheet.setText(startRow+row, column, (dataList.get(0)==null&&dataList.get(0).equals(""))?" ":dataList.get(0)); +// if(dataList.get(1).equals("")) { +// +// }else { +// //行高3.23CM;列宽:5.46CM +// MethodUtil.InsertTitlePicture(sheet,dataList.get(1),new int[] {startRow+row,startRow+row+1,startRow+row+2,startRow+row+3,startRow+row+4}, +// new int[] {column+1,column+2,column+3,column+4,column+5,column+6,column+7},true,3.23,5.46 ); +// +// } +// //sheet.setCellValue(startRow+row, column+1, dataList.get(1)==null?"":dataList.get(1)); +// sheet.setText(startRow+row, column+8, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); +// sheet.setText(startRow+row+1, column+8, (dataList.get(3)==null||dataList.get(3).equals(""))?" ":dataList.get(3)); +// sheet.setText(startRow+row, column+12, (dataList.get(4)==null||dataList.get(4).equals(""))?" ":dataList.get(4)); +// sheet.setText(startRow+row, column+15,( dataList.get(5)==null||dataList.get(5).equals(""))?" ":dataList.get(5)); +// } +// //物料插入数据 +// public void InsertMaterialData(Worksheet sheet,int startRow,int row,int column,List dataList) { +// sheet.setText(startRow+row, column, (dataList.get(0)==null||dataList.get(0).equals(""))?" ":dataList.get(0)); +// sheet.setText(startRow+row, column+3, (dataList.get(1)==null||dataList.get(1).equals(""))?" ":dataList.get(1)); +// sheet.setText(startRow+row, column+6, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); +// sheet.setText(startRow+row, column+9, (dataList.get(3)==null||dataList.get(3).equals(""))?" ":dataList.get(3)); +// } +// //工装插入数据 +// public void InsertFrockData(Worksheet sheet,int startRow,int row,int column,List dataList) { +// sheet.setText(startRow+row, column, (dataList.get(0)==null||dataList.get(0).equals(""))?" ":dataList.get(0)); +// sheet.setText(startRow+row, column+1,( dataList.get(1)==null||dataList.get(1).equals(""))?" ":dataList.get(1)); +// sheet.setText(startRow+row, column+3, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); +// } +// +// +// +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// +// } +// +// +//} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeCommand.java new file mode 100644 index 0000000..96238c7 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeCommand.java @@ -0,0 +1,525 @@ +package com.connor.ml.tcm.metarialChange; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Map.Entry; + +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.JTable; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class MaterialChangeCommand extends JFrame { + private TCSession session; + private TCComponentItemRevision revision; + private TCComponentItemRevision selectedRev; + private TCComponent[] tcComponents; + private String[][] dataValues; + private String gyggId; + private String[] columnNamesLeft = new String[] { "序号", "ID", "版本", "操作内容"}; + private String[] columnNamesRight = new String[] { "序号", "ID", "当前版本", "名称", "发布状态", "同步状态", "创建者", "更改单号"}; + private List> dataTableList= new ArrayList>(); + public MaterialChangeCommand(TCSession session, TCComponentItemRevision revision, TCComponent[] tcComponents) { + this.session=session; + this.revision=revision; + this.tcComponents=tcComponents; + try { + gyggId=revision.getStringProperty("item_id"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + init(); + } + private JTable tabelRight; + private Map revisionMap=new HashMap(); + +// private JTable mainTable; +// @Override + public void init() { +// showDialog(); + + for(int i=0;i aList=new ArrayList(); + aList.add(String.valueOf(i)); + try { + + revisionMap.put(itemRevision.getStringProperty("item_id"), itemRevision); +// itemRevision + aList.add(itemRevision.getStringProperty("item_id")); + aList.add(itemRevision.getStringProperty("item_revision_id")); + + aList.add(itemRevision.getStringProperty("object_desc")); + + dataTableList.add(aList); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + } + + this.dataValues = new String[this.dataTableList.size()][]; + for (int i = 0; i < this.dataTableList.size(); i++) { + this.dataValues[i] = new String[this.dataTableList.get(i).size()]; + for (int j = 0; j < this.dataTableList.get(i).size(); j++) { + this.dataValues[i][j] = this.dataTableList.get(i).get(j); + } + } + + +// getjTable(null, null, columnNamesLeft, dataValues); + + + InitUI(); + + + } + private void InitUI() { + // TODO Auto-generated method stub + + this.setLayout(new BorderLayout()); + + JTable getjTable = getjTable(null, null, columnNamesLeft, dataValues); + + JScrollPane jscrollpane = new JScrollPane(getjTable); + jscrollpane.setPreferredSize(new Dimension(400,300)); + + JPanel jPanelLeft=new JPanel(); + jPanelLeft.setPreferredSize(new Dimension(400,300)); + jPanelLeft.add(jscrollpane); + + this.setTitle("物料属性变更"); + this.setLayout(new BorderLayout()); + + this.setPreferredSize(new Dimension(1320,600)); + + JPanel panelCenter=new JPanel(); + panelCenter.setPreferredSize(new Dimension(100,300)); + + panelCenter.add( new Label("影响分析")); + panelCenter.add( new Label("》》》》》》")); + JButton jButton=new JButton("属性同步"); + panelCenter.add(jButton); + jButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + if(selectedRev !=null) { + Thread thread = new Thread() { + public void run() { + SelectPropDialog dialog=new SelectPropDialog(selectedRev); + } + }; + thread.start(); + }else { + MessageBox.post(MaterialChangeCommand.this,"请选择左边窗口的对象","提示",2); + Thread thread = new Thread() { + public void run() { + SelectPropDialog dialog=new SelectPropDialog(selectedRev); + } + }; + thread.start(); + } + + } + }); + + + JPanel panelN=new JPanel(); + JButton closeBtn =new JButton("取消"); + panelN.add(closeBtn); + closeBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + + getjTable.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + // TODO Auto-generated method stub + if (mouseevent.getClickCount() ==1) { + int selectedRow = getjTable.getSelectedRow(); + DefaultTableModel model =(DefaultTableModel)getjTable.getModel(); + String itemID =(String) model.getValueAt(selectedRow, 1); + selectedRev = revisionMap.get(itemID); + revMapRight = new HashMap(); + getRelatedMBOM(selectedRev); + try { + String tempId = selectedRev.getProperty("ml8_Template_ID"); + TCComponent[] itemRevisionMB = getItemRevisionMB(session,tempId); + for(TCComponent rev:itemRevisionMB) { + revMapRight.put(rev.getProperty("item_id"), ((TCComponentItem)rev).getLatestItemRevision()); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + String tempId = selectedRev.getProperty("ml8_Template_ID"); + TCComponent[] itemRevisionMB = getItemRevisionMB2(session,tempId); + for(TCComponent rev:itemRevisionMB) { + revMapRight.put(rev.getProperty("item_id"), ((TCComponentItem)rev).getLatestItemRevision()); + } + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + revMapRight.remove(itemID); + try { + refreshRightTable(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println(selectedRow+itemID); + } + } + }); + + + tabelRight = getjTable(null, null, columnNamesRight, null); + + JScrollPane jscrollpaneRight = new JScrollPane(tabelRight); + jscrollpaneRight.setPreferredSize(new Dimension(800,300)); + + JPanel jPanelRight=new JPanel(); + jPanelRight.setPreferredSize(new Dimension(800,300)); + jPanelRight.add(jscrollpaneRight); + + + + this.add(panelCenter,BorderLayout.CENTER); + this.add(jPanelLeft,BorderLayout.WEST); + this.add(jPanelRight,BorderLayout.EAST); + this.add(panelN,BorderLayout.SOUTH); +// this.setAlwaysOnTop(true); + this.pack(); + this.validate(); +// this.centerToScreen(); + this.setVisible(true); + + + } + + protected void refreshRightTable() throws TCException { + // TODO Auto-generated method stub + + DefaultTableModel model = (DefaultTableModel) tabelRight.getModel(); + model.setRowCount(0); + int i=1; + for(Entry key:revMapRight.entrySet()) { + String key2 = key.getKey(); + if(revMapRight.containsKey(key2)) { + TCComponentItemRevision rev = revMapRight.get(key2); + TCComponent[] list = rev.getReferenceListProperty("release_status_list"); + String changeNo = rev.getStringProperty("ml8_changeNO"); + TCComponent user = rev.getReferenceProperty("owning_user"); + String userName = user.getStringProperty("user_name"); + model.addRow(new String[]{String.valueOf(i),key2,rev.getStringProperty("item_revision_id"),rev.getProperty("object_name"), + list.length==0?"未发布":"已发布", changeNo.equals(gyggId)?"已更新":"未更新",userName, gyggId}); + i++; + } + } + tabelRight.invalidate(); + tabelRight.revalidate(); + tabelRight.repaint(); + + } + + private Map revMapRight; + public static TCComponent[] getItemRevision(TCSession session, String itemId) throws Exception { + System.out.println("Search Revision: " + itemId); + String queryName = "基于关系查询"; + String[] keys = new String[]{getText(session, "ID")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); +// int len = res.length; +// if (len == 0) { +// return null; +// } else if (len > 1) { +// System.out.println("找到了多个rev"); +// } else { +// return ((TCComponentItem) res[0]).getLatestItemRevision(); +// } + return res; + } + public static TCComponent[] getItemRevisionMB2(TCSession session, String itemId) throws Exception { + System.out.println("Search Revision: " + itemId); + String queryName = "基于工序查询"; + String[] keys = new String[]{getText(session, "模板")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); +// int len = res.length; +// if (len == 0) { +// return null; +// } else if (len > 1) { +// System.out.println("找到了多个rev"); +// } else { +// return ((TCComponentItem) res[0]).getLatestItemRevision(); +// } + return res; + } + public static TCComponent[] getItemRevisionMB(TCSession session, String itemId) throws Exception { + System.out.println("Search Revision: " + itemId); + String queryName = "基于模板查询"; + String[] keys = new String[]{getText(session, "模板")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); +// int len = res.length; +// if (len == 0) { +// return null; +// } else if (len > 1) { +// System.out.println("找到了多个rev"); +// } else { +// return ((TCComponentItem) res[0]).getLatestItemRevision(); +// } + return res; + } + public static String getText(TCSession session, String str) throws Exception { + if (isEmpty(str)) { + return str; + } else { + String res = session.getTextService().getTextValue(str); + return !isEmpty(res) ? res : str; + } + } + + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + public static TCComponent[] query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + System.out.println("null"+queryName); + } else { + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + return null; + } + protected void getRelatedMBOM(TCComponentItemRevision selectedRev2) { + // TODO Auto-generated method stub + + try { + + TCComponent[] itemRevision = getItemRevision(session,selectedRev2.getStringProperty("item_id")); + + for(TCComponent itemC:itemRevision) { + TCComponentItem item=(TCComponentItem)itemC; + TCComponentItemRevision latestItemRevision = item.getLatestItemRevision(); + String id = latestItemRevision.getStringProperty("item_id"); + if(!revMapRight.containsKey(id)) { + revMapRight.put(id, latestItemRevision); + getRelatedMBOM(latestItemRevision); + } + } + +// TCComponent[] relatedComponents = selectedRev2.getRelatedComponents("IMAN_based_on"); +// +// for(TCComponent component:relatedComponents) { +// +// if(component instanceof TCComponentItemRevision) { +// +// TCComponentItemRevision revision=(TCComponentItemRevision)component; +// +// revMapRight.put(revision.getStringProperty("item_id"), revision); +// +// System.out.println(revision.toString()); +// +// getRelatedMBOM(revision); +// } +// +// +// } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + public static DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + + return tableModel; + } + + + class SelectPropDialog extends AbstractAIFDialog{ + + public String changeProp; + + private TCComponentItemRevision selectedRev; + + public SelectPropDialog(TCComponentItemRevision selectedRev) { + this.selectedRev=selectedRev; + init(); + } + + private void init() { +// this.setModal(true); + this.setTitle("属性同步更改"); + this.setLayout(new BorderLayout()); + this.setPreferredSize(new Dimension(250,150)); + JPanel jPanel=new JPanel(); + jPanel.setPreferredSize(new Dimension(250,100)); + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringValues("ML_PropertyChange"); + Map propMap=new HashMap(); + JComboBox comboBox=new JComboBox(); + for(String value:values) { + String[] split = value.split("-"); + if(split[0].equals(selectedRev.getType())) { + + String[] split2 = split[1].split(";"); + + for(String props:split2) { + String[] split3 = props.split(":"); + propMap.put(split3[0], split3[1]); + comboBox.addItem(split3[0]); + } + + break; + } + } +// changeProp=(String)comboBox.getSelectedItem(); + jPanel.add(new JLabel("选择属性")); + jPanel.add(comboBox); + + JPanel nouthPanel=new JPanel(); + JButton okBtn=new JButton("确认"); + JButton disBtn=new JButton("取消"); + + nouthPanel.add(okBtn); + nouthPanel.add(disBtn); + disBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dispose(); + } + }); + okBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + String selectedItem = (String) comboBox.getSelectedItem(); + changeProp = propMap.get(selectedItem); + String stringProperty=""; + try { + stringProperty = selectedRev.getStringProperty(changeProp); + } catch (TCException e2) { + // TODO Auto-generated catch block + e2.printStackTrace(); + } + MaterialChangeOperation operation=new MaterialChangeOperation(changeProp,revMapRight,session,gyggId, + SelectPropDialog.this,stringProperty,tabelRight); + try { + operation.executeOperation(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } +// dispose(); + } + }); + + + this.add(jPanel,BorderLayout.CENTER); + this.add(nouthPanel,BorderLayout.SOUTH); + + this.setAlwaysOnTop(true); + this.pack(); +// this.validate(); +// this.setResizable(false); + this.centerToScreen(); + SelectPropDialog.this.setVisible(true); + } + } + + public static JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } +// @Override +// public void executeModal() throws Exception { +// +// +//// revision.getRelated(); +// +// +// +// +// } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeHandler.java new file mode 100644 index 0000000..87cbf13 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeHandler.java @@ -0,0 +1,99 @@ +package com.connor.ml.tcm.metarialChange; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.sap.tc.logging.standard.Message; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soaictstubs.booleanSeq_tHolder; + + +public class MaterialChangeHandler extends AbstractHandler{ + public AbstractAIFUIApplication application; + private TCComponentItemRevision revision=null; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + + this.application = AIFUtility.getCurrentApplication(); + boolean flag=false; + InterfaceAIFComponent[] targetComponents = this.application.getTargetComponents(); + if(targetComponents.length>0) { + InterfaceAIFComponent targetComponent=targetComponents[0]; + if(targetComponent instanceof TCComponentItemRevision) { + revision =(TCComponentItemRevision) targetComponent; + String type = revision.getType(); + if(type.equals("ML8_MCNoticeRevision")) { // || true + flag=true; + } +// folderN=folder; + } + } + TCSession session = (TCSession) application.getSession(); + if(flag && revision!=null) { + try { + + + AIFComponentContext[] whereReferenced = revision.whereReferenced(); + + for(AIFComponentContext context : whereReferenced) { + String type = context.getComponent().getType(); + System.out.println(type); + } + + TCComponentBOMWindowType windowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = windowType.create(null); + TCComponentBOMLine setWindowTopLine = bomWindow.setWindowTopLine(revision.getItem(), revision, null, null); + + TCComponentBOMLine cachedParent = setWindowTopLine.getCachedParent(); + if(cachedParent!=null) { + System.out.println(cachedParent.toString()); + } + new Thread() { + public void run() { + try { + MaterialChangeCommand command = new MaterialChangeCommand(session,revision,revision.getRelatedComponents("ML8_GXBGH")); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + }.start(); + +// new Thread(command).start(); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { +// command.executeModal(); + + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else { + MessageBox.post("请选择工艺变更通知单版本对象","提示",2); + } + + + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeOperation.java new file mode 100644 index 0000000..f93f9ab --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MaterialChangeOperation.java @@ -0,0 +1,97 @@ +package com.connor.ml.tcm.metarialChange; + +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +import javax.swing.JTable; + +import org.apache.commons.collections.map.HashedMap; + +import com.connor.ml.tcm.metarialChange.MaterialChangeCommand.SelectPropDialog; +//import com.connor.ml.tcm.outfile.ML_14.checkBOPCommand; +import com.connor.ml.tcm.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class MaterialChangeOperation extends AbstractAIFOperation { + + + private String changeProp; + private Map revMapRight; + private TCSession session; + private String gyggId; + private SelectPropDialog selectPropDialog; + + private Map revGXMap=new HashMap(); + private Map revGYGWMap=new HashMap(); + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + System.out.println("changeProp"+changeProp+"gyggId"+gyggId+"propValue"+propValue); + + MethodUtil.setByPass(true,session); + + try { + for(Entry key:revMapRight.entrySet()) { + + String key2 = key.getKey(); + if(revMapRight.containsKey(key2)) { + TCComponentItemRevision rev = revMapRight.get(key2); + + System.out.println(rev.toString()); + + rev.setStringProperty(changeProp, propValue); + rev.setStringProperty("ml8_changeNO", gyggId); + + String type = rev.getItem().getType(); + + if(type.equals("ML8_StdOperation")||type.equals("ML8_DifOperation")||type.equals("ML8_SpecOp")) { + getTopProcess(); + }else if (type.endsWith("Step")) { + + } + } + + } + for(int i=0;i revMapRight, + TCSession session, String gyggId, SelectPropDialog selectPropDialog, String propValue,JTable tabelRight) { + this.changeProp=changeProp; + this.revMapRight=revMapRight; + this.session=session; + this.gyggId=gyggId; + this.selectPropDialog=selectPropDialog; + this.propValue=propValue; + this.tabelRight = tabelRight; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MethodUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MethodUtil.java new file mode 100644 index 0000000..e2420ca --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/MethodUtil.java @@ -0,0 +1,1449 @@ +//package com.connor.ml.tcm.metarialChange; +// +//import java.awt.image.BufferedImage; +//import java.io.File; +//import java.io.FileInputStream; +//import java.io.FileNotFoundException; +//import java.io.FileOutputStream; +//import java.io.IOException; +//import java.text.DecimalFormat; +//import java.text.SimpleDateFormat; +//import java.util.ArrayList; +//import java.util.Date; +//import java.util.List; +//import java.util.Map; +// +//import javax.imageio.ImageIO; +// +//import org.apache.http.client.methods.CloseableHttpResponse; +//import org.apache.http.client.methods.HttpPost; +//import org.apache.http.entity.StringEntity; +//import org.apache.http.impl.client.CloseableHttpClient; +//import org.apache.http.impl.client.HttpClients; +//import org.apache.http.util.EntityUtils; +// +//import com.itextpdf.text.pdf.codec.Base64.InputStream; +//import com.spire.xls.ExcelPicture; +//import com.spire.xls.ViewMode; +//import com.spire.xls.Workbook; +//import com.spire.xls.Worksheet; +//import com.teamcenter.rac.aif.AbstractAIFApplication; +//import com.teamcenter.rac.aif.kernel.AIFComponentContext; +//import com.teamcenter.rac.aifrcp.AIFUtility; +//import com.teamcenter.rac.kernel.ListOfValuesInfo; +//import com.teamcenter.rac.kernel.TCComponent; +//import com.teamcenter.rac.kernel.TCComponentBOMLine; +//import com.teamcenter.rac.kernel.TCComponentDataset; +//import com.teamcenter.rac.kernel.TCComponentDatasetType; +//import com.teamcenter.rac.kernel.TCComponentFolder; +//import com.teamcenter.rac.kernel.TCComponentItem; +//import com.teamcenter.rac.kernel.TCComponentItemRevision; +//import com.teamcenter.rac.kernel.TCComponentItemType; +//import com.teamcenter.rac.kernel.TCComponentListOfValues; +//import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +//import com.teamcenter.rac.kernel.TCComponentProcess; +//import com.teamcenter.rac.kernel.TCComponentProcessType; +//import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +//import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +//import com.teamcenter.rac.kernel.TCComponentTcFile; +//import com.teamcenter.rac.kernel.TCComponentType; +//import com.teamcenter.rac.kernel.TCException; +//import com.teamcenter.rac.kernel.TCPreferenceService; +//import com.teamcenter.rac.kernel.TCProperty; +//import com.teamcenter.rac.kernel.TCSession; +//import com.teamcenter.rac.kernel.TCUserService; +//import com.teamcenter.rac.kernel.ics.ICSKeyLov; +//import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +//import com.teamcenter.rac.util.MessageBox; +//import com.teamcenter.services.rac.core.DataManagementService; +// +//public class MethodUtil { +// +// private static final String SEP1 = ","; +// +// /** +// * 同步超级BOM +// * +// * @param session session +// * @param process 流程对象 +// * @param processUser 节点负责人首选项的值 +// * @param arctic 车型 +// * @throws TCException +// */ +// public static void sendBom(TCSession session, TCComponentItemRevision itemRevision) throws TCException { +// +// TCUserService userservice = session.getUserService(); +// +// Object[] obj = new Object[1]; +// obj[0] = itemRevision; +// userservice.call("Super_Bom_Appent_Data", obj); +// } +// +// /** +// * 根据规则获取ID +// * +// * @param oldItemID 旧的ID +// * @return 新的ID +// */ +// public static String getRuleItemID(TCSession session, String oldItemID) { +// // String[] oldItemIDs = oldItemID.split("-"); +// DecimalFormat df = new DecimalFormat("000"); +// // String newID = oldItemIDs[0] + "-" + oldItemIDs[1] + "-001"; +// String newID = oldItemID + "-001"; +// // String idTemp = +// TCComponentItemType tccomponentitemtype; +// try { +// tccomponentitemtype = (TCComponentItemType) (session.getTypeComponent("Item")); +// +// tccomponentitemtype.getNewID(); +// int i = 1; +// while (tccomponentitemtype.find(newID) != null) { +// i++; +// // newID = oldItemIDs[0] + "-" + oldItemIDs[1] + "-"+ df.format(i); +// newID = oldItemID + "-" + df.format(i); +// } +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// return newID; +// } +// +// +// //插入图片;isProportion:false是将图片嵌入到全部单元格。true是将原图比例放入区域内 +// //sheet:操作的excel;picturePath:图片路径;Rows:插入图片区域的行(excel默认行列都从1开始);colunms插入图片区域的列 +// //RowHeightCM模板插入图片区域的行高(cm);ColumnWidthCM模板插入图片区域的列宽(cm)。false的这两个参数可以随意设置,用不到 +// public static void InsertTitlePicture(Worksheet sheet,String picturePath,int[] Rows,int[] colunms, +// boolean isProportion,double RowHeightCM,double ColumnWidthCM) throws IOException { +//// //获取系统分辨率 +//// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +//// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); +// +// double ColumnWidth=0.0;//列宽单元格像素 +// double RowHeight=0.0;//行高像素 +//// double ColumnWidthCM=0.0;//列宽单元格CM +//// double RowHeightCM=0.0;//行高CM +// for(int i=0;iRH) { +// w=W/CW; +// h=(H/CW)*w1/h1;//w1是放图片区域列宽占的厘米数除以像素(0.18);h1是行高的占的厘米数除以像素(0.23) +// }else { +// h=H/RH; +// w=(W/RH)*h1/w1; +// } +// pic1.setWidth((int) (w)); +// pic1.setHeight((int) (h)); +// }else { +// pic1.setWidth((int) ColumnWidth); +// pic1.setHeight((int) RowHeight); +// } +// } +// +// +// /** +// * List转换String +// * +// * @param list :需要转换的List +// * @return String转换后的字符串 +// */ +// public static String ListToString(List list) { +// +// StringBuffer sb = new StringBuffer(); +// if (list != null && list.size() > 0) { +// for (int i = 0; i < list.size(); i++) { +// if (list.get(i) == null || list.get(i) == "") { +// continue; +// } +// // 如果值是list类型则调用自己 +// if (list.get(i) instanceof List) { +// sb.append(ListToString((List) list.get(i))); +// sb.append(SEP1); +// } else { +// sb.append(list.get(i)); +// sb.append(SEP1); +// } +// } +// } +// return sb.toString(); +// } +// +// //获取工序编号 +// public static String getItemId(String ID) { +// if(ID.indexOf("-")>-1) { +// String[] id=ID.split("-"); +// String value=""; +// for(int i=0;i= revId) { +// itemRevision = items[i]; +// revId = letterToNumber(revisionId); +// } +// } +// return itemRevision; +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// // 字母转数字 A-Z :1-26 +// public static int letterToNumber(String letter) { +// int length = letter.length(); +// int num = 0; +// int number = 0; +// for (int i = 0; i < length; i++) { +// char ch = letter.charAt(length - i - 1); +// num = (int) (ch - 'A' + 1); +// num *= Math.pow(26, i); +// number += num; +// } +// return number; +// } +// +// /** +// * 根据LOV名称获取LOV +// * +// * @param tcsession +// * @param s +// * @return +// */ +//// public static ComboBoxItemBean[] findLOVByName(TCSession tcsession, String s) { +//// TCComponentListOfValues tccomponentlistofvalues = null; +//// ComboBoxItemBean[] comboBoxItemBeans = null; +//// try { +//// TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession +//// .getTypeComponent("ListOfValues"); +//// TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s); +//// if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) { +//// tccomponentlistofvalues = atccomponentlistofvalues[0]; +//// +//// ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); +//// +//// String[] groupName = rtlistOfValuesInfo.getStringListOfValues(); +//// String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); +//// +//// comboBoxItemBeans = new ComboBoxItemBean[groupName.length + 1]; +//// ComboBoxItemBean comboBoxItem = new ComboBoxItemBean("", ""); +//// comboBoxItemBeans[0] = comboBoxItem; +//// for (int i = 0; i < groupName.length; i++) { +//// // resultMap.put(groupDisplayName[i],groupName[i]); +//// ComboBoxItemBean comboBoxItemBean = new ComboBoxItemBean(groupName[i], groupDisplayName[i]); +//// comboBoxItemBeans[i + 1] = comboBoxItemBean; +//// } +//// } +//// } catch (TCException tcexception) { +//// tccomponentlistofvalues = null; +//// } +//// return comboBoxItemBeans; +//// } +// +// /** +// * 根据LOV Key获取LOV值 +// * +// * @param tcsession +// * @param s +// * @return +// */ +// public static String findLovValueByKey(TCSession tcsession, String s, String key) { +// TCComponentListOfValues tccomponentlistofvalues = null; +// String resultValue = null; +// try { +// TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession +// .getTypeComponent("ListOfValues"); +// TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s); +// if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) { +// tccomponentlistofvalues = atccomponentlistofvalues[0]; +// +// ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); +// +// String[] groupName = rtlistOfValuesInfo.getStringListOfValues(); +// String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); +// +// for (int i = 0; i < groupName.length; i++) { +// // resultMap.put(groupDisplayName[i],groupName[i]); +// if (groupName[i].equals(key)) { +// resultValue = groupDisplayName[i]; +// } +// } +// } +// } catch (TCException tcexception) { +// tccomponentlistofvalues = null; +// } +// return resultValue; +// } +// +// /** +// * 指派流程负责人 +// * +// * @param session session +// * @param process 流程对象 +// * @param processUser 节点负责人首选项的值 +// * @param arctic 车型 +// * @throws TCException +// */ +// public static void setProcess(TCSession session, TCComponentProcess process, String processUser, String arctic) +// throws TCException { +// +// TCUserService userservice = session.getUserService(); +// +// Object[] obj = new Object[3]; +// obj[0] = process; +// obj[1] = processUser; +// obj[2] = arctic; +// userservice.call("DMU_Review_Process", obj); +// } +// +// /** +// * 指派适应性改型流程负责人 +// * +// * @param session session +// * @param process 流程对象 +// * @param processUser 节点负责人 +// * @param arctic 车型 +// * @throws TCException +// */ +// public static void setRemodelProcess(TCSession session, TCComponentProcess process, String processUser, +// String arctic) throws TCException { +// +// TCUserService userservice = session.getUserService(); +// +// Object[] obj = new Object[3]; +// obj[0] = process; +// obj[1] = processUser; +// obj[2] = arctic; +// userservice.call("Create_Remodel_Process", obj); +// } +// +// /** +// * 获取单值得首选项 +// * +// * @param prefName +// * @return +// */ +// public static String getPrefStr(String prefName) { +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) app.getSession(); +// TCPreferenceService service = session.getPreferenceService(); +// String str = service.getString(TCPreferenceService.TC_preference_site, prefName); +// if (str == null) { +// str = new String(""); +// } +// return str; +// } +// +// /*** +// * 获取首选项 +// * +// * @param session 会话 +// * @param preferenceName 首选项名称 +// * @return +// */ +// public static String[] getPreferenceValues(String preferenceName) { +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) app.getSession(); +// if (preferenceName == null || session == null) { +// System.out.println(""); +// return null; +// } +// String[] values = null; +// TCPreferenceService service = session.getPreferenceService(); +// values = service.getStringArray(TCPreferenceService.TC_preference_site, preferenceName); +// String[] resultValues = new String[values.length]; +// for (int i = 0; i < values.length; i++) { +// if (values[i].indexOf("\\n") >= 0) { +// resultValues[i] = values[i].replace("\\n", "\n"); +// } else { +// resultValues[i] = values[i]; +// } +// } +// return resultValues; +// } +// +// /*** +// * 获取首选项 +// * +// * @param session 会话 +// * @param preferenceName 首选项名称 +// * @return +// */ +// public static String getPreferenceValue(String preferenceName) { +// AbstractAIFApplication app = AIFUtility.getCurrentApplication(); +// TCSession session = (TCSession) app.getSession(); +// if (preferenceName == null || session == null) { +// System.out.println(""); +// return null; +// } +// TCPreferenceService service = session.getPreferenceService(); +// return service.getString(TCPreferenceService.TC_preference_site, preferenceName); +// } +// +// public static void openByPass(TCSession session) throws TCException { +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[1]; +// obj[0] = "origin"; +// userservice.call("ORIGIN_set_bypass", obj); +// } +// +// public static void closeByPass(TCSession session) throws TCException { +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[1]; +// obj[0] = "origin"; +// userservice.call("ORIGIN_close_bypass", obj); +// } +// public static void setProperty(TCSession session,TCComponent[] items,String propname,String propvalue) throws TCException { +// TCUserService userservice = session.getUserService(); +// Object[] obj = new Object[3]; +// obj[0] = items; +// obj[1] = propname; +// obj[2] = propvalue; +// userservice.call("connor_set_prop_value", obj); +// } +// +// /*** +// * 发送对象到分类(通过webService) +// * +// * @param codeRemark 分类ID +// * @param rev 版本对象 +// * @param propList 分类属性 +// */ +//// public static void sendObjToClassficationByWebService(String codeRemark, TCComponentItemRevision rev, +//// List propList) { +//// try { +//// +//// if (!codeRemark.equals("") && rev != null) { +//// // TCComponentItemRevision rev = item.getLatestItemRevision(); +//// +////// List propList = new ArrayList<>(); +////// for (int i = 0; i < classPropList.size(); i++) { +////// // System.out.println(" CLASS ID = " + integers[i] + " =" + +////// // vals[i]); +////// CNClassPropBean bean = classPropList.get(i); +////// String value = ""; +////// if (bean.isLov) { +////// value = ((Combo) classTextList.get(i)).getText(); +////// value = bean.lovMapping.get(value); +////// } else { +////// value = ((Text) classTextList.get(i)).getText(); +////// } +////// // icspro[i] = new ICSProperty(bean.propID, value); +////// ClassProperty prop = new ClassProperty(bean.propID, value); +////// propList.add(prop); +////// } +//// System.out.println("111"); +//// SoaServerUtil so = new SoaServerUtil(); +//// String json = so.objectToJson(propList); +//// System.out.println("222"); +//// // so.grantWritePrivilege(session, rev); +//// so.sendToClass(rev.getUid(), codeRemark, json); +//// // so.grantReadPrivilege(session, rev); +//// System.out.println("333"); +//// } +//// +//// } catch (Exception e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } +//// +//// } +//// +//// /*** +//// * 将对象从分类中移除(通过webService) +//// * +//// * @param codeRemark 分类对象的UID +//// */ +//// public static void deleteObjToClassficationByWebService(String codeRemark) { +//// try { +//// +//// if (!codeRemark.equals("")) { +//// // TCComponentItemRevision rev = item.getLatestItemRevision(); +//// +////// List propList = new ArrayList<>(); +////// for (int i = 0; i < classPropList.size(); i++) { +////// // System.out.println(" CLASS ID = " + integers[i] + " =" + +////// // vals[i]); +////// CNClassPropBean bean = classPropList.get(i); +////// String value = ""; +////// if (bean.isLov) { +////// value = ((Combo) classTextList.get(i)).getText(); +////// value = bean.lovMapping.get(value); +////// } else { +////// value = ((Text) classTextList.get(i)).getText(); +////// } +////// // icspro[i] = new ICSProperty(bean.propID, value); +////// ClassProperty prop = new ClassProperty(bean.propID, value); +////// propList.add(prop); +////// } +//// System.out.println("111"); +//// SoaServerUtil so = new SoaServerUtil(); +//// System.out.println("222"); +//// // so.grantWritePrivilege(session, rev); +//// so.deleteToClass(codeRemark); +//// // so.grantReadPrivilege(session, rev); +//// System.out.println("333"); +//// } +//// +//// } catch (Exception e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } +//// +//// } +// +// /*** +// * @param matnr 物料号 +// * @param ddlx 订单类型 +// * @param type 流程中订单、历史订单、废弃订单 +// * @return 返回分类id +// */ +// public static String getClassficationId(String matnr, String ddlx, String type) { +// // String classId = "jlcs01010101"; +// String classId = ""; +// if (ddlx.equals("车身") || ddlx.equals("KD")) { +// String[] values = getPreferenceValues("JL_number_to_className"); +// String className = null; +// +// for (String s : values) { +// String[] split = s.split("="); +// if (split[0].equals(matnr)) { +// className = split[1]; +// break; +// } +// } +// String[] values2 = getPreferenceValues("JL_name_to_id"); +// // split[1]--历史,split[2]--流程 split[3]--废弃 +// for (String t : values2) { +// String[] split = t.split("="); +// if (split[0].equals(className)) { +// if (type.equals("历史订单")) { +// classId = split[1]; +// } else if (type.equals("流程中订单")) { +// classId = split[2]; +// } else if (type.equals("废弃订单")) { +// classId = split[3]; +// } +// } +// } +// } else if (ddlx.equals("配件")) { +// classId = "jlcs01010201"; +// String name = matnr.substring(0, 2) + "配件"; +// String[] values = getPreferenceValues("JL_name_to_id"); +// for (String t : values) { +// String[] split = t.split("="); +// if (split[0].equals(name)) { +// if (type.equals("历史订单")) { +// classId = split[1]; +// } else if (type.equals("流程中订单")) { +// classId = split[2]; +// } else if (type.equals("废弃订单")) { +// classId = split[3]; +// } +// } +// } +// } +// +// return classId; +// } +// +// /** +// * 获取分类属性LOV显示值 +// * +// * @param icsD +// * @return +// */ +// public static String getClassDisplayableValue(String value, ICSPropertyDescription icsD) { +// String result = ""; +// ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); +// if (lov1 != null) { +// String[] keys = lov1.getKeys(); +// for (String key : keys) { +// if (value.equals(key)) { +// result = lov1.getValueOfKey(key); +// return result; +// } +// } +// } +// return result; +// } +// +// public static boolean isDouble(String value) { +// try { +// Double.parseDouble(value); +// return true; +// } catch (Exception e) { +// // TODO: handle exception +// return false; +// } +// } +// +// /*** +// * 判断是否有权限 +// * +// * @param session session +// * @param value 首选项名称 +// * @param userId 用户ID +// * @return +// */ +// public static boolean havePrivilege(TCSession session, String commandName, String userId) { +// TCPreferenceService service = session.getPreferenceService(); +// +// String[] values = service.getStringArray(TCPreferenceService.TC_preference_site, "JL_User_Rights"); +// if (values == null || values.length == 0) { +// MessageBox.post("请配置首选项(管理权限)!请联系管理员", "错误", MessageBox.ERROR); +// return false; +// } +// for (String value : values) { +// // value = commandName + "——" + userId +// String[] split = value.split("——"); +// if (split[0].equals(commandName)) { +// if (split.length == 1) { +// return true; +// } else { +// if (split[1].indexOf(userId) >= 0) { +// return true; +// } else { +// return false; +// } +// } +// } +// } +// return false; +// } +// +// public static int getCount(String mainStr, String subStr) { +// int minLength = mainStr.length(); +// int subLength = subStr.length(); +// int count = 0; +// int index = 0; +// +// if (minLength >= subLength) { +// while ((index = mainStr.indexOf(subStr, index)) != -1) { +// count++; +// index += subLength; +// } +// return count; +// } +// return 0; +// } +// +// /** +// * 添加命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param fileName 数据集名称 +// * @param tcResource 文件的物理路径 +// * @param isDelete 是否删除文件 +// * @param isReplace 是否删除原因数据集 +// */ +// public static void setExcelToItem(TCSession session, TCComponentItemRevision item,String fileName, String tcResource, +// boolean isDelete,boolean isReplace) { +// try { +// String as1[] = { tcResource };// 文件的物理路径 +// String as2[] = { "excel" }; +// String as3[] = { "MSExcelX" }; +// String as4[] = { "Plain" }; +// TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session +// .getTypeComponent("Dataset"); +// TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", "MSExcelX"); +// tccomponentDataset.setFiles(as1, as3, as4, as2); +// //是否替換 +// if(isReplace) +// { +// AIFComponentContext[] zyzdsChildrens = item.getChildren(); +// TCComponentItemRevision zyzdsRev = item; +// for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { +// if ("MSExcelX".equals(zyzdsChildren.getComponent().getType())) { +// TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); +// zyzdsRev.remove("IMAN_specification", dateSet); +// dateSet.delete(); +// } +// } +// } +// item.add("IMAN_specification", tccomponentDataset); +// if (isDelete) { +// new File(tcResource).delete(); +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// public static Object getTCPropertyValue(TCComponent item,String propertyName) +// { +// Object result = ""; +// +// try { +// TCProperty tcProperty = item.getTCProperty(propertyName); +// if(tcProperty == null) +// { +// System.out.println("未获取属性:"+propertyName); +// return result; +// } +// switch (tcProperty.getPropertyType()) { +// case TCProperty.PROP_double: +// result = tcProperty.getDoubleValue(); +// break; +// case TCProperty.PROP_int: +// result = tcProperty.getIntValue(); +// break; +// case TCProperty.PROP_string: +// result = tcProperty.getStringValue(); +// break; +// case TCProperty.PROP_date: +// result = tcProperty.getDateValue(); +// break; +// default: +// break; +// } +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// +// return result; +// } +// public static void setTCPropertyValue(TCComponent item,String propertyName,Object value) +// { +// try { +// TCProperty tcProperty = item.getTCProperty(propertyName); +// switch (tcProperty.getPropertyType()) { +// case TCProperty.PROP_double: +// if(value instanceof Double) +// { +// tcProperty.setDoubleValue((double) value); +// } +// else +// { +// tcProperty.setDoubleValue(Double.parseDouble(value.toString())); +// } +// break; +// case TCProperty.PROP_int: +// if(value instanceof Integer) +// { +// tcProperty.setDoubleValue((int) value); +// } +// else +// { +// tcProperty.setDoubleValue(Integer.parseInt(value.toString())); +// } +// break; +// case TCProperty.PROP_string: +// tcProperty.setStringValue(value.toString()); +// break; +// case TCProperty.PROP_date: +// if(value instanceof Date) +// { +// tcProperty.setDateValue((Date) value); +// } +// else +// { +// SimpleDateFormat sdf=new SimpleDateFormat("yyyy-M-dd HH:mm"); +// tcProperty.setDateValue(sdf.parse(value.toString())); +// } +// break; +// default: +// break; +// } +// +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// /** +// * 获取选取的ITEM的目标的信息 +// * +// * @param itemList +// * @return +// */ +//// public static List getTargetsMsg( +//// List itemList) { +//// if (itemList == null) { +//// return null; +//// } +//// List beanList = new ArrayList<>(); +//// try { +//// TCProperty[][] props = TCComponentType.getTCPropertiesSet(itemList, +//// new String[] { "object_name", // 名称 +//// "object_type",// 类型 +//// "uom_tag",// 单位 +//// "item_id" }); +//// for (int i = 0; i < props.length; i++) { +//// +//// TCProperty[] prop = props[i]; +//// ItemBean bean = new ItemBean(); +//// bean.setItem(itemList.get(i)); +//// if (prop[0] != null) { +//// bean.setName(prop[0].getDisplayValue()); +//// } +//// bean.setFolder(getParentFolder(itemList.get(i), bean.getName())); +//// if (prop[1] != null) { +//// bean.setTypeDis(prop[1].getDisplayValue()); +//// bean.setType(itemList.get(i).getType()); +//// } +//// if (prop[2] != null) { +//// bean.setUnit(prop[2].getDisplayableValue()); +//// bean.setUnitDis(prop[2].getDisplayValue()); +//// } +//// if (prop[3] != null) { +//// // bean.setUnit(prop[2].getDisplayableValue()); +//// bean.setItemID(prop[3].getDisplayValue()); +//// } +//// beanList.add(bean); +//// } +//// } catch (TCException e) { +//// e.printStackTrace(); +//// } +//// return beanList; +//// } +// +// /** +// * 获取存放的文件夹 +// * +// * @param item +// * @param name +// * @return +// */ +// public static TCComponentFolder getParentFolder(TCComponentItem item, +// String name) { +// TCComponentFolder folder = null; +// try { +// AIFComponentContext[] comtexts = item.whereReferenced(); +// if (comtexts != null) { +// for (int i = 0; i < comtexts.length; i++) { +// if (comtexts[i].getComponent() instanceof TCComponentFolder) { +// String nameT = ((TCComponentFolder) comtexts[i] +// .getComponent()) +// .getStringProperty("object_name"); +// if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { +// folder = (TCComponentFolder) comtexts[i] +// .getComponent(); +// } +// else if(nameT.equals(name)) +// { +// folder = (TCComponentFolder) comtexts[i] +// .getComponent(); +// } +// } +// } +// } +// } catch (TCException e) { +// e.printStackTrace(); +// } +// return folder; +// } +// +// /** +// * 过滤掉所有不需要显示的属性的 +// * +// * @param session +// * @return +// */ +//// public static List getExplictPropList(TCSession session) { +//// List beanList = new ArrayList<>(); +//// TCPreferenceService service = session.getPreferenceService(); +//// String[] values = service.getStringArray( +//// TCPreferenceService.TC_preference_site, +//// "Cust_prop_explict_mapping"); +//// if (values != null) { +//// for (int i = 0; i < values.length; i++) { +//// String[] types = values[i].split("\\|"); +//// if (types.length != 2) { +//// continue; +//// } +//// String[] props = types[1].split("\\;"); +//// if (props.length == 0) { +//// continue; +//// } +//// List list = new ArrayList<>(); +//// for (String str : props) { +//// list.add(str); +//// } +//// PropExplictBean bean = new PropExplictBean(); +//// bean.setType(types[0]); +//// bean.setPropList(list); +//// beanList.add(bean); +//// } +//// } +//// +//// return beanList; +//// } +// +// /** +// * 通过SOA创建ITEM对象 +// * +// * @param session +// * 会话 +// * @param itemID +// * 创建对象的ID +// * @param itemRev +// * 创建对象的版本 +// * @param itemType +// * 创建对象的类型 +// * @param itemName +// * 创建对象的名称 +// * @param itemDesc +// * 创建对象的描述 +// * @param unit +// * 创建对象的单位 +// * @param itemPropMap +// * 创建对象的ITEM属性 +// * @param itemRevPropMap +// * 创建对象的版本属性 +// * @param itemRevMasterPropMap +// * 创建对象的版本表单属性 +// */ +// public static TCComponentItem createNewItemSoa(TCSession session, +// String itemID, String itemRev, String itemType, String itemName, +// String itemDesc, String unit, Map itemPropMap, +// Map itemRevPropMap, +// Map itemRevMasterPropMap) { +// TCComponentItem newComp = null; +// try { +// DataManagementService datamanagementservice = DataManagementService +// .getService(session); +// com.teamcenter.services.rac.core._2006_03.DataManagement.CreateItemsResponse createitemsresponse = null; +// // 设置创建对象的主要属性 +// com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties aitemproperties[] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties[1]; +// aitemproperties[0] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties(); +// aitemproperties[0].clientId = Integer.toString(1); +// aitemproperties[0].description = itemDesc; +// aitemproperties[0].itemId = itemID; +// aitemproperties[0].name = itemName; +// aitemproperties[0].revId = itemRev; +// aitemproperties[0].type = itemType; +// aitemproperties[0].uom = unit;// == null ? "" : uomComp.toString(); +// // 设置扩展属性 +// // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes +// // extendedattributes[] = new +// // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[3]; +// ArrayList list = new ArrayList(); +// // 设置item对象的扩展属性 +// if (itemPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.RevisionIds revids = null; +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesItem.objectType = itemType; +// extendedattributesItem.attributes = itemPropMap; +// list.add(extendedattributesItem); +// } +// // 设置REV的扩展属性 +// if (itemRevPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRev.objectType = itemType + "Revision"; +// extendedattributesRev.attributes = itemRevPropMap; +// list.add(extendedattributesRev); +// } +// // 设置REVMASTER的扩展属性 +// if (itemRevMasterPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRevMaster.objectType = itemType +// + "RevisionMaster"; +// extendedattributesRevMaster.attributes = itemRevMasterPropMap; +// list.add(extendedattributesRevMaster); +// } +// // 添加扩展属性 +// if (list.size() != 0) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributes[] = null; +// extendedattributes = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[list +// .size()]; +// for (int i = 0; i < list.size(); i++) { +// extendedattributes[i] = list.get(i); +// } +// aitemproperties[0].extendedAttributes = extendedattributes; +// } +// TCComponent tccomponent1 = null; +// String s1 = ""; +// createitemsresponse = datamanagementservice.createItems( +// aitemproperties, tccomponent1, s1); +// if (createitemsresponse.serviceData.sizeOfPartialErrors() == 0) { +// newComp = createitemsresponse.output[0].item; +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// System.out.println("创建对象[item_id= " + itemID + " / rev =" + itemRev +// + " / name= " + itemName + "]失败"); +// } +// return newComp; +// } +// +// /** +// * 获取模板文件 +// * @param session session +// * @param fileName 文件名 +// * @param Filetype 文件类型 +// * @return +// */ +// public static File getFile(TCSession session,String fileName,String Filetype) { +// // TODO Auto-generated method stub +// try { +// TCPreferenceService service = session.getPreferenceService(); +// String[] modelFiles = service.getStringValues("ML_Doc_Teamplate"); +// if (modelFiles == null) +// { +// System.out.println("未找到首选项"); +// return null; +// } +// String puid = ""; +// String item_id=""; +// for (int i = 0; i < modelFiles.length; i++) { +// if(modelFiles[i].split(":")[0].equals(fileName)) +// { +// item_id = modelFiles[i].split(":")[1]; +// } +// } +// //通过item的id来找item对象 +// puid =((TCComponentItemType)(session.getTypeComponent("Item"))).find(item_id).getUid(); +// TCComponentItem fileItem = (TCComponentItem)session +// .stringToComponent(puid); +// TCComponentDataset dat = null; +// TCComponentItemRevision fileItemLastRev = getLastItemRevision(fileItem); +// TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); +// System.out.println("count =" + comps == null ? "null" +// : comps.length); +// // 遍历TC_Attaches关系下的所有对象 +// for (TCComponent compt : comps) { +// // 获取对象类型 +// String type = compt.getType(); +// System.out.println(" TYPE = " + type); +// // 判断类型 +// if (type.equals(type)) { +// dat = (TCComponentDataset)compt; +// } +// } +// TCComponentTcFile[] tcFile = dat.getTcFiles(); +// if(tcFile != null && tcFile.length == 0) +// { +// System.out.println("未找到配置文件"); +// } +// else +// { +// return tcFile[0].getFmsFile(); +// } +// } catch (Exception e) { +// // TODO: handle exception +// e.printStackTrace(); +// } +// return null; +// } +// //复制图片 +// public static void CopyPic(File path1,String path2) { +// // 创建文件字节输入流对象 +// FileInputStream fis = null; +// // 创建文件字节输出流对象 +// FileOutputStream fos = null; +// try { +// // 连接文件字节输入流 +// fis = new FileInputStream(path1); +// // 连接文件字节输出流 +// fos = new FileOutputStream(path2); +// //准备一个byte[]数组,存储字节码,大小为1024字节,即1KB +// byte[] bytes = new byte[1024]; +// int readCount = 0; +// // 开始读和写 +// while ((readCount = fis.read(bytes)) != -1) { +// // 将数组中读到的字节码写入 +// fos.write(bytes, 0, readCount); +// } +// // 最后刷新管道,强制输出完数据 +// fos.flush(); +// +// } catch (FileNotFoundException e) { +// e.printStackTrace(); +// } catch (IOException e) { +// e.printStackTrace(); +// } finally { +// if (fis != null) { +// try { +// fis.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// if (fos != null) { +// try { +// fos.close(); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// } +// } +// } +// +// /** +// * 获取命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param relationType 关系名称 +// */ +// public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, +// String fileType,String name) { +// try { +// TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); +// if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { +// return null; +// } +// for (TCComponent zyzdsChildren : zyzdsChildrens) { +// if (fileType.equals(zyzdsChildren.getType())&&name.equals(zyzdsChildren.getStringProperty("object_name"))) { +// TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * 获取需要的数据集 +// * +// * @param session +// * @param item 对象的版本 +// * @param relationType 关系名称 +// */ +// public static File getExcelDateSet(TCSession session, TCComponentItemRevision item, String relationType, +// String fileType,String targetName) { +// try { +// TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); +// if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { +// return null; +// } +// for (TCComponent zyzdsChildren : zyzdsChildrens) { +// if (fileType.equals(zyzdsChildren.getType())&&zyzdsChildren.getStringProperty("object_name").equals(targetName)) { +// TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// +// +// /** +// * 添加命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param tcResource 文件的物理路径 +// * @param relationType 关系名称 +// * @param fileName 文件名 +// */ +// public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, +// String fileName, String relationType, String excelType, boolean isDelete) { +// try { +// String as1[] = { tcResource };// 文件的物理路径 +// String as2[] = { "excel" }; +// String as3[] = { excelType }; +// String as4[] = { "Plain" }; +// TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session +// .getTypeComponent("Dataset"); +// TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); +// tccomponentDataset.setFiles(as1, as3, as4, as2); +// AIFComponentContext[] zyzdsChildrens = item.getChildren(); +// TCComponentItemRevision zyzdsRev = item; +// for (AIFComponentContext zyzdsChildren : zyzdsChildrens) {// +// if (excelType.equals(zyzdsChildren.getComponent().getType())) { +// TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); +// if (dateSet.getStringProperty("object_name").equals(fileName)) { +// dateSet.delete(); +// zyzdsRev.remove(relationType, dateSet); +// } +// } +// } +// item.add(relationType, tccomponentDataset); +// if (isDelete) { +// new File(tcResource).delete(); +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } +// +// /** +// * 获取命名的引用 +// * +// * @param session +// * @param item 对象的版本 +// * @param relationType 关系名称 +// */ +// public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, +// String relationType, String fileType,String name) { +// try { +// TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); +// if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { +// return null; +// } +// for (TCComponent zyzdsChildren : zyzdsChildrens) { +// if (fileType.equals(zyzdsChildren.getType())&&name.equals(zyzdsChildren.getStringProperty("object_name"))) { +// return (TCComponentDataset) zyzdsChildren; +//// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +//// return tcFile[0].getFmsFile(); +// } +// } +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// return null; +// } +// +// /** +// * 改变数据集的命名引用 +// * +// * @param tccomponentDataset +// * @param quote +// * @param type +// * @param path +// * @throws TCException +// */ +// public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) +// throws TCException { +// String myPath[] = { path }; +// String myQuote[] = { quote };// 引用"excel" +// String myType[] = { type };// 类型"MSExcelX" +// String myPlain[] = { "Plain" }; +// +// // 删除数据集的引用 +// deleDateSetRef(tccomponentDataset);//删除数据集里面的内容 +// // 数据集的替换 +// tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote);//将新内容添加到数据集 +// +// } +// +// /** +// * 删除数据集的命名引用 +// * +// * @param dataset +// * @throws TCException +// */ +// private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { +// +// TCComponentTcFile[] tcFiles = dataset.getTcFiles(); +// for (int i = 0; i < tcFiles.length; i++) { +// // 得到数据集的引用类型 +// String str_temp = getNamedRefType(dataset, tcFiles[i]); +// // 删除引用 +// dataset.removeNamedReference(str_temp); +// } +// +// } +// +// /** +// * 得到数据集的引用类型 +// * +// * @param datasetComponent +// * @param tccomponent +// * @return +// * @throws TCException +// */ +// private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) +// throws TCException { +// String s; +// s = ""; +// TCProperty tcproperty; +// TCProperty tcproperty1; +// TCComponent atccomponent[]; +// String as[]; +// int i; +// int j; +// int k; +// try { +// tcproperty = datasetComponent.getTCProperty("ref_list"); +// tcproperty1 = datasetComponent.getTCProperty("ref_names"); +// if (tcproperty == null || tcproperty1 == null) +// return s; +// } catch (TCException tcexception) { +// return s; +// } +// atccomponent = tcproperty.getReferenceValueArray(); +// as = tcproperty1.getStringValueArray(); +// if (atccomponent == null || as == null) +// return s; +// i = atccomponent.length; +// if (i != as.length) +// return s; +// j = -1; +// k = 0; +// do { +// if (k >= i) +// break; +// if (tccomponent == atccomponent[k]) { +// j = k; +// break; +// } +// k++; +// } while (true); +// if (j != -1) +// s = as[j]; +// return s; +// } +// +// public static String sendPost(String url, String data) { +// String response = null; +// +// try { +// CloseableHttpClient httpclient = null; +// CloseableHttpResponse httpresponse = null; +// try { +// httpclient = HttpClients.createDefault(); +// HttpPost httppost = new HttpPost(url); +// StringEntity stringentity = new StringEntity(data, "UTF-8"); +// httppost.setHeader("Content-type", "application/json"); +// httppost.setEntity(stringentity); +// httpresponse = httpclient.execute(httppost); +// response = EntityUtils.toString(httpresponse.getEntity()); +// } finally { +// if (httpclient != null) { +// httpclient.close(); +// } +// if (httpresponse != null) { +// httpresponse.close(); +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// return response; +// } +// +// public static void CreateProcess(TCSession session,TCComponent target,String processName) throws TCException { +// try { +// TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); +// TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate"); +// TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); +// if (taskTemplate == null) { +// return; +// } +// // 创建一个流程 流程名称、描述、流程模板、目标对象、附件数 +// String name = target.getProperty("object_string"); +// processType.create(processName + ":" + name, "", taskTemplate, new TCComponent[] { target }, new int[] { 1 }); +// } catch (TCException e) { +// e.printStackTrace(); +// throw e; +// } +// } +// +//// public static void sendObjToClassficationByWebService(TCComponentItem item,String classId) { +//// try { +//// +//// if (!classId.replace(" ", "").equals("") && item != null) { +//// TCComponentItemRevision rev = item.getLatestItemRevision(); +//// +//// SoaServerUtil.sendToClass(rev.getUid(), classId, ""); +//// } +//// +//// } catch (TCException e) { +//// // TODO Auto-generated catch block +//// e.printStackTrace(); +//// } +//// +//// } +//} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/Tree02.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/Tree02.java new file mode 100644 index 0000000..febbdd6 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/Tree02.java @@ -0,0 +1,64 @@ +package com.connor.ml.tcm.metarialChange; + +import java.util.ArrayList; +import java.util.List; + +public class Tree02 { + private String ProductCode;//产品代号 + private String ProductType;//产品型号 + private String ItemID;//工序编号 + private String Name;//工序名称 + private String Time;//标准时间 + private List> WorkStep=new ArrayList>();//工步 + private List> Material=new ArrayList>();//物料 + private List> Frock=new ArrayList>();//工装 + + public void setProductCode(String ProductCode) { + this.ProductCode=ProductCode; + } + public String getProductCode() { + return this.ProductCode; + } + public void setProductType(String ProductType) { + this.ProductType=ProductType; + } + public String getProductType() { + return this.ProductType; + } + public void setItemID(String ItemID) { + this.ItemID=ItemID; + } + public String getItemID() { + return this.ItemID; + } + public void setName(String Name) { + this.Name=Name; + } + public String getName() { + return this.Name; + } + public void setTime(String Time) { + this.Time=Time; + } + public String getTime() { + return this.Time; + } + public void setMaterial(List> Material) { + this.Material=Material; + } + public List> getMaterial() { + return this.Material; + } + public void setFrock(List> Frock) { + this.Frock=Frock; + } + public List> getFrock() { + return this.Frock; + } + public void setWorkStep(List> WorkStep) { + this.WorkStep=WorkStep; + } + public List> getWorkStep() { + return this.WorkStep; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/test.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/test.java new file mode 100644 index 0000000..b9bdd49 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/metarialChange/test.java @@ -0,0 +1,259 @@ +package com.connor.ml.tcm.metarialChange; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.RowSorter; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.connor.ml.tcm.metarialChange.MaterialChangeCommand.SelectPropDialog; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.classification.icadmin.InterfaceICAdminUI; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.util.PropertyLayout; + +public class test { + + public static void main(String[] args) { + JFrame dialog=new JFrame(); +// dialog.setExtendedState(JFrame.ICONIFIED); + dialog.setTitle("属性同步更改"); + dialog.setLayout(new BorderLayout()); + dialog.setPreferredSize(new Dimension(400,150)); + JPanel jPanel=new JPanel(); + jPanel.setPreferredSize(new Dimension(300,100)); +// TCPreferenceService service = session.getPreferenceService(); +// String[] values = service.getStringValues("ML_PropertyChange"); + Map propMap=new HashMap(); + JComboBox comboBox=new JComboBox(); +// for(String value:values) { +// String[] split = value.split("-"); +// if(true || split[0].equals(selectedRev.getType())) { +// +// String[] split2 = split[1].split(";"); +// +// for(String props:split2) { +// String[] split3 = props.split(":"); +// propMap.put(split3[0], split3[1]); +// comboBox.addItem(split3[0]); +// } +// +// break; +// } +// } +// changeProp=(String)comboBox.getSelectedItem(); + jPanel.add(new JLabel("选择属性")); + jPanel.add(comboBox); + comboBox.addItem("操作说明"); + JPanel nouthPanel=new JPanel(); + JButton okBtn=new JButton("确认"); + JButton disBtn=new JButton("取消"); + disBtn.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + dialog.dispose(); + } + }); +// okBtn.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// String selectedItem = (String) comboBox.getSelectedItem(); +// changeProp = propMap.get(selectedItem); +// MaterialChangeOperation operation=new MaterialChangeOperation(changeProp,revMapRight,session,gyggId,SelectPropDialog.dialog); +// try { +// operation.executeOperation(); +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +//// dispose(); +// } +// }); + nouthPanel.add(okBtn);nouthPanel.add(disBtn); + dialog.add(jPanel,BorderLayout.CENTER); + dialog.add(nouthPanel,BorderLayout.SOUTH); + + dialog.setAlwaysOnTop(true); + + dialog.pack(); +// dialog.validate(); +// dialog.centerToScreen(); + dialog.setVisible(true); + + + +// String[][] dataValues; +// List> dataTableList= new ArrayList>(); +// for(int i=0;i<4;i++) { +// +// List aList=new ArrayList(); +// aList.add(String.valueOf(i+1)); +// aList.add("item_id"+String.valueOf(i)); +// aList.add("item_revision_id"+String.valueOf(i)); +// +// aList.add("object_desc"+String.valueOf(i)); +// +// dataTableList.add(aList); +// } +// String[] columnNamesLeft = new String[] { "序号", "ID", "版本", "操作内容"}; +// String[] columnNamesRight = new String[] { "序号", "ID", "当前版本", "名称", "发布状态", "同步状态", "创建者", "更改单号"}; +// +// dataValues = new String[dataTableList.size()][]; +// for (int i = 0; i < dataTableList.size(); i++) { +// dataValues[i] = new String[dataTableList.get(i).size()]; +// for (int j = 0; j < dataTableList.get(i).size(); j++) { +// dataValues[i][j] = dataTableList.get(i).get(j); +// } +// } +// JDialog dialog=new JDialog(); +// JTable getjTable = getjTable(null, null, columnNamesLeft, dataValues); +// +// JScrollPane jscrollpane = new JScrollPane(getjTable); +// jscrollpane.setPreferredSize(new Dimension(400,300)); +// +// JPanel jPanelLeft=new JPanel(); +// jPanelLeft.setPreferredSize(new Dimension(400,300)); +// jPanelLeft.add(jscrollpane); +// +// +// dialog.setLayout(new BorderLayout()); +// +// dialog.setPreferredSize(new Dimension(1320,600)); +// +// JPanel panelCenter=new JPanel(); +// panelCenter.setPreferredSize(new Dimension(100,300)); +// +// panelCenter.add( new Label("影响分析")); +// panelCenter.add( new Label("》》》》》》")); +// JButton jButton=new JButton("属性同步"); +// panelCenter.add(jButton); +// jButton.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +//// SelectPropDialog dialog=new SelectPropDialog(); +// } +// }); +// +// +// JPanel panelN=new JPanel(); +// JButton closeBtn =new JButton("取消"); +// panelN.add(closeBtn); +// closeBtn.addActionListener(new ActionListener() { +// +// @Override +// public void actionPerformed(ActionEvent e) { +// // TODO Auto-generated method stub +// dialog.dispose(); +// } +// }); +// +// getjTable.addMouseListener(new MouseAdapter() { +// @Override +// public void mouseClicked(MouseEvent mouseevent) { +// // TODO Auto-generated method stub +// if (mouseevent.getClickCount() ==1) { +// int selectedRow = getjTable.getSelectedRow(); +// DefaultTableModel model =(DefaultTableModel)getjTable.getModel(); +// String itemID =(String) model.getValueAt(selectedRow, 1); +// System.out.println(selectedRow+itemID); +// } +// } +// }); +// +// +// JTable tabelRight = getjTable(null, null, columnNamesRight, null); +// +// JScrollPane jscrollpaneRight = new JScrollPane(tabelRight); +// jscrollpaneRight.setPreferredSize(new Dimension(800,300)); +// +// JPanel jPanelRight=new JPanel(); +// jPanelRight.setPreferredSize(new Dimension(800,300)); +// jPanelRight.add(jscrollpaneRight); +// +// +// dialog.add(panelCenter,BorderLayout.CENTER); +// dialog.add(jPanelLeft,BorderLayout.WEST); +// dialog.add(jPanelRight,BorderLayout.EAST); +// dialog.add(panelN,BorderLayout.SOUTH); +// dialog.setAlwaysOnTop(true); +// dialog.pack(); +// dialog.validate(); +//// designPanel.centerToScreen(); +// dialog.setVisible(true); + } + public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width) { newRow(panel, comp, s, width, 0.0D); } + /* */ + /* */ + /* */ public static void newRow(JPanel panel, Component comp, GridBagConstraints s, int width, double weightx) { + /* 555 */ s.weightx = weightx; + /* 556 */ s.gridwidth = width; + /* 557 */ s.gridx = 0; + /* 558 */ s.gridy++; + /* 559 */ panel.add(comp, s); + /* */ } + public static DefaultTableModel getTableModel(DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + DefaultTableModel tableModel = null; + if (dtm == null) { + tableModel = new DefaultTableModel(values, titleNames) { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + } + + return tableModel; + } + + + public static JTable getjTable(JTable partsTable, DefaultTableModel dtm, Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1000; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)); + partsTable.setRowHeight(20); + RowSorter sorter = new TableRowSorter(partsTable.getModel()); + partsTable.setRowSorter(sorter); + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/Activator.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/Activator.java new file mode 100644 index 0000000..95c6b6a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/Activator.java @@ -0,0 +1,44 @@ +package com.connor.ml.tcm.outfile; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "com.connor.ml"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomCommand.java new file mode 100644 index 0000000..6338585 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomCommand.java @@ -0,0 +1,245 @@ +package com.connor.ml.tcm.outfile.ML_01; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DbomTransitionToEbomCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine bomLine = null; + + public DbomTransitionToEbomCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub +// TCComponentType compType = session.getTypeComponent("ML8_Washing"); +// String[] allProperties=compType.getPropertyNames();//获取类所有属性 + //TCProperty[] allProperties=compType.getPropertyNames();//获取类所有属性 + + //获取选中的对象 + if(!(comp instanceof TCComponentBOMLine)) + { + MessageBox.post("请在结构管理器中选中BOMLine对象!", "错误", MessageBox.ERROR); + return; + } + //System.out.println("11111111111"); + bomLine = (TCComponentBOMLine) comp; + + //判断对象类型 + TCComponentItem item = bomLine.getItem(); + System.out.println(item.getType()); +// if(!item.getType().equals("ML8_Design")) +// { +// MessageBox.post("请选中设计对象!", "错误", MessageBox.ERROR); +// return; +// } + //final List> bomPropertyList = this.getBomPropertys(session, bomLine); + + final DefaultMutableTreeTableNode node = this.getBomPropertyToNode(session, bomLine); + + + new Thread() { + @Override + public void run() { + DbomTransitionToEbomDialog dialog = new DbomTransitionToEbomDialog( + comp, session,node); + } + }.start(); + super.executeModal(); + } + + /** + * 获取BOM属性 + * @throws TCException + */ + public static DefaultMutableTreeTableNode getBomPropertyToNode(TCSession session, TCComponentBOMLine topBomLine) throws TCException { + // TODO Auto-generated method stub + + NodeBean nodeBean = new NodeBean(); + + //String ss = subline.getStringProperty("bl_indented_title"); + //对象ID + nodeBean.setDbom("顶层"); + nodeBean.setEbom(""); + nodeBean.setEbomId(""); + nodeBean.setNum(""); + nodeBean.setLabel(""); + nodeBean.setRefreshStatus(""); + nodeBean.setParentString(""); + + DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode(nodeBean); + //获取BOM + try { + //getRepresentationPropertysToNode(topBomLine, rootNode, ""); + getBomPropertysToNode(topBomLine, rootNode, ""); + return rootNode; + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + /*** + * 获取表示下的对象 + * @param bomLine + * @param rootNode + * @param parentID + * @throws TCException + */ + public static void getRepresentationPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID,String quantity) throws TCException + { + TCComponentItemRevision itemRevision = bomLine.getItemRevision(); + + //获取表示关系下的对象 + TCComponent[] tcComponents = itemRevision.getReferenceListProperty("representation_for"); + for (TCComponent tcComponent : tcComponents) { + + TCProperty refreshStatusProperty = tcComponent.getTCProperty("release_status_list"); + TCComponent[] refreshStatus = refreshStatusProperty.getReferenceValueArray(); + TCProperty processProperty = tcComponent.getTCProperty("process_stage_list"); + TCComponent[] processStage = processProperty.getReferenceValueArray(); + + NodeBean nodeBean = new NodeBean(); + + nodeBean.setDbom(""); + nodeBean.setEbom(tcComponent.getStringProperty("object_string")); + nodeBean.setEbomId(tcComponent.getStringProperty("item_id")); + nodeBean.setEbomDesc(tcComponent.getStringProperty("ml8_StdDesc")); + nodeBean.setNum(quantity); + nodeBean.setLabel("0"); + if(refreshStatus.length > 0) + { + StringBuffer stringBuffer = new StringBuffer(); + //添加发布状态 + for (int i = 0; i < refreshStatus.length; i++) { + stringBuffer.append(refreshStatus[i].toString()); + if(i < refreshStatus.length - 1) + { + stringBuffer.append(","); + } + } + nodeBean.setRefreshStatus(stringBuffer.toString()); + } + else if(processStage.length > 0) + { + nodeBean.setRefreshStatus("流程中"); + } + else + { + nodeBean.setRefreshStatus(""); + } + nodeBean.setParentString(itemRevision.getStringProperty("object_string")); + + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean); + rootNode.add(node); + + if(tcComponents.length == 1) + { + if(getTopRefresh(node)) + { + nodeBean.setLabel("0"); + } + else + { + nodeBean.setLabel("1"); + } + } + } + } + /*** + * 判断上级是否勾选已发布对象 + * @param node + * @return + */ + private static boolean getTopRefresh(DefaultMutableTreeTableNode node) + { + boolean result = false; + + //判断上层是否勾选已发布的对象 + DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent(); + if(parentNode != null) + { + DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent(); + if(rootNode != null) + { + for (int i = 0; i < rootNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1") && childBean.getRefreshStatus().indexOf("发布") >= 0) + { + //MessageBox.post("上层["+childBean.getEbom()+"]已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR); + return true; + } + else + { + return getTopRefresh(childNode); + } + } + } + } + + return result; + } + + + /** + * 获取BOM信息 + * @param bomLine + * @param bomPropertyList + * @param parentID + */ + public static void getBomPropertysToNode(TCComponentBOMLine bomLine, DefaultMutableTreeTableNode rootNode,String parentID) + { + try { + + NodeBean nodeBean = new NodeBean(); + + nodeBean.setDbom(bomLine.getStringProperty("bl_item_object_string")); + nodeBean.setNum(bomLine.getStringProperty("bl_quantity")); + nodeBean.setEbom(""); + nodeBean.setEbomId(""); + nodeBean.setLabel(""); + nodeBean.setRefreshStatus(""); + nodeBean.setParentString(""); + + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(nodeBean); + rootNode.add(node); + + + getRepresentationPropertysToNode(bomLine, node,bomLine.getStringProperty("bl_item_item_id"),bomLine.getStringProperty("bl_quantity")); + + if(bomLine.getChildren().length > 0) + { + AIFComponentContext aif[] = bomLine.getChildren(); + for (int i = 0; i < aif.length; i++) + { + TCComponentBOMLine subline = (TCComponentBOMLine) aif[i] + .getComponent(); + + getBomPropertysToNode(subline, node,bomLine.getStringProperty("bl_item_item_id")); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomDialog.java new file mode 100644 index 0000000..60951ea --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomDialog.java @@ -0,0 +1,658 @@ +package com.connor.ml.tcm.outfile.ML_01; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.TreePath; + +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.Adapter; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.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.soa.exceptions.NotLoadedException; + +public class DbomTransitionToEbomDialog extends AbstractAIFDialog implements +ActionListener, MouseListener { + + private TCSession session; + private InterfaceAIFComponent comp; + //private InterfaceAIFComponent comp;//获取选中的对象 + + private List isNotEditableRow = new ArrayList(); + //private TCComponentBOMLine bomLine; + private DefaultMutableTreeTableNode node; + + private String[] header = new String[] { "DBOM对象", "EBOM对象","选中", "EBOMID", "物料描述","数量","发布状态","对应父节点"}; + + private JPanel titlePanel; + private JLabel titleLabel; + private JTreeTable table; + private JTreeTableModel map; + + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + private JButton refreshButton; + + + public DbomTransitionToEbomDialog(InterfaceAIFComponent comp,TCSession session, + DefaultMutableTreeTableNode node) { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.node = node; + + init(); + } + + private void init() { + // TODO Auto-generated method stub + this.setTitle("DBOM转EBOM"); + this.setPreferredSize(new Dimension(800,600)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("DBOM转EBOM"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + JPanel panel = new JPanel(); + panel.add(this.titlePanel,BorderLayout.NORTH); + + this.table = getJTreeTable(null, null, header, null); + + this.table.addMouseListener(this); + Adapter adapter = new Adapter(table); + + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("确认"); + this.celButton = new JButton("取消"); + this.refreshButton = new JButton("刷新"); + + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + this.rootPanel.add(refreshButton); + //this.rootPanel.add(celValueButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + // this.add(centerPanel, BorderLayout.NORTH); + this.add(panel, BorderLayout.NORTH); + this.add(new JScrollPane(this.table), BorderLayout.CENTER); + // dialog.add(tablePanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + //this.setAlwaysOnTop(true); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + + //添加监听 + public void createActionEvent() { + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + this.refreshButton.addActionListener(this); + //this.celValueButton.addActionListener(this); + } + + //Jtable通用方法 + public JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 100; + int totleLen = 1500; + if (partsTable == null) { + this.map = new JTreeTableModel(this.node); + this.map.setIsNotEditableRow(this.isNotEditableRow); + //map.setColumnIdentifiers(titleNames); + + partsTable = new JTreeTable(map); + partsTable.setIsNotEditableRow(this.isNotEditableRow); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + // partsTable.setRowHeight(1, 50); + // partsTable.setRowHeight(2, 100); + partsTable.setRowHeight(30); + partsTable.expandAll(); // 展开全部节点 + // 隐藏列 +// partsTable.HiddenCell(0); + + partsTable.getColumnModel().getColumn(0).setPreferredWidth(188); // 设置第一列宽度 + partsTable.getColumnModel().getColumn(1).setPreferredWidth(150); // 设置第二列宽度 + partsTable.getColumnModel().getColumn(2).setPreferredWidth(55); // 设置第三列宽度 + + partsTable.setHighlighters(HighlighterFactory.createSimpleStriping()); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + @Override + public void mouseClicked(MouseEvent e) { + // TODO Auto-generated method stub + if(e.getClickCount() == 2) + { + TreePath treePath = table.getPathForLocation(e.getX(),e.getY()); + if (treePath != null) { + DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent(); + NodeBean nodeBean = (NodeBean) node.getUserObject(); + String itemId = nodeBean.getDbom(); + if(itemId != null && !itemId.isEmpty()) + { + try { + //获取对象 + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent("Item"); + TCComponentItem item = itemType.find(itemId.split("-")[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[] { item }); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + } + } + else if (e.getClickCount() > 0) + { + // 获得选中列 + int selectColumn = table.getTableHeader().columnAtPoint(e.getPoint()); + + if(selectColumn != 2) + { + return; + } + + TreePath treePath = table.getPathForLocation(e.getX(),e.getY()); + if (treePath != null) { + DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) treePath.getLastPathComponent(); + NodeBean nodeBean = (NodeBean) node.getUserObject(); + + if(getTopRefresh(node)) + { + MessageBox.post("上层已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR); + return; + } + + if(getTopProcessRefresh(node)) + { + MessageBox.post("上层已勾选流程中的对象,下层不允许勾选!", "错误", MessageBox.ERROR); + return; + } + + DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent(); + if(parentNode != null) + { + DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent(); + NodeBean rootNodeBean = (NodeBean) rootNode.getUserObject(); + + + if(!rootNodeBean.getDbom().equals("顶层") && !getTop(node) && nodeBean.getLabel().equals("0")) + { + MessageBox.post("上层未勾选对象,下层不允许勾选!", "错误", MessageBox.ERROR); + return; + } + } + + + try { + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + + if(nodeBean.getLabel().equals("0")) + { + //判断同一层是否已勾选 + if(parentNode != null) + { + for (int i = 0; i < parentNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) parentNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1")) + { + MessageBox.post("同一层级只允许选中一个!", "错误", MessageBox.ERROR); + return; + } + } + + } + + nodeBean.setLabel("1"); + isHaveBom(node, nodeBean.getEbomId(), "1", itemType); + } + else if(nodeBean.getLabel().equals("1")) + { + nodeBean.setLabel("0"); + isHaveBom(node, nodeBean.getEbomId(), "0", itemType); + } + Robot robot = new Robot(); + robot.keyPress(KeyEvent.VK_TAB); + robot.keyRelease(KeyEvent.VK_TAB); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + } + } + + /*** + * 判断上级是否勾选 + * @param node + * @return + * @throws TCException + */ + private void isHaveBom(DefaultMutableTreeTableNode node,String parentID,String status,TCComponentItemType itemType) throws TCException + { + TCComponentItem item = itemType.find(parentID); + TCComponentItemRevision itemRevision = item.getLatestItemRevision(); + + TCComponent[] tcComponents = itemRevision.getReferenceListProperty("view"); + if(tcComponents.length > 0) + { + for (int ii = 0; ii < node.getParent().getChildCount(); ii++) { + DefaultMutableTreeTableNode tableNode = (DefaultMutableTreeTableNode)node.getParent().getChildAt(ii); + + if(tableNode.getChildCount() > 0) + { + for (int i = 0; i < tcComponents.length; i++) { + TCComponent childBomLine = tcComponents[i]; + List haveItemID = new ArrayList(); + for (int j = 0; j < tableNode.getChildCount(); j++) { + String childItemId = childBomLine.getStringProperty("item_id"); + NodeBean childNodeBean = (NodeBean) tableNode.getChildAt(j).getUserObject(); + if(childItemId.equals(childNodeBean.getEbomId()) && !haveItemID.contains(childNodeBean.getEbomId())) + { + haveItemID.add(childNodeBean.getEbomId()); + childNodeBean.setLabel(status); + isHaveBom((DefaultMutableTreeTableNode)(tableNode.getChildAt(j)), childNodeBean.getEbomId(), status, itemType); + } + } + } + } + } + } + } + + /*** + * 判断上级是否勾选 + * @param node + * @return + */ + private boolean getTop(DefaultMutableTreeTableNode node) + { + boolean result = false; + + //判断上层是否勾选已发布的对象 + DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent(); + if(parentNode != null) + { + DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent(); + if(rootNode != null) + { + for (int i = 0; i < rootNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1")) + { + //MessageBox.post("上层["+childBean.getEbom()+"]已勾选发布的对象,下层不允许勾选!", "错误", MessageBox.ERROR); + return true; + } + } + } + } + + return result; + } + + /*** + * 判断上级是否勾选已发布对象 + * @param node + * @return + */ + private boolean getTopRefresh(DefaultMutableTreeTableNode node) + { + boolean result = false; + + //判断上层是否勾选已发布的对象 + DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent(); + if(parentNode != null) + { + DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent(); + if(rootNode != null) + { + for (int i = 0; i < rootNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1") && !childBean.getRefreshStatus().equals("属性发布") && !childBean.getRefreshStatus().isEmpty()) + { + result = true; + break; + } + else + { + if(getTopRefresh(childNode)) + { + result = true; + break; + } + } + } + } + } + + return result; + } + + /*** + * 判断上级是否勾选流程中对象 + * @param node + * @return + */ + private boolean getTopProcessRefresh(DefaultMutableTreeTableNode node) + { + boolean result = false; + + //判断上层是否勾选已发布的对象 + DefaultMutableTreeTableNode parentNode = (DefaultMutableTreeTableNode) node.getParent(); + if(parentNode != null) + { + DefaultMutableTreeTableNode rootNode = (DefaultMutableTreeTableNode) parentNode.getParent(); + if(rootNode != null) + { + for (int i = 0; i < rootNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) rootNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1") && childBean.getRefreshStatus().equals("流程中")) + { + result = true; + break; + } + else + { + if(getTopProcessRefresh(childNode)) + { + result = true; + break; + } + } + } + } + } + + return result; + } + + @Override + public void mousePressed(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseReleased(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseEntered(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void mouseExited(MouseEvent e) { + // TODO Auto-generated method stub + + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) + { + //获取选中的EBOM对象 + try { + MethodUtil.openByPass(session); + try { + TCComponentItemType itemType = (TCComponentItemType) session + .getTypeComponent("Item"); + this.adaptiveVariants((DefaultMutableTreeTableNode)(this.node.getChildAt(0)), itemType); + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + }finally { + MethodUtil.closeByPass(session); + } + MessageBox.post("转换成功!", "成功", MessageBox.INFORMATION); + } catch (TCException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + else if(source.equals(this.refreshButton)) + { + this.dispose(); + try { + DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(comp,session); + command.executeModal(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + else + { + this.dispose(); + } + } + + TCComponentBOMLine resultTopline = null; + /** + * 重新搭建BOM + * + * @param topItem + * @throws TCException + */ + private void adaptiveVariants(DefaultMutableTreeTableNode tableNode,TCComponentItemType itemType) throws TCException + { + TCComponentItem topItem = null; + ArrayList itemList = new ArrayList(); + Map itemNumMap = new HashMap(); + for (int i = 0; i < tableNode.getChildCount(); i++) { + DefaultMutableTreeTableNode childNode = (DefaultMutableTreeTableNode) tableNode.getChildAt(i); + NodeBean childBean = (NodeBean) childNode.getUserObject(); + if(childBean.getLabel().equals("1")) + { + topItem = itemType.find(childBean.getEbomId()); + for (int j = 0; j < tableNode.getChildCount(); j++) { + DefaultMutableTreeTableNode node = (DefaultMutableTreeTableNode) tableNode.getChildAt(j); + + for (int k = 0; k < node.getChildCount(); k++) { + DefaultMutableTreeTableNode childTableNode = (DefaultMutableTreeTableNode) node.getChildAt(k); + NodeBean childNodeBean = (NodeBean) childTableNode.getUserObject(); + if(childNodeBean.getLabel().equals("1")) + { + TCComponentItem item = itemType.find(childNodeBean.getEbomId()); + itemList.add(item.getLatestItemRevision()); + itemNumMap.put(item.getStringProperty("item_id"), childNodeBean.getNum()); + if(childNodeBean.getRefreshStatus().equals("属性发布") || childNodeBean.getRefreshStatus().equals("")) + { + adaptiveVariants((DefaultMutableTreeTableNode)(childTableNode.getParent()), itemType); + } + } + + } + } + } + } + if(topItem != null) + { + resultTopline = null; + this.recreateBom(topItem.getLatestItemRevision(), itemList, true); + if(resultTopline != null) + { + resultTopline.lock(); + //设置BOM行属性 + for (int j = 0; j < resultTopline.getChildren().length; j++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) resultTopline.getChildren()[j].getComponent(); + if(itemNumMap.keySet().contains((bomLine.getStringProperty("bl_item_item_id")))) + { + String quantity = itemNumMap.get(bomLine.getStringProperty("bl_item_item_id")); + if(quantity == null || quantity.isEmpty() || quantity.equals("0")) + { + String uom = ""; + try { + uom = bomLine.getPropertyDisplayableValue("bl_uom"); + } catch (NotLoadedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println("单位:++++++++++++++++"+uom); + if(uom.equals("每个")) + { + continue; + } + quantity = "1.00"; + } + System.out.println("数量:++++++++++++++++"+quantity); + if(quantity.indexOf(".") > 0) + { + Double bomNum = Double.parseDouble(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + else + { + Integer bomNum = Integer.parseInt(quantity); + bomLine.setStringProperty("bl_quantity", bomNum.toString()); + } + //bomLine.setStringProperty("bl_quantity", itemNumMap.get(bomLine.getStringProperty("bl_item_item_id"))); + } + } + resultTopline.save(); + resultTopline.unlock(); + resultTopline.refresh(); + if(resultTopline.getBOMView() != null) + { + resultTopline.getBOMView().save(); + resultTopline.getBOMView().refresh(); + } + } + } + } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev, + ArrayList itemRevisionlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), + topItemRev, null, null); + resultTopline = topline; + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if(n_itemRevision != null) + { + boolean isHave = false; + if(!isDelete) + { + for (AIFComponentContext children : topline.getChildren()) { + if(n_itemRevision.getStringProperty("item_id").compareTo(children.getComponent().getProperty("bl_child_id")) == 0) + { + isHave = true; + } + } + } + if(!isHave) + { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if(topline.getBOMView() != null) + { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomHandler.java new file mode 100644 index 0000000..1bf70ff --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomHandler.java @@ -0,0 +1,30 @@ +package com.connor.ml.tcm.outfile.ML_01; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCSession; + + +public class DbomTransitionToEbomHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + DbomTransitionToEbomCommand command = new DbomTransitionToEbomCommand(app.getTargetComponent(),session); + command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomOperation.java new file mode 100644 index 0000000..995c6f5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/DbomTransitionToEbomOperation.java @@ -0,0 +1,25 @@ +package com.connor.ml.tcm.outfile.ML_01; + +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +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; + +public class DbomTransitionToEbomOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/JTreeTable.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/JTreeTable.java new file mode 100644 index 0000000..af75660 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/JTreeTable.java @@ -0,0 +1,85 @@ +package com.connor.ml.tcm.outfile.ML_01; + +import java.awt.event.MouseEvent; +import java.util.List; + +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; + +import org.jdesktop.swingx.JXTreeTable; + +public class JTreeTable extends JXTreeTable { + + + private List isNotEditableRow; + //CheckBoxCellEditor checkBoxCellEditor = new CheckBoxCellEditor(this); + TableCellCheckboxRenderer checkboxRenderer = new TableCellCheckboxRenderer(this); + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + public JTreeTable(JTreeTableModel testTreeTableModel) { + // TODO Auto-generated constructor stub + super(testTreeTableModel); + } + + @Override + public boolean isCellEditable(int arg0, int arg1) { + // TODO Auto-generated method stub + return true;//super.isCellEditable(arg0, arg1); + } + + @Override + public TableCellEditor getCellEditor(int row, int column) { + // TODO Auto-generated method stub + //if(isNotEditableRow.contains(row) && column == 2) + + + return cellEditor; + //return super.getCellEditor(row, column); + } + + public String getToolTipText(MouseEvent e) { + int row = this.rowAtPoint(e.getPoint()); + int col = this.columnAtPoint(e.getPoint()); + String tiptextString = null; + if (row > -1 && col > -1) { + Object value = this.getValueAt(row, col); + if (null != value && !"".equals(value)) + tiptextString = value.toString();// 悬浮显示单元格内容 + } + return tiptextString; + } + + @Override + public TableCellRenderer getCellRenderer(int row, int column) { + // TODO Auto-generated method stub + if(this.getValueAt(row, 2) != null && (this.getValueAt(row, 2).toString().equals("0") || this.getValueAt(row, 2).toString().equals("1")) && column == 2) + { + return checkboxRenderer; + } + else + { + return super.getCellRenderer(row, column); + } + } + + // 隐藏列 + public void HiddenCell(int column) { + TableColumn tc = this.getTableHeader().getColumnModel() + .getColumn(column); + tc.setMaxWidth(0); + tc.setPreferredWidth(0); + tc.setWidth(0); + tc.setMinWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMaxWidth(0); + this.getTableHeader().getColumnModel().getColumn(column).setMinWidth(0); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/JTreeTableModel.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/JTreeTableModel.java new file mode 100644 index 0000000..3afce81 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/JTreeTableModel.java @@ -0,0 +1,119 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.outfile.ML_01; + +import java.util.List; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; +import org.jdesktop.swingx.treetable.DefaultTreeTableModel; +import org.jdesktop.swingx.treetable.TreeTableNode; + +import com.connor.ml.tcm.outfile.bean.NodeBean; + +/** + * + * @author vearn + */ +public class JTreeTableModel extends DefaultTreeTableModel { + + private String[] _names = { "DBOM对象", "EBOM对象","选中", "EBOMID", "物料描述","数量","发布状态","对应父节点"}; + + + private List isNotEditableRow; + + + + public JTreeTableModel(TreeTableNode node) { + super(node); + } + + + public List getIsNotEditableRow() { + return isNotEditableRow; + } + + public void setIsNotEditableRow(List isNotEditableRow) { + this.isNotEditableRow = isNotEditableRow; + } + + /** + * 列的数量 + */ + @Override + public int getColumnCount() { + return _names.length; + } + + /** + * 表头显示的内容 + */ + @Override + public String getColumnName(int column) { + return _names[column]; + } + + /** + * 返回在单元格中显示的Object + */ + @Override + public Object getValueAt(Object node, int column) { + Object value = null; + if (node instanceof DefaultMutableTreeTableNode) { + DefaultMutableTreeTableNode mutableNode = (DefaultMutableTreeTableNode) node; + Object o = mutableNode.getUserObject(); + if (o != null && o instanceof NodeBean) { + NodeBean bean = (NodeBean) o; + switch (column) { + case 0: + value = bean.getDbom(); + break; + case 1: + value = bean.getEbom(); + break; + case 2: + value = bean.getLabel(); + break; + case 3: + value = bean.getEbomId(); + break; + case 4: + value = bean.getEbomDesc(); + break; + case 5: + value = bean.getNum(); + break; + case 6: + value = bean.getRefreshStatus(); + break; + case 7: + value = bean.getParentString(); + break; + } + } + } + return value; + } + + /** + * 设置所有单元格都不能编辑 + * + * @param the node (i.e. row) for which editing is to be determined + * @param the column for which editing is to be determined + * @return false + */ + @Override + public boolean isCellEditable(Object node, int column) { + //if(column == 5) + //{ + return true; + //} + //else + //{ + // return false; + //} + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/TableCellCheckboxRenderer.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/TableCellCheckboxRenderer.java new file mode 100644 index 0000000..af87e96 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_01/TableCellCheckboxRenderer.java @@ -0,0 +1,71 @@ +package com.connor.ml.tcm.outfile.ML_01; + +import java.awt.Component; +import java.util.List; + +import javax.swing.JCheckBox; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.event.ChangeEvent; +import javax.swing.event.EventListenerList; +import javax.swing.table.TableCellRenderer; + + +public class TableCellCheckboxRenderer extends JCheckBox implements + TableCellRenderer { + private List processRows; + protected EventListenerList listenerList = new EventListenerList(); + protected ChangeEvent changeEvent = new ChangeEvent(this); + //private TestTreeTableModel tableModel; + + public List getProcessRows() { + return processRows; + } + + public void setProcessRows(List processRows) { + this.processRows = processRows; + + } + + public TableCellCheckboxRenderer(final JTreeTable table) { + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { + // TODO Auto-generated method stub + this.setHorizontalAlignment(SwingConstants.CENTER);// 表头标签剧中 + this.setBorderPainted(true); + + if(value != null) + { +// if(value.toString().equals("1")) +// { +// if(table.getColumnName(column).equals("改制") && hasFocus) +// { +// if(table.getValueAt(row, column + 1).toString().equals("1")) +// { +// table.setValueAt(0, row, column + 1); +// } +// } +// else if(table.getColumnName(column).equals("删除") && hasFocus) +// { +// if(table.getValueAt(row, column - 1).toString().equals("1")) +// { +// table.setValueAt(0, row, column - 1); +// } +// } +// } +// if(value.toString().equals("1")) +// { +// System.out.println(value.toString().equals("1") + "===="); +// } + this.setSelected(value.toString().equals("1")); + } + else + { + this.setSelected(false); + } + return this; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSCommand.java new file mode 100644 index 0000000..d5f54cb --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSCommand.java @@ -0,0 +1,291 @@ +package com.connor.ml.tcm.outfile.ML_02; + +import java.awt.image.RenderedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.xml.crypto.Data; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.ExcelUtil07; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + +public class GXZYZDSCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine BomLine = null; + private List> JobDatas=new ArrayList>(); + private String ProductCode=""; + private String ProductType=""; + private boolean isMEOP=false; + private ListerrorList=new ArrayList(); + public GXZYZDSCommand(InterfaceAIFComponent comp, TCSession session,boolean isMEOP) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + this.isMEOP=isMEOP; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //获取选中的对象 + + BomLine = (TCComponentBOMLine) comp; + // List> JobData=new ArrayList>(); +// //判断对象类型 +// TCComponentItem item = BomLine.getItem(); + + + //获取产品版本对象 + TCComponentBOMLine topBomLine=MethodUtil.getTopLine(BomLine); + TCComponentItemRevision productItem; + if(topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget").length==0) { + MessageBox.post("目标下无产品!", "失败", MessageBox.INFORMATION); + return; + }else { + productItem=(TCComponentItemRevision) (topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget"))[0]; + } + + + //产品代号 + ProductCode=productItem.getStringProperty("ml8_ProductCode"); + //产品型号 + ProductType=productItem.getStringProperty("ml8_ProductType"); + + //从选中目标逐层分解类型:工序则生成指导书,工艺就继续分解 + if(isMEOP) { + getMeopValues(BomLine); + }else { + getOP(BomLine); + } + + //非工序的错误信息统一打印 + if(errorList.size()>0) { + String errorMessage=""; + for(int i=0;i-1) { + getOP(bomLine); + }else if(bomLine.getItem().getType().indexOf("Op")>-1) { + getMeopValues(bomLine); + } + } + } + + //获取工序数据 + public void getMeopValues(TCComponentBOMLine MEOP) throws TCException, IOException { + List> WorkStepDatas=new ArrayList>();//工步数据 + List> MaterialDatas=new ArrayList>();//物料数据 + List> FrockDatas=new ArrayList>();//工装数据 + Tree02 jobTree=new Tree02(); + jobTree.setProductCode(ProductCode); + jobTree.setProductType(ProductType); + + TCComponentBOMLine MEOPBomLine=MEOP; + //jobTree.setItemID(MEOPBomLine.getItemRevision().getStringProperty("item_id"));//工序编号 + jobTree.setItemID(ExcelUtil07.getID(MEOPBomLine.getItemRevision().getStringProperty("item_id")));//工序编号 + jobTree.setName(MEOPBomLine.getItemRevision().getStringProperty("object_name"));//工序名称 + jobTree.setTime(String.valueOf(MEOPBomLine.getDoubleProperty("bl_me_work_time")));//标准时间 + + +// MessageBox.post(MEOPBomLine.getItem().getType(),"cuowu",MessageBox.ERROR); + + //获取工序下工步 + TCComponent[] WorkStep=MEOPBomLine.getReferenceListProperty("Mfg0sub_elements"); + + if(WorkStep==null||WorkStep.length==0) { + //选中的对象不是工序的话就要将报错信息统一打出 + if(((TCComponentBOMLine)comp).getItem().getType().equals("ML8_StdOperation")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_DifOperation")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_SpecOp")) { + MessageBox.post("工序:"+MEOPBomLine.getStringProperty("bl_line_name")+"下没有内容。","错误",MessageBox.ERROR); + }else { + errorList.add(MEOPBomLine.getStringProperty("bl_line_name")); + } + + } + if(MEOPBomLine.getItemRevision().getProperty("release_status_list") != ""){ + MessageBox.post("工序:"+MEOPBomLine.getStringProperty("bl_line_name")+"已发布,无法生成工序作业指导书。","错误",MessageBox.ERROR); + }else{ + int frockNo=0; + for(int j=0;j WorkStepData=new ArrayList(); + TCComponentBOMLine WorkStepLine=(TCComponentBOMLine)WorkStep[j]; + //获取操作图片先生成图片待插入后再删除 + boolean isExist=true; + //WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("IMAN_specification"));//操作图片 + WorkStepData.add(String.valueOf(j+1)); + if(WorkStepLine.getItemRevision().getReferenceListProperty("IMAN_specification").length!=0) { + TCComponent[] sssComponents=WorkStepLine.getItemRevision().getReferenceListProperty("IMAN_specification"); + for(TCComponent num:sssComponents) { + if(num.getType().equals("Image")) { + WorkStepData.add(copyImage(num, String.valueOf(j+1))); + isExist=false; + break; + } + } + } + if(isExist)WorkStepData.add(""); + //WorkStepData.add("C:\\美菱导出测试\\测试图.png");//图片 + WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("object_name"));//工步名称 + WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("object_desc"));//描述 + WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("ml8_ProcessStandard"));//工艺标准 + WorkStepData.add(String.valueOf(WorkStepLine.getDoubleProperty("bl_me_work_time")));//工时 + WorkStepDatas.add(WorkStepData); + + //获取工步下的事例,提取工装和物料的数据 + AIFComponentContext[] WorkStepExample=WorkStepLine.getChildren(); + for(int k=0;k MaterialData=new ArrayList(); + MaterialData.add((exampleBomLine.getItemRevision().getStringProperty("item_id")).split("-")[0]); + MaterialData.add(exampleBomLine.getItemRevision().getStringProperty("object_name")); + MaterialData.add(exampleBomLine.getItemRevision().getStringProperty("ml8_FigureNum")); + MaterialData.add(exampleBomLine.getStringProperty("bl_quantity"));//统计数量 + MaterialDatas.add(MaterialData); + } + //工装类型 + if(exampleBomLine.getStringProperty("bl_occ_type").equals("METool")) { + List FrockData=new ArrayList(); + FrockData.add(exampleBomLine.getItemRevision().getStringProperty("item_id")); + FrockData.add(exampleBomLine.getItemRevision().getStringProperty("object_name")); + FrockDatas.add(FrockData); + } + + } + } + + //合并工装数量 + if(FrockDatas!=null) { + Map frockMapNo=new HashMap(); + Map frockMapName=new HashMap(); + List listValuefrock=new ArrayList(); + for(int m=0;m FrockData=new ArrayList(); + FrockData.add(String.valueOf(n+1)); + FrockData.add(listValuefrock.get(n)); + FrockData.add(frockMapName.get(listValuefrock.get(n))); + //FrockData.add(String.valueOf(frockMapNo.get(listValuefrock.get(n))));//数量不用显示 + FrockDatas.add(FrockData); + } + } + + + //合并物料数量 + if(MaterialDatas!=null) { + Map materialMapNo=new HashMap(); + Map materialMapName=new HashMap(); + Map materialMapTh=new HashMap();//图号 + List listValue=new ArrayList(); + for(int m=0;m MaterialData=new ArrayList(); + MaterialData.add(listValue.get(n)); + MaterialData.add(materialMapName.get(listValue.get(n))); + MaterialData.add(materialMapTh.get(listValue.get(n))); + MaterialData.add(String.valueOf(materialMapNo.get(listValue.get(n)))); + MaterialDatas.add(MaterialData); + } + + } + + jobTree.setWorkStep(WorkStepDatas); + jobTree.setFrock(FrockDatas); + jobTree.setMaterial(MaterialDatas); + + System.out.println("工序ID:"+jobTree.getItemID()); + System.out.println("工序名称:"+jobTree.getName()); + System.out.println("产品代号:"+jobTree.getProductCode()); + System.out.println("产品型号:"+jobTree.getProductType()); + System.out.println("标准时间:"+jobTree.getTime()); + System.out.println("工装数据:"+jobTree.getFrock().toString()); + System.out.println("物料数据:"+jobTree.getMaterial().toString()); + System.out.println("工步数据:"+jobTree.getWorkStep().toString()); + + + //每个工序生成一棵树 + + GXZYZDSDialog gxzyzdsDialog=new GXZYZDSDialog(comp,session,jobTree,MEOPBomLine.getItem()); + } + } + + + + //通过图片获取对象复制图片 + public String copyImage(TCComponent ttComponent,String name) throws TCException { + TCComponentDataset Dataset; + TCComponentTcFile picFile; + Dataset=(TCComponentDataset) ttComponent; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + MethodUtil.CopyPic(picFile.getFmsFile(),System.getenv("TEMP") + "\\"+name); + return System.getenv("TEMP") + "\\"+name; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSDialog.java new file mode 100644 index 0000000..96ef72d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSDialog.java @@ -0,0 +1,552 @@ +package com.connor.ml.tcm.outfile.ML_02; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.TreePath; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.ML_01.JTreeTable; +import com.connor.ml.tcm.outfile.ML_01.JTreeTableModel; +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.Adapter; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.itextpdf.text.pdf.codec.Base64.InputStream; +import com.spire.xls.CellStyle; +import com.spire.xls.ExcelPicture; +import com.spire.xls.ExcelVersion; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.spire.xls.core.INameRanges; +import com.spire.xls.core.IXLSRange; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.internal.core._2008_06.dispatchermanagement.InsertDatasetVersionArgs; +import com.teamcenter.soa.client.model.Lov.Style; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class GXZYZDSDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private InterfaceAIFComponent comp; + + private List> WorkStepDatas=new ArrayList>();//工步 + private List> MaterialDatas=new ArrayList>();//物料 + private List> FrockDatas=new ArrayList>();//工装 + private Tree02 tree; + private TCComponentItem target; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private String nameString=""; + private CellStyle cellStyle; + private double RowHeight=20; + public GXZYZDSDialog(InterfaceAIFComponent comp, TCSession session,Tree02 tree,TCComponentItem target) throws IOException { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.tree=tree; + this.target=target; + nameString=tree.getItemID()+tree.getName(); + init(); + } + + private void init() throws IOException { + //创建Workbook对象 + Workbook wb = new Workbook(); + File file1 = null; + file1=MethodUtil.getFile(session, "工序作业指导书", "MSExcelX"); + FileInputStream input1 = new FileInputStream(file1); + wb.loadFromHtml(input1); + //加载一个测试文档 + //wb.loadFromFile("C:\\美菱导出测试\\作业指导书.xlsx"); + //MessageBox.post(outPathString,"错误",MessageBox.ERROR); + //获取第一个工作表 + Worksheet sheet = wb.getWorksheets().get(0); + sheet.setName(nameString+"工序作业指导书"); + +// +// //获取全局命名区域 +// //获取局部命名区域(对局部命名区域进行相关操作) +// INameRanges namedRange1 = wb.getNameRanges(); +// IXLSRange ddd=namedRange1.get(4).getRefersToRange(); +// System.out.println(ddd.getColumn()); +// namedRange1.get(0).setRefersToRange(sheet.getCellRange("A24")); + + String Formula1 = "=IF(ml8_Design=\"\",\"\",ml8_Design)";//编制 + String Formula2 = "=IF(ml8_Examine=\"\",\"\",ml8_Examine)";//审核 + String Formula3 = "=IF(ml8_Standardization=\"\",\"\",ml8_Standardization)";//会签 + String Formula4 = "=IF(ml8_Approval=\"\",\"\",ml8_Approval)";//批准 + + +// //获取公式,倒数第二行的4,11,20,28列 +// int PenultimateRow=sheet.getLastRow()-1;//倒数第二行行数 +// String formatCell1=null; +// String formatCell2=null; +// String formatCell3=null; +// String formatCell4=null; +// //判断单元格是否含有公式 +// if (sheet.getCellRange(PenultimateRow,4).hasFormula()){ +// formatCell1=sheet.getCellRange(PenultimateRow,4).getFormula(); +// } +// if (sheet.getCellRange(PenultimateRow,11).hasFormula()){ +// formatCell2=sheet.getCellRange(PenultimateRow,11).getFormula(); +// } +// if (sheet.getCellRange(PenultimateRow,20).hasFormula()){ +// formatCell3=sheet.getCellRange(PenultimateRow,20).getFormula(); +// } +// if (sheet.getCellRange(PenultimateRow,28).hasFormula()){ +// formatCell4=sheet.getCellRange(PenultimateRow,28).getFormula(); +// } + + + + //获取行高 + RowHeight=sheet.getRowHeight(5); + + ExcelPicture pic1 = sheet.getPictures().get(1); + BufferedImage loImage1 = pic1.getPicture(); + ImageIO.write(loImage1,"jpg",new File(outPathString+"图标1.jpg")); + ExcelPicture pic2 = sheet.getPictures().get(2); + BufferedImage loImage2 = pic2.getPicture(); + ImageIO.write(loImage2,"jpg",new File(outPathString+"图标2.jpg")); + ExcelPicture pic3 = sheet.getPictures().get(3); + BufferedImage loImage3 = pic3.getPicture(); + ImageIO.write(loImage3,"jpg",new File(outPathString+"图标3.jpg")); + + + //判断一共复制多少表格 + WorkStepDatas=tree.getWorkStep(); + MaterialDatas=tree.getMaterial(); + FrockDatas=tree.getFrock(); + int num=0; + if(WorkStepDatas.size()>0) { + num=(int) Math.ceil((double)WorkStepDatas.size()/6); + if((int) Math.ceil((double)MaterialDatas.size()/10)>num) { + num=(int) Math.ceil((double)MaterialDatas.size()/10); + } + if((int) Math.ceil((double)FrockDatas.size()/5)>num) { + num=(int) Math.ceil((double)FrockDatas.size()/5); + } + }else { + num=1; + } + + //在工作表内复制单元格区域 + for(int i=1;i WorkStepData=new ArrayList(); + WorkStepData=WorkStepDatas.get(i-1); + int startRow=flag*29+1;//开始行 + if(i%6!=0) { + switch (i%6) { + case 1: + InsertWorkStepData(sheet,startRow,4,1,WorkStepData); + break; + case 2: + InsertWorkStepData(sheet,startRow,9,1,WorkStepData); + break; + case 3: + InsertWorkStepData(sheet,startRow,14,1,WorkStepData); + break; + case 4: + InsertWorkStepData(sheet,startRow,4,17,WorkStepData); + break; + case 5: + InsertWorkStepData(sheet,startRow,9,17,WorkStepData); + break; + default: + break; + } + }else { + InsertWorkStepData(sheet,startRow,14,17,WorkStepData); + flag++; + } + } + flag=0; + //插入物料 + for(int i=1;i<=MaterialDatas.size();i++) { + List MaterialData=new ArrayList(); + MaterialData=MaterialDatas.get(i-1); + int startRow=flag*29+1;//开始行 + if(i%10!=0) { + switch (i%10) { + case 1: + InsertMaterialData(sheet,startRow,21,1,MaterialData); + break; + case 2: + InsertMaterialData(sheet,startRow,22,1,MaterialData); + break; + case 3: + InsertMaterialData(sheet,startRow,23,1,MaterialData); + break; + case 4: + InsertMaterialData(sheet,startRow,24,1,MaterialData); + break; + case 5: + InsertMaterialData(sheet,startRow,25,1,MaterialData); + break; + case 6: + InsertMaterialData(sheet,startRow,21,11,MaterialData); + break; + case 7: + InsertMaterialData(sheet,startRow,22,11,MaterialData); + break; + case 8: + InsertMaterialData(sheet,startRow,23,11,MaterialData); + break; + case 9: + InsertMaterialData(sheet,startRow,24,11,MaterialData); + break; + default: + break; + } + }else { + InsertMaterialData(sheet,startRow,25,11,MaterialData); + flag++; + } + } + flag=0; + //插入工装 + for(int i=1;i<=FrockDatas.size();i++) { + List FrockData=new ArrayList(); + FrockData=FrockDatas.get(i-1); + int startRow=flag*29+1;//开始行 + if(i%5!=0) { + switch (i%5) { + case 1: + InsertFrockData(sheet,startRow,21,21,FrockData); + break; + case 2: + InsertFrockData(sheet,startRow,22,21,FrockData); + break; + case 3: + InsertFrockData(sheet,startRow,23,21,FrockData); + break; + case 4: + InsertFrockData(sheet,startRow,24,21,FrockData); + break; + default: + break; + } + }else { + InsertFrockData(sheet,startRow,25,21,FrockData); + flag++; + } + } + + +// //插入公式 +// int PenultimateRow2=sheet.getLastRow()-1;//倒数第二行行数 +// System.out.println("复制后的倒数第二行行数=======>"+PenultimateRow2); +// if(PenultimateRow2!=PenultimateRow) { +// if(formatCell1!=null) { +// sheet.getCellRange(PenultimateRow2,4).setFormula(formatCell1); +// } +// if(formatCell2!=null) { +// sheet.getCellRange(PenultimateRow2,11).setFormula(formatCell2); +// } +// if(formatCell3!=null) { +// sheet.getCellRange(PenultimateRow2,20).setFormula(formatCell3); +// } +// if(formatCell4!=null) { +// sheet.getCellRange(PenultimateRow2,28).setFormula(formatCell4); +// } +// } + + + wb.saveToFile(outPathString+nameString+"工序作业指导书.xlsx"); + Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());//删除有水印的最后一页 + sheetRemove.remove(); + wb.saveToFile(outPathString+nameString+"工序作业指导书.xlsx"); + try { + if (MethodUtil.getExcelToItem(session, this.target.getLatestItemRevision(), "ML8_ProcessSOP", + "MSExcelX", nameString + "工序作业指导书") != null) { + System.out.println("当前对象ML8_ProcessSOP下有相同的指导书,换个最新的11111111111111"); + MethodUtil.changeDataSet( + MethodUtil.getExcelToDataset(session, this.target.getLatestItemRevision(), "ML8_ProcessSOP", + "MSExcelX", nameString + "工序作业指导书"), + "excel", "MSExcelX", outPathString + nameString + "工序作业指导书.xlsx"); + } else { + System.out.println("当前对象ML8_ProcessSOP下没有相同的指导书,换个最新的else2222222222222"); + MethodUtil.setExcelToItem(session, this.target.getLatestItemRevision(), + outPathString + nameString + "工序作业指导书.xlsx", nameString + "工序作业指导书", "ML8_ProcessSOP", + "MSExcelX", true); + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(new File(outPathString+nameString+"工序作业指导书.xlsx").exists()) { + new File(outPathString+nameString+"工序作业指导书.xlsx").delete(); + } + } + + + //创建表格 + public void copyTable(Worksheet sheet, int startRow,int endRow) throws IOException { + String s1="A".concat(String.valueOf(startRow)); + String s2=":AF".concat(String.valueOf(endRow)); + sheet.copy(sheet.getCellRange("A1:AF28"),sheet.getCellRange( + s1.concat(s2)),true); + //合并单元格 + sheet.getRange().get("A".concat(String.valueOf(startRow)).concat(":G".concat(String.valueOf(startRow+1)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow)).concat(":AB".concat(String.valueOf(startRow+1)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow)).concat(":AF".concat(String.valueOf(startRow)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+1)).concat(":AF".concat(String.valueOf(startRow+1)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+2)).concat(":B".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("C".concat(String.valueOf(startRow+2)).concat(":G".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+2)).concat(":I".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("J".concat(String.valueOf(startRow+2)).concat(":N".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("o".concat(String.valueOf(startRow+2)).concat(":P".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+2)).concat(":U".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("V".concat(String.valueOf(startRow+2)).concat(":W".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+2)).concat(":AB".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+2)).concat(":AD".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("AE".concat(String.valueOf(startRow+2)).concat(":AF".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+3)).concat(":H".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+3)).concat(":L".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("M".concat(String.valueOf(startRow+3)).concat(":O".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+3)).concat(":X".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+3)).concat(":AB".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+3)).concat(":AE".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+4)).concat(":A".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+4)).concat(":H".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+4)).concat(":L".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+5)).concat(":L".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("M".concat(String.valueOf(startRow+4)).concat(":O".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("P".concat(String.valueOf(startRow+4)).concat(":P".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+4)).concat(":Q".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+4)).concat(":X".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+4)).concat(":AB".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+5)).concat(":AB".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+4)).concat(":AE".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("AF".concat(String.valueOf(startRow+4)).concat(":AF".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+9)).concat(":A".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+9)).concat(":H".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+9)).concat(":L".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+10)).concat(":L".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("M".concat(String.valueOf(startRow+9)).concat(":O".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("P".concat(String.valueOf(startRow+9)).concat(":P".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+9)).concat(":Q".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+9)).concat(":X".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+9)).concat(":AB".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+10)).concat(":AB".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+9)).concat(":AE".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("AF".concat(String.valueOf(startRow+9)).concat(":AF".concat(String.valueOf(startRow+13)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+14)).concat(":A".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+14)).concat(":H".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+14)).concat(":L".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+15)).concat(":L".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("M".concat(String.valueOf(startRow+14)).concat(":O".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("P".concat(String.valueOf(startRow+14)).concat(":P".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+14)).concat(":Q".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+14)).concat(":X".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+14)).concat(":AB".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+15)).concat(":AB".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+14)).concat(":AE".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("AF".concat(String.valueOf(startRow+14)).concat(":AF".concat(String.valueOf(startRow+18)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+19)).concat(":T".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("U".concat(String.valueOf(startRow+19)).concat(":Y".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+19)).concat(":AF".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+20)).concat(":C".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+20)).concat(":F".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+20)).concat(":I".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("K".concat(String.valueOf(startRow+20)).concat(":M".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+20)).concat(":P".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+20)).concat(":S".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("V".concat(String.valueOf(startRow+20)).concat(":W".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+20)).concat(":Y".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+21)).concat(":C".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+21)).concat(":F".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+21)).concat(":I".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("K".concat(String.valueOf(startRow+21)).concat(":M".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+21)).concat(":P".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+21)).concat(":S".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("V".concat(String.valueOf(startRow+21)).concat(":W".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+21)).concat(":Y".concat(String.valueOf(startRow+21)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+22)).concat(":C".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+22)).concat(":F".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+22)).concat(":I".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("K".concat(String.valueOf(startRow+22)).concat(":M".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+22)).concat(":P".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+22)).concat(":S".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("V".concat(String.valueOf(startRow+22)).concat(":W".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+22)).concat(":Y".concat(String.valueOf(startRow+22)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+23)).concat(":C".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+23)).concat(":F".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+23)).concat(":I".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("K".concat(String.valueOf(startRow+23)).concat(":M".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+23)).concat(":P".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+23)).concat(":S".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("V".concat(String.valueOf(startRow+23)).concat(":W".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+23)).concat(":Y".concat(String.valueOf(startRow+23)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+24)).concat(":C".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+24)).concat(":F".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+24)).concat(":I".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("K".concat(String.valueOf(startRow+24)).concat(":M".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+24)).concat(":P".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+24)).concat(":S".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("V".concat(String.valueOf(startRow+24)).concat(":W".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+24)).concat(":Y".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+25)).concat(":C".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+25)).concat(":F".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+25)).concat(":I".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("K".concat(String.valueOf(startRow+25)).concat(":M".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+25)).concat(":P".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+25)).concat(":S".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("V".concat(String.valueOf(startRow+25)).concat(":W".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+25)).concat(":Y".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+20)).concat(":AF".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+26)).concat(":C".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+26)).concat(":H".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+26)).concat(":K".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("L".concat(String.valueOf(startRow+26)).concat(":P".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+26)).concat(":S".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+26)).concat(":X".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+26)).concat(":AA".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("AB".concat(String.valueOf(startRow+26)).concat(":AF".concat(String.valueOf(startRow+26)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+27)).concat(":AF".concat(String.valueOf(startRow+27)))).merge(); + + + for(int i=4;i<19;i++) { + sheet.setRowHeight(startRow+i,RowHeight); + } + //sheet.getRange().get("".concat(String.valueOf(startRow+)).concat(":".concat(String.valueOf(startRow+)))).merge(); + //插入图片 + MethodUtil.InsertTitlePicture(sheet,outPathString+"图标1.jpg",new int[] {startRow,startRow+1}, + new int[] {1,2,3,4,5,6,7},false ,0,0); + MethodUtil.InsertTitlePicture(sheet,outPathString+"图标2.jpg",new int[] {startRow}, + new int[] {29,30,31,32},false ,0,0); + MethodUtil.InsertTitlePicture(sheet,outPathString+"图标3.jpg",new int[] {startRow+27},new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14, + 15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32},false ,0,0); +// ExcelPicture pic1 = sheet.getPictures().add(startRow, 1,outPathString+"图标1.jpg"); +// pic1.setWidth(290); +// pic1.setHeight(75); +// ExcelPicture pic2 = sheet.getPictures().add(startRow, 29,outPathString+"图标2.jpg"); +// pic2.setWidth(155); +// pic2.setHeight(43); +// ExcelPicture pic3 = sheet.getPictures().add(startRow+27, 1,outPathString+"图标3.jpg"); +// pic3.setWidth(1350); +// pic3.setHeight(25); + } + //工步插入数据 + public void InsertWorkStepData(Worksheet sheet,int startRow,int row,int column,List dataList) throws IOException { + sheet.setText(startRow+row, column, (dataList.get(0)==null&&dataList.get(0).equals(""))?" ":dataList.get(0)); + if(dataList.get(1).equals("")) { + + }else { + //行高3.23CM;列宽:5.46CM + MethodUtil.InsertTitlePicture(sheet,dataList.get(1),new int[] {startRow+row,startRow+row+1,startRow+row+2,startRow+row+3,startRow+row+4}, + new int[] {column+1,column+2,column+3,column+4,column+5,column+6,column+7},true,3.23,5.46 ); + + } + //sheet.setCellValue(startRow+row, column+1, dataList.get(1)==null?"":dataList.get(1)); + sheet.setText(startRow+row, column+8, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); + sheet.setText(startRow+row+1, column+8, (dataList.get(3)==null||dataList.get(3).equals(""))?" ":dataList.get(3)); + sheet.setText(startRow+row, column+12, (dataList.get(4)==null||dataList.get(4).equals(""))?" ":dataList.get(4)); + sheet.setText(startRow+row, column+15,( dataList.get(5)==null||dataList.get(5).equals(""))?" ":dataList.get(5)); + } + //物料插入数据 + public void InsertMaterialData(Worksheet sheet,int startRow,int row,int column,List dataList) { + sheet.setText(startRow+row, column, (dataList.get(0)==null||dataList.get(0).equals(""))?" ":dataList.get(0)); + sheet.setText(startRow+row, column+3, (dataList.get(1)==null||dataList.get(1).equals(""))?" ":dataList.get(1)); + sheet.setText(startRow+row, column+6, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); + sheet.setText(startRow+row, column+9, (dataList.get(3)==null||dataList.get(3).equals(""))?" ":dataList.get(3)); + } + //工装插入数据 + public void InsertFrockData(Worksheet sheet,int startRow,int row,int column,List dataList) { + sheet.setText(startRow+row, column, (dataList.get(0)==null||dataList.get(0).equals(""))?" ":dataList.get(0)); + sheet.setText(startRow+row, column+1,( dataList.get(1)==null||dataList.get(1).equals(""))?" ":dataList.get(1)); + sheet.setText(startRow+row, column+3, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); + } + + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSHandler.java new file mode 100644 index 0000000..7f5f30b --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSHandler.java @@ -0,0 +1,54 @@ +package com.connor.ml.tcm.outfile.ML_02; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.sap.tc.logging.standard.Message; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + +public class GXZYZDSHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp; + try { + comp=app.getTargetComponent(); + if(!(comp instanceof TCComponentBOMLine)) { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + }else if(((TCComponentBOMLine)comp).getItemRevision().getProperty("release_status_list") != ""){ + MessageBox.post("选择对象已发布,无法生成工序作业指导书。", "错误", MessageBox.ERROR); + }else{ + if(((TCComponentBOMLine)comp).getItem().getType().equals("ML8_ProdProcess")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_StdProcess")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_SpecProcess")) {//工艺 + GXZYZDSCommand command = new GXZYZDSCommand(app.getTargetComponent(),session,false); + command.executeModal(); + }else if(((TCComponentBOMLine)comp).getItem().getType().equals("ML8_StdOperation")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_DifOperation")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_SpecOp")){ + GXZYZDSCommand command = new GXZYZDSCommand(app.getTargetComponent(),session,true);//工序 + command.executeModal(); + }else { + MessageBox.post("请选择产品总装工艺、标准工艺、专项工艺对象!", "错误", MessageBox.ERROR); + } + } + // MessageBox.post("cuowu ", "错误", MessageBox.ERROR); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSOperation.java new file mode 100644 index 0000000..402545e --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/GXZYZDSOperation.java @@ -0,0 +1,25 @@ +package com.connor.ml.tcm.outfile.ML_02; + +import java.util.ArrayList; +import java.util.List; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +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; + +public class GXZYZDSOperation extends AbstractAIFOperation { + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + + } + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/Tree02.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/Tree02.java new file mode 100644 index 0000000..d31d9df --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_02/Tree02.java @@ -0,0 +1,64 @@ +package com.connor.ml.tcm.outfile.ML_02; + +import java.util.ArrayList; +import java.util.List; + +public class Tree02 { + private String ProductCode;//产品代号 + private String ProductType;//产品型号 + private String ItemID;//工序编号 + private String Name;//工序名称 + private String Time;//标准时间 + private List> WorkStep=new ArrayList>();//工步 + private List> Material=new ArrayList>();//物料 + private List> Frock=new ArrayList>();//工装 + + public void setProductCode(String ProductCode) { + this.ProductCode=ProductCode; + } + public String getProductCode() { + return this.ProductCode; + } + public void setProductType(String ProductType) { + this.ProductType=ProductType; + } + public String getProductType() { + return this.ProductType; + } + public void setItemID(String ItemID) { + this.ItemID=ItemID; + } + public String getItemID() { + return this.ItemID; + } + public void setName(String Name) { + this.Name=Name; + } + public String getName() { + return this.Name; + } + public void setTime(String Time) { + this.Time=Time; + } + public String getTime() { + return this.Time; + } + public void setMaterial(List> Material) { + this.Material=Material; + } + public List> getMaterial() { + return this.Material; + } + public void setFrock(List> Frock) { + this.Frock=Frock; + } + public List> getFrock() { + return this.Frock; + } + public void setWorkStep(List> WorkStep) { + this.WorkStep=WorkStep; + } + public List> getWorkStep() { + return this.WorkStep; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSCommand.java new file mode 100644 index 0000000..4d2133a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSCommand.java @@ -0,0 +1,334 @@ +package com.connor.ml.tcm.outfile.ML_03; + +import java.awt.image.RenderedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; + +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.ML_02.GXZYZDSDialog; +import com.connor.ml.tcm.outfile.ML_02.Tree02; +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + + +public class GWZYZDSCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine BomLine = null; + private String ProductCode=""; + private String ProductType=""; + private String Linebody=""; + private List> JobDatas=new ArrayList>(); + private ListerrorList=new ArrayList(); + public GWZYZDSCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //获取选中的对象 + BomLine = (TCComponentBOMLine) comp; + + //获取产品版本对象 + TCComponentBOMLine topBomLine=MethodUtil.getTopLine(BomLine); + TCComponentItemRevision productItem; + if(topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget").length==0) { + MessageBox.post("目标下无产品!", "失败", MessageBox.INFORMATION); + return; + }else { + productItem=(TCComponentItemRevision) (topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget"))[0]; + } + + //产品代号 + ProductCode=productItem.getStringProperty("ml8_ProductCode"); + //产品型号 + ProductType=productItem.getStringProperty("ml8_ProductType"); + //线体 + Linebody=productItem.getStringProperty("ml8_Line"); + +// ProductCode="11"; +// ProductType="sss"; +// Linebody="ddd"; + //从选中目标逐层分解类型:工序则生成指导书,工艺就继续分解 + getOP(BomLine); + + + //非工序的错误信息统一打印 + if(errorList.size()>0) { + String errorMessage=""; + for(int i=0;i> WorkStepDatas=new ArrayList>();//工步数据 + List> MaterialDatas=new ArrayList>();//物料数据 + List> FrockDatas=new ArrayList>();//工装数据 + Tree03 jobTree=new Tree03(); + jobTree.setProductCode(ProductCode); + jobTree.setProductType(ProductType); + jobTree.setLineBody(Linebody); + TCComponentBOMLine MEOPBomLine=MEOP; +// jobTree.setItemID("test编号");//工序编号 +// jobTree.setName("test名称");//工序名称 + jobTree.setTime(String.valueOf(MEOPBomLine.getDoubleProperty("bl_me_work_time")));//标准时间 + + +// MessageBox.post(MEOPBomLine.getItem().getType(),"cuowu",MessageBox.ERROR); + + //获取工序下工步 + AIFComponentContext[] WorkStep=MEOPBomLine.getChildren(); + for(int j=0;j WorkStepData=new ArrayList(); + TCComponentBOMLine WorkStepLine=(TCComponentBOMLine)WorkStep[j].getComponent(); + WorkStepData.add(String.valueOf(WorkStepDatas.size()+1));//工步序号 + WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("object_name"));//工步名称 + WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("object_desc"));//内容 + WorkStepData.add(String.valueOf(WorkStepLine.getDoubleProperty("bl_me_work_time")));//工时 + //获取操作图片先生成图片待插入后再删除 + boolean isExist=true; + //WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("IMAN_specification"));//操作图片 + if(WorkStepLine.getItemRevision().getReferenceListProperty("IMAN_specification").length!=0) { + TCComponent[] sssComponents=WorkStepLine.getItemRevision().getReferenceListProperty("IMAN_specification"); + for(TCComponent num:sssComponents) { + if(num.getType().equals("Image")) { + WorkStepData.add(copyImage(num, String.valueOf(j+1))); + isExist=false; + break; + } + } + } + if(isExist)WorkStepData.add(""); + //WorkStepData.add("C:\\美菱导出测试\\测试图.png");//图片 + WorkStepData.add(WorkStepLine.getItemRevision().getStringProperty("ml8_ProcessStandard"));//工艺标准 + WorkStepDatas.add(WorkStepData); + + //获取工步下的事例,提取工装和物料的数据 + AIFComponentContext[] WorkStepExample=WorkStepLine.getChildren(); + for(int k=0;k MaterialData=new ArrayList(); + MaterialData.add(exampleBomLine.getItemRevision().getStringProperty("item_id").split("-")[0]); + MaterialData.add(exampleBomLine.getItemRevision().getStringProperty("object_name")); + MaterialData.add(exampleBomLine.getItemRevision().getStringProperty("ml8_FigureNum")); + MaterialData.add(exampleBomLine.getStringProperty("bl_quantity"));//统计数量 + MaterialDatas.add(MaterialData); + } + //工装类型 + if(exampleBomLine.getStringProperty("bl_occ_type").equals("METool")) { + frockNo++; + List FrockData=new ArrayList(); + //FrockData.add(String.valueOf(frockNo)); + FrockData.add(exampleBomLine.getItemRevision().getStringProperty("item_id")); + FrockData.add(exampleBomLine.getItemRevision().getStringProperty("object_name")); + FrockDatas.add(FrockData); + } + + } + + + } + } + + //合并工装数量 + if(FrockDatas!=null) { + Map frockMapNo=new HashMap(); + Map frockMapName=new HashMap(); + List listValuefrock=new ArrayList(); + for(int m=0;m FrockData=new ArrayList(); + FrockData.add(String.valueOf(n+1)); + FrockData.add(listValuefrock.get(n)); + FrockData.add(frockMapName.get(listValuefrock.get(n))); + FrockData.add(String.valueOf(frockMapNo.get(listValuefrock.get(n)))); + FrockDatas.add(FrockData); + } + } + + + + //合并物料数量 + if(MaterialDatas!=null) { + Map materialMapNo=new HashMap(); + Map materialMapName=new HashMap(); + Map materialMapTh=new HashMap();//图号 + List listValue=new ArrayList(); + for(int m=0;m MaterialData=new ArrayList(); + MaterialData.add(String.valueOf(n+1)); + MaterialData.add(listValue.get(n)); + MaterialData.add(materialMapName.get(listValue.get(n))); + MaterialData.add(materialMapTh.get(listValue.get(n))); + MaterialData.add(String.valueOf(materialMapNo.get(listValue.get(n)))); + MaterialDatas.add(MaterialData); + } + + } +// //++++ +// MaterialDatas.clear(); +// for(int i=0;i<17;i++) { +// List MaterialData=new ArrayList(); +// MaterialData.add(String.valueOf(i+1)); +// MaterialData.add(20211127+String.valueOf(i+1)); +// MaterialData.add("物料"+i); +// MaterialData.add("图号"+i); +// MaterialData.add(String.valueOf(i+1)); +// MaterialDatas.add(MaterialData); +// } +// FrockDatas.clear(); +// for(int i=0;i<17;i++) { +// List MaterialData=new ArrayList(); +// MaterialData.add(String.valueOf(i+1)); +// MaterialData.add(20211127+String.valueOf(i+1)); +// MaterialData.add("物料"+i); +// MaterialData.add(String.valueOf(i+1)); +// FrockDatas.add(MaterialData); +// } +// //+++ + + jobTree.setWorkStep(WorkStepDatas); + jobTree.setFrock(FrockDatas); + jobTree.setMaterial(MaterialDatas); + + System.out.println("工序ID:"+jobTree.getItemID()); + System.out.println("工序名称:"+jobTree.getName()); + System.out.println("产品代号:"+jobTree.getProductCode()); + System.out.println("产品型号:"+jobTree.getProductType()); + System.out.println("标准时间:"+jobTree.getTime()); + System.out.println("--->获取到的工装数据:"+jobTree.getFrock().toString()); + System.out.println("--->获取到的物料数据:"+jobTree.getMaterial().toString()); + System.out.println("工步数据:"+jobTree.getWorkStep().toString()); + + + //每个工序生成一棵树 + + GWZYZDSDialog gwzyzdsDialog=new GWZYZDSDialog(comp,session,jobTree,MEOPBomLine.getItem()); + } + } + + + //通过图片获取对象复制图片 + public String copyImage(TCComponent ttComponent,String name) throws TCException { + TCComponentDataset Dataset; + TCComponentTcFile picFile; + Dataset=(TCComponentDataset) ttComponent; + TCComponentTcFile[] tcFile; + tcFile =Dataset.getTcFiles(); + picFile=tcFile[0]; + MethodUtil.CopyPic(picFile.getFmsFile(),System.getenv("TEMP") + "\\"+name); + return System.getenv("TEMP") + "\\"+name; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSDialog.java new file mode 100644 index 0000000..3a79e58 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSDialog.java @@ -0,0 +1,490 @@ +package com.connor.ml.tcm.outfile.ML_03; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.TreePath; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.ML_01.JTreeTable; +import com.connor.ml.tcm.outfile.ML_01.JTreeTableModel; +import com.connor.ml.tcm.outfile.ML_02.Tree02; +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.Adapter; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.itextpdf.text.pdf.codec.Base64.InputStream; +import com.spire.xls.ExcelPicture; +import com.spire.xls.ExcelVersion; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.internal.core._2008_06.dispatchermanagement.InsertDatasetVersionArgs; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class GWZYZDSDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private InterfaceAIFComponent comp; + + private List> WorkStepDatas=new ArrayList>();//工步 + private List> MaterialDatas=new ArrayList>();//物料 + private List> FrockDatas=new ArrayList>();//工装 + private Tree03 tree; + private TCComponentItem target; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private String nameString=""; + private double RowHeight=20; +// public GWZYZDSDialog(InterfaceAIFComponent comp, TCSession session,Tree tree,TCComponentItem target) throws IOException { +// // TODO Auto-generated constructor stub +// super(false); +// this.session = session; +// this.comp = comp; +// this.tree=tree; +// this.target=target; +// nameString=tree.getItemID()+tree.getName(); +// init(); +// } + int numss; + public GWZYZDSDialog(InterfaceAIFComponent comp, TCSession session,Tree03 tree,TCComponentItem target) throws IOException { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.tree=tree; + this.target=target; + this.nameString=tree.getItemID()+tree.getName(); + //this.nameString="test"; + init(); + + } + + private void init() throws IOException { + //创建Workbook对象 + Workbook wb = new Workbook(); + File file1 = null; + file1=MethodUtil.getFile(session, "工位作业指导书", "MSExcelX"); + FileInputStream input1 = new FileInputStream(file1); + wb.loadFromHtml(input1); + //加载一个测试文档 + //wb.loadFromFile("C:\\美菱导出测试\\作业指导书.xlsx"); + //MessageBox.post(outPathString,"错误",MessageBox.ERROR); + //获取第一个工作表 + Worksheet sheet = wb.getWorksheets().get(0); + sheet.setName(nameString+"工位作业指导书"); + + //公式 + String Formula1 = "=IF(ml8_Design=\"\",\"\",ml8_Design)";//编制 + String Formula2 = "=IF(ml8_Examine=\"\",\"\",ml8_Examine)";//审核 + String Formula3 = "=IF(ml8_Standardization=\"\",\"\",ml8_Standardization)";//会签 + String Formula4 = "=IF(ml8_Approval=\"\",\"\",ml8_Approval)";//批准 + + + //获取行高 + RowHeight=sheet.getRowHeight(12); + + + ExcelPicture pic1 = sheet.getPictures().get(0); + BufferedImage loImage1 = pic1.getPicture(); + ImageIO.write(loImage1,"jpg",new File(outPathString+"图标1.jpg")); +// ExcelPicture pic2 = sheet.getPictures().get(0); +// BufferedImage loImage2 = pic2.getPicture(); +// ImageIO.write(loImage2,"jpg",new File(outPathString+"图标2.jpg")); +// ExcelPicture pic3 = sheet.getPictures().get(0); +// BufferedImage loImage3 = pic3.getPicture(); +// ImageIO.write(loImage3,"jpg",new File(outPathString+"图标3.jpg")); + + + //判断一共复制多少表格 + WorkStepDatas=tree.getWorkStep(); + MaterialDatas=tree.getMaterial(); + FrockDatas=tree.getFrock(); + int num=0; + if(WorkStepDatas!=null) { + num=(int) Math.ceil((double)WorkStepDatas.size()/6); + if((int) Math.ceil((double)MaterialDatas.size()/10)>num) { + num=(int) Math.ceil((double)MaterialDatas.size()/10); + } + if((int) Math.ceil((double)FrockDatas.size()/5)>num) { + num=(int) Math.ceil((double)FrockDatas.size()/5); + } + } + + //在工作表内复制单元格区域 + for(int i=1;i WorkStepData=new ArrayList(); + WorkStepData=WorkStepDatas.get(i-1); + int startRow=flag*27+1;//开始行 + if(i%6!=0) { + switch (i%6) { + case 1: + InsertWorkStepData(sheet,startRow,10,1,WorkStepData); + break; + case 2: + InsertWorkStepData(sheet,startRow,15,1,WorkStepData); + break; + case 3: + InsertWorkStepData(sheet,startRow,20,1,WorkStepData); + break; + case 4: + InsertWorkStepData(sheet,startRow,10,18,WorkStepData); + break; + case 5: + InsertWorkStepData(sheet,startRow,15,18,WorkStepData); + break; + default: + break; + } + }else { + InsertWorkStepData(sheet,startRow,20,18,WorkStepData); + flag++; + } + } + flag=0; + //插入物料 + for(int i=1;i<=MaterialDatas.size();i++) { + List MaterialData=new ArrayList(); + MaterialData=MaterialDatas.get(i-1); + int startRow=flag*27+1;//开始行 + if(i%10!=0) { + switch (i%10) { + case 1: + InsertMaterialData(sheet,startRow,4,1,MaterialData); + break; + case 2: + InsertMaterialData(sheet,startRow,5,1,MaterialData); + break; + case 3: + InsertMaterialData(sheet,startRow,6,1,MaterialData); + break; + case 4: + InsertMaterialData(sheet,startRow,7,1,MaterialData); + break; + case 5: + InsertMaterialData(sheet,startRow,8,1,MaterialData); + break; + case 6: + InsertMaterialData(sheet,startRow,4,13,MaterialData); + break; + case 7: + InsertMaterialData(sheet,startRow,5,13,MaterialData); + break; + case 8: + InsertMaterialData(sheet,startRow,6,13,MaterialData); + break; + case 9: + InsertMaterialData(sheet,startRow,7,13,MaterialData); + break; + default: + break; + } + }else { + InsertMaterialData(sheet,startRow,8,13,MaterialData); + flag++; + } + } + flag=0; + //插入工装 + for(int i=1;i<=FrockDatas.size();i++) { + List FrockData=new ArrayList(); + FrockData=FrockDatas.get(i-1); + int startRow=flag*27+1;//开始行 + if(i%5!=0) { + switch (i%5) { + case 1: + InsertFrockData(sheet,startRow,4,25,FrockData); + break; + case 2: + InsertFrockData(sheet,startRow,5,25,FrockData); + break; + case 3: + InsertFrockData(sheet,startRow,6,25,FrockData); + break; + case 4: + InsertFrockData(sheet,startRow,7,25,FrockData); + break; + default: + break; + } + }else { + InsertFrockData(sheet,startRow,8,25,FrockData); + flag++; + } + } + wb.saveToFile(outPathString+nameString+"工位指导书.xlsx"); + Worksheet sheetRemove = wb.getWorksheets().get(wb.getActiveSheetIndex());//删除有水印的最后一页 + sheetRemove.remove(); + wb.saveToFile(outPathString+nameString+"工位指导书.xlsx"); + try { + if (MethodUtil.getExcelToItem(session, this.target.getLatestItemRevision(), "ML8_ProcessSOP", "MSExcelX", + nameString + "工位作业指导书") != null) { + MethodUtil.changeDataSet( + MethodUtil.getExcelToDataset(session, this.target.getLatestItemRevision(), "ML8_ProcessSOP", + "MSExcelX", nameString + "工位作业指导书"), + "excel", "MSExcelX", outPathString + nameString + "工位指导书.xlsx"); + } else { + MethodUtil.setExcelToItem(session, this.target.getLatestItemRevision(), + outPathString + nameString + "工位指导书.xlsx", nameString + "工位作业指导书", "ML8_ProcessSOP", + "MSExcelX", true); + + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(new File(outPathString+nameString+"工位指导书.xlsx").exists()) { + new File(outPathString+nameString+"工位指导书.xlsx").delete(); + } + } + + + //创建表格 + public void copyTable(Worksheet sheet, int startRow,int endRow) throws IOException { + String s1="A".concat(String.valueOf(startRow)); + String s2=":AH".concat(String.valueOf(endRow)); + sheet.copy(sheet.getCellRange("A1:AH26"),sheet.getCellRange( + s1.concat(s2)),true); + //合并单元格 + sheet.getRange().get("A".concat(String.valueOf(startRow)).concat(":F".concat(String.valueOf(startRow+1)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow)).concat(":AD".concat(String.valueOf(startRow+1)))).merge(); + sheet.getRange().get("AE".concat(String.valueOf(startRow)).concat(":AH".concat(String.valueOf(startRow+1)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+2)).concat(":B".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("C".concat(String.valueOf(startRow+2)).concat(":D".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("E".concat(String.valueOf(startRow+2)).concat(":G".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+2)).concat(":K".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("L".concat(String.valueOf(startRow+2)).concat(":M".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+2)).concat(":Q".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+2)).concat(":S".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+2)).concat(":W".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+2)).concat(":Z".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("AA".concat(String.valueOf(startRow+2)).concat(":AB".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+2)).concat(":AD".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("AE".concat(String.valueOf(startRow+2)).concat(":AF".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("AG".concat(String.valueOf(startRow+2)).concat(":AH".concat(String.valueOf(startRow+2)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+3)).concat(":D".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("E".concat(String.valueOf(startRow+3)).concat(":G".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+3)).concat(":K".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+3)).concat(":P".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+3)).concat(":S".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+3)).concat(":W".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+3)).concat(":AB".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+3)).concat(":AG".concat(String.valueOf(startRow+3)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+4)).concat(":D".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("E".concat(String.valueOf(startRow+4)).concat(":G".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+4)).concat(":K".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+4)).concat(":P".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+4)).concat(":S".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+4)).concat(":W".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+4)).concat(":AB".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+4)).concat(":AG".concat(String.valueOf(startRow+4)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+5)).concat(":D".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("E".concat(String.valueOf(startRow+5)).concat(":G".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+5)).concat(":K".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+5)).concat(":P".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+5)).concat(":S".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+5)).concat(":W".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+5)).concat(":AB".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+5)).concat(":AG".concat(String.valueOf(startRow+5)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+6)).concat(":D".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("E".concat(String.valueOf(startRow+6)).concat(":G".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+6)).concat(":K".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+6)).concat(":P".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+6)).concat(":S".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+6)).concat(":W".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+6)).concat(":AB".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+6)).concat(":AG".concat(String.valueOf(startRow+6)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+7)).concat(":D".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("E".concat(String.valueOf(startRow+7)).concat(":G".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+7)).concat(":K".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+7)).concat(":P".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+7)).concat(":S".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+7)).concat(":W".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+7)).concat(":AB".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+7)).concat(":AG".concat(String.valueOf(startRow+7)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+8)).concat(":D".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("E".concat(String.valueOf(startRow+8)).concat(":G".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+8)).concat(":K".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("N".concat(String.valueOf(startRow+8)).concat(":P".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+8)).concat(":S".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+8)).concat(":W".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("Z".concat(String.valueOf(startRow+8)).concat(":AB".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("AC".concat(String.valueOf(startRow+8)).concat(":AG".concat(String.valueOf(startRow+8)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+9)).concat(":F".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+9)).concat(":N".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("O".concat(String.valueOf(startRow+9)).concat(":Q".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("S".concat(String.valueOf(startRow+9)).concat(":W".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+9)).concat(":AE".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("AF".concat(String.valueOf(startRow+9)).concat(":AH".concat(String.valueOf(startRow+9)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+10)).concat(":A".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+10)).concat(":F".concat(String.valueOf(startRow+10)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+11)).concat(":F".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+10)).concat(":G".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+10)).concat(":N".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("O".concat(String.valueOf(startRow+10)).concat(":Q".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+10)).concat(":R".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("S".concat(String.valueOf(startRow+10)).concat(":W".concat(String.valueOf(startRow+10)))).merge(); + sheet.getRange().get("S".concat(String.valueOf(startRow+11)).concat(":W".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+10)).concat(":X".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+10)).concat(":AE".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("AF".concat(String.valueOf(startRow+10)).concat(":AH".concat(String.valueOf(startRow+14)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+15)).concat(":A".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+15)).concat(":F".concat(String.valueOf(startRow+15)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+16)).concat(":F".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+15)).concat(":G".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+15)).concat(":N".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("O".concat(String.valueOf(startRow+15)).concat(":Q".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+15)).concat(":R".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("S".concat(String.valueOf(startRow+15)).concat(":W".concat(String.valueOf(startRow+15)))).merge(); + sheet.getRange().get("S".concat(String.valueOf(startRow+16)).concat(":W".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+15)).concat(":X".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+15)).concat(":AE".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("AF".concat(String.valueOf(startRow+15)).concat(":AH".concat(String.valueOf(startRow+19)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+20)).concat(":A".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+20)).concat(":F".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("B".concat(String.valueOf(startRow+21)).concat(":F".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("G".concat(String.valueOf(startRow+20)).concat(":G".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("H".concat(String.valueOf(startRow+20)).concat(":N".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("O".concat(String.valueOf(startRow+20)).concat(":Q".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("R".concat(String.valueOf(startRow+20)).concat(":R".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("S".concat(String.valueOf(startRow+20)).concat(":W".concat(String.valueOf(startRow+20)))).merge(); + sheet.getRange().get("S".concat(String.valueOf(startRow+21)).concat(":W".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("X".concat(String.valueOf(startRow+20)).concat(":X".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("Y".concat(String.valueOf(startRow+20)).concat(":AE".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("AF".concat(String.valueOf(startRow+20)).concat(":AH".concat(String.valueOf(startRow+24)))).merge(); + sheet.getRange().get("A".concat(String.valueOf(startRow+25)).concat(":C".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("D".concat(String.valueOf(startRow+25)).concat(":H".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("I".concat(String.valueOf(startRow+25)).concat(":K".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("L".concat(String.valueOf(startRow+25)).concat(":P".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("Q".concat(String.valueOf(startRow+25)).concat(":S".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("T".concat(String.valueOf(startRow+25)).concat(":AA".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("AB".concat(String.valueOf(startRow+25)).concat(":AC".concat(String.valueOf(startRow+25)))).merge(); + sheet.getRange().get("AD".concat(String.valueOf(startRow+25)).concat(":AH".concat(String.valueOf(startRow+25)))).merge(); + + for(int i=10;i<25;i++) { + sheet.setRowHeight(startRow+i,RowHeight); + } +// //sheet.getRange().get("".concat(String.valueOf(startRow+)).concat(":".concat(String.valueOf(startRow+)))).merge(); + //插入图片 + MethodUtil.InsertTitlePicture(sheet,outPathString+"图标1.jpg",new int[] {startRow,startRow+1}, + new int[] {1,2,3,4,5,6},false ,0,0); +// ExcelPicture pic2 = sheet.getPictures().add(startRow, 29,outPathString+"图标2.jpg"); +// pic2.setWidth(155); +// pic2.setHeight(43); +// ExcelPicture pic3 = sheet.getPictures().add(startRow+27, 1,outPathString+"图标3.jpg"); +// pic3.setWidth(1350); +// pic3.setHeight(25); + } + //工步插入数据 + public void InsertWorkStepData(Worksheet sheet,int startRow,int row,int column,List dataList) throws IOException { + sheet.setText(startRow+row, column, (dataList.get(0)==null||dataList.get(0).equals(""))?" ":dataList.get(0)); + sheet.setText(startRow+row, column+1, (dataList.get(1)==null||dataList.get(1).equals(""))?" ":dataList.get(1)); + sheet.setText(startRow+row+1, column+1, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); + sheet.setText(startRow+row, column+6, (dataList.get(3)==null||dataList.get(3).equals(""))?" ":dataList.get(3)); + if(dataList.get(4).equals("")) { + + }else { + //行高:3.75CM;列宽:5.25CM + MethodUtil.InsertTitlePicture(sheet,dataList.get(4),new int[] {startRow+row,startRow+row+1,startRow+row+2,startRow+row+3,startRow+row+4}, + new int[] {column+7,column+8,column+9,column+10,column+11,column+12,column+13},true,3.75 ,5.25); + } + sheet.setText(startRow+row, column+14, (dataList.get(5)==null||dataList.get(5).equals(""))?" ":dataList.get(5)); + } + //物料插入数据 + public void InsertMaterialData(Worksheet sheet,int startRow,int row,int column,List dataList) { + sheet.setText(startRow+row, column, (dataList.get(0)==null||dataList.get(0).equals(""))?" ":dataList.get(0)); + sheet.setText(startRow+row, column+1, (dataList.get(1)==null||dataList.get(1).equals(""))?" ":dataList.get(1)); + sheet.setText(startRow+row, column+4, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); + sheet.setText(startRow+row, column+7, (dataList.get(3)==null||dataList.get(3).equals(""))?" ":dataList.get(3)); + sheet.setText(startRow+row, column+11, (dataList.get(4)==null||dataList.get(4).equals(""))?" ":dataList.get(4)); + } + //工装插入数据 + public void InsertFrockData(Worksheet sheet,int startRow,int row,int column,List dataList) { + sheet.setText(startRow+row, column, (dataList.get(0)==null||dataList.get(0).equals(""))?" ":dataList.get(0)); + sheet.setText(startRow+row, column+1, (dataList.get(1)==null||dataList.get(1).equals(""))?" ":dataList.get(1)); + sheet.setText(startRow+row, column+4, (dataList.get(2)==null||dataList.get(2).equals(""))?" ":dataList.get(2)); + sheet.setText(startRow+row, column+9,( dataList.get(3)==null||dataList.get(3).equals(""))?" ":dataList.get(3)); + } + + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSHandler.java new file mode 100644 index 0000000..78d44fc --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/GWZYZDSHandler.java @@ -0,0 +1,69 @@ +package com.connor.ml.tcm.outfile.ML_03; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; + +import javax.imageio.ImageIO; + +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.outfile.ML_02.GXZYZDSCommand; +import com.itextpdf.text.pdf.codec.Base64.InputStream; +import com.sap.tc.logging.standard.Message; +import com.spire.xls.*; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.core._2008_06.datamanagement.IntMap; + +import java.awt.image.BufferedImage; +import java.io.*; + + +public class GWZYZDSHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent comp; + try { + comp=app.getTargetComponent(); + if(!(comp instanceof TCComponentBOMLine)) { + MessageBox.post("请在结构管理器或制造工艺规划器中选中BOMLine对象!", "错误", MessageBox.ERROR); + }else if(((TCComponentBOMLine)comp).getItemRevision().getProperty("release_status_list") != ""){ + MessageBox.post("选择对象已发布,无法生成工位作业指导书。", "错误", MessageBox.ERROR); + }else{ + if(((TCComponentBOMLine)comp).getItem().getType().equals("ML8_PlantBOP")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_ProcLine")|| + ((TCComponentBOMLine)comp).getItem().getType().equals("ML8_ProcStatn")) { + GWZYZDSCommand command = new GWZYZDSCommand(app.getTargetComponent(),session); + command.executeModal(); + }else { + MessageBox.post("请选择工厂BOP、工位工艺、产线工艺对象!", "错误", MessageBox.ERROR); + } + } + // MessageBox.post("cuowu ", "错误", MessageBox.ERROR); + }catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/Tree03.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/Tree03.java new file mode 100644 index 0000000..e548c91 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_03/Tree03.java @@ -0,0 +1,71 @@ +package com.connor.ml.tcm.outfile.ML_03; + +import java.util.ArrayList; +import java.util.List; + +public class Tree03 { + private String ProductCode;//产品代号 + private String ProductType;//产品型号 + private String LineBody;//产品型号 + private String ItemID;//工序编号 + private String Name;//工序名称 + private String Time;//标准时间 + private List> WorkStep=new ArrayList>();//工步 + private List> Material=new ArrayList>();//物料 + private List> Frock=new ArrayList>();//工装 + + public void setProductCode(String ProductCode) { + this.ProductCode=ProductCode; + } + public String getProductCode() { + return this.ProductCode; + } + public void setProductType(String ProductType) { + this.ProductType=ProductType; + } + public String getProductType() { + return this.ProductType; + } + public void setLineBody(String LineBody) { + this.LineBody=LineBody; + } + public String getLineBody() { + return this.LineBody; + } + public void setItemID(String ItemID) { + this.ItemID=ItemID; + } + public String getItemID() { + return this.ItemID; + } + public void setName(String Name) { + this.Name=Name; + } + public String getName() { + return this.Name; + } + public void setTime(String Time) { + this.Time=Time; + } + public String getTime() { + return this.Time; + } + public void setMaterial(List> Material) { + this.Material=Material; + } + public List> getMaterial() { + return this.Material; + } + public void setFrock(List> Frock) { + this.Frock=Frock; + } + public List> getFrock() { + return this.Frock; + } + public void setWorkStep(List> WorkStep) { + this.WorkStep=WorkStep; + } + public List> getWorkStep() { + return this.WorkStep; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/CPGYSOPCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/CPGYSOPCommand.java new file mode 100644 index 0000000..bbdfc72 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/CPGYSOPCommand.java @@ -0,0 +1,205 @@ +package com.connor.ml.tcm.outfile.ML_09; + +import java.awt.image.RenderedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; + +import org.jdesktop.swingx.renderer.StringValue; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.ML_02.GXZYZDSDialog; +import com.connor.ml.tcm.outfile.ML_02.Tree02; +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.ExcelUtil07; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.ibm.icu.util.Calendar; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.exceptions.NotLoadedException; +import java.util.Date; +import java.text.SimpleDateFormat; + + +public class CPGYSOPCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine BomLine = null; + private String ProductItemID="";//产品ID + private String ProductName="";//产品名称 + private String ProductCode="";//产品代号 + private String ProductType="";//产品型号 + private String carrentDate="";//当前时间 + private String LCKtitle="";//订单工艺流程卡标题 + private String ManufacturingCompany="";//制造公司 + private String Manager="";//经营体 + private double TotalHours=0.0;//总工时 + private int Totals=0;//总工位数 + private List> StationDatas=new ArrayList>();//总工时数据 + private Map Files=new HashMap();//工位工艺作业指导书 + private List files=new ArrayList();//工位工艺作业指导书 + private String falseNameString=""; + private Tree09 jobTree=new Tree09(); + private String ERPCode=""; + public CPGYSOPCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //获取选中的对象 + BomLine = (TCComponentBOMLine) comp; + + //获取产品版本对象 + TCComponentBOMLine topBomLine=MethodUtil.getTopLine(BomLine); + TCComponentItemRevision productItem; + if(topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget").length==0) { + MessageBox.post("目标下无产品!", "失败", MessageBox.INFORMATION); + return; + }else { + productItem=(TCComponentItemRevision) (topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget"))[0]; + } + + + //产品ID + ProductItemID=ExcelUtil07.getID(productItem.getStringProperty("item_id")); + + //产品名称 + ProductName=(productItem.getStringProperty("object_name")); + + //产品代号 + ProductCode=productItem.getStringProperty("ml8_ProductCode"); + + //产品型号 + ProductType=productItem.getStringProperty("ml8_ProductType"); + + //当前时间 + Calendar c = Calendar.getInstance();//可以对每个时间域单独修改 + int year = c.get(Calendar.YEAR); + int month = c.get(Calendar.MONTH); + int date = c.get(Calendar.DATE); + //MessageBox.post(String.valueOf(year)+":"+String.valueOf(month+1)+":"+String.valueOf(date), "错误", MessageBox.ERROR); + carrentDate=String.valueOf(year)+"年"+String.valueOf(month+1)+"月"+String.valueOf(date)+"日"; + + //订单工艺流程卡标题 + LCKtitle=ProductItemID+" "+"订单工艺流程卡"; + + //制造公司 + ManufacturingCompany=productItem.getPropertyDisplayableValue("ml8_Factory"); + + + //经营体 + Manager=productItem.getStringProperty("ml8_Line"); + + + getOP(BomLine); + + +// if(falseNameString!=""||!falseNameString.equals("")) { +// //MessageBox.post(falseNameString+"版本下没有没有工序卡片,不能够合成产品工艺SOP!", "失败", MessageBox.INFORMATION); +// }else { + jobTree.setTitle(ProductItemID+" "+"产品工艺作业指导书"); + jobTree.setLCKtitle(LCKtitle); + jobTree.setProductItemID(ProductItemID); + jobTree.setProductName(ProductName); + jobTree.setProductCode(ProductCode); + jobTree.setProductType(ProductType); + jobTree.setManufacturingCompany(ManufacturingCompany); + jobTree.setManager(Manager); + jobTree.setcarrentDate(carrentDate); + jobTree.setTotalHours(String.valueOf(TotalHours)); + jobTree.setTotals(String.valueOf(Totals)); + jobTree.setMEOP(StationDatas); + CPGYSOPDialog cpgysopDialog=new CPGYSOPDialog(comp,session,jobTree,BomLine.getItem(),Files,files); + + System.out.println("标题:"+jobTree.getTitle()); + System.out.println("产品ID:"+jobTree.getProductItemID()); + System.out.println("产品名称:"+jobTree.getProductName()); + System.out.println("产品代号:"+jobTree.getProductCode()); + System.out.println("产品型号:"+jobTree.getProductType()); + System.out.println("当前时间:"+jobTree.getcarrentDate()); + System.out.println("制造公司:"+jobTree.getManufacturingCompany()); + System.out.println("经营体:"+jobTree.getManager()); + System.out.println("总工位数:"+jobTree.getTotals()); + System.out.println("总工时:"+jobTree.getTotalHours()); + System.out.println("工序数据:"+jobTree.getMEOP().toString()); + + MessageBox.post("产品工艺SOP已输出成功", "成功", MessageBox.INFORMATION); +// } + + } + + //分解工艺 + public void getOP(TCComponentBOMLine OPprocess) throws TCException, IOException, NotLoadedException { + if(OPprocess.getItem().getType().indexOf("Op")>-1) {//工序 + getMeopValues(OPprocess); + }else { + TCComponent[] tccomponets=OPprocess.getReferenceListProperty("Mfg0sub_elements"); + for(int i=0;i StationData=new ArrayList(); + Double allWorkTime = 0.0; + StationData.add(String.valueOf((StationDatas.size()+1)));//序号 + String ID=ExcelUtil07.getID(bomline.getItemRevision().getStringProperty("item_id"));//工序编号 + String name=bomline.getItemRevision().getStringProperty("object_name");//工序名称 + StationData.add(ID);//工序编号 + StationData.add(name);//工序名称 + if(MethodUtil.getExcelDateSet(session,bomline.getItemRevision(),"IMAN_specification","MSExcelX",ID+name+"工序作业指导书")!=null) { + files.add(ID+name+"工序作业指导书"); + Files.put(ID+name+"工序作业指导书",MethodUtil.getExcelDateSet(session,bomline.getItemRevision(),"IMAN_specification","MSExcelX",ID+name+"工序作业指导书")); + }else { + falseNameString=bomline.getItemRevision().getStringProperty("object_name"); + } + allWorkTime=bomline.getDoubleProperty("bl_me_work_time"); + TotalHours=TotalHours+allWorkTime; + StationData.add(String.valueOf(allWorkTime)); + StationDatas.add(StationData); + } + + +// //通过图片获取对象复制图片 +// public String copyImage(TCComponent ttComponent,String name) throws TCException { +// TCComponentDataset Dataset; +// TCComponentTcFile picFile; +// Dataset=(TCComponentDataset) ttComponent; +// TCComponentTcFile[] tcFile; +// tcFile =Dataset.getTcFiles(); +// picFile=tcFile[0]; +// MethodUtil.CopyPic(picFile.getFmsFile(),System.getenv("TEMP") + "\\"+name); +// return System.getenv("TEMP") + "\\"+name; +// } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/CPGYSOPDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/CPGYSOPDialog.java new file mode 100644 index 0000000..1b8f29d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/CPGYSOPDialog.java @@ -0,0 +1,335 @@ +package com.connor.ml.tcm.outfile.ML_09; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Robot; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.TreePath; + +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.ML_01.JTreeTable; +import com.connor.ml.tcm.outfile.ML_01.JTreeTableModel; +import com.connor.ml.tcm.outfile.ML_02.Tree02; +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.Adapter; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.itextpdf.text.pdf.codec.Base64.InputStream; +import com.spire.xls.ExcelFont; +import com.spire.xls.ExcelPicture; +import com.spire.xls.ExcelVersion; +import com.spire.xls.RichText; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.spire.xls.core.IFont; +import com.spire.xls.core.spreadsheet.shapes.XlsTextBoxShape; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.internal.core._2008_06.dispatchermanagement.InsertDatasetVersionArgs; +import com.teamcenter.soa.exceptions.NotLoadedException; + +public class CPGYSOPDialog extends AbstractAIFDialog implements ActionListener { + + private TCSession session; + private InterfaceAIFComponent comp; + + private List> StationDatas=new ArrayList>();//工步 + private Tree09 tree; + private TCComponentItem target; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private String nameString=""; + private Map Files=new HashMap();//工位工艺作业指导书 + private List files=new ArrayList();//工位工艺作业指导书 + //InterfaceAIFComponent comp, TCSession session,Tree05 tree,TCComponentItem target + public CPGYSOPDialog(InterfaceAIFComponent comp, TCSession session,Tree09 tree,TCComponentItem target, + Map Files,List files) throws IOException { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.tree=tree; + this.target=target; + this.nameString=tree.getProductCode()+"("+tree.getProductType()+")"; + this.Files=Files; + this.files=files; + //this.nameString="test"; + init(); + + } +// public DDGYSOPDialog(TCSession session) throws IOException { +// this.session = session; +// init(); +// } + + private void init() throws IOException { + //创建Workbook对象 + Workbook wb = new Workbook(); + + //产品工艺封面 + File file1 = null; + file1=MethodUtil.getFile(session, "产品工艺SOP封面", "MSExcelX"); + FileInputStream input1 = new FileInputStream(file1); + wb.loadFromHtml(input1); + //获取第一个工作表 + Worksheet sheet1 = wb.getWorksheets().get(0); + XlsTextBoxShape shape0 = (XlsTextBoxShape)sheet1.getTextBoxes().get(0); + shape0.setText(tree.getTitle()); + XlsTextBoxShape shape1 = (XlsTextBoxShape)sheet1.getTextBoxes().get(3); + shape1.setText("产品名称:"+tree.getProductName()); + XlsTextBoxShape shape2 = (XlsTextBoxShape)sheet1.getTextBoxes().get(4); + shape2.setText("产品型号:"+tree.getProductType()); + XlsTextBoxShape shape3 = (XlsTextBoxShape)sheet1.getTextBoxes().get(2); + shape3.setText(tree.getcarrentDate()); + + ExcelFont font1=wb.createFont(); + font1.setFontName("宋体(正文)"); + font1.setSize(32); + shape0.getRichText().setFont(0, shape0.getText().length() - 1, font1); + ExcelFont font2=wb.createFont(); + font2.setFontName("宋体(正文)"); + font2.setSize(20); + ExcelFont font3=wb.createFont(); + font3.setFontName("Calibri (正文)"); + font3.setSize(11); + + shape1.getRichText().setFont(0, shape1.getText().length() - 1, font2); + shape2.getRichText().setFont(0, shape2.getText().length() - 1, font2); + shape3.getRichText().setFont(0, shape3.getText().length() - 1, font3); + + //变更记录单 + File file2 = null; + file2=MethodUtil.getFile(session, "产品工艺变更记录单", "MSExcelX"); + FileInputStream input2 = new FileInputStream(file2); + Workbook wb2 = new Workbook(); + wb2.loadFromHtml(input2); + Worksheet sheet2 = wb2.getWorksheets().get(0); + Worksheet sheetAdd2 = wb.getWorksheets().add("变更记录单"); + sheetAdd2.copyFrom(sheet2); + + //工艺流程卡 + File file3 = null; + file3=MethodUtil.getFile(session, "产品工艺流程卡", "MSExcelX"); + FileInputStream input3 = new FileInputStream(file3); + Workbook wb3 = new Workbook(); + wb3.loadFromHtml(input3); + Worksheet sheet3 = wb3.getWorksheets().get(0); + Worksheet sheetAdd3 = wb.getWorksheets().add("工艺流程卡"); + sheetAdd3.copyFrom(sheet3); + + //插入工艺流程卡的数据 + StationDatas=tree.getMEOP(); + Worksheet sheetLCK = wb.getWorksheets().get(2); + //记录行高数据 + double H7=sheetLCK.getRowHeight(7); + double H8=sheetLCK.getRowHeight(8); + double H9=sheetLCK.getRowHeight(9); + double H10=sheetLCK.getRowHeight(10); + sheetLCK.setText(1, 1, (tree.getLCKtitle()==null||tree.getLCKtitle().equals(""))?" ":tree.getLCKtitle().toString()); + sheetLCK.setText(5, 5, (tree.getManufacturingCompany()==null||tree.getManufacturingCompany().equals(""))?" ":tree.getManufacturingCompany().toString()); + sheetLCK.setText(5, 16, (tree.getManager()==null||tree.getManager().equals(""))?" ":tree.getManager().toString()); + sheetLCK.setText(5, 26, String.valueOf(StationDatas.size())); + sheetLCK.setText(5, 38, (tree.getTotalHours()==null||tree.getTotalHours().equals(""))?" ":tree.getTotalHours().toString()); + int num=0; + num=(int) Math.ceil((double)tree.getMEOP().size()/42); + //复制单元格 + for(int i=1;i StationData=new ArrayList(); + if(StationDatas.size()>42*i+j) { + StationData=StationDatas.get(42*i+j); + sheetLCK.setText(7+i*4, j+2, (StationData.get(0) == null || StationData.get(0).equals("")) ? " " : (StationData.get(0)).toString()); + sheetLCK.setText(8+i*4, j+2, (StationData.get(1) == null || StationData.get(1).equals("")) ? " " : (StationData.get(1)).toString()); + sheetLCK.setText(9+i*4, j+2, (StationData.get(2) == null || StationData.get(2).equals("")) ? " " : (StationData.get(2)).toString()); + sheetLCK.setText(10+i*4, j+2, (StationData.get(3) == null || StationData.get(3).equals("")) ? " " : (StationData.get(3)).toString()); + } + + } + } + + + //添加工位工艺作业指导书 + for(int i=0;i32) { +// num=(int) Math.ceil((double)MEOPDatas.size()/4); +// } +// //插入行 +// sheet.insertRow(10,num*4); +// for(int i=0;i Data=new ArrayList(); +// Data=MEOPDatas.get(i-1); +// int startRow=flag*4+7;//开始行 +// if(i%4!=0) { +// switch (i) { +// case 1: +// insertData(sheet,startRow,1,Data); +// break; +// case 2: +// insertData(sheet,startRow,3,Data); +// break; +// case 3: +// insertData(sheet,startRow,5,Data); +// break; +// default: +// break; +// } +// }else { +// insertData(sheet,startRow,7,Data); +// flag++; +// } +// +// } +// + + +// File file=new File(outPathString+"工艺流程图(水印).xlsx"); +// FileInputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outPathString+nameString+".xlsx")); +// XSSFWorkbook wb1 = new XSSFWorkbook(input); +// wb1.removeSheetAt(1); +// wb1.write(output); +// new File(outPathString+"工艺流程图(水印).xlsx").delete(); +// try { +// if(MethodUtil.getExcelToItem(session,this.target.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX") != null) { +// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,this.target.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX"), "excel", "MSExcelX", outPathString+nameString+".xlsx"); +// }else { +// MethodUtil.setExcelToItem(session,this.target.getLatestItemRevision(),outPathString+nameString+".xlsx", +// nameString+"产品工艺流程图","IMAN_specification", +// "MSExcelX", true); +// +// } +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + } + + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/Tree09.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/Tree09.java new file mode 100644 index 0000000..bd7e14c --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_09/Tree09.java @@ -0,0 +1,96 @@ +package com.connor.ml.tcm.outfile.ML_09; + +import java.util.ArrayList; +import java.util.List; + +public class Tree09 { + private String Title;//封面标题 + private String ProductItemID;//产品ID + private String ProductCode;//产品代号 + private String ProductName;//产品名称 + private String carrentDate;//当前时间 + private String ProductType;//产品型号 + private String LCKtitle="";//订单工艺流程卡标题 + private String ManufacturingCompany="";//订单工艺流程卡标题 + private String Manager="";//经营体 + private String TotalHours="";//总工时 + private String Totals="";//总工位数 + private List> MEOP=new ArrayList>();//工序 + + + public void setProductCode(String ProductCode) { + this.ProductCode=ProductCode; + } + public String getProductCode() { + return this.ProductCode; + } + + public void setProductName(String ProductName) { + this.ProductName=ProductName; + } + public String getProductName() { + return this.ProductName; + } + public void setProductType(String ProductType) { + this.ProductType=ProductType; + } + public String getProductType() { + return this.ProductType; + } + + public void setTitle(String Title) { + this.Title=Title; + } + public String getTitle() { + return this.Title; + } + public void setProductItemID(String ProductItemID) { + this.ProductItemID=ProductItemID; + } + public String getProductItemID() { + return this.ProductItemID; + } + public void setLCKtitle(String LCKtitle) { + this.LCKtitle=LCKtitle; + } + public String getLCKtitle() { + return this.LCKtitle; + } + public void setManufacturingCompany(String ManufacturingCompany) { + this.ManufacturingCompany=ManufacturingCompany; + } + public String getManufacturingCompany() { + return this.ManufacturingCompany; + } + public void setManager(String Manager) { + this.Manager=Manager; + } + public String getManager() { + return this.Manager; + } + public void setTotalHours(String TotalHours) { + this.TotalHours=TotalHours; + } + public String getTotalHours() { + return this.TotalHours; + } + public void setTotals(String Totals) { + this.Totals=Totals; + } + public String getTotals() { + return this.Totals; + } + public void setcarrentDate(String carrentDate) { + this.carrentDate=carrentDate; + } + public String getcarrentDate() { + return this.carrentDate; + } + public void setMEOP(List> MEOP) { + this.MEOP=MEOP; + } + public List> getMEOP() { + return this.MEOP; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_10/CXGYSOPCommand.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_10/CXGYSOPCommand.java new file mode 100644 index 0000000..2832616 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_10/CXGYSOPCommand.java @@ -0,0 +1,205 @@ +package com.connor.ml.tcm.outfile.ML_10; + +import java.awt.image.RenderedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; + +import org.jdesktop.swingx.renderer.StringValue; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.outfile.ML_02.GXZYZDSDialog; +import com.connor.ml.tcm.outfile.ML_02.Tree02; +import com.connor.ml.tcm.outfile.bean.NodeBean; +import com.connor.ml.tcm.outfile.util.MethodUtil; +import com.ibm.icu.util.Calendar; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.soa.exceptions.NotLoadedException; +import java.util.Date; +import java.text.SimpleDateFormat; + + +public class CXGYSOPCommand extends AbstractAIFCommand { + + private InterfaceAIFComponent comp; + private TCSession session; + private TCComponentBOMLine BomLine = null; + private String ProductItemID="";//产品代号 + private String ProductName="";//产品名称 + private String ProductType="";//产品型号 + private String carrentDate="";//当前时间 + private String LCKtitle="";//订单工艺流程卡标题 + private String ManufacturingCompany="";//制造公司 + private String Manager="";//经营体 + private double TotalHours=0.0;//总工时 + private int Totals=0;//总工位数 + private List> StationDatas=new ArrayList>();//总工时数据 + private Map Files=new HashMap();//工位工艺作业指导书 + private List files=new ArrayList();//工位工艺作业指导书 + private String falseNameString=""; + private Tree10 jobTree=new Tree10(); + private String ERPCode=""; + public CXGYSOPCommand(InterfaceAIFComponent comp, TCSession session) { + // TODO Auto-generated constructor stub + this.comp = comp; + this.session = session; + } + + @Override + public void executeModal() throws Exception { + // TODO Auto-generated method stub + //获取选中的对象 + BomLine = (TCComponentBOMLine) comp; + + //获取产品版本对象 + TCComponentBOMLine topBomLine=MethodUtil.getTopLine(BomLine); + TCComponentItemRevision productItem; + if(topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget").length==0) { + MessageBox.post("目标下无产品!", "失败", MessageBox.INFORMATION); + return; + }else { + productItem=(TCComponentItemRevision) (topBomLine.getItemRevision().getReferenceListProperty("IMAN_METarget"))[0]; + } + + + //产品物料代码 + ProductItemID=productItem.getStringProperty("item_id"); + //产品名称 + ProductName=(productItem.getStringProperty("object_name")).split("-")[0]; + + //产品型号 + ProductType=productItem.getStringProperty("ml8_ProductType"); + + //当前时间 + Calendar c = Calendar.getInstance();//可以对每个时间域单独修改 + int year = c.get(Calendar.YEAR); + int month = c.get(Calendar.MONTH); + int date = c.get(Calendar.DATE); + //MessageBox.post(String.valueOf(year)+":"+String.valueOf(month+1)+":"+String.valueOf(date), "错误", MessageBox.ERROR); + carrentDate=String.valueOf(year)+"年"+String.valueOf(month+1)+"月"+String.valueOf(date)+"日"; + + //订单工艺流程卡标题 + LCKtitle=ProductItemID+" "+"产线工艺流程卡"; + + //制造公司 + ManufacturingCompany=productItem.getPropertyDisplayableValue("ml8_Factory"); + + //经营体 + Manager=productItem.getStringProperty("ml8_Line"); + + + getOP(BomLine); + + +// if(falseNameString!=""||!falseNameString.equals("")) { +// //MessageBox.post(falseNameString+"版本下没有工位作业指导书,不能够合成产线工艺SOP!", "失败", MessageBox.INFORMATION); +// }else { + jobTree.setTitle(ProductItemID+" "+"产线工艺作业指导书"); + jobTree.setLCKtitle(LCKtitle); + jobTree.setProductItemID(ProductItemID); + jobTree.setProductName(ProductName); + jobTree.setProductType(ProductType); + jobTree.setManager(Manager); + jobTree.setManufacturingCompany(ManufacturingCompany); + jobTree.setcarrentDate(carrentDate); + jobTree.setTotalHours(String.valueOf(TotalHours)); + jobTree.setTotals(String.valueOf(Totals)); + jobTree.setMEOP(StationDatas); + CXGYSOPDialog cxgysopDialog=new CXGYSOPDialog(comp,session,jobTree,BomLine.getItem(),Files,files); + + System.out.println("标题:"+jobTree.getTitle()); + System.out.println("产品ID:"+jobTree.getProductItemID()); + System.out.println("产品名称:"+jobTree.getProductName()); + System.out.println("产品型号:"+jobTree.getProductType()); + System.out.println("当前时间:"+jobTree.getcarrentDate()); + System.out.println("制造公司:"+jobTree.getManufacturingCompany()); + System.out.println("经营体:"+jobTree.getManager()); + System.out.println("总工位数:"+jobTree.getTotals()); + System.out.println("总工时:"+jobTree.getTotalHours()); + System.out.println("工序数据:"+jobTree.getMEOP().toString()); + + MessageBox.post("产线工艺SOP已输出成功", "成功", MessageBox.INFORMATION); + //} + + } + + //分解工艺 + public void getOP(TCComponentBOMLine OPprocess) throws TCException, IOException, NotLoadedException { + if(OPprocess.getItem().getType().equals("ML8_ProcStatn")) {//工位工艺 + getMeopValues(OPprocess); + }else { + TCComponent[] tccomponets=OPprocess.getReferenceListProperty("Mfg0sub_elements"); + for(int i=0;i StationData=new ArrayList(); + Double allWorkTime = 0.0; + AIFComponentContext[] WorkStep=bomline.getChildren();//工步和工位 + for(int j=0;j> StationDatas=new ArrayList>();//工步 + private Tree10 tree; + private TCComponentItem target; + private String outPathString =System.getenv("TEMP") + "\\";//导出路径 + private String nameString=""; + private Map Files=new HashMap();//工位工艺作业指导书 + private List files=new ArrayList();//工位工艺作业指导书 + //InterfaceAIFComponent comp, TCSession session,Tree05 tree,TCComponentItem target + public CXGYSOPDialog(InterfaceAIFComponent comp, TCSession session,Tree10 tree,TCComponentItem target, + Map Files,List files) throws IOException { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.comp = comp; + this.tree=tree; + this.target=target; + this.nameString=tree.getProductItemID(); + this.Files=Files; + this.files=files; + //this.nameString="test"; + init(); + + } +// public DDGYSOPDialog(TCSession session) throws IOException { +// this.session = session; +// init(); +// } + + private void init() throws IOException { + //创建Workbook对象 + Workbook wb = new Workbook(); + + //产线工艺封面 + File file1 = null; + file1=MethodUtil.getFile(session, "产线工艺SOP封面", "MSExcelX"); + FileInputStream input1 = new FileInputStream(file1); + wb.loadFromHtml(input1); + //获取第一个工作表 + Worksheet sheet1 = wb.getWorksheets().get(0); + XlsTextBoxShape shape0 = (XlsTextBoxShape)sheet1.getTextBoxes().get(0); + shape0.setText(tree.getTitle()); + XlsTextBoxShape shape1 = (XlsTextBoxShape)sheet1.getTextBoxes().get(3); + shape1.setText("产品名称:"+tree.getProductName()); + XlsTextBoxShape shape2 = (XlsTextBoxShape)sheet1.getTextBoxes().get(4); + shape2.setText("产品型号:"+tree.getProductType()); + XlsTextBoxShape shape3 = (XlsTextBoxShape)sheet1.getTextBoxes().get(2); + shape3.setText(tree.getcarrentDate()); + + ExcelFont font1=wb.createFont(); + font1.setFontName("宋体(正文)"); + font1.setSize(32); + shape0.getRichText().setFont(0, shape0.getText().length() - 1, font1); + ExcelFont font2=wb.createFont(); + font2.setFontName("宋体(正文)"); + font2.setSize(20); + ExcelFont font3=wb.createFont(); + font3.setFontName("Calibri (正文)"); + font3.setSize(11); + + shape1.getRichText().setFont(0, shape1.getText().length() - 1, font2); + shape2.getRichText().setFont(0, shape2.getText().length() - 1, font2); + shape3.getRichText().setFont(0, shape3.getText().length() - 1, font3); + + //变更记录单 + File file2 = null; + file2=MethodUtil.getFile(session, "产线工艺变更记录单", "MSExcelX"); + FileInputStream input2 = new FileInputStream(file2); + Workbook wb2 = new Workbook(); + wb2.loadFromHtml(input2); + Worksheet sheet2 = wb2.getWorksheets().get(0); + Worksheet sheetAdd2 = wb.getWorksheets().add("变更记录单"); + sheetAdd2.copyFrom(sheet2); + + //工艺流程卡 + File file3 = null; + file3=MethodUtil.getFile(session, "产线工艺流程卡", "MSExcelX"); + FileInputStream input3 = new FileInputStream(file3); + Workbook wb3 = new Workbook(); + wb3.loadFromHtml(input3); + Worksheet sheet3 = wb3.getWorksheets().get(0); + Worksheet sheetAdd3 = wb.getWorksheets().add("工艺流程卡"); + sheetAdd3.copyFrom(sheet3); + + //插入工艺流程卡的数据 + StationDatas=tree.getMEOP(); + Worksheet sheetLCK = wb.getWorksheets().get(2); + //记录行高数据 + double H7=sheetLCK.getRowHeight(7); + double H8=sheetLCK.getRowHeight(8); + double H9=sheetLCK.getRowHeight(9); + double H10=sheetLCK.getRowHeight(10); + sheetLCK.setText(1, 1, (tree.getLCKtitle()==null||tree.getLCKtitle().equals(""))?" ":tree.getLCKtitle().toString()); + sheetLCK.setText(5, 5, (tree.getManufacturingCompany()==null||tree.getManufacturingCompany().equals(""))?" ":tree.getManufacturingCompany().toString()); + sheetLCK.setText(5, 16, (tree.getManager()==null||tree.getManager().equals(""))?" ":tree.getManager().toString()); + sheetLCK.setText(5, 26, String.valueOf(StationDatas.size())); + sheetLCK.setText(5, 38, (tree.getTotalHours()==null||tree.getTotalHours().equals(""))?" ":tree.getTotalHours().toString()); + int num=0; + num=(int) Math.ceil((double)tree.getMEOP().size()/42); + //复制单元格 + for(int i=1;i StationData=new ArrayList(); + if(StationDatas.size()>42*i+j) { + StationData=StationDatas.get(42*i+j); + sheetLCK.setText(7+i*4, j+2, (StationData.get(0) == null || StationData.get(0).equals("")) ? " " : (StationData.get(0)).toString()); + sheetLCK.setText(8+i*4, j+2, (StationData.get(1) == null || StationData.get(1).equals("")) ? " " : (StationData.get(1)).toString()); + sheetLCK.setText(9+i*4, j+2, (StationData.get(2) == null || StationData.get(2).equals("")) ? " " : (StationData.get(2)).toString()); + sheetLCK.setText(10+i*4, j+2, (StationData.get(3) == null || StationData.get(3).equals("")) ? " " : (StationData.get(3)).toString()); + } + + } + } + + + //添加工位工艺作业指导书 + for(int i=0;i32) { +// num=(int) Math.ceil((double)MEOPDatas.size()/4); +// } +// //插入行 +// sheet.insertRow(10,num*4); +// for(int i=0;i Data=new ArrayList(); +// Data=MEOPDatas.get(i-1); +// int startRow=flag*4+7;//开始行 +// if(i%4!=0) { +// switch (i) { +// case 1: +// insertData(sheet,startRow,1,Data); +// break; +// case 2: +// insertData(sheet,startRow,3,Data); +// break; +// case 3: +// insertData(sheet,startRow,5,Data); +// break; +// default: +// break; +// } +// }else { +// insertData(sheet,startRow,7,Data); +// flag++; +// } +// +// } +// + + +// File file=new File(outPathString+"工艺流程图(水印).xlsx"); +// FileInputStream input = new FileInputStream(file); +// FileOutputStream output = new FileOutputStream(new File(outPathString+nameString+".xlsx")); +// XSSFWorkbook wb1 = new XSSFWorkbook(input); +// wb1.removeSheetAt(1); +// wb1.write(output); +// new File(outPathString+"工艺流程图(水印).xlsx").delete(); +// try { +// if(MethodUtil.getExcelToItem(session,this.target.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX") != null) { +// MethodUtil.changeDataSet(MethodUtil.getExcelToDataset(session,this.target.getLatestItemRevision(), +// "IMAN_specification", "MSExcelX"), "excel", "MSExcelX", outPathString+nameString+".xlsx"); +// }else { +// MethodUtil.setExcelToItem(session,this.target.getLatestItemRevision(),outPathString+nameString+".xlsx", +// nameString+"产品工艺流程图","IMAN_specification", +// "MSExcelX", true); +// +// } +// +// } catch (TCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } + } + + + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_10/Tree10.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_10/Tree10.java new file mode 100644 index 0000000..e112530 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/ML_10/Tree10.java @@ -0,0 +1,87 @@ +package com.connor.ml.tcm.outfile.ML_10; + +import java.util.ArrayList; +import java.util.List; + +public class Tree10 { + private String Title;//封面标题 + private String ProductItemID;//产品代号 + private String ProductName;//产品名称 + private String carrentDate;//当前时间 + private String ProductType;//产品型号 + private String LCKtitle="";//订单工艺流程卡标题 + private String ManufacturingCompany="";//订单工艺流程卡标题 + private String Manager="";//经营体 + private String TotalHours="";//总工时 + private String Totals="";//总工位数 + private List> MEOP=new ArrayList>();//工序 + + public void setProductName(String ProductCode) { + this.ProductName=ProductCode; + } + public String getProductName() { + return this.ProductName; + } + public void setProductType(String ProductType) { + this.ProductType=ProductType; + } + public String getProductType() { + return this.ProductType; + } + + public void setTitle(String Title) { + this.Title=Title; + } + public String getTitle() { + return this.Title; + } + public void setProductItemID(String ProductItemID) { + this.ProductItemID=ProductItemID; + } + public String getProductItemID() { + return this.ProductItemID; + } + public void setLCKtitle(String LCKtitle) { + this.LCKtitle=LCKtitle; + } + public String getLCKtitle() { + return this.LCKtitle; + } + public void setManufacturingCompany(String ManufacturingCompany) { + this.ManufacturingCompany=ManufacturingCompany; + } + public String getManufacturingCompany() { + return this.ManufacturingCompany; + } + public void setManager(String Manager) { + this.Manager=Manager; + } + public String getManager() { + return this.Manager; + } + public void setTotalHours(String TotalHours) { + this.TotalHours=TotalHours; + } + public String getTotalHours() { + return this.TotalHours; + } + public void setTotals(String Totals) { + this.Totals=Totals; + } + public String getTotals() { + return this.Totals; + } + public void setcarrentDate(String carrentDate) { + this.carrentDate=carrentDate; + } + public String getcarrentDate() { + return this.carrentDate; + } + public void setMEOP(List> MEOP) { + this.MEOP=MEOP; + } + public List> getMEOP() { + return this.MEOP; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ComboBoxItemBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ComboBoxItemBean.java new file mode 100644 index 0000000..64c534b --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ComboBoxItemBean.java @@ -0,0 +1,43 @@ +package com.connor.ml.tcm.outfile.bean; + +import com.teamcenter.rac.kernel.TCComponent; + +public class ComboBoxItemBean { + + private String key; + private String value; + private TCComponent item; + + public ComboBoxItemBean(String key, String value) { + super(); + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + public TCComponent getItem() { + return item; + } + + public void setItem(TCComponent item) { + this.item = item; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/CreatePropBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/CreatePropBean.java new file mode 100644 index 0000000..75c6d46 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/CreatePropBean.java @@ -0,0 +1,44 @@ +package com.connor.ml.tcm.outfile.bean; + +import com.teamcenter.rac.kernel.TCPropertyDescriptor; + +public class CreatePropBean { + + private String displayName; + private String name; + private String value; + private TCPropertyDescriptor descriptor; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public TCPropertyDescriptor getDescriptor() { + return descriptor; + } + + public void setDescriptor(TCPropertyDescriptor descriptor) { + this.descriptor = descriptor; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/DoubleBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/DoubleBean.java new file mode 100644 index 0000000..cf26442 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/DoubleBean.java @@ -0,0 +1,14 @@ +package com.connor.ml.tcm.outfile.bean; + +public class DoubleBean { + private Double value = new Double(0); + + public Double getValue() { + return value; + } + + public void setValue(Double value) { + this.value = value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ItemBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ItemBean.java new file mode 100644 index 0000000..4072722 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ItemBean.java @@ -0,0 +1,130 @@ +package com.connor.ml.tcm.outfile.bean; + +import java.util.Map; + +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; + +public class ItemBean { + private TCComponentItem item; + private String itemID;// 零组件ID + private String revID;// 版本ID + private String name;// 名称 + private String unitDis;// 单位显示 + private String unit;// 单位 + private String typeDis;// 类型显示 + private String type;// 类型 + private Map itemProps;// 零组件属性 + private Map revProps;// 版本属性 + private Map formProps;// 版本表单属性 + private TCComponentFolder folder; + + public TCComponentFolder getFolder() { + return folder; + } + + public void setFolder(TCComponentFolder folder) { + this.folder = folder; + } + + public String getTypeDis() { + return typeDis; + } + + public void setTypeDis(String typeDis) { + this.typeDis = typeDis; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUnitDis() { + return unitDis; + } + + public void setUnitDis(String unitDis) { + this.unitDis = unitDis; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public TCComponentItem getItem() { + return item; + } + + public void setItem(TCComponentItem item) { + this.item = item; + } + + // ---------------------------------------------------- + public String getItemID() { + return itemID; + } + + public void setItemID(String itemID) { + this.itemID = itemID; + } + + public String getRevID() { + return revID; + } + + public void setRevID(String revID) { + this.revID = revID; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Map getItemProps() { + return itemProps; + } + + public void setItemProps(Map itemProps) { + this.itemProps = itemProps; + } + + public Map getRevProps() { + return revProps; + } + + public void setRevProps(Map revProps) { + this.revProps = revProps; + } + + public Map getFormProps() { + return formProps; + } + + public void setFormProps(Map formProps) { + + this.formProps = formProps; + } + + @Override + public String toString() { + return "TMom001DeriveItemBean [itemID=" + itemID + ", revID=" + revID + + ", name=" + name + ", itemProps=" + itemProps + ", revProps=" + + revProps + ", formProps=" + formProps + "]"; + + } + + // ------------------------------ + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/LOVBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/LOVBean.java new file mode 100644 index 0000000..4cf93d6 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/LOVBean.java @@ -0,0 +1,38 @@ +package com.connor.ml.tcm.outfile.bean; + +public class LOVBean { + private String displayName; + private String realName; + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public LOVBean(String displayName, String realName) { + super(); + this.displayName = displayName; + this.realName = realName; + } + + public LOVBean() { + super(); + } + + @Override + public String toString() { + return displayName; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrNumBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrNumBean.java new file mode 100644 index 0000000..7333cb2 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrNumBean.java @@ -0,0 +1,18 @@ +package com.connor.ml.tcm.outfile.bean; + +public class MatnrNumBean { + private String matnr = ""; + private String werks = ""; + public String getMatnr() { + return matnr; + } + public void setMatnr(String matnr) { + this.matnr = matnr; + } + public String getWerks() { + return werks; + } + public void setWerks(String werks) { + this.werks = werks; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrNumResultBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrNumResultBean.java new file mode 100644 index 0000000..5b15904 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrNumResultBean.java @@ -0,0 +1,33 @@ +package com.connor.ml.tcm.outfile.bean; + +public class MatnrNumResultBean { + + private String matnr = ""; + private String werks = ""; + private String quantity = ""; + private String flag = ""; + public String getMatnr() { + return matnr; + } + public void setMatnr(String matnr) { + this.matnr = matnr; + } + public String getWerks() { + return werks; + } + public void setWerks(String werks) { + this.werks = werks; + } + public String getQuantity() { + return quantity; + } + public void setQuantity(String quantity) { + this.quantity = quantity; + } + public String getFlag() { + return flag; + } + public void setFlag(String flag) { + this.flag = flag; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrPriceBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrPriceBean.java new file mode 100644 index 0000000..9e7b0a5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrPriceBean.java @@ -0,0 +1,147 @@ +package com.connor.ml.tcm.outfile.bean; + +public class MatnrPriceBean { + + private int index; + private String level; + private String matnrId; + private String revision; + private String figureNum; + private String matnrName; + private String specifications; + private String processModel; + private String num; + private String uom; + private String suttle; + private String materials; + private String colour; + private String status; + private String generalIdentify; + private String projectTeam; + private String remark; + private String werks; + private String price; + private String sum; + public int getIndex() { + return index; + } + public void setIndex(int index) { + this.index = index; + } + public String getLevel() { + return level; + } + public void setLevel(String level) { + this.level = level; + } + public String getMatnrId() { + return matnrId; + } + public void setMatnrId(String matnrId) { + this.matnrId = matnrId; + } + public String getRevision() { + return revision; + } + public void setRevision(String revision) { + this.revision = revision; + } + public String getFigureNum() { + return figureNum; + } + public void setFigureNum(String figureNum) { + this.figureNum = figureNum; + } + public String getMatnrName() { + return matnrName; + } + public void setMatnrName(String matnrName) { + this.matnrName = matnrName; + } + public String getSpecifications() { + return specifications; + } + public void setSpecifications(String specifications) { + this.specifications = specifications; + } + public String getProcessModel() { + return processModel; + } + public void setProcessModel(String processModel) { + this.processModel = processModel; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + public String getUom() { + return uom; + } + public void setUom(String uom) { + this.uom = uom; + } + public String getSuttle() { + return suttle; + } + public void setSuttle(String suttle) { + this.suttle = suttle; + } + public String getMaterials() { + return materials; + } + public void setMaterials(String materials) { + this.materials = materials; + } + public String getColour() { + return colour; + } + public void setColour(String colour) { + this.colour = colour; + } + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } + public String getGeneralIdentify() { + return generalIdentify; + } + public void setGeneralIdentify(String generalIdentify) { + this.generalIdentify = generalIdentify; + } + public String getProjectTeam() { + return projectTeam; + } + public void setProjectTeam(String projectTeam) { + this.projectTeam = projectTeam; + } + public String getRemark() { + return remark; + } + public void setRemark(String remark) { + this.remark = remark; + } + public String getWerks() { + return werks; + } + public void setWerks(String werks) { + this.werks = werks; + } + public String getPrice() { + return price; + } + public void setPrice(String price) { + this.price = price; + } + public String getSum() { + return sum; + } + public void setSum(String sum) { + this.sum = sum; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrPriceResultBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrPriceResultBean.java new file mode 100644 index 0000000..1abbdbd --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/MatnrPriceResultBean.java @@ -0,0 +1,33 @@ +package com.connor.ml.tcm.outfile.bean; + +public class MatnrPriceResultBean { + + private String matnr = ""; + private String werks = ""; + private String price = ""; + private String flag = ""; + public String getMatnr() { + return matnr; + } + public void setMatnr(String matnr) { + this.matnr = matnr; + } + public String getWerks() { + return werks; + } + public void setWerks(String werks) { + this.werks = werks; + } + public String getPrice() { + return price; + } + public void setPrice(String price) { + this.price = price; + } + public String getFlag() { + return flag; + } + public void setFlag(String flag) { + this.flag = flag; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/NodeBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/NodeBean.java new file mode 100644 index 0000000..9050439 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/NodeBean.java @@ -0,0 +1,73 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.connor.ml.tcm.outfile.bean; + +import java.util.Random; + +/** + * + * @author vearn + */ +public class NodeBean { + + private String dbom;//对象ID + private String ebom;//对象名称 + private String ebomId;//对象名称 + private String ebomDesc;//物料描述 + private String num;//数量 + private String label;//对象名称 + private String refreshStatus;//发布状态 + private String parentString;//对应父节点 + + public String getDbom() { + return dbom; + } + public void setDbom(String dbom) { + this.dbom = dbom; + } + public String getEbom() { + return ebom; + } + public void setEbom(String ebom) { + this.ebom = ebom; + } + public String getEbomId() { + return ebomId; + } + public void setEbomId(String ebomId) { + this.ebomId = ebomId; + } + public String getLabel() { + return label; + } + public void setLabel(String label) { + this.label = label; + } + public String getRefreshStatus() { + return refreshStatus; + } + public void setRefreshStatus(String refreshStatus) { + this.refreshStatus = refreshStatus; + } + public String getParentString() { + return parentString; + } + public void setParentString(String parentString) { + this.parentString = parentString; + } + public String getNum() { + return num; + } + public void setNum(String num) { + this.num = num; + } + public String getEbomDesc() { + return ebomDesc; + } + public void setEbomDesc(String ebomDesc) { + this.ebomDesc = ebomDesc; + } + +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ObjectFactory.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ObjectFactory.java new file mode 100644 index 0000000..d53c6bf --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ObjectFactory.java @@ -0,0 +1,63 @@ +// +// 此文件是由 JavaTM Architecture for XML Binding (JAXB) 引用实现 v2.2.8-b130911.1802 生成的 +// 请访问 http://java.sun.com/xml/jaxb +// 在重新编译源模式时, 对此文件的所有修改都将丢失。 +// 生成时间: 2021.07.15 时间 04:03:34 PM CST +// + + +package com.connor.ml.tcm.outfile.bean; + +import javax.xml.bind.annotation.XmlRegistry; + + +/** + * This object contains factory methods for each + * Java content interface and Java element interface + * generated in the com.bean package. + *

An ObjectFactory allows you to programatically + * construct new instances of the Java representation + * for XML content. The Java representation of XML + * content can consist of schema derived interfaces + * and classes representing the binding of schema + * type definitions, element declarations and model + * groups. Factory methods for each of these are + * provided in this class. + * + */ +@XmlRegistry +public class ObjectFactory { + + + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.bean + * + */ + public ObjectFactory() { + } + + /** + * Create an instance of {@link Search } + * + */ + public Search createSearch() { + return new Search(); + } + + /** + * Create an instance of {@link Property } + * + */ + public Property createProperty() { + return new Property(); + } + + /** + * Create an instance of {@link Searchs } + * + */ + public Searchs createSearchs() { + return new Searchs(); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostBean.java new file mode 100644 index 0000000..bd52a96 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostBean.java @@ -0,0 +1,25 @@ +package com.connor.ml.tcm.outfile.bean; + +public class ProjectCostBean { + private String posid; + private String month; + private String phase; + public String getPosid() { + return posid; + } + public void setPosid(String posid) { + this.posid = posid; + } + public String getMonth() { + return month; + } + public void setMonth(String month) { + this.month = month; + } + public String getPhase() { + return phase; + } + public void setPhase(String phase) { + this.phase = phase; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostDetail.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostDetail.java new file mode 100644 index 0000000..dbc4036 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostDetail.java @@ -0,0 +1,40 @@ +package com.connor.ml.tcm.outfile.bean; + +public class ProjectCostDetail { + + private String belnr;//凭证编号 + private String sgtxt;//凭证文本 + private String posid;//wbs元素 + private String budat;//记账日期 + private String dmbtr;//本币金额 + public String getBelnr() { + return belnr; + } + public void setBelnr(String belnr) { + this.belnr = belnr; + } + public String getSgtxt() { + return sgtxt; + } + public void setSgtxt(String sgtxt) { + this.sgtxt = sgtxt; + } + public String getPosid() { + return posid; + } + public void setPosid(String posid) { + this.posid = posid; + } + public String getBudat() { + return budat; + } + public void setBudat(String budat) { + this.budat = budat; + } + public String getDmbtr() { + return dmbtr; + } + public void setDmbtr(String dmbtr) { + this.dmbtr = dmbtr; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostResultBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostResultBean.java new file mode 100644 index 0000000..6ec5718 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/ProjectCostResultBean.java @@ -0,0 +1,44 @@ +package com.connor.ml.tcm.outfile.bean; + +import java.util.List; + +public class ProjectCostResultBean { + + private String posid; + private String flag; + private String result; + + private List detail; + + public String getPosid() { + return posid; + } + + public void setPosid(String posid) { + this.posid = posid; + } + + public String getFlag() { + return flag; + } + + public void setFlag(String flag) { + this.flag = flag; + } + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public List getDetail() { + return detail; + } + + public void setDetail(List detail) { + this.detail = detail; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/PropExplictBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/PropExplictBean.java new file mode 100644 index 0000000..2bd3acb --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/PropExplictBean.java @@ -0,0 +1,25 @@ +package com.connor.ml.tcm.outfile.bean; + +import java.util.List; + +public class PropExplictBean { + private String Type = ""; + private List PropList; + + public String getType() { + return Type; + } + + public void setType(String type) { + Type = type; + } + + public List getPropList() { + return PropList; + } + + public void setPropList(List propList) { + PropList = propList; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Property.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Property.java new file mode 100644 index 0000000..9da6e86 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Property.java @@ -0,0 +1,205 @@ +// +// 此文件是由 JavaTM Architecture for XML Binding (JAXB) 引用实现 v2.2.8-b130911.1802 生成的 +// 请访问 http://java.sun.com/xml/jaxb +// 在重新编译源模式时, 对此文件的所有修改都将丢失。 +// 生成时间: 2021.07.15 时间 04:03:34 PM CST +// + + +package com.connor.ml.tcm.outfile.bean; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + *

anonymous complex type的 Java 类。 + * + *

以下模式片段指定包含在此类中的预期内容。 + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <attribute name="displayName" use="required" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" />
+ *       <attribute name="isLov" use="required" type="{http://www.w3.org/2001/XMLSchema}boolean" />
+ *       <attribute name="lovName" use="required" type="{http://www.w3.org/2001/XMLSchema}anySimpleType" />
+ *       <attribute name="propertyType" use="required" type="{http://www.w3.org/2001/XMLSchema}NCName" />
+ *       <attribute name="defaultValue" use="required" type="{http://www.w3.org/2001/XMLSchema}NCName" />
+ *       <attribute name="realName" use="required" type="{http://www.w3.org/2001/XMLSchema}NCName" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "") +@XmlRootElement(name = "property") +public class Property { + + @XmlAttribute(name = "displayName", required = true) + @XmlSchemaType(name = "anySimpleType") + protected String displayName; + @XmlAttribute(name = "isLov", required = true) + protected boolean isLov; + @XmlAttribute(name = "lovName", required = true) + @XmlSchemaType(name = "anySimpleType") + protected String lovName; + @XmlAttribute(name = "propertyType", required = true) + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "NCName") + protected String propertyType; + @XmlAttribute(name = "defaultValue", required = true) + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "NCName") + protected String defaultValue; + @XmlAttribute(name = "realName", required = true) + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "NCName") + protected String realName; + + /** + * 获取displayName属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getDisplayName() { + return displayName; + } + + /** + * 设置displayName属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDisplayName(String value) { + this.displayName = value; + } + + /** + * 获取isLov属性的值。 + * + */ + public boolean isIsLov() { + return isLov; + } + + /** + * 设置isLov属性的值。 + * + */ + public void setIsLov(boolean value) { + this.isLov = value; + } + + /** + * 获取lovName属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getLovName() { + return lovName; + } + + /** + * 设置lovName属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLovName(String value) { + this.lovName = value; + } + + /** + * 获取propertyType属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getPropertyType() { + return propertyType; + } + + /** + * 设置propertyType属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPropertyType(String value) { + this.propertyType = value; + } + + /** + * 获取defaultValue属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getDefaultValue() { + return defaultValue; + } + + /** + * 设置defaultValue属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDefaultValue(String value) { + this.defaultValue = value; + } + + /** + * 获取realName属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getRealName() { + return realName; + } + + /** + * 设置realName属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setRealName(String value) { + this.realName = value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Search.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Search.java new file mode 100644 index 0000000..9e22ef3 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Search.java @@ -0,0 +1,168 @@ +// +// 此文件是由 JavaTM Architecture for XML Binding (JAXB) 引用实现 v2.2.8-b130911.1802 生成的 +// 请访问 http://java.sun.com/xml/jaxb +// 在重新编译源模式时, 对此文件的所有修改都将丢失。 +// 生成时间: 2021.07.16 时间 10:50:04 AM CST +// + + +package com.connor.ml.tcm.outfile.bean; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; + + +/** + *

anonymous complex type的 Java 类。 + * + *

以下模式片段指定包含在此类中的预期内容。 + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}property" maxOccurs="unbounded"/>
+ *       </sequence>
+ *       <attribute name="queryName" use="required" type="{http://www.w3.org/2001/XMLSchema}NCName" />
+ *       <attribute name="objectType" use="required" type="{http://www.w3.org/2001/XMLSchema}NCName" />
+ *       <attribute name="puid" use="required" type="{http://www.w3.org/2001/XMLSchema}NCName" />
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "property" +}) +@XmlRootElement(name = "search") +public class Search { + + @XmlElement(required = true) + protected List property; + @XmlAttribute(name = "queryName", required = true) + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "NCName") + protected String queryName; + @XmlAttribute(name = "objectType", required = true) + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "NCName") + protected String objectType; + @XmlAttribute(name = "puid", required = true) + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "NCName") + protected String puid; + + /** + * Gets the value of the property property. + * + *

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

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

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

+ * Objects of the following type(s) are allowed in the list + * {@link Property } + * + * + */ + public List getProperty() { + if (property == null) { + property = new ArrayList(); + } + return this.property; + } + /** + * 获取objectType属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getQueryName() { + return queryName; + } + + /** + * 设置objectType属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setQueryName(String value) { + this.queryName = value; + } + + /** + * 获取objectType属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getObjectType() { + return objectType; + } + + /** + * 设置objectType属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setObjectType(String value) { + this.objectType = value; + } + + /** + * 获取puid属性的值。 + * + * @return + * possible object is + * {@link String } + * + */ + public String getPuid() { + return puid; + } + + /** + * 设置puid属性的值。 + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setPuid(String value) { + this.puid = value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Searchs.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Searchs.java new file mode 100644 index 0000000..03bca8b --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/Searchs.java @@ -0,0 +1,78 @@ +// +// 此文件是由 JavaTM Architecture for XML Binding (JAXB) 引用实现 v2.2.8-b130911.1802 生成的 +// 请访问 http://java.sun.com/xml/jaxb +// 在重新编译源模式时, 对此文件的所有修改都将丢失。 +// 生成时间: 2021.07.15 时间 04:48:15 PM CST +// + + +package com.connor.ml.tcm.outfile.bean; + +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + + +/** + *

anonymous complex type的 Java 类。 + * + *

以下模式片段指定包含在此类中的预期内容。 + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element ref="{}search" maxOccurs="unbounded"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "search" +}) +@XmlRootElement(name = "searchs") +public class Searchs { + + @XmlElement(required = true) + protected List search; + + /** + * Gets the value of the search property. + * + *

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

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

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

+ * Objects of the following type(s) are allowed in the list + * {@link Search } + * + * + */ + public List getSearch() { + if (search == null) { + search = new ArrayList(); + } + return this.search; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/SendOABean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/SendOABean.java new file mode 100644 index 0000000..92fd547 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/SendOABean.java @@ -0,0 +1,51 @@ +package com.connor.ml.tcm.outfile.bean; + +import java.util.ArrayList; +import java.util.List; + +public class SendOABean { + + private String infotype = ""; + private String infocode = ""; + private String infoname = ""; + private List data = new ArrayList(); + private List list = new ArrayList(); + private List file = new ArrayList(); + + public String getInfotype() { + return infotype; + } + public void setInfotype(String infotype) { + this.infotype = infotype; + } + public String getInfocode() { + return infocode; + } + public void setInfocode(String infocode) { + this.infocode = infocode; + } + public String getInfoname() { + return infoname; + } + public void setInfoname(String infoname) { + this.infoname = infoname; + } + public List getData() { + return data; + } + public void setData(List data) { + this.data = data; + } + public List getList() { + return list; + } + public void setList(List list) { + this.list = list; + } + public List getFile() { + return file; + } + public void setFile(List file) { + this.file = file; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/SendOAPropertyBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/SendOAPropertyBean.java new file mode 100644 index 0000000..27e5e1f --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/bean/SendOAPropertyBean.java @@ -0,0 +1,20 @@ +package com.connor.ml.tcm.outfile.bean; + +public class SendOAPropertyBean { + + private String field = ""; + private String value = ""; + + public String getField() { + return field; + } + public void setField(String field) { + this.field = field; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/Adapter.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/Adapter.java new file mode 100644 index 0000000..c654807 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/Adapter.java @@ -0,0 +1,299 @@ +package com.connor.ml.tcm.outfile.util; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ClassProperty.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ClassProperty.java new file mode 100644 index 0000000..6d874f6 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.ml.tcm.outfile.util; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-3 下午11:47:03 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class ClassProperty { + private int propertyID; + private String value; + + public ClassProperty() { + + } + + public ClassProperty(int propertyID, String value) { + this.propertyID = propertyID; + this.value = value; + } + + public int getPropertyID() { + return propertyID; + } + + public void setPropertyID(int propertyID) { + this.propertyID = propertyID; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/DbPool.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/DbPool.java new file mode 100644 index 0000000..c7358ba --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/DbPool.java @@ -0,0 +1,278 @@ +package com.connor.ml.tcm.outfile.util; + +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Types; +import java.util.Properties; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DbPool { + + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + private static DbPool instance = null; + + public static synchronized Connection getConnection() { + if (instance == null) { + instance = new DbPool(); + } + return instance._getConnection(); + } + + private Connection _getConnection() { + try { + String sDBDriver = null; + String sConnection = null; + String sUser = null; + String sPassword = null; + Properties p = new Properties(); +// InputStream is = getClass().getResourceAsStream( +// "/sqlconn.properties"); +// p.load(is); +// sDBDriver = p.getProperty("DBDriver", "1"); +// sConnection = p.getProperty("Connection", "2"); +// sUser = p.getProperty("User", ""); +// sPassword = p.getProperty("Password", ""); + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringArray( + TCPreferenceService.TC_preference_site, "TC13_SqlServer_Link"); + + if (array != null) + { + for (String str : array) { + System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("DBDriver=")) { + sDBDriver = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("Connection=")) { + sConnection = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("User=")) { + sUser = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("Password=")) { + sPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (sDBDriver == null || sConnection == null || sUser == null + || sPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + + Class.forName(sDBDriver); + connection = DriverManager.getConnection(sConnection, sUser, + sPassword); + return connection; + } catch (Exception se) { + System.out.println(se); + } + return null; + } + + public static void executeUpdateSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + System.out.println("sql===" + sql); + int i = st.executeUpdate(sql); + } catch (SQLException e) { + System.out.println(e.getMessage()); + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + // connection.close(); + } + + } + + public static void executeDeleteSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + System.out.println("sql===" + sql); + st.executeUpdate(sql); + connection.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + connection.close(); + } + + } + + public static ResultSet executeSelectSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + System.out.println("sql===" + sql); + rs = st.executeQuery(sql); + // conn.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } + return rs; + + } + + public static String getNewNo(String str1,String str2,String str3) throws SQLException + { + String newNo = ""; + // 创建CallableStatement对象 + CallableStatement clbStmt = null; + try { + clbStmt = connection.prepareCall("{CALL getNewNo(?,?,?,?,?,?,?)}"); + // 设置输入参数 + clbStmt.setString(1, str1); // 大类 + clbStmt.setString(2, str2); // 中类 + clbStmt.setString(3, str3); // 小类 + + // 注册输出参数 + clbStmt.registerOutParameter(4, Types.NVARCHAR); + clbStmt.registerOutParameter(5, Types.NVARCHAR); + clbStmt.registerOutParameter(6, Types.NVARCHAR); + clbStmt.registerOutParameter(7, Types.NVARCHAR); + + // 执行调用存储过程,并获取结果集 + clbStmt.execute(); + + //System.out.println(clbStmt.getString(3)); + //System.out.println(clbStmt.getString(4)); + newNo = clbStmt.getString(5); +// System.out.println(); +// System.out.println(clbStmt.getString(6)); +// System.out.println(clbStmt.getString(7)); + // 获取输出参数值 + newNo = clbStmt.getString(5); + } catch (SQLException e) { + e.printStackTrace(); + if(clbStmt != null) + clbStmt.close(); + connection.close(); + } finally { + if(clbStmt != null) + clbStmt.close(); + connection.close(); + } + return newNo; + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(DbPool.rs, DbPool.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(DbPool.rs, DbPool.ps, DbPool.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ExcelUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ExcelUtil.java new file mode 100644 index 0000000..ab98a29 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ExcelUtil.java @@ -0,0 +1,1047 @@ +package com.connor.ml.tcm.outfile.util; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.imageio.ImageIO; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; +import org.apache.poi.hssf.usermodel.HSSFName; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +/** + * Excel 签名 + * + * @author hub 2015-09-06 + */ +public class ExcelUtil { + // private static Registry reg = Registry.getRegistry(this); + // private static HSSFSheet sheet; + // private static final int MY_ROWS = 46; + private SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + + /** + * 读取EXCEL表 + * + * @param File + * excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(File excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + HSSFWorkbook workBook = new HSSFWorkbook( + new FileInputStream(excel_file)); + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workBook); + HSSFSheet sheet = workBook.getSheetAt(0); + HSSFRow title_row = sheet.getRow(0); + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + HSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < col_count; i++) { + String value = getStringCellValue(evaluator, + row.getCell((short) i)); + line_msg.add(value); + } + lines_msg.add(line_msg); + } + // insertRow(sheet,4,1); + return lines_msg; + } + + public void writeSignName(String intExcelFilePath, String outExcelFilePath, + String signName, String msgValue, int sheetIndex, int rowIndex, + int cellIndex) throws IOException { + // 输出文件的路径 + FileOutputStream outPut = new FileOutputStream(new File( + outExcelFilePath)); + // 输入文件的路径 + FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); + HSSFWorkbook wb = new HSSFWorkbook(inPut); + wb.getName(""); + AreaReference[] areaR2 = AreaReference.generateContiguous(wb + .getName("").getRefersToFormula()); + AreaReference areaR = null; + CellReference[] cellR = areaR.getAllReferencedCells(); + cellR[0].getSheetName();// s + cellR[0].getCol();// + cellR[0].getRow();// + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFSheet sheet = wb.getSheetAt(sheetIndex); + HSSFRow row = sheet.getRow(rowIndex); + + HSSFCell cell = row.getCell(cellIndex); + String value = getStringCellValue(evaluator, cell); + if (value.startsWith(signName)) { + value = value.substring(0, signName.length()); + } + + cell.setCellValue(value + msgValue); + wb.write(outPut); + inPut.close(); + outPut.close(); + } + + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont(HSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + HSSFFont font1 = (HSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + HSSFFont font = (HSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont_XSSF(XSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine(HSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine_XSSF(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex(HSSFWorkbook wb, String cellName) + throws IOException { + int index = -1; + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex_XSSF(XSSFWorkbook wb, String cellName) + throws IOException { + int index = -1; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + + /** + * 添加命名的引用 + * + * @param session + * @param item + * 对象的版本 + * @param tcResource + * 文件的物理路径 + * @param relationName + * 关系名称 + */ + public static void setExcelToItem(TCSession session, + TCComponentItemRevision item, String tcResource, String fileName, + boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { "MSExcel" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType + .create(fileName, "excel", "MSExcel"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if ("MSExcel".equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren + .getComponent(); + zyzdsRev.remove("TC_Attaches", dateSet); + dateSet.delete(); + } + } + item.add("TC_Attaches", tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static String getNamedCellValue(HSSFWorkbook wb, String cellName) + throws IOException { + String value = null; + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFName name = wb.getName(cellName); + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + HSSFCell cell = row.getCell(colIndex); + value = getStringCellValue(evaluator, cell); + } + } + } + return value; + } + + // 导出Excel + public void writeExcel(String xls_write_Address, InputStream stream, + Vector> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + Vector ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + if (ls2.get(cols) instanceof Date) { + String date = ls2.get(cols) == null ? "" + : dateFormat.format(ls2.get(cols)); + cell.setCellValue(date);// 写入内容 + } else { + cell.setCellValue(ls2.get(cols) == null ? "" : ls2 + .get(cols).toString());// 写入内容 + } + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void writeExcel(String xls_write_Address, InputStream stream, + ArrayList> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + cell.setCellValue(ls2.get(cols));// 写入内容 + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel5(String xls_write_Address, InputStream stream, + ArrayList> ls, String[] sheetnames) + throws IOException { + FileOutputStream output = new FileOutputStream(new File( + xls_write_Address)); // 读取的文件路径 + HSSFWorkbook wb = new HSSFWorkbook(stream);// (new + // BufferedInputStream(output)); + HSSFCellStyle style = wb.createCellStyle(); + for (int sn = 0; sn < sheetnames.length; sn++) { + HSSFSheet sheet = wb.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + HSSFRow row = sheet.createRow(i + 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + HSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + cell.setCellValue(ls2.get(cols));// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel(String xls_write_Address, ArrayList ls, + String[] sheetnames) throws IOException { + FileOutputStream output = new FileOutputStream(new File( + xls_write_Address)); // 读取的文件路径 + HSSFWorkbook wb = new HSSFWorkbook();// (new + // BufferedInputStream(output)); + for (int sn = 0; sn < ls.size(); sn++) { + HSSFSheet sheet = wb.createSheet(String.valueOf(sn)); + wb.setSheetName(sn, sheetnames[sn]); + ArrayList ls2 = ls.get(sn); + for (int i = 0; i < ls2.size(); i++) { + HSSFRow row = sheet.createRow(i); + String[] s = ls2.get(i); + for (int cols = 0; cols < s.length; cols++) { + HSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellValue(s[cols]);// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /** + * 根据单元格的名字来找到单元格的内容 + * + * @param inputFilePath + * @param cellName + * @return + */ + public static List getExcelNamedCellValue(String inputFilePath, + String[] cellNames) { + List valueList = new ArrayList(); + try { + FileInputStream is = new FileInputStream(new File(inputFilePath)); + HSSFWorkbook wb = new HSSFWorkbook(is); + for (String name : cellNames) + valueList.add(getNamedCellValue(wb, name)); + is.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return valueList; + } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcel(String outPath, InputStream input, + * List beanListAll) throws IOException { int + * rowsCount = 5; + * + * // insertRow(); + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // + * 读取的文件路径 // FileInputStream input= new FileInputStream(); HSSFWorkbook wb + * = new HSSFWorkbook(input);// (new HSSFSheet sheet = wb.getSheetAt(0); for + * (int i = 0; i < (beanListAll.size() - rowsCount); i++) insertRow(sheet, + * 4, 1); int startRow = 2; for (int i = 0; i < beanListAll.size(); i++) { + * JFomProjectChangeBean bean = beanListAll.get(i); HSSFRow row = null; + * Boolean isCreat = false; if ((i + startRow) > sheet.getLastRowNum()) { + * row = sheet.createRow(i + startRow); isCreat = true; } else { row = + * sheet.getRow(i + startRow); isCreat = false; } + * + * for (int cols = 0; cols < 12; cols++) { HSSFCell cell = null; if + * (isCreat) { cell = row.createCell(cols); } else { cell = + * row.getCell(cols); } if (cell == null) cell = row.createCell(cols); + * cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: + * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: + * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: + * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: + * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: + * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: + * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: + * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: + * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: + * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// + * 写入内容 break; } } } + * + * // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + public void insertPicture(HSSFWorkbook wb, HSSFSheet sheet1, + String picPath, short colIndex, int rowIndex) { + + // FileOutputStream fileOut = null; + BufferedImage bufferImg = null; + // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray + try { + if (!new File(picPath).exists()) { + return; + } + String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, + picPath.length()); + + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + System.out.println(picPath); + bufferImg = ImageIO.read(new File(picPath)); + ImageIO.write(bufferImg, dexStr, byteArrayOut); + // HSSFWorkbook wb = new HSSFWorkbook(); + // HSSFSheet sheet1 = wb.createSheet("test picture"); + // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) + HSSFPatriarch patriarch = sheet1.createDrawingPatriarch(); + // anchor主要用于设置图片的属性 + HSSFClientAnchor anchor = new HSSFClientAnchor(13, 13, 0, 0, + (short) colIndex, rowIndex, (short) (colIndex + 1), + rowIndex + 1); + //anchor.setAnchorType(3); + // 插入图片 + patriarch + .createPicture(anchor, wb.addPicture( + byteArrayOut.toByteArray(), + HSSFWorkbook.PICTURE_TYPE_JPEG)); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue(HSSFWorkbook wb, String cellName, + String cellValue) throws IOException { + String value = null; + HSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + HSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue_XSSF(XSSFWorkbook wb, String cellName, + String cellValue) throws IOException { + String value = null; + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + + /** + * 移除合并的单元格 + * + * @param startRow + * @param endRow + * @return + */ + public static boolean removeMergen(HSSFSheet sheet, int startRow, int endRow) { + boolean isOK = false; + int count = sheet.getNumMergedRegions(); + for (int i = 0; i < count; i++) { + CellRangeAddress address = sheet.getMergedRegion(i); + System.out.println(address.getFirstRow() + "|" + + address.getLastRow()); + if (address.getFirstRow() == startRow + && address.getLastRow() == endRow) { + sheet.removeMergedRegion(i); + isOK = true; + break; + } + } + return isOK; + } + + /** + * 截取字符串 + * + * @param inStr + * @return + */ + public static String changeStringToInt(String inStr) { + int index = inStr.indexOf("."); + System.out.println(index); + String outStr = null; + if (index != -1) { + + outStr = inStr.substring(0, index); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 截取一定长度的字符串 + * + * @param inStr + * @param inLen + * @return + */ + public static String changeStringToInt(String inStr, int inLen) { + int index = inStr.indexOf("."); + inLen++; + System.out.println(index); + String outStr = null; + if (index != -1 && (inStr.length() - index) >= inLen) { + + outStr = inStr.substring(0, index + inLen); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 将float转换成保留两位的字符串 + * + * @param f + * 需要转换的float数 + * @return + */ + public static String changeFloatToStr(float f) { + DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. + String str = decimalFormat.format(f);// format 返回的是字符串 + return str; + } + + /** + * 将字符串转换成int + * + * @param str + * @return + */ + public static float changeStrToFloat(String str) { + float temp_int = 0; + try { + temp_int = Float.parseFloat(str.trim()); + return temp_int; + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return -1; + } + } + + /** + * 设置formual的时候用来替换原有的单元格号到新的单元格号 + * + * @param originStr + * @param subStr + * @param index + * @param index2 + * @return + */ + public static String replaceSubString(String originStr, String subStr, + int index, int index2) { + StringBuffer sbO = new StringBuffer(); + sbO.append(subStr); + sbO.append(index); + StringBuffer sbR = new StringBuffer(); + sbR.append(subStr); + sbR.append(index2); + String resultStr = originStr.replace(sbO.toString(), sbR.toString()); + return resultStr; + } + + /** + * 读取EXCEL信息 + * + * @param String + * excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(String excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null) { + return null; + } + File file = new File(excel_file); + return readExcel(file); + } + + /** + * 获取单元格数据内容为字符串类型的数据 + * + * @param cell + * Excel单元格 + * @return String 单元格数据内容 + */ + private static String getStringCellValue(HSSFFormulaEvaluator evaluator, + HSSFCell cell) { + if (cell == null) { + return ""; + } + String strCell = ""; + switch (cell.getCellType()) { + case HSSFCell.CELL_TYPE_STRING: + strCell = cell.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_NUMERIC: + strCell = "" + cell.getNumericCellValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + break; + case HSSFCell.CELL_TYPE_BOOLEAN: + strCell = String.valueOf(cell.getBooleanCellValue()); + break; + case HSSFCell.CELL_TYPE_BLANK: + strCell = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + strCell = String.valueOf(cell.getErrorCellValue()); + break; + case HSSFCell.CELL_TYPE_FORMULA: + CellValue value = evaluator.evaluate(cell); + try { + strCell = value.getStringValue(); + if (strCell == null) { + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + } catch (Exception e) { + + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + break; + default: + strCell = ""; + break; + } + if (strCell.equals("") || strCell == null) { + return ""; + } + return strCell; + } + + // public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + // HSSFRow sourceRow = sheet.getRow(starRow); + // sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + // // starRow = starRow -1; + // for (int i = 0; i < rows; i++) { + // // sheet.shiftRows(starRow + i, sheet.getLastRowNum(), 1, true, + // // false); + // HSSFRow targetRow = null; + // HSSFCell sourceCell = null; + // HSSFCell targetCell = null; + // short m; + // targetRow = sheet.createRow(starRow + 1); + // targetRow.setHeight(sourceRow.getHeight()); + // System.out.println(sourceRow.getLastCellNum()); + // for (m = sourceRow.getFirstCellNum(); m < sourceRow + // .getLastCellNum(); m++) { + // System.out.println(m); + // sourceCell = sourceRow.getCell(m); + // targetCell = targetRow.createCell(m); + // // System.out.println(" ===== " + sourceCell + " " + + // // targetCell); + // // targetCell.setEncoding(sourceCell.get); + // targetCell.setCellStyle(sourceCell.getCellStyle()); + // targetCell.setCellType(sourceCell.getCellType()); + // // targetCell.setCellValue("11111"); + // } + // } + // } + + /** + * 插入行数 + * + * @param starRow + * @param rows + */ + public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + HSSFRow sourceRow = sheet.getRow(starRow); + sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(starRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + + /*** + * 向sheet中插入一行 + * + * @param sheet + * @param startRow + * @param rows + * @return + */ + public static HSSFSheet insertRows(HSSFSheet sheet, int startRow, int rows) { + HSSFRow sourceRow = sheet.getRow(startRow); + sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(startRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + return sheet; + } + + /** + * 检查单元格内容是否是数字 + * + * @param value + * @return + */ + public static boolean CheckCellValueIsNumber(String value) { + boolean is_ok = false; + if (value.equals("")) { + return false; + } + try { + Float.parseFloat(value); + } catch (NumberFormatException e) { + e.printStackTrace(); + System.out.println("===>" + value); + is_ok = true; + } + return is_ok; + } + + public static void setFlowChart(Map valueMap, File file) { + // TODO Auto-generated method stub + file.setWritable(true); + try { + InputStream is = new FileInputStream(file); + HSSFWorkbook wb = new HSSFWorkbook(is);// ( + //HSSFSheet sheet = wb.getSheetAt(0); + + Iterator> it = valueMap.entrySet() + .iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + setNamedCellValue(wb, entry.getKey(), entry.getValue()); + } + FileOutputStream output = new FileOutputStream(file); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + //file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ExcelUtil07.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ExcelUtil07.java new file mode 100644 index 0000000..df36afd --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ExcelUtil07.java @@ -0,0 +1,2547 @@ +package com.connor.ml.tcm.outfile.util; + +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.tree.DefaultMutableTreeNode; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.schemas.core._2020_01.datamanagement.GetIdContextsInput; + +/** + * Excel Toolling + * + * @author hub 2015-09-06 + */ +public class ExcelUtil07 { + // private static Registry reg = Registry.getRegistry(this); + // private static XSSFSheet sheet; + // private static final int MY_ROWS = 46; + private static Map map = new HashMap(); + private static final String EXCEL_XLS = "xls"; + private static final String EXCEL_XLSX = "xlsx"; + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(File excel_file) throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < col_count; i++) { + String value = getStringCellValue(evaluator, row.getCell((short) i)); + line_msg.add(value); + } + lines_msg.add(line_msg); + } + // insertRow(sheet,4,1); + return lines_msg; + } + + /** + * 读取控制计划EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readControlPlanExcel(File excel_file) throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + int startRow = 1; + // 获取合并单元格 + Map regionCellMap = getRegionCell(sheet); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = startRow; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < 18; i++) { + String value = getStringCellValue(evaluator, row.getCell((short) i)); + if (value == null || value.equals("")) { + line_msg.add(getRegionValue(workBook, sheet, j, i)); + } else { + line_msg.add(value); + } + } + // 行号 + line_msg.add(((Integer) (j - startRow)).toString()); + // 合并单元格 + line_msg.add(toControlPlanRegionCell(regionCellMap, j)); + if (line_msg.get(0) != null) { + lines_msg.add(line_msg); + } + } + // insertRow(sheet,4,1); + return lines_msg; + } + + /** + * 读取委托内容EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readEntrustingContentExcel(File excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + int startRow = 0; + // 获取合并单元格 + Map regionCellMap = getEntrustingContentRegionCell(sheet); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = startRow; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < 3; i++) { + String value = getStringCellValue(evaluator, row.getCell((short) i)); + if (value == null || value.equals("")) { + line_msg.add(getRegionValue(workBook, sheet, j, i)); + } else { + line_msg.add(value); + } + } + // 合并单元格 + line_msg.add(toEntrustingContentRegionCell(regionCellMap, j)); + if (line_msg.get(0) != null) { + lines_msg.add(line_msg); + } + } + // insertRow(sheet,4,1); + return lines_msg; + } + + public static void main(String[] args) { + try { + List> strList = readExcel(new File("F:\\Connor(项目管理)\\东睦项目\\东睦系统\\控制计划\\生产控制计划模板3.xlsx")); + for (List list : strList) { + for (String str : list) { + System.out.print(str + "|"); + } + System.out.println(); + } + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void writeSignName(String intExcelFilePath, String outExcelFilePath, String signName, String msgValue, + int sheetIndex, int rowIndex, int cellIndex) throws IOException { + // 输出文件的路径 + FileOutputStream outPut = new FileOutputStream(new File(outExcelFilePath)); + // 输入文件的路径 + FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); + XSSFWorkbook wb = new XSSFWorkbook(inPut); + wb.getName(""); + AreaReference[] areaR2 = AreaReference.generateContiguous(wb.getName("").getRefersToFormula()); + AreaReference areaR = null; + CellReference[] cellR = areaR.getAllReferencedCells(); + cellR[0].getSheetName();// s + cellR[0].getCol();// + cellR[0].getRow();// + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFSheet sheet = wb.getSheetAt(sheetIndex); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(cellIndex); + String value = getStringCellValue(evaluator, cell); + if (value.startsWith(signName)) { + value = value.substring(0, signName.length()); + } + cell.setCellValue(value + msgValue); + wb.write(outPut); + inPut.close(); + outPut.close(); + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param beanListAll + * @param sheetnames + * @throws IOException + */ + /* + * public void writeExcel(String xls_write_Address, String path, + * List beanListAll, int index) throws IOException { + * FileOutputStream output = new FileOutputStream(new File(path)); // 读取的文件路径 + * FileInputStream input = new FileInputStream(new File(xls_write_Address)); + * XSSFWorkbook wb = new XSSFWorkbook(input);// (new XSSFSheet sheet = + * wb.getSheetAt(0); for (int i = 0; i < beanListAll.size(); i++) { + * JFomPasteBean bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat + * = false; if ((i + 3) > sheet.getLastRowNum()) { row = sheet.createRow(i + 3); + * isCreat = true; } else { row = sheet.getRow(i + 3); isCreat = false; } + * + * for (int cols = 0; cols < 7; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getProductName());// 写入内容 break; case 2: // + * cell.setCellValue(bean.getPicturePath());// 写入内容 insertPicture(wb, sheet, + * bean.getPicturePath(), (short) 2, (i + 3)); break; case 3: + * cell.setCellValue(bean.getDatasetName());// 写入内容 break; case 4: + * cell.setCellValue(bean.getItemRevisionId());// 写入内容 break; case 5: + * cell.setCellValue("");// 写入内容 + * + * break; case 6: // cell.setCellType(XSSFCell.CELL_TYPE_);// 文本格式 + * cell.setCellValue(bean.getReleaseDateStr());// 写入内容 break; + * + * } } } // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static String getNamedCellValue(XSSFWorkbook wb, String cellName) throws IOException { + String value = null; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return ""; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + value = getStringCellValue(evaluator, cell); + } + } + } + return value; + } + + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue(XSSFWorkbook wb, String cellName, String cellValue) throws IOException { + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + + /** + * 插入图片到指定的单元格中 + * + * @param wb + * @param sheet1 + * @param picPath + * @param colIndex + * @param rowIndex + */ + public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, ImageIcon imageIcon, String cellName, + int columns, int rows) { + + // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray + try { + if (imageIcon == null) { + return; + } + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + ImageIO.write(toBufferedImage(imageIcon.getImage()), "jpg", byteArrayOut); + // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) + XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); + // anchor主要用于设置图片的属性 + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, + (short) (colIndex + columns), rowIndex + rows); + //anchor.setAnchorType(3); + // 插入图片 + patriarch.createPicture(anchor, + wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 将Image转BufferedImage + * + * @param image + * @return + */ + public static BufferedImage toBufferedImage(Image image) { + if (image instanceof BufferedImage) { + return (BufferedImage) image; + } + + // This code ensures that all the pixels in the image are loaded + image = new ImageIcon(image).getImage(); + + // Determine if the image has transparent pixels; for this method's + // implementation, see e661 Determining If an Image Has Transparent Pixels + // boolean hasAlpha = hasAlpha(image); + + // Create a buffered image with a format that's compatible with the screen + BufferedImage bimage = null; + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + try { + // Determine the type of transparency of the new buffered image + int transparency = Transparency.OPAQUE; + /* + * if (hasAlpha) { transparency = Transparency.BITMASK; } + */ + + // Create the buffered image + GraphicsDevice gs = ge.getDefaultScreenDevice(); + GraphicsConfiguration gc = gs.getDefaultConfiguration(); + bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); + } catch (HeadlessException e) { + // The system does not have a screen + } + + if (bimage == null) { + // Create a buffered image using the default color model + int type = BufferedImage.TYPE_INT_RGB; + // int type = BufferedImage.TYPE_3BYTE_BGR;//by wang + /* + * if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } + */ + bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); + } + + // Copy image to buffered image + Graphics g = bimage.createGraphics(); + + // Paint the image onto the buffered image + g.drawImage(image, 0, 0, null); + g.dispose(); + + return bimage; + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel(String xls_write_Address, ArrayList ls, String[] sheetnames) throws IOException { + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 + XSSFWorkbook wb = new XSSFWorkbook();// (new + // BufferedInputStream(output)); + for (int sn = 0; sn < ls.size(); sn++) { + XSSFSheet sheet = wb.createSheet(String.valueOf(sn)); + wb.setSheetName(sn, sheetnames[sn]); + ArrayList ls2 = ls.get(sn); + for (int i = 0; i < ls2.size(); i++) { + XSSFRow row = sheet.createRow(i); + String[] s = ls2.get(i); + for (int cols = 0; cols < s.length; cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellValue(s[cols]);// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /** + * 根据单元格的名字来找到单元格的内容 + * + * @param inputFilePath + * @param cellName + * @return + */ + public static List getExcelNamedCellValue(String inputFilePath, String[] cellNames) { + List valueList = new ArrayList(); + if (!new File(inputFilePath).exists()) { + for (int i = 0; i < cellNames.length; i++) + valueList.add(""); + return valueList; + } + try { + FileInputStream is = new FileInputStream(new File(inputFilePath)); + XSSFWorkbook wb = new XSSFWorkbook(is); + for (String name : cellNames) + valueList.add(getNamedCellValue(wb, name)); + is.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return valueList; + } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcel(String outPath, InputStream input, + * List beanListAll) throws IOException { + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 + * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new + * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow + * = 2; for (int i = 0; i < beanListAll.size(); i++) { JFomProjectChangeBean + * bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat = false; if + * ((i + startRow) > sheet.getLastRowNum()) { row = sheet.createRow(i + + * startRow); isCreat = true; } else { row = sheet.getRow(i + startRow); isCreat + * = false; } + * + * for (int cols = 0; cols < 12; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: + * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: + * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: + * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: + * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: + * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: + * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: + * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: + * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: + * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// 写入内容 + * break; } } } // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(XSSFRow row1, int index, String str) { + XSSFCell cell = row1.getCell(index); + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(Row row1, int index, String str) { + Cell cell = row1.getCell(index); + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcelBomExport(String outPath, InputStream input, + * List beanListAll, JFomBomExportProjBean projBean) throws + * IOException { + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 + * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new + * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow + * = 4; if (projBean != null) { XSSFRow row1 = sheet.getRow(0); + * setCellValue(row1, 11, projBean.getPROJ_NAME()); setCellValue(row1, 14, + * projBean.getPROJ_MODE()); setCellValue(row1, 16, projBean.getPRODUCT_LIFE()); + * row1 = sheet.getRow(1); setCellValue(row1, 11, projBean.getPROJ_CUSTOMER()); + * setCellValue(row1, 14, projBean.getPROJ_MEMBER()); } for (int i = 0; i < + * beanListAll.size(); i++) { JFomBomExportBean bean = beanListAll.get(i); + * XSSFRow row = null; Boolean isCreat = false; if ((i + startRow) > + * sheet.getLastRowNum()) { row = sheet.createRow(i + startRow); isCreat = true; + * } else { row = sheet.getRow(i + startRow); isCreat = false; } + * + * for (int cols = 0; cols < 22; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 int indexStr = + * bean.getIndexStr(); if (cols == (indexStr + 1)) { + * cell.setCellValue(JFomUtil.JF3_INDEX_STR);// 写入内容 } + * + * switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexExt());// 写入内容 break; case 7: + * cell.setCellValue(bean.getWlNumber());// 写入内容 break; case 8: + * cell.setCellValue(bean.getMPS()); break; case 9: + * cell.setCellValue(bean.getCustomerNo()); break; case 10: + * cell.setCellValue(bean.getWlName()); break; case 11: + * cell.setCellValue(bean.getK3code()); break; case 12: insertPicture(wb, sheet, + * bean.getPicturePath(), (short) 14, i + startRow); break; case 13: + * cell.setCellValue(bean.getMaterialName()); break; case 14: + * cell.setCellValue(bean.getMaterialSize()); break; case 15: + * cell.setCellValue(bean.getMaterialStander()); break; case 16: + * cell.setCellValue(bean.getMaterialPark()); break; case 17: + * cell.setCellValue(bean.getJingzhong()); break; case 18: + * cell.setCellValue(bean.getMaozhong()); break; case 19: + * cell.setCellValue(bean.getGongyi()); break; case 20: + * cell.setCellValue(bean.getGongyingshang()); break; default: break; } } } // } + * wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, String picPath, short colIndex, int rowIndex) { + + // FileOutputStream fileOut = null; + BufferedImage bufferImg = null; + // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray + try { + if (!new File(picPath).exists()) { + return; + } + String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, picPath.length()); + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + System.out.println(picPath); + bufferImg = ImageIO.read(new File(picPath)); + ImageIO.write(bufferImg, dexStr, byteArrayOut); + // XSSFWorkbook wb = new XSSFWorkbook(); + // XSSFSheet sheet1 = wb.createSheet("test picture"); + // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) + XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); + // anchor主要用于设置图片的属性 + XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, + (short) (colIndex + 1), rowIndex + 1); + //anchor.setAnchorType(3); + // 插入图片 + patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 移除合并的单元格 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean removeMergen(XSSFSheet sheet, int startRow, int endRow) { + boolean isOK = false; + int count = sheet.getNumMergedRegions(); + for (int i = 0; i < count; i++) { + CellRangeAddress address = sheet.getMergedRegion(i); + System.out.println(address.getFirstRow() + "|" + address.getLastRow()); + if (address.getFirstRow() == startRow && address.getLastRow() == endRow) { + sheet.removeMergedRegion(i); + isOK = true; + break; + } + } + return isOK; + } + + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion( + new CellRangeAddress(rows[0], rows[rows.length - 1], columns[0], columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + + /** + * 截取字符串 + * + * @param inStr + * @return + */ + public static String changeStringToInt(String inStr) { + int index = inStr.indexOf("."); + System.out.println(index); + String outStr = null; + if (index != -1) { + + outStr = inStr.substring(0, index); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 截取一定长度的字符串 + * + * @param inStr + * @param inLen + * @return + */ + public static String changeStringToInt(String inStr, int inLen) { + int index = inStr.indexOf("."); + inLen++; + System.out.println(index); + String outStr = null; + if (index != -1 && (inStr.length() - index) >= inLen) { + + outStr = inStr.substring(0, index + inLen); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 将float转换成保留两位的字符串 + * + * @param f 需要转换的float数 + * @return + */ + public static String changeFloatToStr(float f) { + DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. + String str = decimalFormat.format(f);// format 返回的是字符串 + return str; + } + + /** + * 将字符串转换成int + * + * @param str + * @return + */ + public static float changeStrToFloat(String str) { + float temp_int = 0; + try { + temp_int = Float.parseFloat(str.trim()); + return temp_int; + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return -1; + } + } + + /** + * 设置formual的时候用来替换原有的单元格号到新的单元格号 + * + * @param originStr + * @param subStr + * @param index + * @param index2 + * @return + */ + public static String replaceSubString(String originStr, String subStr, int index, int index2) { + StringBuffer sbO = new StringBuffer(); + sbO.append(subStr); + sbO.append(index); + StringBuffer sbR = new StringBuffer(); + sbR.append(subStr); + sbR.append(index2); + String resultStr = originStr.replace(sbO.toString(), sbR.toString()); + return resultStr; + } + + /** + * 读取EXCEL信息 + * + * @param String excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(String excel_file) throws FileNotFoundException, IOException { + if (excel_file == null) { + return null; + } + File file = new File(excel_file); + // 获取EXCEL数据的具体逻辑的函数 + return readExcel(file); + } + + public static String combinationString(String s) { + String result = ""; + List sList = new ArrayList(); + List sList2 = new ArrayList(); + if (s.indexOf("&") > -1) { + String[] ss = s.split("&"); + if (ss[0].indexOf("/") > -1) { + String[] sss = ss[0].split("/"); + for (int i = 0; i < sss.length; i++) { + sList.add(sss[i]); + } + } else { + sList.add(ss[0]); + } + if (ss[1].indexOf("/") > -1) { + String[] sss = ss[1].split("/"); + for (int i = 0; i < sss.length; i++) { + sList2.add(sss[i]); + } + } else { + sList2.add(ss[1]); + } + + if (sList.size() == sList2.size()) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < sList.size(); i++) { + sb.append(sList.get(i) + "/" + sList2.get(i) + "&"); + } + if (sb != null && sb.length() != 0) { + result = sb.substring(0, sb.length() - 1); + } + } + } + return result; + + } + + /** + * 读取控制计划信息 + * + * @param String excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static Map> readExcel(String excel_file, String cellName) + throws FileNotFoundException, IOException { + if (excel_file == null) { + return null; + } + File file = new File(excel_file); + XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file)); + Map> result = new LinkedHashMap>(); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(xwb); + XSSFSheet sheet = xwb.getSheetAt(0); + XSSFRow row; + String cell; + for (int i = sheet.getFirstRowNum(); i < sheet.getPhysicalNumberOfRows(); i = i + 2) { + + row = sheet.getRow(i); + if (getRegionValue(xwb, sheet, i, 1).toString().equals(cellName)) { + List rowValue = new ArrayList(); + int lastRow = getRegionIndex(sheet, i, 1, cellName); + for (int j = row.getFirstCellNum(); j < row.getLastCellNum(); j++) { + if (j == 10) { + continue; + } + if ((row.getCell(j) == null || row.getCell(j).toString().equals("")) && i <= lastRow) { + String s = getRegionValue(xwb, sheet, i, j); + if (s == null) { + cell = ""; + } else { + if (j == 9) { + if (row.getCell(10) != null && !row.getCell(10).toString().equals("")) { + s = s + "/" + sheet.getRow(i - 1).getCell(10).toString() + "/" + + row.getCell(10).toString(); + } + } + cell = s; + } + } else { + cell = getStringCellValue(evaluator, row.getCell(j)); + } + System.out.print(cell + ","); + rowValue.add(cell); + } + result.put((int) Float.parseFloat(rowValue.get(3)), rowValue); + } + System.out.println("**********************"); + } + return result; + } + + /** + * 获取单个的命名单元格的位置 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int[] getNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { + int[] index = new int[2]; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return null; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + index[0] = cellR.getCol(); + index[1] = cellR.getRow(); + // colIndex = cellR.getCol(); + // rowIndex = cellR.getRow(); + } + } + } + } + return index; + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex(XSSFWorkbook wb, String cellName) throws IOException { + int index = -1; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + + /** + * 获取合并单元格内容 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static String getRegionValue(XSSFWorkbook workbook, XSSFSheet sheet, int rowIndex, int cellIndex) { + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook); + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); + if (rowIndex <= lastRowNum && rowIndex >= rowNum && cellIndex <= lastColIndex && cellIndex >= colIndex) { + return getStringCellValue(evaluator, sheet.getRow(rowNum).getCell((short) colIndex)); + } + } + return null; + } + + /** + * 获取EXCEL合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static Map getRegionCell(XSSFSheet sheet) { + Map regionCellMap = new HashMap(); + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + if (rowNum >= 13) { + // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); + // 行集合 + int[] rows = new int[lastRowNum - (rowNum - 1)]; + // 列集合 + for (int j = 0; j < rows.length; j++) { + rows[j] = rowNum + j; + } + int[] columns = new int[lastColIndex - (colIndex - 1)]; + for (int j = 0; j < columns.length; j++) { + columns[j] = colIndex + j + 1; + } + regionCellMap.put(rows, columns); + } + } + return regionCellMap; + } + + /** + * 获取EXCEL合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static Map getEntrustingContentRegionCell(XSSFSheet sheet) { + Map regionCellMap = new HashMap(); + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + if (rowNum >= 0) { + // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); + // 行集合 + int[] rows = new int[lastRowNum - (rowNum - 1)]; + // 列集合 + for (int j = 0; j < rows.length; j++) { + rows[j] = rowNum + j; + } + int[] columns = new int[lastColIndex - (colIndex - 1)]; + for (int j = 0; j < columns.length; j++) { + columns[j] = colIndex + j + 1; + } + regionCellMap.put(rows, columns); + } + } + return regionCellMap; + } + + /** + * 转换为控制计划合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static String toControlPlanRegionCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k] - 13); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k]); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) + + "-"); + } + } + if (sb.length() > 0) { + return sb.toString().substring(0, sb.length() - 1); + } else { + return ""; + } + } + + /** + * 转换为委托内容合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static String toEntrustingContentRegionCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k]); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k] - 1); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) + + "-"); + } + } + if (sb.length() > 0) { + return sb.toString().substring(0, sb.length() - 1); + } else { + return ""; + } + } + + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s 内容 + * @param firstIndex 起始位置 + * @param lastIndex 结束位置 + * @param fontSize 字体大小 + * @param FontName 字体样式 + * @return + */ + public static XSSFRichTextString setCellFont(XSSFWorkbook wb, String s, int firstIndex, int lastIndex, int fontSize, + String FontName) { + XSSFRichTextString ts = new XSSFRichTextString(s); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + + /** + * 获取单元格大小 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @param cellValue + */ + public static int getRegionIndex(XSSFSheet sheet, int rowIndex, int cellIndex, String cellValue) { + int lastRow = 0; + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + if (sheet.getRow(rowNum).getCell(colIndex).toString().equals(cellValue)) { + lastRow = lastRowNum; + } + } + return lastRow; + } + + /** + * 获取单元格数据内容为字符串类型的数据 + * + * @param cell Excel单元格 + * @return String 单元格数据内容 + */ + private static String getStringCellValue(XSSFFormulaEvaluator evaluator, XSSFCell cell) { + if (cell == null) { + return ""; + } + String strCell = ""; + switch (cell.getCellType()) { + case XSSFCell.CELL_TYPE_STRING: + strCell = cell.getStringCellValue(); + break; + case XSSFCell.CELL_TYPE_NUMERIC: + // strCell = cell.getStringCellValue(); + if (DateUtil.isCellDateFormatted(cell)) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + Date date = cell.getDateCellValue(); + if (date != null) + strCell = sdf.format(date); + } else { + + strCell = "" + cell.getNumericCellValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + strCell = String.valueOf(cell.getBooleanCellValue()); + break; + case XSSFCell.CELL_TYPE_BLANK: + strCell = ""; + break; + case XSSFCell.CELL_TYPE_ERROR: + strCell = String.valueOf(cell.getErrorCellValue()); + break; + case XSSFCell.CELL_TYPE_FORMULA: + CellValue value = evaluator.evaluate(cell); + try { + strCell = value.getStringValue(); + if (strCell == null) { + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + } catch (Exception e) { + + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + break; + + default: + strCell = ""; + break; + } + if (strCell.equals("") || strCell == null) { + return ""; + } + // System.out.println(" === Type =" + cell.getCellType() + " Value =" + + // strCell); + return strCell; + } + + /** + * 插入行数 + * + * @param starRow + * @param rows + */ + public static void insertRow(XSSFSheet sheet, int starRow, int rows) { + XSSFRow sourceRow = sheet.getRow(starRow); + sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + XSSFRow targetRow = null; + XSSFCell sourceCell = null; + XSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(starRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + + /*** + * 向sheet中插入一行 + * + * @param sheet + * @param startRow + * @param rows + * @return + */ + public static XSSFSheet insertRows(XSSFSheet sheet, int startRow, int rows) { + XSSFRow sourceRow = sheet.getRow(startRow); + sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + XSSFRow targetRow = null; + XSSFCell sourceCell = null; + XSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(startRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + return sheet; + } + + /** + * 检查单元格内容是否是数字 + * + * @param value + * @return + */ + public static boolean CheckCellValueIsNumber(String value) { + boolean is_ok = false; + if (value.equals("")) { + return false; + } + try { + Float.parseFloat(value); + } catch (NumberFormatException e) { + e.printStackTrace(); + System.out.println("===>" + value); + is_ok = true; + } + return is_ok; + } + +// /** +// * 拼接麦格纳的联系人和联系电话 +// * +// * @param persion +// * @param phone +// * @return +// */ +// public static String connectPhoneAndPersion(String persion, String phone) { +// StringBuffer persionPhoneSb = new StringBuffer(); +// if (persion != null && phone != null) { +// +// String[] persions = null; +// String[] phones = null; +// if (persion.contains("、")) { +// persions = persion.split("、"); +// } else if (persion.contains("\\/")) { +// persions = persion.split("\\/"); +// } else if (persion.contains(",")) { +// persions = persion.split(","); +// } else { +// persions = new String[] { persion }; +// } +// +// if (phone.contains("、")) { +// phones = phone.split("、"); +// } else if (phone.contains("\\/")) { +// phones = phone.split("\\/"); +// } else if (phone.contains(",")) { +// phones = phone.split(","); +// } else { +// phones = new String[] { phone }; +// } +// +// if (persions != null && phones != null) { +// int persionCount = persions.length; +// int phonesCount = phones.length; +// if (persionCount == phonesCount) { +// for (int i = 0; i < persionCount; i++) { +// persionPhoneSb.append(persions[i]).append("/") +// .append(phones[i]).append(" "); +// +// } +// } +// } +// } +// +// return persionPhoneSb.toString(); +// } + + /*** + * 输出成形作业指导书 + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @param row_num + * @param col_num + * @throws IOException + * + */ + public static void writeExcelForCX(String xls_write_Address, File file, ArrayList> ls, + int row_num, int col_num) throws IOException { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// (new + is.close(); + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 + XSSFCellStyle style = wb.createCellStyle(); +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); + XSSFFont font = wb.createFont(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + XSSFSheet sheet = wb.getSheetAt(0); + sheet.setForceFormulaRecalculation(true); + if (ls != null) + for (int i = 0; i < ls.size(); i++) { + if (i % 27 == 0 && i != 0) { + row_num += 11; + } + XSSFRow row = sheet.getRow(i + row_num - 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.getCell(cols + col_num - 1); + if (cell == null) { + cell = row.createCell(cols + col_num - 1); + } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// cell.setCellStyle(style);// 添加边框 + if (cols + col_num == 9) { + String cpgc = ls2.get(cols); + System.out.println(cpgc); + String[] strs = cpgc.split("special"); + System.out.println("strs.length=>" + strs.length); + if (cpgc != null && cpgc != "") { + if (!" ".equals(strs[1])) { + String special = strs[1]; + if (special.indexOf("|") <= 0) { + if ("产品/过程/规格/公差".equals(special.split("-")[0])) { + int index = Integer.valueOf(special.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + + } else { + String[] tstxs = special.split("\\|"); + for (String str : tstxs) { + if ("产品/过程/规格/公差".equals(str.split("-")[0])) { + int index = Integer.valueOf(str.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue( + setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + } + } + } else { + // 直接写入strs[0] + cell.setCellValue(strs[0]); + } + } + } else + cell.setCellValue(ls2.get(cols));// 写入内容 + } + + } + else + MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /** + * 输出整形作业指导书 + * + * @param string + * @param is + * @param zx + * @param strings + * @param i + * @param j + */ + public static void writeExcelForZX(String xls_write_Address, File file, ArrayList> ls, + int row_num, int col_num) throws IOException { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// (new + is.close(); + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 + XSSFCellStyle style = wb.createCellStyle(); + XSSFFont font = wb.createFont(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + XSSFSheet sheet = wb.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + if (i % 30 == 0 && i != 0) { + row_num += 10; + } + XSSFRow row = sheet.getRow(i + row_num - 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = null; + if (cols == ls2.size() - 1) + cell = row.getCell(cols + col_num - 1); + else + cell = row.getCell(cols + col_num - 1); + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// cell.setCellStyle(style);// 添加边框 + if (cols + col_num == 11) { + String cpgc = ls2.get(cols); + System.out.println(cpgc); + String[] strs = cpgc.split("special"); + System.out.println("strs.length=>" + strs.length); + if (cpgc != null && cpgc != "") { + if (!" ".equals(strs[1])) { + String special = strs[1]; + if (special.indexOf("|") <= 0) { + if ("产品/过程/规格/公差".equals(special.split("-")[0])) { + int index = Integer.valueOf(special.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + + } else { + String[] tstxs = special.split("\\|"); + for (String str : tstxs) { + if ("产品/过程/规格/公差".equals(str.split("-")[0])) { + int index = Integer.valueOf(str.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + } + } + } else { + // 直接写入strs[0] + cell.setCellValue(strs[0]); + } + } + } else + cell.setCellValue(ls2.get(cols));// 写入内容 + } + + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + + } + + /** + * 输出烧结作业指导书 + * + * @param string + * @param is + * @param zx + * @param strings + * @param i + * @param j + */ + public static void writeExcelForSJ(String xls_write_Address, File file, ArrayList> ls, + List productNameList24, List productNameList18) throws IOException { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// (new + is.close(); + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// writeExcelWithOneCellName(wb, "生产设备", rb3_jqsb); + XSSFCellStyle style = wb.createCellStyle(); + XSSFFont font = wb.createFont(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + XSSFSheet s = wb.getSheetAt(0); + s.setForceFormulaRecalculation(true); + if (productNameList24 != null) { + setNamedCellValue(wb, "二十四寸", + productNameList24.toString().substring(1, productNameList24.toString().length() - 1)); + } + if (productNameList18 != null) { + setNamedCellValue(wb, "十八寸", + productNameList18.toString().substring(1, productNameList18.toString().length() - 1)); + } + int[] indexs = getNamedCellIndex(wb, "设备"); + int startRow = indexs[1] + 1; + int startColumn = indexs[0]; + for (int i = 0; i < productNameList24.size(); i++) { + + Row r = s.getRow(startRow + i); + setCellValue(r, startColumn, productNameList24.get(i)); + } + for (int i = 0; i < productNameList18.size(); i++) { + Row r = s.getRow(startRow + productNameList24.size() + i); + setCellValue(r, startColumn, productNameList18.get(i)); + } + + int row_num = 0; + int t = 0; + for (int i = 0; i < ls.size(); i++) { + if (t % 12 == 0 && i != 0) { + t = 0; + row_num += 29; + } + + ArrayList ls2 = ls.get(i); + System.out.println("SJ_data.size===============>" + ls2.size()); + System.out.println("SJ_data====================>" + ls2.toString()); + for (int j = 0; j < ls2.size() + 1; j++) { + int namedCellIdx = wb.getNameIndex("head" + String.valueOf(j + 1)); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + CellReference[] crefs = arefs[0].getAllReferencedCells(); + for (int k = 0; k < crefs.length; k++) { + Row r = s.getRow(crefs[k].getRow() + row_num + 1); + Cell c = r.getCell(crefs[k].getCol()); + if (j == 2) { + toSpecial(j, wb, c, ls2); + } else if (namedCellIdx != wb.getNameIndex("head7")) + c.setCellValue(ls2.get(j)); + else + c.setCellValue("√"); + } + } + + } + t++; + row_num++; + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + + } + + // 20181220-ReinhartEdit + /*** + * 输出热处理作业指导书 + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @param row_num + * @param col_num + * @throws IOException + * + */ + public static void writeExcelForRCL(String xls_write_Address, File file, ArrayList> ls, + int row_num, int col_num) throws IOException { + // InputStream is = new FileInputStream(file); + // XSSFWorkbook wb = new XSSFWorkbook(is);// (new + // is.close(); + // FileOutputStream output = new FileOutputStream(new File( + // xls_write_Address)); // 读取的文件路径 + + // XSSFCellStyle style = wb.createCellStyle(); + // MessageBox.post("In Processing", "Step", MessageBox.WARNING); + + // MessageBox.post(xls_write_Address, "Step", MessageBox.WARNING); + + // 读取Excel文档 + // File finalXlsxFile = new File("D:/NBTM热处理工艺指导书.xlsx"); + File finalXlsxFile = new File(xls_write_Address); + Workbook workBook = getWorkbok(finalXlsxFile); + // sheet 对应一个工作页 + Sheet getSheet = workBook.getSheetAt(0); + +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); + // XSSFFont font = wb.createFont(); + /// font.setFontHeightInPoints((short) 8); + // style.setFont(font); + + if (ls != null) { + + int rowNumber = getSheet.getLastRowNum(); // 第一行从0开始算 + System.out.println("原始数据总行数:" + ls.size()); + + // 先把模板文件内容清空了 + for (int i = 0; i < 10; i++) { + Row row = getSheet.getRow(i + 26); + + if (row == null) { + row = getSheet.createRow(i + 26); + } + try { + Cell Itemcell = row.getCell(2); + if (Itemcell == null) { + Itemcell = row.createCell(2); + } + Itemcell.setCellValue("");// 写入内容 + + Cell Valuecell = row.getCell(6); + if (Valuecell == null) { + Valuecell = row.createCell(6); + } + Valuecell.setCellValue("");// 写入内容 + + Cell Processcell = row.getCell(10); + if (Processcell == null) { + Processcell = row.createCell(10); + } + Processcell.setCellValue("");// 写入内容 + + Cell Doublecell = row.getCell(14); + if (Doublecell == null) { + Doublecell = row.createCell(14); + } + Doublecell.setCellValue("");// 写入内容 + + } catch (Exception ex) { + System.out.println(ex.toString()); + MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); + + return; + } + + } + // System.out.println("先把模板文件内容清空了" ); + + // 先把模板文件内容清空了 + // 写入参数数据 + // System.out.println(ls.size()); + for (int i = 0; i < ls.size(); i++) { + + System.out.println("写入实际数据!"); + Row row = getSheet.getRow(i + 26); + + if (row == null) { + row = getSheet.createRow(i + 26); + } + + ArrayList ls2 = ls.get(i); + // System.out.println(ls2.get(i)); + // MessageBox.post(ls2.get(0), "Step", MessageBox.WARNING); + + try { + + Cell Itemcell = row.getCell(2); + if (Itemcell == null) { + Itemcell = row.createCell(2); + } + System.out.println(ls2.get(1)); + Itemcell.setCellValue(ls2.get(1));// 写入内容 + + Cell Valuecell = row.getCell(6); + if (Valuecell == null) { + Valuecell = row.createCell(6); + } + System.out.println(ls2.get(2)); + Valuecell.setCellValue(ls2.get(2));// 写入内容 + + Cell Processcell = row.getCell(10); + if (Processcell == null) { + Processcell = row.createCell(10); + } + System.out.println(ls2.get(3)); + Processcell.setCellValue(ls2.get(3));// 写入内容 + + Cell Doublecell = row.getCell(14); + if (Doublecell == null) { + Doublecell = row.createCell(14); + } + System.out.println(ls2.get(4)); + Doublecell.setCellValue(ls2.get(4));// 写入内容 + + } catch (Exception ex) { + System.out.println(ex.toString()); + MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); + + return; + } + + } + // 写入参数数据 + + // FileOutputStream output = new FileOutputStream("D:/MY热处理工艺指导书.xlsx"); // + // 读取的文件路径 + FileOutputStream output = new FileOutputStream(xls_write_Address); // 读取的文件路径 + + workBook.write(output); + // wb.write(output); + + if (output != null) { + output.flush(); + output.close(); + } + + // System.out.println("Start output data to Excel end!!!!!"); + // MessageBox.post(" output data to Excel end!!!!!", "Step", + // MessageBox.WARNING); + + } else { + MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); + } + + System.out.println("-------WRITE EXCEL OVER-------"); + } + + public static void toSpecial(int cols, XSSFWorkbook wb, Cell cell, ArrayList cell_Date) { + String cpgc = cell_Date.get(cols); +// System.out.println(cpgc); + String[] strs = cpgc.split("special"); +// System.out.println(strs.length); + if (cpgc != null || cpgc != "") { + if (!"null".equals(strs[1]) && !" ".equals(strs[1])) { + String special = strs[1]; + if (special.indexOf("|") <= 0) { + if ("产品/过程/规格/公差".equals(special.split("-")[0])) { + int index = Integer.valueOf(special.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + + } else { + String[] tstxs = special.split("\\|"); + for (String str : tstxs) { + if ("产品/过程/规格/公差".equals(str.split("-")[0])) { + int index = Integer.valueOf(str.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + } + } + } else { + // 直接写入strs[0] + cell.setCellValue(strs[0]); + } + } + + } + + public static void writeExcelWithOneCellName(XSSFWorkbook wb, String cellName, String value) { + + int namedCellIdx = wb.getNameIndex(cellName); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + for (int i = 0; i < arefs.length; i++) { + CellReference[] crefs = arefs[i].getAllReferencedCells(); + for (int j = 0; j < crefs.length; j++) { + Sheet s = wb.getSheet(crefs[j].getSheetName()); + Row r = s.getRow(crefs[j].getRow()); + Cell c = r.getCell(crefs[j].getCol()); + c.setCellValue(value); + } + } + } + } + + /** + * 将对象属性值写入到Excel中 + * + * @param output + * @param file + * @param cellName + * @param cellValue + */ + public static void writeExcelWithCellName(File file, String fileOutUrl, Map map, int code, + String meop_name) { + try { + InputStream is = new FileInputStream(file); + Workbook wb = new XSSFWorkbook(is);// retrieve workbook + is.close(); + FileOutputStream output = new FileOutputStream(new File(fileOutUrl)); + boolean is_first = true; + for (String key : map.keySet()) { + if (is_first && "产品代号".equals(key) && (code == 3 || code == 4 || code == 5)) { + int a1CellIndex = wb.getNameIndex("head"); + if (a1CellIndex != -1) { + Name a1NameCell = wb.getNameAt(a1CellIndex); + AreaReference[] a1ARF = AreaReference.generateContiguous(a1NameCell.getRefersToFormula()); + CellReference[] a1CRF = a1ARF[0].getAllReferencedCells(); + Sheet s = wb.getSheet(a1CRF[0].getSheetName()); + Row r = s.getRow(a1CRF[0].getRow()); + Cell c = r.getCell(a1CRF[0].getCol()); + System.out.println(key + ":" + c.getStringCellValue()); + c.setCellValue(c.getStringCellValue() + map.get(key)); + is_first = false; + } + } + + if ("工艺流程".equals(key)) { + SetFont(wb, map.get(key), meop_name); + } + + else { + + int namedCellIdx = wb.getNameIndex(key); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + for (int i = 0; i < arefs.length; i++) { + CellReference[] crefs = arefs[i].getAllReferencedCells(); + + for (int j = 0; j < crefs.length; j++) { + + Sheet s = wb.getSheet(crefs[j].getSheetName()); + Row r = s.getRow(crefs[j].getRow()); + Cell c = r.getCell(crefs[j].getCol()); + if (code == 2) { + c.setCellValue(map.get(key).split("/")[0]); + } else + c.setCellValue(map.get(key)); + } + } + } + } + } + wb.write(output); + output.close(); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 设置str1中str2的字体 + * + * @param wb + * @param str1 + * @param str2 + * @throws IOException + */ + private static void SetFont(Workbook wb, String str1, String str2) throws IOException { + int index = 0; + int start_index = 0; + int end_index = str1.length(); + String meop_name = str2.split("/")[0]; + if (str1.indexOf("成形") != -1) + start_index = str1.indexOf("成形"); + if (str1.lastIndexOf("包装") != -1) + end_index = str1.lastIndexOf("包装") + 2; + str1 = str1.substring(start_index, end_index); + while ((index = str1.indexOf(meop_name, index)) != -1) { + int next_index = index + meop_name.length(); + boolean begin = index - 1 < 0 || str1.charAt(index - 1) == '-'; + boolean end = next_index > str1.length() || next_index + 1 > str1.length() ? true + : str1.charAt(next_index) == '-'; + if (begin && end) + break; + else + index = index + meop_name.length(); + } + XSSFRichTextString ts = new XSSFRichTextString(str1); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 10); // 字体高度 + font1.setFontName("仿宋"); // 字体 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) 12); // 字体高度 + font.setFontName("仿宋"); + ts.applyFont(index, index + meop_name.length(), font); + ts.applyFont(index + meop_name.length(), ts.length(), font1); +// XSSFFont font = (XSSFFont) wb.createFont(); +// +// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); +// ts.applyFont(index, index+str2.length(), font); + int namedCellIdx = wb.getNameIndex("工艺流程"); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + for (int i = 0; i < arefs.length; i++) { + CellReference[] crefs = arefs[i].getAllReferencedCells(); + for (int j = 0; j < crefs.length; j++) { + Sheet s = wb.getSheet(crefs[j].getSheetName()); + Row r = s.getRow(crefs[j].getRow()); + Cell c = r.getCell(crefs[j].getCol()); + c.setCellValue(ts); + } + } + } + } + + /** + * 添加命名的引用 + * + * @param session + * @param item 对象的版本 + * @param tcResource 文件的物理路径 + * @param relationType 关系名称 + * @param fileName 文件名 + */ + public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, + String fileName, String relationType, String excelType, boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { excelType }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if (excelType.equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + if (dateSet.getStringProperty("object_name").equals(fileName)) { + dateSet.delete(); + zyzdsRev.remove(relationType, dateSet); + } + } + } + item.add(relationType, tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取命名的引用返回所有对象 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset[] getComponentToDatasets(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + TCComponentDataset[] Childrens = new TCComponentDataset[zyzdsChildrens.length]; + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (int ii = 0; ii < zyzdsChildrens.length; ii++) { + + if (zyzdsChildrens[ii] instanceof TCComponentDataset) { + // + + Childrens[ii] = (TCComponentDataset) zyzdsChildrens[ii]; + + // + } + +// + + } + + return Childrens; + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + + public static TCComponentDataset getComponentToDataset(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + + return (TCComponentDataset) zyzdsChildren; +// + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, + String relationType, String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + return (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, + String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取合并单元格 + * + * @param value 值 + * @param startIndex 起始行 + * @return + */ + public static void getCombineRow(String value, int startIndex) { + // TODO Auto-generated method stub + String[] sombines = null; + if (value != null && !value.equals("")) { + if (value.indexOf("-") >= 0) { + sombines = value.split("-"); + } else { + sombines = new String[] { value }; + } + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + startIndex; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + startIndex }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]) - 1; + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) - 1 }; + } + map.put(row, cloumn); + } + } + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getOneNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { + int index = -1; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + + /** + * 改变数据集的命名引用 + * + * @param tccomponentDataset + * @param quote + * @param type + * @param path + * @throws TCException + */ + public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) + throws TCException { + String myPath[] = { path }; + String myQuote[] = { quote };// 引用"excel" + String myType[] = { type };// 类型"MSExcelX" + String myPlain[] = { "Plain" }; + + // 删除数据集的引用 + deleDateSetRef(tccomponentDataset); + // 数据集的替换 + tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote); + + } + + /** + * 删除数据集的命名引用 + * + * @param dataset + * @throws TCException + */ + private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { + + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + for (int i = 0; i < tcFiles.length; i++) { + // 得到数据集的引用类型 + String str_temp = getNamedRefType(dataset, tcFiles[i]); + // 删除引用 + dataset.removeNamedReference(str_temp); + } + + } + + /** + * 得到数据集的引用类型 + * + * @param datasetComponent + * @param tccomponent + * @return + * @throws TCException + */ + private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) + throws TCException { + String s; + s = ""; + TCProperty tcproperty; + TCProperty tcproperty1; + TCComponent atccomponent[]; + String as[]; + int i; + int j; + int k; + try { + tcproperty = datasetComponent.getTCProperty("ref_list"); + tcproperty1 = datasetComponent.getTCProperty("ref_names"); + if (tcproperty == null || tcproperty1 == null) + return s; + } catch (TCException tcexception) { + return s; + } + atccomponent = tcproperty.getReferenceValueArray(); + as = tcproperty1.getStringValueArray(); + if (atccomponent == null || as == null) + return s; + i = atccomponent.length; + if (i != as.length) + return s; + j = -1; + k = 0; + do { + if (k >= i) + break; + if (tccomponent == atccomponent[k]) { + j = k; + break; + } + k++; + } while (true); + if (j != -1) + s = as[j]; + return s; + } + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponentDataset dateSet, String compType) throws TCException, IOException { + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyymmdd"); + TCComponentTcFile[] tcFiles = dateSet.getTcFiles(); + File file = null; + if (tcFiles != null) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); +// if (compType.equals("MSExcelX")) { +// this.excelDataset = (TCComponentDataset) comp; +// } + return fileName; + } + return value; + } + + public static void setFlowChart(Map valueMap, File file) { + // TODO Auto-generated method stub + file.setWritable(true); + try { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// ( + XSSFSheet sheet = wb.getSheetAt(0); + + Iterator> it = valueMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + setNamedCellValue(wb, entry.getKey(), entry.getValue()); + } + FileOutputStream output = new FileOutputStream(file); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + // file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + public static Workbook getWorkbok(File file) throws IOException { + Workbook wb = null; + FileInputStream in = new FileInputStream(file); + System.out.println(file.getName()); + + if (file.getName().endsWith(EXCEL_XLS)) { // Excel 2003 + wb = new HSSFWorkbook(in); + } else if (file.getName().endsWith(EXCEL_XLSX)) { // Excel 2007/2010 + System.out.println("OK"); + wb = new XSSFWorkbook(in); + } + return wb; + } + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List readExcelByEntrustment(File excel_file, String type) + throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List lines_msg = new ArrayList(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + boolean isSelectType = false;// 判断是否找到指定的类型 + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + if (row == null) { + isSelectType = false; + continue; + } + // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); + if (getStringCellValue(evaluator, row.getCell((short) 0)) == null + || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { + isSelectType = false; + } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { + isSelectType = true; + if (row.getCell((short) 2) != null) { + String value = getStringCellValue(evaluator, row.getCell((short) 1)); + lines_msg.add(value); + } + } else { + continue; + } + + } + // insertRow(sheet,4,1); + return lines_msg; + } + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static DefaultMutableTreeNode readExcelNodeByEntrustment(File excel_file, String type) + throws FileNotFoundException, IOException { + DefaultMutableTreeNode node = new DefaultMutableTreeNode("应用领域"); + if (excel_file == null || !excel_file.exists()) { + return node; + } + // 用来返回的所有的行的信息 + //List lines_msg = new ArrayList(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + boolean isSelectType = false;// 判断是否找到指定的类型 + String no1 = ""; + String no2 = ""; + DefaultMutableTreeNode no1Node = null; + DefaultMutableTreeNode no2Node = null; + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + if (row == null) { + isSelectType = false; + continue; + } + // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); + if (getStringCellValue(evaluator, row.getCell((short) 0)) == null + || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { + isSelectType = false; + } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { + isSelectType = true; + if (row.getCell((short) 4) != null) { + String value1 = getStringCellValue(evaluator, row.getCell((short) 1)); + String value2 = getStringCellValue(evaluator, row.getCell((short) 2)); + //String value = getStringCellValue(evaluator, row.getCell((short) 3)); + String value4 = getStringCellValue(evaluator, row.getCell((short) 4)); + if(!value1.isEmpty() && value1.compareTo(no1) != 0) + { + no1Node = new DefaultMutableTreeNode(value1); + node.add(no1Node); + no2Node = new DefaultMutableTreeNode(value2); + no1Node.add(no2Node); + } + else if(!value2.isEmpty() && value2.compareTo(no2) != 0) { + no2Node = new DefaultMutableTreeNode(value2); + no1Node.add(no2Node); + } + + no2Node.add(new DefaultMutableTreeNode(value4)); + + //lines_msg.add(value); + } + } else { + continue; + } + + } + // insertRow(sheet,4,1); + return node; + } + + //去除工序号最后的流水 + public static String getID(String ID) { + if(ID.indexOf("-")>-1) { + String[] iDs=ID.split("-"); + String id=""; + for(int i=0;i 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + @SuppressWarnings("unchecked") + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + // v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/JProTextField.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/JProTextField.java new file mode 100644 index 0000000..f895464 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/JProTextField.java @@ -0,0 +1,16 @@ +package com.connor.ml.tcm.outfile.util; + +import javax.swing.JTextField; + +public class JProTextField extends JTextField { + private String realName; + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/JaxbUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/JaxbUtil.java new file mode 100644 index 0000000..7cabaca --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/JaxbUtil.java @@ -0,0 +1,69 @@ +package com.connor.ml.tcm.outfile.util; + + +import java.io.File; +import java.io.FileNotFoundException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +public class JaxbUtil { + + public static boolean validate(final String xmlPath, final String xsdPath) { + boolean result = true; + try { + final String language = "http://www.w3.org/2001/XMLSchema"; + final SchemaFactory factory = SchemaFactory.newInstance(language); + final Schema schema = factory.newSchema(new File(xsdPath)); + final Validator validator = schema.newValidator(); + validator.validate(new StreamSource(xmlPath)); + } catch (final Exception e) { + result = false; + } + return result; + } + + /** + * 序列化 + * @param clazz + * @param object + * @param path + * @throws JAXBException + */ + public static void marshall(final Class clazz, final Object object, final String path) throws JAXBException { + // 通过映射的类创建XMLContext上下文对象,其中参数为映射的类。 + JAXBContext jaxbContext = JAXBContext.newInstance(clazz); + // 通过JAXBComtext上下文对象的createMarshaller()方法,创建一个对象java格式转化成XML的格式 + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + // 最后,将JAVA对象转换到制定的输出位置,其中的object为java对象。 + marshaller.marshal(object, new File(path)); + } + + /** + * 解析 + * @param clazz + * @param path + * @return + * @throws Exception + */ + public static Object unmarshaller(final Class clazz, final String path) throws Exception { + if (path == null || !new File(path).exists()) { + throw new FileNotFoundException(); + } + // 通过映射的类创建XMLComtext上下文对象,其中参数为映射的类。 + JAXBContext jaxbContext = JAXBContext.newInstance(clazz); + // 通过JAXBContext上下文对象创建createUnmarshaller()方法,创建XML转换成JAVA对象的格式。 + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + // 最后,将XML转换成对映的类,转换后需要强制性转换成映射的类 + Object object = unmarshaller.unmarshal(new File(path)); + return object; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MethodUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MethodUtil.java new file mode 100644 index 0000000..29f3740 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MethodUtil.java @@ -0,0 +1,1452 @@ +package com.connor.ml.tcm.outfile.util; + +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; + +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; + +import com.connor.ml.tcm.outfile.bean.ComboBoxItemBean; +import com.connor.ml.tcm.outfile.bean.ItemBean; +import com.connor.ml.tcm.outfile.bean.PropExplictBean; +import com.itextpdf.text.pdf.codec.Base64.InputStream; +import com.spire.xls.ExcelPicture; +import com.spire.xls.ViewMode; +import com.spire.xls.Workbook; +import com.spire.xls.Worksheet; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.DataManagementService; + +public class MethodUtil { + + private static final String SEP1 = ","; + + /** + * 同步超级BOM + * + * @param session session + * @param process 流程对象 + * @param processUser 节点负责人首选项的值 + * @param arctic 车型 + * @throws TCException + */ + public static void sendBom(TCSession session, TCComponentItemRevision itemRevision) throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[1]; + obj[0] = itemRevision; + userservice.call("Super_Bom_Appent_Data", obj); + } + + /** + * 根据规则获取ID + * + * @param oldItemID 旧的ID + * @return 新的ID + */ + public static String getRuleItemID(TCSession session, String oldItemID) { + // String[] oldItemIDs = oldItemID.split("-"); + DecimalFormat df = new DecimalFormat("000"); + // String newID = oldItemIDs[0] + "-" + oldItemIDs[1] + "-001"; + String newID = oldItemID + "-001"; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session.getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + while (tccomponentitemtype.find(newID) != null) { + i++; + // newID = oldItemIDs[0] + "-" + oldItemIDs[1] + "-"+ df.format(i); + newID = oldItemID + "-" + df.format(i); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return newID; + } + + + //插入图片;isProportion:false是将图片嵌入到全部单元格。true是将原图比例放入区域内 + //sheet:操作的excel;picturePath:图片路径;Rows:插入图片区域的行(excel默认行列都从1开始);colunms插入图片区域的列 + //RowHeightCM模板插入图片区域的行高(cm);ColumnWidthCM模板插入图片区域的列宽(cm)。false的这两个参数可以随意设置,用不到 + public static void InsertTitlePicture(Worksheet sheet,String picturePath,int[] Rows,int[] colunms, + boolean isProportion,double RowHeightCM,double ColumnWidthCM) throws IOException { +// //获取系统分辨率 +// int screenWidth=((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().width); +// int screenHeight = ((int)java.awt.Toolkit.getDefaultToolkit().getScreenSize().height); + + double ColumnWidth=0.0;//列宽单元格像素 + double RowHeight=0.0;//行高像素 +// double ColumnWidthCM=0.0;//列宽单元格CM +// double RowHeightCM=0.0;//行高CM + for(int i=0;iRH) { + w=W/CW; + h=(H/CW)*w1/h1;//w1是放图片区域列宽占的厘米数除以像素(0.18);h1是行高的占的厘米数除以像素(0.23) + }else { + h=H/RH; + w=(W/RH)*h1/w1; + } + pic1.setWidth((int) (w)); + pic1.setHeight((int) (h)); + }else { + pic1.setWidth((int) ColumnWidth); + pic1.setHeight((int) RowHeight); + } + } + + + /** + * List转换String + * + * @param list :需要转换的List + * @return String转换后的字符串 + */ + public static String ListToString(List list) { + + StringBuffer sb = new StringBuffer(); + if (list != null && list.size() > 0) { + for (int i = 0; i < list.size(); i++) { + if (list.get(i) == null || list.get(i) == "") { + continue; + } + // 如果值是list类型则调用自己 + if (list.get(i) instanceof List) { + sb.append(ListToString((List) list.get(i))); + sb.append(SEP1); + } else { + sb.append(list.get(i)); + sb.append(SEP1); + } + } + } + return sb.toString(); + } + + //获取工序编号 + public static String getItemId(String ID) { + if(ID.indexOf("-")>-1) { + String[] id=ID.split("-"); + String value=""; + for(int i=0;i= revId) { + itemRevision = items[i]; + revId = letterToNumber(revisionId); + } + } + return itemRevision; + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + // 字母转数字 A-Z :1-26 + public static int letterToNumber(String letter) { + int length = letter.length(); + int num = 0; + int number = 0; + for (int i = 0; i < length; i++) { + char ch = letter.charAt(length - i - 1); + num = (int) (ch - 'A' + 1); + num *= Math.pow(26, i); + number += num; + } + return number; + } + + /** + * 根据LOV名称获取LOV + * + * @param tcsession + * @param s + * @return + */ + public static ComboBoxItemBean[] findLOVByName(TCSession tcsession, String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + ComboBoxItemBean[] comboBoxItemBeans = null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession + .getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s); + if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) { + tccomponentlistofvalues = atccomponentlistofvalues[0]; + + ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); + + String[] groupName = rtlistOfValuesInfo.getStringListOfValues(); + String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); + + comboBoxItemBeans = new ComboBoxItemBean[groupName.length + 1]; + ComboBoxItemBean comboBoxItem = new ComboBoxItemBean("", ""); + comboBoxItemBeans[0] = comboBoxItem; + for (int i = 0; i < groupName.length; i++) { + // resultMap.put(groupDisplayName[i],groupName[i]); + ComboBoxItemBean comboBoxItemBean = new ComboBoxItemBean(groupName[i], groupDisplayName[i]); + comboBoxItemBeans[i + 1] = comboBoxItemBean; + } + } + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return comboBoxItemBeans; + } + + /** + * 根据LOV Key获取LOV值 + * + * @param tcsession + * @param s + * @return + */ + public static String findLovValueByKey(TCSession tcsession, String s, String key) { + TCComponentListOfValues tccomponentlistofvalues = null; + String resultValue = null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession + .getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype.find(s); + if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) { + tccomponentlistofvalues = atccomponentlistofvalues[0]; + + ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); + + String[] groupName = rtlistOfValuesInfo.getStringListOfValues(); + String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); + + for (int i = 0; i < groupName.length; i++) { + // resultMap.put(groupDisplayName[i],groupName[i]); + if (groupName[i].equals(key)) { + resultValue = groupDisplayName[i]; + } + } + } + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return resultValue; + } + + /** + * 指派流程负责人 + * + * @param session session + * @param process 流程对象 + * @param processUser 节点负责人首选项的值 + * @param arctic 车型 + * @throws TCException + */ + public static void setProcess(TCSession session, TCComponentProcess process, String processUser, String arctic) + throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[3]; + obj[0] = process; + obj[1] = processUser; + obj[2] = arctic; + userservice.call("DMU_Review_Process", obj); + } + + /** + * 指派适应性改型流程负责人 + * + * @param session session + * @param process 流程对象 + * @param processUser 节点负责人 + * @param arctic 车型 + * @throws TCException + */ + public static void setRemodelProcess(TCSession session, TCComponentProcess process, String processUser, + String arctic) throws TCException { + + TCUserService userservice = session.getUserService(); + + Object[] obj = new Object[3]; + obj[0] = process; + obj[1] = processUser; + obj[2] = arctic; + userservice.call("Create_Remodel_Process", obj); + } + + /** + * 获取单值得首选项 + * + * @param prefName + * @return + */ + public static String getPrefStr(String prefName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String str = service.getString(TCPreferenceService.TC_preference_site, prefName); + if (str == null) { + str = new String(""); + } + return str; + } + + /*** + * 获取首选项 + * + * @param session 会话 + * @param preferenceName 首选项名称 + * @return + */ + public static String[] getPreferenceValues(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if (preferenceName == null || session == null) { + System.out.println(""); + return null; + } + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringArray(TCPreferenceService.TC_preference_site, preferenceName); + String[] resultValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + if (values[i].indexOf("\\n") >= 0) { + resultValues[i] = values[i].replace("\\n", "\n"); + } else { + resultValues[i] = values[i]; + } + } + return resultValues; + } + + /*** + * 获取首选项 + * + * @param session 会话 + * @param preferenceName 首选项名称 + * @return + */ + public static String getPreferenceValue(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + if (preferenceName == null || session == null) { + System.out.println(""); + return null; + } + TCPreferenceService service = session.getPreferenceService(); + return service.getString(TCPreferenceService.TC_preference_site, preferenceName); + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + userservice.call("ORIGIN_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + userservice.call("ORIGIN_close_bypass", obj); + } + public static void setProperty(TCSession session,TCComponent[] items,String propname,String propvalue) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[3]; + obj[0] = items; + obj[1] = propname; + obj[2] = propvalue; + userservice.call("connor_set_prop_value", obj); + } + + /*** + * 发送对象到分类(通过webService) + * + * @param codeRemark 分类ID + * @param rev 版本对象 + * @param propList 分类属性 + */ + public static void sendObjToClassficationByWebService(String codeRemark, TCComponentItemRevision rev, + List propList) { + try { + + if (!codeRemark.equals("") && rev != null) { + // TCComponentItemRevision rev = item.getLatestItemRevision(); + +// List propList = new ArrayList<>(); +// for (int i = 0; i < classPropList.size(); i++) { +// // System.out.println(" CLASS ID = " + integers[i] + " =" + +// // vals[i]); +// CNClassPropBean bean = classPropList.get(i); +// String value = ""; +// if (bean.isLov) { +// value = ((Combo) classTextList.get(i)).getText(); +// value = bean.lovMapping.get(value); +// } else { +// value = ((Text) classTextList.get(i)).getText(); +// } +// // icspro[i] = new ICSProperty(bean.propID, value); +// ClassProperty prop = new ClassProperty(bean.propID, value); +// propList.add(prop); +// } + System.out.println("111"); + SoaServerUtil so = new SoaServerUtil(); + String json = so.objectToJson(propList); + System.out.println("222"); + // so.grantWritePrivilege(session, rev); + so.sendToClass(rev.getUid(), codeRemark, json); + // so.grantReadPrivilege(session, rev); + System.out.println("333"); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /*** + * 将对象从分类中移除(通过webService) + * + * @param codeRemark 分类对象的UID + */ + public static void deleteObjToClassficationByWebService(String codeRemark) { + try { + + if (!codeRemark.equals("")) { + // TCComponentItemRevision rev = item.getLatestItemRevision(); + +// List propList = new ArrayList<>(); +// for (int i = 0; i < classPropList.size(); i++) { +// // System.out.println(" CLASS ID = " + integers[i] + " =" + +// // vals[i]); +// CNClassPropBean bean = classPropList.get(i); +// String value = ""; +// if (bean.isLov) { +// value = ((Combo) classTextList.get(i)).getText(); +// value = bean.lovMapping.get(value); +// } else { +// value = ((Text) classTextList.get(i)).getText(); +// } +// // icspro[i] = new ICSProperty(bean.propID, value); +// ClassProperty prop = new ClassProperty(bean.propID, value); +// propList.add(prop); +// } + System.out.println("111"); + SoaServerUtil so = new SoaServerUtil(); + System.out.println("222"); + // so.grantWritePrivilege(session, rev); + so.deleteToClass(codeRemark); + // so.grantReadPrivilege(session, rev); + System.out.println("333"); + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /*** + * @param matnr 物料号 + * @param ddlx 订单类型 + * @param type 流程中订单、历史订单、废弃订单 + * @return 返回分类id + */ + public static String getClassficationId(String matnr, String ddlx, String type) { + // String classId = "jlcs01010101"; + String classId = ""; + if (ddlx.equals("车身") || ddlx.equals("KD")) { + String[] values = getPreferenceValues("JL_number_to_className"); + String className = null; + + for (String s : values) { + String[] split = s.split("="); + if (split[0].equals(matnr)) { + className = split[1]; + break; + } + } + String[] values2 = getPreferenceValues("JL_name_to_id"); + // split[1]--历史,split[2]--流程 split[3]--废弃 + for (String t : values2) { + String[] split = t.split("="); + if (split[0].equals(className)) { + if (type.equals("历史订单")) { + classId = split[1]; + } else if (type.equals("流程中订单")) { + classId = split[2]; + } else if (type.equals("废弃订单")) { + classId = split[3]; + } + } + } + } else if (ddlx.equals("配件")) { + classId = "jlcs01010201"; + String name = matnr.substring(0, 2) + "配件"; + String[] values = getPreferenceValues("JL_name_to_id"); + for (String t : values) { + String[] split = t.split("="); + if (split[0].equals(name)) { + if (type.equals("历史订单")) { + classId = split[1]; + } else if (type.equals("流程中订单")) { + classId = split[2]; + } else if (type.equals("废弃订单")) { + classId = split[3]; + } + } + } + } + + return classId; + } + + /** + * 获取分类属性LOV显示值 + * + * @param icsD + * @return + */ + public static String getClassDisplayableValue(String value, ICSPropertyDescription icsD) { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + for (String key : keys) { + if (value.equals(key)) { + result = lov1.getValueOfKey(key); + return result; + } + } + } + return result; + } + + public static boolean isDouble(String value) { + try { + Double.parseDouble(value); + return true; + } catch (Exception e) { + // TODO: handle exception + return false; + } + } + + /*** + * 判断是否有权限 + * + * @param session session + * @param value 首选项名称 + * @param userId 用户ID + * @return + */ + public static boolean havePrivilege(TCSession session, String commandName, String userId) { + TCPreferenceService service = session.getPreferenceService(); + + String[] values = service.getStringArray(TCPreferenceService.TC_preference_site, "JL_User_Rights"); + if (values == null || values.length == 0) { + MessageBox.post("请配置首选项(管理权限)!请联系管理员", "错误", MessageBox.ERROR); + return false; + } + for (String value : values) { + // value = commandName + "——" + userId + String[] split = value.split("——"); + if (split[0].equals(commandName)) { + if (split.length == 1) { + return true; + } else { + if (split[1].indexOf(userId) >= 0) { + return true; + } else { + return false; + } + } + } + } + return false; + } + + public static int getCount(String mainStr, String subStr) { + int minLength = mainStr.length(); + int subLength = subStr.length(); + int count = 0; + int index = 0; + + if (minLength >= subLength) { + while ((index = mainStr.indexOf(subStr, index)) != -1) { + count++; + index += subLength; + } + return count; + } + return 0; + } + + /** + * 添加命名的引用 + * + * @param session + * @param item 对象的版本 + * @param fileName 数据集名称 + * @param tcResource 文件的物理路径 + * @param isDelete 是否删除文件 + * @param isReplace 是否删除原因数据集 + */ + public static void setExcelToItem(TCSession session, TCComponentItemRevision item,String fileName, String tcResource, + boolean isDelete,boolean isReplace) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { "MSExcelX" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", "MSExcelX"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + //是否替換 + if(isReplace) + { + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if ("MSExcelX".equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + zyzdsRev.remove("IMAN_specification", dateSet); + dateSet.delete(); + } + } + } + item.add("IMAN_specification", tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static Object getTCPropertyValue(TCComponent item,String propertyName) + { + Object result = ""; + + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + if(tcProperty == null) + { + System.out.println("未获取属性:"+propertyName); + return result; + } + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + result = tcProperty.getDoubleValue(); + break; + case TCProperty.PROP_int: + result = tcProperty.getIntValue(); + break; + case TCProperty.PROP_string: + result = tcProperty.getStringValue(); + break; + case TCProperty.PROP_date: + result = tcProperty.getDateValue(); + break; + default: + break; + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + return result; + } + public static void setTCPropertyValue(TCComponent item,String propertyName,Object value) + { + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + switch (tcProperty.getPropertyType()) { + case TCProperty.PROP_double: + if(value instanceof Double) + { + tcProperty.setDoubleValue((double) value); + } + else + { + tcProperty.setDoubleValue(Double.parseDouble(value.toString())); + } + break; + case TCProperty.PROP_int: + if(value instanceof Integer) + { + tcProperty.setDoubleValue((int) value); + } + else + { + tcProperty.setDoubleValue(Integer.parseInt(value.toString())); + } + break; + case TCProperty.PROP_string: + tcProperty.setStringValue(value.toString()); + break; + case TCProperty.PROP_date: + if(value instanceof Date) + { + tcProperty.setDateValue((Date) value); + } + else + { + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-M-dd HH:mm"); + tcProperty.setDateValue(sdf.parse(value.toString())); + } + break; + default: + break; + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * 获取选取的ITEM的目标的信息 + * + * @param itemList + * @return + */ + public static List getTargetsMsg( + List itemList) { + if (itemList == null) { + return null; + } + List beanList = new ArrayList<>(); + try { + TCProperty[][] props = TCComponentType.getTCPropertiesSet(itemList, + new String[] { "object_name", // 名称 + "object_type",// 类型 + "uom_tag",// 单位 + "item_id" }); + for (int i = 0; i < props.length; i++) { + + TCProperty[] prop = props[i]; + ItemBean bean = new ItemBean(); + bean.setItem(itemList.get(i)); + if (prop[0] != null) { + bean.setName(prop[0].getDisplayValue()); + } + bean.setFolder(getParentFolder(itemList.get(i), bean.getName())); + if (prop[1] != null) { + bean.setTypeDis(prop[1].getDisplayValue()); + bean.setType(itemList.get(i).getType()); + } + if (prop[2] != null) { + bean.setUnit(prop[2].getDisplayableValue()); + bean.setUnitDis(prop[2].getDisplayValue()); + } + if (prop[3] != null) { + // bean.setUnit(prop[2].getDisplayableValue()); + bean.setItemID(prop[3].getDisplayValue()); + } + beanList.add(bean); + } + } catch (TCException e) { + e.printStackTrace(); + } + return beanList; + } + + /** + * 获取存放的文件夹 + * + * @param item + * @param name + * @return + */ + public static TCComponentFolder getParentFolder(TCComponentItem item, + String name) { + TCComponentFolder folder = null; + try { + AIFComponentContext[] comtexts = item.whereReferenced(); + if (comtexts != null) { + for (int i = 0; i < comtexts.length; i++) { + if (comtexts[i].getComponent() instanceof TCComponentFolder) { + String nameT = ((TCComponentFolder) comtexts[i] + .getComponent()) + .getStringProperty("object_name"); + if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + else if(nameT.equals(name)) + { + folder = (TCComponentFolder) comtexts[i] + .getComponent(); + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return folder; + } + + /** + * 过滤掉所有不需要显示的属性的 + * + * @param session + * @return + */ + public static List getExplictPropList(TCSession session) { + List beanList = new ArrayList<>(); + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringArray( + TCPreferenceService.TC_preference_site, + "Cust_prop_explict_mapping"); + if (values != null) { + for (int i = 0; i < values.length; i++) { + String[] types = values[i].split("\\|"); + if (types.length != 2) { + continue; + } + String[] props = types[1].split("\\;"); + if (props.length == 0) { + continue; + } + List list = new ArrayList<>(); + for (String str : props) { + list.add(str); + } + PropExplictBean bean = new PropExplictBean(); + bean.setType(types[0]); + bean.setPropList(list); + beanList.add(bean); + } + } + + return beanList; + } + + /** + * 通过SOA创建ITEM对象 + * + * @param session + * 会话 + * @param itemID + * 创建对象的ID + * @param itemRev + * 创建对象的版本 + * @param itemType + * 创建对象的类型 + * @param itemName + * 创建对象的名称 + * @param itemDesc + * 创建对象的描述 + * @param unit + * 创建对象的单位 + * @param itemPropMap + * 创建对象的ITEM属性 + * @param itemRevPropMap + * 创建对象的版本属性 + * @param itemRevMasterPropMap + * 创建对象的版本表单属性 + */ + public static TCComponentItem createNewItemSoa(TCSession session, + String itemID, String itemRev, String itemType, String itemName, + String itemDesc, String unit, Map itemPropMap, + Map itemRevPropMap, + Map itemRevMasterPropMap) { + TCComponentItem newComp = null; + try { + DataManagementService datamanagementservice = DataManagementService + .getService(session); + com.teamcenter.services.rac.core._2006_03.DataManagement.CreateItemsResponse createitemsresponse = null; + // 设置创建对象的主要属性 + com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties aitemproperties[] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties[1]; + aitemproperties[0] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties(); + aitemproperties[0].clientId = Integer.toString(1); + aitemproperties[0].description = itemDesc; + aitemproperties[0].itemId = itemID; + aitemproperties[0].name = itemName; + aitemproperties[0].revId = itemRev; + aitemproperties[0].type = itemType; + aitemproperties[0].uom = unit;// == null ? "" : uomComp.toString(); + // 设置扩展属性 + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes + // extendedattributes[] = new + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[3]; + ArrayList list = new ArrayList(); + // 设置item对象的扩展属性 + if (itemPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.RevisionIds revids = null; + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesItem.objectType = itemType; + extendedattributesItem.attributes = itemPropMap; + list.add(extendedattributesItem); + } + // 设置REV的扩展属性 + if (itemRevPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRev.objectType = itemType + "Revision"; + extendedattributesRev.attributes = itemRevPropMap; + list.add(extendedattributesRev); + } + // 设置REVMASTER的扩展属性 + if (itemRevMasterPropMap != null) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); + extendedattributesRevMaster.objectType = itemType + + "RevisionMaster"; + extendedattributesRevMaster.attributes = itemRevMasterPropMap; + list.add(extendedattributesRevMaster); + } + // 添加扩展属性 + if (list.size() != 0) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributes[] = null; + extendedattributes = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[list + .size()]; + for (int i = 0; i < list.size(); i++) { + extendedattributes[i] = list.get(i); + } + aitemproperties[0].extendedAttributes = extendedattributes; + } + TCComponent tccomponent1 = null; + String s1 = ""; + createitemsresponse = datamanagementservice.createItems( + aitemproperties, tccomponent1, s1); + if (createitemsresponse.serviceData.sizeOfPartialErrors() == 0) { + newComp = createitemsresponse.output[0].item; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println("创建对象[item_id= " + itemID + " / rev =" + itemRev + + " / name= " + itemName + "]失败"); + } + return newComp; + } + + /** + * 获取模板文件 + * @param session session + * @param fileName 文件名 + * @param Filetype 文件类型 + * @return + */ + public static File getFile(TCSession session,String fileName,String Filetype) { + // TODO Auto-generated method stub + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("ML_Doc_Teamplate"); + if (modelFiles == null) + { + System.out.println("未找到首选项"); + return null; + } + String puid = ""; + String item_id=""; + for (int i = 0; i < modelFiles.length; i++) { + if(modelFiles[i].split(":")[0].equals(fileName)) + { + item_id = modelFiles[i].split(":")[1]; + } + } + //通过item的id来找item对象 + puid =((TCComponentItemType)(session.getTypeComponent("Item"))).find(item_id).getUid(); + TCComponentItem fileItem = (TCComponentItem)session + .stringToComponent(puid); + TCComponentDataset dat = null; + TCComponentItemRevision fileItemLastRev = getLastItemRevision(fileItem); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + System.out.println("count =" + comps == null ? "null" + : comps.length); + // 遍历TC_Attaches关系下的所有对象 + for (TCComponent compt : comps) { + // 获取对象类型 + String type = compt.getType(); + System.out.println(" TYPE = " + type); + // 判断类型 + if (type.equals(type)) { + dat = (TCComponentDataset)compt; + } + } + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if(tcFile != null && tcFile.length == 0) + { + System.out.println("未找到配置文件"); + } + else + { + return tcFile[0].getFmsFile(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + return null; + } + //复制图片 + public static void CopyPic(File path1,String path2) { + // 创建文件字节输入流对象 + FileInputStream fis = null; + // 创建文件字节输出流对象 + FileOutputStream fos = null; + try { + // 连接文件字节输入流 + fis = new FileInputStream(path1); + // 连接文件字节输出流 + fos = new FileOutputStream(path2); + //准备一个byte[]数组,存储字节码,大小为1024字节,即1KB + byte[] bytes = new byte[1024]; + int readCount = 0; + // 开始读和写 + while ((readCount = fis.read(bytes)) != -1) { + // 将数组中读到的字节码写入 + fos.write(bytes, 0, readCount); + } + // 最后刷新管道,强制输出完数据 + fos.flush(); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (fis != null) { + try { + fis.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (fos != null) { + try { + fos.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, + String fileType,String name) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())&&name.equals(zyzdsChildren.getStringProperty("object_name"))) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取需要的数据集 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelDateSet(TCSession session, TCComponentItemRevision item, String relationType, + String fileType,String targetName) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())&&zyzdsChildren.getStringProperty("object_name").equals(targetName)) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + + + /** + * 添加命名的引用 + * + * @param session + * @param item 对象的版本 + * @param tcResource 文件的物理路径 + * @param relationType 关系名称 + * @param fileName 文件名 + */ + public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, + String fileName, String relationType, String excelType, boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { excelType }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; +// for (AIFComponentContext zyzdsChildren : zyzdsChildrens) {// +// if (excelType.equals(zyzdsChildren.getComponent().getType())) { +// TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); +// if (dateSet.getStringProperty("object_name").equals(fileName)) { +// dateSet.delete(); +// zyzdsRev.remove(relationType, dateSet); +// } +// } +// } + item.add(relationType, tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, + String relationType, String fileType,String name) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())&&name.equals(zyzdsChildren.getStringProperty("object_name"))) { + return (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 改变数据集的命名引用 + * + * @param tccomponentDataset + * @param quote + * @param type + * @param path + * @throws TCException + */ + public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) + throws TCException { + String myPath[] = { path }; + String myQuote[] = { quote };// 引用"excel" + String myType[] = { type };// 类型"MSExcelX" + String myPlain[] = { "Plain" }; + + // 删除数据集的引用 + deleDateSetRef(tccomponentDataset);//删除数据集里面的内容 + // 数据集的替换 + tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote);//将新内容添加到数据集 + + } + + /** + * 删除数据集的命名引用 + * + * @param dataset + * @throws TCException + */ + private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { + + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + for (int i = 0; i < tcFiles.length; i++) { + // 得到数据集的引用类型 + String str_temp = getNamedRefType(dataset, tcFiles[i]); + // 删除引用 + dataset.removeNamedReference(str_temp); + } + + } + + /** + * 得到数据集的引用类型 + * + * @param datasetComponent + * @param tccomponent + * @return + * @throws TCException + */ + private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) + throws TCException { + String s; + s = ""; + TCProperty tcproperty; + TCProperty tcproperty1; + TCComponent atccomponent[]; + String as[]; + int i; + int j; + int k; + try { + tcproperty = datasetComponent.getTCProperty("ref_list"); + tcproperty1 = datasetComponent.getTCProperty("ref_names"); + if (tcproperty == null || tcproperty1 == null) + return s; + } catch (TCException tcexception) { + return s; + } + atccomponent = tcproperty.getReferenceValueArray(); + as = tcproperty1.getStringValueArray(); + if (atccomponent == null || as == null) + return s; + i = atccomponent.length; + if (i != as.length) + return s; + j = -1; + k = 0; + do { + if (k >= i) + break; + if (tccomponent == atccomponent[k]) { + j = k; + break; + } + k++; + } while (true); + if (j != -1) + s = as[j]; + return s; + } + + public static String sendPost(String url, String data) { + String response = null; + + try { + CloseableHttpClient httpclient = null; + CloseableHttpResponse httpresponse = null; + try { + httpclient = HttpClients.createDefault(); + HttpPost httppost = new HttpPost(url); + StringEntity stringentity = new StringEntity(data, "UTF-8"); + httppost.setHeader("Content-type", "application/json"); + httppost.setEntity(stringentity); + httpresponse = httpclient.execute(httppost); + response = EntityUtils.toString(httpresponse.getEntity()); + } finally { + if (httpclient != null) { + httpclient.close(); + } + if (httpresponse != null) { + httpresponse.close(); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return response; + } + + public static void CreateProcess(TCSession session,TCComponent target,String processName) throws TCException { + try { + TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (taskTemplate == null) { + return; + } + // 创建一个流程 流程名称、描述、流程模板、目标对象、附件数 + String name = target.getProperty("object_string"); + processType.create(processName + ":" + name, "", taskTemplate, new TCComponent[] { target }, new int[] { 1 }); + } catch (TCException e) { + e.printStackTrace(); + throw e; + } + } + + public static void sendObjToClassficationByWebService(TCComponentItem item,String classId) { + try { + + if (!classId.replace(" ", "").equals("") && item != null) { + TCComponentItemRevision rev = item.getLatestItemRevision(); + + SoaServerUtil.sendToClass(rev.getUid(), classId, ""); + } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MultiComboBox.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MultiComboBox.java new file mode 100644 index 0000000..722e8ce --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MultiComboBox.java @@ -0,0 +1,205 @@ +package com.connor.ml.tcm.outfile.util; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicArrowButton; + +import com.teamcenter.rac.util.PropertyLayout; + +public class MultiComboBox extends JComponent { + + private Object[] values; + + public Object[] defaultValues; + + private List listeners = new ArrayList(); + + public MultiPopup popup; + + public JTextField editor; + + protected JButton arrowButton; + + private String valueSperator; + + private static final String DEFAULT_VALUE_SPERATOR = ","; + + public MultiComboBox(Object[] value, Object[] defaultValue){ + this(value,defaultValue,DEFAULT_VALUE_SPERATOR); + } + + public MultiComboBox(Object[] value, Object[] defaultValue , String valueSperator) { + values = value; + defaultValues = defaultValue; + this.valueSperator = valueSperator; + initComponent(); + } + + private void initComponent() { + //暂时使用该布局,后续自己写个布局 + this.setLayout(new PropertyLayout()); + //this.set + popup =new MultiPopup(values,defaultValues); + popup.addActionListener(new PopupAction()); + editor = new JTextField(); + editor.setBackground(Color.WHITE); + editor.setEditable(false); + editor.setPreferredSize(new Dimension(150,30)); +// editor.setBorder(getBorder()); + editor.addMouseListener(new EditorHandler()); + arrowButton = createArrowButton(); + arrowButton.addMouseListener(new EditorHandler()); + add("1.1.left.top",editor); + //add(arrowButton); + setText() ; + + + } + + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + private class PopupAction implements ActionListener{ + + public void actionPerformed(ActionEvent e) { + + if(e.getActionCommand().equals(MultiPopup.CANCEL_EVENT)){ + + }else if(e.getActionCommand().equals(MultiPopup.COMMIT_EVENT)){ + defaultValues = popup.getSelectedValues(); + setText(); + //把事件继续传递出去 + fireActionPerformed(e); + } + + togglePopup(); + + + } + + } + + private void togglePopup(){ + if(popup.isVisible()){ + popup.setVisible(false); + }else{ + popup.setDefaultValue(defaultValues); + popup.show(this, 0, getHeight()); + } + } + + private void setText() { + StringBuilder builder = new StringBuilder(); + for(Object dv : defaultValues){ + builder.append(dv); + builder.append(valueSperator); + } + + editor.setText(builder.substring(0, builder.length() > 0 ? builder.length() -1 : 0).toString()); + } + + private class EditorHandler implements MouseListener{ + + public void mouseClicked(MouseEvent e) { + togglePopup(); + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + + } + + + public void paintComponent(Graphics g){ + g.setColor(Color.white); + g.fillRect(0,0,getWidth(),getHeight()); + } + + + protected JButton createArrowButton() { + JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, + UIManager.getColor("ComboBox.buttonBackground"), + UIManager.getColor("ComboBox.buttonShadow"), + UIManager.getColor("ComboBox.buttonDarkShadow"), + UIManager.getColor("ComboBox.buttonHighlight")); + button.setName("ComboBox.arrowButton"); + return button; + } + + private class MulitComboboxLayout implements LayoutManager{ + + public void addLayoutComponent(String name, Component comp) { + // TODO Auto-generated method stub + + } + + public void removeLayoutComponent(Component comp) { + // TODO Auto-generated method stub + + } + + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + public Dimension minimumLayoutSize(Container parent) { + return parent.getMinimumSize(); + } + + public void layoutContainer(Container parent) { + int w=parent.getWidth(); + int h=parent.getHeight(); + Insets insets=parent.getInsets(); + h=h-insets.top-insets.bottom; + + } + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MultiPopup.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MultiPopup.java new file mode 100644 index 0000000..e27eb32 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/MultiPopup.java @@ -0,0 +1,194 @@ +package com.connor.ml.tcm.outfile.util; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + + + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + private List checkBoxList = new ArrayList(); + + private JButton commitButton ; + + private JButton cancelButton; + + public static final String COMMIT_EVENT = "commit"; + + public static final String CANCEL_EVENT = "cancel"; + + public MultiPopup(Object[] value , Object[] defaultValue) { + super(); + values = value; + defaultValues = defaultValue; + initComponent(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + private void initComponent() { + + JPanel checkboxPane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + + for(Object v : values){ + if(v == null) + { + continue; + } + JCheckBox temp = new JCheckBox(v.toString() , selected(v)); + checkBoxList.add(temp); + } + + if(checkBoxList.get(0).getText().equals("Selected All")) + checkBoxList.get(0).addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + System.out.println("被选中状态 "+checkBoxList.get(0).isSelected()); + if(checkBoxList.get(0).isSelected())//Select All 被选中 + { + //检查其他的是否被选中乳沟没有就选中他们 + for(int i=1; i< checkBoxList.size();i++) + { + if(!checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(true); + } + } + else + { + for(int i=1; i< checkBoxList.size();i++) + { + if(checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(false); + } + } + } + }); + + + + checkboxPane.setLayout(new GridLayout(checkBoxList.size() , 1 ,3, 3)); + for(JCheckBox box : checkBoxList){ + checkboxPane.add(box); + } + + commitButton = new JButton("ok"); + + commitButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("cancel"); + + cancelButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + cancel(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(checkboxPane , BorderLayout.CENTER); + + this.add(buttonPane , BorderLayout.SOUTH); + + + } + + private boolean selected(Object v) { + for(Object dv : defaultValues){ + if( dv .equals(v) ){ + return true; + } + } + return false; + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + public Object[] getSelectedValues(){ + List selectedValues = new ArrayList(); + + if(checkBoxList.get(0).getText().equals("Selected All")) + { + if(checkBoxList.get(0).isSelected()) + { + for(int i = 1 ; i < checkBoxList.size() ; i++) + { + selectedValues.add(values[i]); + } + } + else + { + for(int i = 1 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + } + }else + for(int i = 0 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + public void setDefaultValue(Object[] defaultValue) { + defaultValues = defaultValue; + + } + + public void commit(){ + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + public void cancel(){ + fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ProgressBar.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ProgressBar.java new file mode 100644 index 0000000..de5a89f --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ProgressBar.java @@ -0,0 +1,143 @@ +package com.connor.ml.tcm.outfile.util; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.*; +import javax.swing.*; + +import org.eclipse.swt.graphics.Rectangle; + +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * 内部类,线程任务 + * + * @author Administrator + * + */ + class TaskThread extends Thread { + + public void run() { + + Dimension d = progressbar.getSize(); + bar.paintAll(bar.getGraphics()); + // Rectangle rect = new Rectangle(0,0, d.width, d.height); + for (int i = 0; i < i + 1; i++) { + // 启动线程 + timer.start(); + int value = progressbar.getValue(); + // 让进度条分为100格,以每秒进5格 + if (value < 100) { + value += 5; + progressbar.setValue(value); + + } else { + // 计时器停止,重新开始加载 + timer.stop(); + progressbar.setValue(0); + bar.paintAll(bar.getGraphics()); + } + progressbar.paintImmediately(0, 0, d.width, d.height); + try { + // 线程停止100毫秒 + sleep(100L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (bool) { + // 设置进度条的可见或者不可见 + bar.setVisible(false); + bar.dispose(); + return; + } + } + + } + + private ProgressBar bar; + + final ProgressBar this$0; + + // 将线程添加到任务中 + public TaskThread(ProgressBar bar) { + super(); + this$0 = ProgressBar.this; + this.bar = bar; + } + } + + public ProgressBar(String showlable) { + super(true); + bool = false; + showLable = null; + showLable = showlable; + } + + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * 构造进度条的面板 + * + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + label = new JLabel(showLable, 0); + progressbar = new JProgressBar(); + progressbar.setOrientation(0); + // 进度条从0开始,100结束 + progressbar.setMinimum(0); + progressbar.setMaximum(100); + progressbar.setValue(0); + progressbar.setPreferredSize(new Dimension(200, 15)); + progressbar.setBorderPainted(true); + // 启动计时器 + timer = new Timer(50, this); + timer.setRepeats(false); + // 控件的调整 + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + // 线程任务启动 + TaskThread thread = new TaskThread(this); + thread.start(); + // 内部类,监听关闭按钮的事件 + addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + bool = true; + } + + }); + setVisible(true); + } + + public void actionPerformed(ActionEvent actionevent) { + } + + public void setText(String message) { + // System.out.println(message); + label.setText(message); + } + + private JProgressBar progressbar; + + private JLabel label; + + private Timer timer; + + private boolean bool; + + private Registry registry; + + private String showLable; + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ProgressBarThread.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ProgressBarThread.java new file mode 100644 index 0000000..c07e6e9 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/ProgressBarThread.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.outfile.util; + +// Referenced classes of package com.teamcenter.rac.importflex: +// ProgressBar + +public class ProgressBarThread extends Thread { + + public ProgressBarThread(String title, String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + // 调用初始化面板 + bar.initUI(); + } + + /* + * 设置进度条可显示和不可显示 + */ + public void setBool(boolean bool) { + bar.setBool(true); + } + + private ProgressBar bar; + + private String title; +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/SAPConn.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/SAPConn.java new file mode 100644 index 0000000..8a40f1a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/SAPConn.java @@ -0,0 +1,78 @@ +package com.connor.ml.tcm.outfile.util; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.Properties; + +import org.apache.log4j.Logger; + +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoDestinationManager; +import com.sap.conn.jco.JCoException; +import com.sap.conn.jco.ext.DestinationDataProvider; +import com.teamcenter.rac.util.MessageBox; + +public class SAPConn { + private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL"; + + static { + Properties connectProperties = new Properties(); + + connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, + "10.3.1.224"); + connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "01"); + connectProperties + .setProperty(DestinationDataProvider.JCO_CLIENT, "800"); + connectProperties.setProperty(DestinationDataProvider.JCO_USER, + "MLSCP"); + connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, + "654321"); + connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "zh"); + connectProperties.setProperty( + DestinationDataProvider.JCO_POOL_CAPACITY, "3"); + connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, + "10"); + + createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties); + + } + + private static void createDataFile(String name, String suffix, + Properties properties) { + File cfg = new File(name + "." + suffix); + if (cfg.exists()) { + cfg.deleteOnExit(); + } + try { + FileOutputStream fos = new FileOutputStream(cfg, false); + properties.store(fos, "for tests only !"); + fos.close(); + } catch (Exception e) { + log.error("Create Data file fault, error msg: " + e.toString()); + throw new RuntimeException("Unable to create the destination file " + + cfg.getName(), e); + } + } + + /** + * 获取sap连接 + * + * @return SAP连接对象 + */ + public static JCoDestination connect() { + JCoDestination destination = null; + try { + destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED); + if(destination==null){ + MessageBox.post("sap连接不上","错误",MessageBox.ERROR); + } + } catch (JCoException e) { + MessageBox.post("sap连接不上","错误",MessageBox.ERROR); + log.error("Connect SAP fault, error msg: " + e.toString()); + } + return destination; + } + + private static Logger log = Logger.getLogger(SAPConn.class); + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/SoaServerUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/SoaServerUtil.java new file mode 100644 index 0000000..1b44801 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/SoaServerUtil.java @@ -0,0 +1,283 @@ +package com.connor.ml.tcm.outfile.util; + +import java.util.List; + +import net.sf.json.JSONArray; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; + + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class SoaServerUtil { + + public static TCPreferenceService preferenceService; + public static String priverUserID; + public static String webServiceURL; + + static { + try { + + if (preferenceService == null) { + preferenceService = ((TCSession) AIFUtility + .getCurrentApplication().getSession()) + .getPreferenceService(); + } + + if (priverUserID == null) { + priverUserID = preferenceService.getString( + TCPreferenceService.TC_preference_site, + "Autocode_PriverUser_ID"); + } + + if (webServiceURL == null) { + webServiceURL = preferenceService.getString( + TCPreferenceService.TC_preference_site, + "Autocode_SendClassServer_URL"); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void sendToClass(String wsoPUID, String classID, String json) { + try { + + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = webServiceURL;// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + System.out.println("url="+url); + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void deleteToClass(String classID) { + try { + + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = webServiceURL;// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + System.out.println("url="+url); + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + //OMElement value = fac.createOMElement("wsoPuiid", omNs); + //value.setText(wsoPUID); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(classID); + //OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + //value2.setText(json); + + method.addChild(value); +// method.addChild(value1); +// method.addChild(value2); + + OMElement res = sc.sendReceive(method); + + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// 将java对象转换为json对象 + str = json.toString();// 将json对象转换为字符串 + System.out.println("JSON =>" + str); + } catch (Exception e) { + e.printStackTrace(); + } + return str; + } + + public void grantReadPrivilege(TCSession tcSession, + TCComponent tccomponent) { + try { + TCAccessControlService accessControlService = tcSession + .getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession + .getTypeComponent("User"); + TCComponentUser user = type.find(priverUserID);// 2135 + + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent) + .getItem(); + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tempItem, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + closeByPass(tcSession); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } else { + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void grantWritePrivilege(TCSession tcSession, + TCComponent tccomponent) { + try { + TCAccessControlService accessControlService = tcSession + .getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession + .getTypeComponent("User"); + + TCComponentUser user = type.find(priverUserID);// 2135 + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ", "WRITE", "DELETE" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent) + .getItem(); + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tempItem, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } else { + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + userservice.call("Connor_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + userservice.call("ORIGIN_close_bypass", obj); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/TCLOVUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/TCLOVUtil.java new file mode 100644 index 0000000..ba3e285 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/TCLOVUtil.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.outfile.util; + +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class TCLOVUtil { + + public static TCComponentListOfValues findLOVByName(TCSession tcsession, + String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession + .getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype + .find(s); + if (atccomponentlistofvalues != null + && atccomponentlistofvalues.length > 0) + tccomponentlistofvalues = atccomponentlistofvalues[0]; + else + tccomponentlistofvalues = null; + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return tccomponentlistofvalues; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/TableUtil3.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/TableUtil3.java new file mode 100644 index 0000000..6ff2e6b --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/outfile/util/TableUtil3.java @@ -0,0 +1,59 @@ +package com.connor.ml.tcm.outfile.util; + +import javax.swing.JTable; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +public class TableUtil3 { + + private TableUtil3() { + throw new Error("Don't let anyone instantiate this class."); + } + + /*** + * hide specified column + * + * @param table + * @param column + */ + public static void hideTableColumn(JTable table, Object column) { + TableColumnModel columns = table.getColumnModel(); + int temp; + if (column instanceof String) { + temp = columns.getColumnIndex(column); + } else { + temp = (int) column; + } + TableColumn column_id_data = columns.getColumn(temp); + column_id_data.setMaxWidth(0); + column_id_data.setPreferredWidth(0); + column_id_data.setMinWidth(0); + + TableColumn column_id_header = table.getTableHeader().getColumnModel().getColumn(temp); + column_id_header.setMaxWidth(0); + column_id_header.setPreferredWidth(0); + column_id_header.setMinWidth(0); + } + + /*** + * show specified column + * + * @param table + * @param column + * @param width + */ + public static void showTableColumn(JTable table, int column) { + int width = 40; + TableColumnModel columns = table.getColumnModel(); + TableColumn column_id_data = columns.getColumn(column); + + column_id_data.setMaxWidth(width + 1000); + column_id_data.setPreferredWidth(width); + column_id_data.setMinWidth(width); + + TableColumn column_id_header = table.getTableHeader().getColumnModel().getColumn(column); + column_id_header.setMaxWidth(width + 1000); + column_id_header.setPreferredWidth(width); + column_id_header.setMinWidth(width); + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/setTemplateID/ChangeTemplateID.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/setTemplateID/ChangeTemplateID.java new file mode 100644 index 0000000..d6b19eb --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/setTemplateID/ChangeTemplateID.java @@ -0,0 +1,84 @@ +package com.connor.ml.tcm.setTemplateID; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.util.MessageBox; + +public class ChangeTemplateID extends AbstractHandler{ + public AbstractAIFUIApplication application; + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + + + this.application = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent[] targetComponents = this.application.getTargetComponents(); + if(targetComponents.length>0) { + + for(InterfaceAIFComponent targetComponent:targetComponents) { + TCComponentItemRevision revision = null; + if(targetComponent instanceof TCComponentItemRevision) { + revision =(TCComponentItemRevision) targetComponent; + }else if (targetComponent instanceof TCComponentBOMLine ) { + try { + revision = ((TCComponentBOMLine)targetComponent).getItemRevision(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if(revision !=null) { + try { + String stringProperty = revision.getStringProperty("item_id"); + System.out.println("item_id"+stringProperty); + try { + revision.setStringProperty("ml8_Template_ID", stringProperty); + } catch (Exception e) { + // TODO: handle exception + System.out.println(revision + "没有ml*_templateid"); + } + +// TCProperty tcProperty = revision.getTCProperty("ml8_Template_ID"); +// +// System.out.println(revision.getItem().getStringProperty("object_string")); +// +// if(tcProperty !=null) { +// tcProperty.setStringValue(stringProperty); +// } + + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + } + + MessageBox.post("设置完成","提示",2); +// InterfaceAIFComponent targetComponent=targetComponents[0]; +// if(targetComponent instanceof TCComponentItemRevision) { +// revision =(TCComponentItemRevision) targetComponent; +// String type = revision.getType(); +// if(type.equals("ML8_MCNoticeRevision")) { // || true +// flag=true; +// } +//// folderN=folder; +// } + }else { + MessageBox.post("请选择版本对象","提示",2); + } + + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/JsonEntity.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/JsonEntity.java new file mode 100644 index 0000000..8e48d0d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/JsonEntity.java @@ -0,0 +1,273 @@ +package com.connor.ml.tcm.showOrderReviewInfo; + +import java.util.List; + +public class JsonEntity { + + private String DemandOrgName; + private String PlanTypeName; + private String OrgComparationName; + private String ProductStatusName; + private String PriorityName; + private String ManuFactoryName; + private String TechAttribute; + private String TechAttributeName; + private String CountoryName; + private String ProductAlias; + private String DeliveryTimeStr; + private String IsExportStr; + private String ManuAttributeName; + private String BrandName; + private String SpecMaterailCode; + private String CustomerDeliveryTimeStr; + private String Code; + private String ReferCode; + private String ExportModel; + private String MaterailDrawingNo; + private String ManuCode; + private String FactoryCode; + private String PrototypeCode; + private String PrototypeDesr; + private String ProductCode; + private String ProductName; + private String Phone; + private String CapacityPrototypeCode; + private String CapacityPrototypeDesr; + private int Qty; + private String ContractCode; + private String IsExamRequiredStr; + private String IsROHSRequiredStr; + private String IsLockInstallStr; + + private String Property; + + public String getProperty() { + return Property; + } + public void setProperty(String property) { + Property = property; + } + public String getDemandOrgName() { + return DemandOrgName; + } + public void setDemandOrgName(String demandOrgName) { + DemandOrgName = demandOrgName; + } + public String getPlanTypeName() { + return PlanTypeName; + } + public void setPlanTypeName(String planTypeName) { + PlanTypeName = planTypeName; + } + public String getOrgComparationName() { + return OrgComparationName; + } + public void setOrgComparationName(String orgComparationName) { + OrgComparationName = orgComparationName; + } + public String getProductStatusName() { + return ProductStatusName; + } + public void setProductStatusName(String productStatusName) { + ProductStatusName = productStatusName; + } + public String getPriorityName() { + return PriorityName; + } + public void setPriorityName(String priorityName) { + PriorityName = priorityName; + } + public String getManuFactoryName() { + return ManuFactoryName; + } + public void setManuFactoryName(String manuFactoryName) { + ManuFactoryName = manuFactoryName; + } + public String getTechAttribute() { + return TechAttribute; + } + public void setTechAttribute(String techAttribute) { + TechAttribute = techAttribute; + } + public String getTechAttributeName() { + return TechAttributeName; + } + public void setTechAttributeName(String techAttributeName) { + TechAttributeName = techAttributeName; + } + public String getCountoryName() { + return CountoryName; + } + public void setCountoryName(String countoryName) { + CountoryName = countoryName; + } + public String getProductAlias() { + return ProductAlias; + } + public void setProductAlias(String productAlias) { + ProductAlias = productAlias; + } + public String getDeliveryTimeStr() { + return DeliveryTimeStr; + } + public void setDeliveryTimeStr(String deliveryTimeStr) { + DeliveryTimeStr = deliveryTimeStr; + } + public String getIsExportStr() { + return IsExportStr; + } + public void setIsExportStr(String isExportStr) { + IsExportStr = isExportStr; + } + public String getManuAttributeName() { + return ManuAttributeName; + } + public void setManuAttributeName(String manuAttributeName) { + ManuAttributeName = manuAttributeName; + } + public String getBrandName() { + return BrandName; + } + public void setBrandName(String brandName) { + BrandName = brandName; + } + public String getSpecMaterailCode() { + return SpecMaterailCode; + } + public void setSpecMaterailCode(String specMaterailCode) { + SpecMaterailCode = specMaterailCode; + } + public String getCustomerDeliveryTimeStr() { + return CustomerDeliveryTimeStr; + } + public void setCustomerDeliveryTimeStr(String customerDeliveryTimeStr) { + CustomerDeliveryTimeStr = customerDeliveryTimeStr; + } + public String getCode() { + return Code; + } + public void setCode(String code) { + Code = code; + } + public String getReferCode() { + return ReferCode; + } + public void setReferCode(String referCode) { + ReferCode = referCode; + } + public String getExportModel() { + return ExportModel; + } + public void setExportModel(String exportModel) { + ExportModel = exportModel; + } + public String getMaterailDrawingNo() { + return MaterailDrawingNo; + } + public void setMaterailDrawingNo(String materailDrawingNo) { + MaterailDrawingNo = materailDrawingNo; + } + public String getManuCode() { + return ManuCode; + } + public void setManuCode(String manuCode) { + ManuCode = manuCode; + } + public String getFactoryCode() { + return FactoryCode; + } + public void setFactoryCode(String factoryCode) { + FactoryCode = factoryCode; + } + public String getPrototypeCode() { + return PrototypeCode; + } + public void setPrototypeCode(String prototypeCode) { + PrototypeCode = prototypeCode; + } + public String getPrototypeDesr() { + return PrototypeDesr; + } + public void setPrototypeDesr(String prototypeDesr) { + PrototypeDesr = prototypeDesr; + } + public String getProductCode() { + return ProductCode; + } + public void setProductCode(String productCode) { + ProductCode = productCode; + } + public String getProductName() { + return ProductName; + } + public void setProductName(String productName) { + ProductName = productName; + } + public String getPhone() { + return Phone; + } + public void setPhone(String phone) { + Phone = phone; + } + public String getCapacityPrototypeCode() { + return CapacityPrototypeCode; + } + public void setCapacityPrototypeCode(String capacityPrototypeCode) { + CapacityPrototypeCode = capacityPrototypeCode; + } + public String getCapacityPrototypeDesr() { + return CapacityPrototypeDesr; + } + public void setCapacityPrototypeDesr(String capacityPrototypeDesr) { + CapacityPrototypeDesr = capacityPrototypeDesr; + } + public int getQty() { + return Qty; + } + public void setQty(int qty) { + Qty = qty; + } + public String getContractCode() { + return ContractCode; + } + public void setContractCode(String contractCode) { + ContractCode = contractCode; + } + public String getIsExamRequiredStr() { + return IsExamRequiredStr; + } + public void setIsExamRequiredStr(String isExamRequiredStr) { + IsExamRequiredStr = isExamRequiredStr; + } + public String getIsROHSRequiredStr() { + return IsROHSRequiredStr; + } + public void setIsROHSRequiredStr(String isROHSRequiredStr) { + IsROHSRequiredStr = isROHSRequiredStr; + } + public String getIsLockInstallStr() { + return IsLockInstallStr; + } + public void setIsLockInstallStr(String isLockInstallStr) { + IsLockInstallStr = isLockInstallStr; + } + @Override + public String toString() { + return "JsonEntity [DemandOrgName=" + DemandOrgName + ", PlanTypeName=" + PlanTypeName + ", OrgComparationName=" + + OrgComparationName + ", ProductStatusName=" + ProductStatusName + ", PriorityName=" + PriorityName + + ", ManuFactoryName=" + ManuFactoryName + ", TechAttribute=" + TechAttribute + ", TechAttributeName=" + + TechAttributeName + ", CountoryName=" + CountoryName + ", ProductAlias=" + ProductAlias + + ", DeliveryTimeStr=" + DeliveryTimeStr + ", IsExportStr=" + IsExportStr + ", ManuAttributeName=" + + ManuAttributeName + ", BrandName=" + BrandName + ", SpecMaterailCode=" + SpecMaterailCode + + ", CustomerDeliveryTimeStr=" + CustomerDeliveryTimeStr + ", Code=" + Code + ", ReferCode=" + ReferCode + + ", ExportModel=" + ExportModel + ", MaterailDrawingNo=" + MaterailDrawingNo + ", ManuCode=" + ManuCode + + ", FactoryCode=" + FactoryCode + ", PrototypeCode=" + PrototypeCode + ", PrototypeDesr=" + + PrototypeDesr + ", ProductCode=" + ProductCode + ", ProductName=" + ProductName + ", Phone=" + Phone + + ", CapacityPrototypeCode=" + CapacityPrototypeCode + ", CapacityPrototypeDesr=" + + CapacityPrototypeDesr + ", Qty=" + Qty + ", ContractCode=" + ContractCode + ", IsExamRequiredStr=" + + IsExamRequiredStr + ", IsROHSRequiredStr=" + IsROHSRequiredStr + ", IsLockInstallStr=" + + IsLockInstallStr + ", Property=" + Property + "]"; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/OrderReviewInfoHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/OrderReviewInfoHandler.java new file mode 100644 index 0000000..5c6bda5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/OrderReviewInfoHandler.java @@ -0,0 +1,82 @@ +package com.connor.ml.tcm.showOrderReviewInfo; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +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 OrderReviewInfoHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + InterfaceAIFComponent[] targetComponents = app.getTargetComponents(); + List revList = new ArrayList(); + for(InterfaceAIFComponent comp:targetComponents) { + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + String type = rev.getType(); + System.out.println("当前选中类型:"+type); + if("ML8_OrdMBOMItemRevision".equals(type)) { + revList.add(rev); + } +// else { +// MessageBox.post("请选择订单BOM版本对象!","",MessageBox.INFORMATION); +// } + }else if(comp instanceof TCComponentBOPLine) { + TCComponentBOPLine bopLine = (TCComponentBOPLine)comp; + try { + TCComponentItemRevision rev = bopLine.getItemRevision(); + String type = rev.getType(); + System.out.println("当前选中类型:"+type); + if("ML8_OrdMBOMItemRevision".equals(type)) { + revList.add(rev); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + }else if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine bopLine = (TCComponentBOMLine)comp; + try { + TCComponentItemRevision rev = bopLine.getItemRevision(); + String type = rev.getType(); + System.out.println("当前选中类型:"+type); + if("ML8_OrdMBOMItemRevision".equals(type)) { + revList.add(rev); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } +// else { +// MessageBox.post("请选择订单BOM版本对象!","",MessageBox.INFORMATION); +// } + + } + if(revList.size()==0) { + MessageBox.post("请选择订单BOM版本对象!","",MessageBox.INFORMATION); + }else { + OrderReviewInfoOperation operation = new OrderReviewInfoOperation(app,session,revList); + session.queueOperation(operation); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/OrderReviewInfoOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/OrderReviewInfoOperation.java new file mode 100644 index 0000000..c320a93 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/OrderReviewInfoOperation.java @@ -0,0 +1,650 @@ +package com.connor.ml.tcm.showOrderReviewInfo; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Frame; +import java.awt.Label; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.SwingConstants; + +import org.apache.http.HttpEntity; +import org.apache.http.ParseException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicHeader; +import org.apache.http.protocol.HTTP; +import org.apache.http.util.EntityUtils; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.connor.ml.tcm.showOrderReviewInfo.PLM.Item; +import com.connor.ml.tcm.util.DbPool; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +public class OrderReviewInfoOperation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private StringBuilder sb = new StringBuilder(); + private List revList; + private JDialog dialog = new JDialog(); + private JPanel mainPanel = new JPanel(new BorderLayout()); + private JTextArea ta = new JTextArea(); + private List list; + private String errorInfo = ""; + private String ml8_BatchNo = ""; + private File excel; + private Map> configMap = new HashMap>(); + private Map> row0Map = new HashMap>(); + private Map> row1Map = new HashMap>(); + private Map> row2Map = new HashMap>(); + private Map> row3Map = new HashMap>(); + private Map> row4Map = new HashMap>(); + private Map> row5Map = new HashMap>(); + private Map> row6Map = new HashMap>(); + private Map> row7Map = new HashMap>(); + private Map> row8Map = new HashMap>(); + private List>> mapList = new ArrayList>>(); + + public OrderReviewInfoOperation(AbstractAIFUIApplication app, TCSession session, List revList) { + this.app = app; + this.session = session; + this.revList = revList; + String modelUid = session.getPreferenceService().getStringValue("ML_SCP"); + excel = getExcel(modelUid); + configMap = getMap(); + mapList.add(row0Map); + mapList.add(row1Map); + mapList.add(row2Map); + mapList.add(row3Map); + mapList.add(row4Map); + mapList.add(row5Map); + mapList.add(row6Map); + mapList.add(row7Map); + mapList.add(row8Map); + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在发送请求......"); + dia.setVisible(true); + try { + + boolean flag = false; + flag = show(); + if (flag) { + dia.setVisible(false); +// MessageBox.post(sb.toString(), "SCP订单评审结果", MessageBox.INFORMATION); + } else { + dia.setVisible(false); +// MessageBox.post("解析失败,返回结果:\n"+sb.toString(), "SCP订单评审结果", MessageBox.INFORMATION); + } + }finally { + dia.setVisible(false); + dia.dispose(); + ta.setText(sb.toString()); + ta.setFont(new Font("微软雅黑", Font.PLAIN, 14)); + ta.setWrapStyleWord(true); +// ta.setLineWrap(true); + ta.setEditable(false); + JScrollPane jScrollPane = new JScrollPane(ta); + JButton button = new JButton("下载"); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + JFileChooser jfc = new JFileChooser(); + jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);// 设定只能选择到文件夹 + int state = jfc.showOpenDialog(dialog);// 此句是打开文件选择器界面的触发语句 + if (state == 1) { + return; + } else { + File f = jfc.getSelectedFile();// f为选择到的目录 + String dirPath = f.getAbsolutePath(); + Date date = new Date(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");//设置格式 + String filePah = dirPath + File.separator+ml8_BatchNo+"订单评审表.xlsx"; +// String filePah = dirPath + File.separator+ml8_BatchNo+"SCP订单评审结果"+simpleDateFormat.format(date)+".xlsx"; +// SummaryOperation operation = new SummaryOperation(app, session, SummaryDialog.this, "导出",filePah); +// session.queueOperation(operation); + + WaitingDialog dia2 = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在生成EXCEL......"); + dia2.setVisible(true); + dialog.setAlwaysOnTop(false); + try { + + boolean flag2 = false; + flag2 = export(filePah); + if (flag2) { + dia2.setVisible(false); + MessageBox.post("下载完成!", "", MessageBox.INFORMATION); + } else { + dia2.setVisible(false); + MessageBox.post("下载失败!\n"+errorInfo, "", MessageBox.INFORMATION); + } + }catch (Exception e1) { + e1.printStackTrace(); + }finally { + dia2.setVisible(false); + dia2.dispose(); + } + dialog.setAlwaysOnTop(true); + } + } + }); + JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); + buttonPanel.add(button); + mainPanel.add(jScrollPane,BorderLayout.CENTER); + mainPanel.add(buttonPanel,BorderLayout.SOUTH); + mainPanel.setPreferredSize(new Dimension(500,500)); + dialog.setTitle("SCP订单评审结果"); + dialog.add(mainPanel); + dialog.pack(); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + dialog.setAlwaysOnTop(true); + } + }; + }.start(); + } + + private boolean export(String filePah) throws Exception{ + System.out.println("开始导出excel"); + try { + FileInputStream in = null; + FileOutputStream out = null; + Workbook wb = null; + try { + in = new FileInputStream(excel); + String suffix = excel.getAbsolutePath().substring(excel.getAbsolutePath().lastIndexOf(".")+1); + if(suffix.equals("xls"))wb = new HSSFWorkbook(in); + else wb = new XSSFWorkbook(in); + out = new FileOutputStream(filePah); + + Sheet sheet = wb.getSheet("订单详细"); + Row row = sheet.getRow(0); + if(row == null)row = sheet.createRow(0); + + Cell cell = row.getCell(0); + if(cell == null)cell = row.createCell(0); + CellStyle cellStyle0 = cell.getCellStyle(); + + cell = row.getCell(1); + if(cell == null)cell = row.createCell(1); + CellStyle cellStyle1 = cell.getCellStyle(); + + + + int rowIndex = 0; + Gson gson = new Gson(); + for(JsonEntity jsonEntity :list) { + System.out.println(jsonEntity); + String property = jsonEntity.getProperty(); +// System.out.println("property="+property); + if(property ==null||property.equals(""))continue; + String json = gson.toJson(jsonEntity); + JSONObject fromObject1 = JSONObject.fromObject(json); + for (Map> map1:mapList) { + + for(Map.Entry> entry2: map1.entrySet()) { + List value = entry2.getValue(); + String enStr = value.get(0); + String cnStr = value.get(1); + Object object = fromObject1.get(enStr); + Row row2 = getRow(sheet, rowIndex); + Cell cell2 = getCell(row2, entry2.getKey()); + cell2.setCellValue(object+""); + } + rowIndex++; + } + JSONArray fromObject = JSONArray.fromObject(property); + List list2 = gson.fromJson(fromObject.toString(), new TypeToken>() {}.getType()); + for(PLM plm : list2) { + System.out.println(plm); + row = getRow(sheet, rowIndex); + cell = getCell(row, 0); + cell.setCellStyle(cellStyle0); +// cell.setCellValue(plm.getRemark()); + cell.setCellValue(plm.getRemark().replace(":", "").replace(":", "")); +// sb.append(plm.getRemark()); + if(plm.getItem()==null) { + cell = getCell(row, 1); + cell.setCellStyle(cellStyle1); + cell.setCellValue(plm.getValue()); +// sb.append(plm.getValue()); + }else { + List item = plm.getItem(); + cell = getCell(row, 1); + cell.setCellStyle(cellStyle1); + StringBuilder sb = new StringBuilder(); + for(int i = 0;i>() {}.getType()); +// sb.append(""); + for(JsonEntity jsonEntity :list) { + System.out.println(jsonEntity); + String property = jsonEntity.getProperty(); +// System.out.println("property="+property); + if(property ==null||property.equals(""))continue; + String json = gson.toJson(jsonEntity); + JSONObject fromObject1 = JSONObject.fromObject(json); + for(Map> map1:mapList) { + for(Map.Entry> entry2: map1.entrySet()) { + List value = entry2.getValue(); + String enStr = value.get(0); + String cnStr = value.get(1); + Object object = fromObject1.get(enStr); + String resultStr = cnStr +":"+object; + resultStr = appentStr4Length(resultStr, 70); + sb.append(resultStr).append("\t"); + } + sb.append("\n"); + + } + JSONArray fromObject = JSONArray.fromObject(property); + List list2 = gson.fromJson(fromObject.toString(), new TypeToken>() {}.getType()); + for(PLM plm : list2) { + System.out.println(plm); + sb.append(plm.getRemark()); + if(plm.getItem()==null) { + sb.append(plm.getValue()); + }else { + List item = plm.getItem(); + for(int i = 0;i"); + + + + + } catch (Exception e) { + e.printStackTrace(); + sb.delete(0, sb.length()); + sb.append("").append("解析失败,返回结果:").append("
").append(result).append(""); + return false; + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return true; + } + public static String appentStr4Length(String str , int length){ + if(str == null){ + str = ""; + } + try { + int strLen = 0;//计算原字符串所占长度,规定中文占两个,其他占一个 + for(int i = 0 ; i=length){ + return str; + } + int remain = length - strLen;//计算所需补充空格长度 + for(int i =0 ; i< remain ;i++){ + str = str + " "; + } + } catch (Exception e) { + e.printStackTrace(); + } + return str; + } + // 根据Unicode编码完美的判断中文汉字和符号 + private static boolean isChinese(char c) { + Character.UnicodeBlock ub = Character.UnicodeBlock.of(c); + if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS + || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS + || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A + || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B + || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION + || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS + || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION) { + return true; + } + return false; + } + + private Map> getMap(){ + configMap.clear(); + FileInputStream in = null; + Workbook wb = null; + try { + in = new FileInputStream(excel); + String suffix = excel.getAbsolutePath().substring(excel.getAbsolutePath().lastIndexOf(".")+1); + if(suffix.equals("xls"))wb = new HSSFWorkbook(in); + else wb = new XSSFWorkbook(in); + Sheet sheet = wb.getSheet("订单详细"); + int numberOfNames = wb.getNumberOfNames(); + System.out.println("名称总数量:"+numberOfNames); + for(int i = 0;i list2 = new ArrayList(); + list2.add(name.getNameName()); + list2.add(stringCellValue); + switch (rowindex) { + case 0: + row0Map.put(colindex, list2); + break; + case 1: + row1Map.put(colindex, list2); + + break; + case 2: + row2Map.put(colindex, list2); + + break; + case 3: + row3Map.put(colindex, list2); + + break; + case 4: + row4Map.put(colindex, list2); + + break; + case 5: + row5Map.put(colindex, list2); + + break; + case 6: + row6Map.put(colindex, list2); + + break; + case 7: + row7Map.put(colindex, list2); + + break; + case 8: + row8Map.put(colindex, list2); + + break; + + default: + break; + } + } + }catch (Exception e) { + e.printStackTrace(); + }finally { + if(in !=null) { + try { + in.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + return configMap; + } + + /** + * 发送post请求 + * + * @param url 路径 + * @param jsonObject 参数(json类型) + * @param encoding 编码格式 + * @return + * @throws ParseException + * @throws IOException + */ + public static String send(String url, String jsonstr, String encoding) throws ParseException, IOException { + String body = ""; + + //创建httpclient对象 + CloseableHttpClient client = HttpClients.createDefault(); + //创建post方式请求对象 + HttpPost httpPost = new HttpPost(url); + + //装填参数 + StringEntity s = new StringEntity(jsonstr, "utf-8"); + s.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, + "application/json")); + //设置参数到请求对象中 + httpPost.setEntity(s); + System.out.println("请求地址:" + url); + + //设置header信息 + //指定报文头【Content-type】、【User-Agent】 + httpPost.setHeader("Content-type", "application/json"); + httpPost.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); + + //执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpPost); + //获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + //按指定编码转换结果实体为String类型 + body = EntityUtils.toString(entity, encoding); + } + EntityUtils.consume(entity); + //释放链接 + response.close(); + return body; + + } + + private File getExcel(String puid) { + File fmsFile = null; + TCComponentDataset dateset = null; + try { + dateset = (TCComponentDataset) session.stringToComponent(puid); + } catch (TCException e) { + e.printStackTrace(); + } + if (dateset == null) { + MessageBox.post("未找到数据集,请联系管理员检查首选项...", "", MessageBox.ERROR); + return null; + } + try { + System.out.println("temPlateFilePath:" + dateset.getStringProperty("object_name")); + TCComponentTcFile[] file = dateset.getTcFiles(); + if (file.length == 0 || file.length != 1) { + MessageBox.post("数据集没有命名引用的文件或文件过多,请检查!...", "", MessageBox.ERROR); + return null; + } else { + fmsFile = file[0].getFmsFile(); + } + } catch (Exception e) { + e.printStackTrace(); + } + return fmsFile; + } + + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + setAlwaysOnTop(true); + pack(); + + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/PLM.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/PLM.java new file mode 100644 index 0000000..e7a5cb0 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/showOrderReviewInfo/PLM.java @@ -0,0 +1,66 @@ +package com.connor.ml.tcm.showOrderReviewInfo; + +import java.util.List; + +public class PLM { + + private String remark; + private List item; + private String value; + + + public String getRemark() { + return remark; + } + + + public void setRemark(String remark) { + this.remark = remark; + } + + public List getItem() { + return item; + } + + + public void setItem(List item) { + this.item = item; + } + + + public String getValue() { + return value; + } + + + public void setValue(String value) { + this.value = value; + } + + @Override + public String toString() { + return "PLM [remark=" + remark + ", item=" + item + ", value=" + value + "]"; + } + + class Item{ + private String name; + private String value; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + @Override + public String toString() { + return "Item [name=" + name + ", value=" + value + "]"; + } + + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_prop/SynMBOMPropDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_prop/SynMBOMPropDialog.java new file mode 100644 index 0000000..64393f3 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_prop/SynMBOMPropDialog.java @@ -0,0 +1,353 @@ +package com.connor.ml.tcm.synchronization_MBOM_prop; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +public class SynMBOMPropDialog extends AbstractAIFDialog{ + + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentItemRevision target; + private JTable table1; + private JTable table2; + private DefaultTableModel model1; + private DefaultTableModel model2; + private JScrollPane scrollPane1; + private JScrollPane scrollPane2; + private JPanel mainPanel; + private JButton button; + private List left; + private List right; + private final static String PRE = "ML_PropertyChange"; + public SynMBOMPropDialog() { + + } + public SynMBOMPropDialog(AbstractAIFUIApplication app,TCSession session,TCComponentItemRevision target) { + this.app = app; + this.session = session; + this.target = target; + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void init() throws Exception{ + scrollPane1 = new JScrollPane(); + scrollPane2 = new JScrollPane(); + mainPanel = new JPanel(new BorderLayout()); + JPanel panel1 = new JPanel(new PropertyLayout()); + button = new JButton("属性同步"); + + table1 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + };; + table1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table1.getTableHeader().setReorderingAllowed(false); + table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table1.getSelectionModel().addListSelectionListener(new ListSelectionListener() { + + @Override + public void valueChanged(ListSelectionEvent e) { + // TODO Auto-generated method stub + try { + updateTable2(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + }); + + table2 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + };; + table2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table2.getTableHeader().setReorderingAllowed(false); + + scrollPane1.setViewportView(table1); + scrollPane2.setViewportView(table2); + scrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane1.setPreferredSize(new Dimension(400, 400)); + scrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane2.setPreferredSize(new Dimension(800, 400)); + + panel1.add("1.1.left.top",new JLabel("影响分析:")); + panel1.add("2.1.left.top",new JLabel(" 》》》")); + panel1.add("3.1.left.top",new JLabel(" ")); + panel1.add("4.1.left.top",button); + button.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + int selectedRow = table1.getSelectedRow(); + if(selectedRow!=-1) { + SynPropDialog dialog = new SynPropDialog(); + new Thread(dialog).start(); + + }else { + MessageBox.post("请选择要同步的对象!","",MessageBox.INFORMATION); + } + } + }); + updateTable1(); + + mainPanel.add(scrollPane1,BorderLayout.WEST); + mainPanel.add(panel1,BorderLayout.CENTER); + mainPanel.add(scrollPane2,BorderLayout.EAST); + + add(mainPanel); + setTitle("MBOM属性变更"); + pack(); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + } + + private void updateTable1() throws Exception { + System.out.println("更新左侧表格!"); + TCComponent[] relatedComponents = target.getRelatedComponents("ML8_GXBGH"); + left = new ArrayList(); + for(TCComponent comp:relatedComponents) { + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + String ml8_ProcessingMode = rev.getStringProperty("ml8_ProcessingMode"); + String ml8_AddTrade = rev.getStringProperty("ml8_AddTrade"); + if(ml8_ProcessingMode==null) ml8_ProcessingMode = ""; + if(ml8_AddTrade==null) ml8_AddTrade = ""; + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + left.add(rev); + } + } + } + String[] header = {"序号","物料编码","版本","名称","加工方式","加贸"}; + String data[][] = new String[left.size()][6]; + for(int i = 0;i(); + + String[] header = {"序号","物料编码","当前版本","名称","制造厂","产线","是否发布","同步方式","同步状态","创建者","更改单号"}; + String data[][] = null; + if(table1.getSelectedRow()!=-1) { + TCComponentItemRevision rev = left.get(table1.getSelectedRow()); + TCComponent[] relatedComponents = rev.getRelatedComponents("ML8_RelatedMBOM"); + for(TCComponent comp: relatedComponents) { + if(comp instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem)comp; + TCComponentItemRevision revision = item.getLatestItemRevision(); + right.add(revision); + } + } + data = new String[right.size()][11]; + for(int i = 0;i map;//(属性显示名称,属性真实名称) + public SynPropDialog() { + + } + + @Override + public void run() { + // TODO Auto-generated method stub + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init() throws Exception{ + map = new HashMap(); + String[] stringValues = session.getPreferenceService().getStringValues(PRE); + if(stringValues==null||stringValues.length==0) { + MessageBox.post("请配置首选项"+PRE+"!","",MessageBox.INFORMATION); + return; + } + TCComponentItemRevision rev = left.get(table1.getSelectedRow()); + String revType = rev.getType(); + String stringValue = null; + for(String s:stringValues) { + if(s.startsWith(revType)) { + stringValue = s; + break; + } + } + if(stringValue==null) { + MessageBox.post(PRE+"首选项未配置类型"+revType,"",MessageBox.INFORMATION); + return; + } + stringValue = stringValue.split("-")[1]; + String[] split = stringValue.split(";"); + for(String s:split) { + String[] split2 = s.split(":"); + choiceType.addItem(split2[0]); + map.put(split2[0], split2[1]); + } + JPanel panel = new JPanel(new BorderLayout()); + JPanel panel01 = new JPanel(); + JPanel panel02 = new JPanel(new FlowLayout(FlowLayout.CENTER)); + okButton = new JButton("确定"); + cancelButton = new JButton("取消"); + okButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + TCComponentItemRevision rev = left.get(table1.getSelectedRow()); + String prop = map.get(choiceType.getSelectedItem().toString()); + try { + TCUserService service = session.getUserService(); + service.call("CONNOR_open_bypass", new Object[] { "" }); + TCProperty tcProperty = rev.getTCProperty(prop); + for(int i =0;i left; + private List right; + private List conditionRevs; + private String [] tableheader1 = {"执行","子物料R3码(原为)","物料名称","数量","子物料R3码(现改为)","物料名称","数量",}; + private String [] tableheader2 = {"序号","物料编码","当前版本","名称","制造厂","产线","发布状态","同步方式","同步状态","创建者","更改单号"}; + private SynMBOMStructureDialog dialog; + private TCComponentBOMWindow bomwin; + private TCComponentItemRevision ebomTarget; + private final static String RELATION = "ML8_RelatedMBOM"; + + + public ConditionSynBomDialog() { + + } + + public ConditionSynBomDialog(AbstractAIFUIApplication app,TCSession session,TCComponentItemRevision target,List left,List right,JTable table1,JTable table2,SynMBOMStructureDialog dialog) { + this.app = app; + this.session = session; + this.target = target; + this.table1 = table1; + this.table2 = table2; + this.left = left; + this.right = right; + this.dialog = dialog; + this.bomwin = MyUtil.createBOMWindow(session); + ebomTarget = left.get(table1.getSelectedRow()); + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private void init()throws Exception{ + mainPanel = new JPanel(new BorderLayout()); + panel1 = new JPanel(new FlowLayout(FlowLayout.LEADING)); + panel2 = new JPanel(new FlowLayout(FlowLayout.LEADING)); + panel3 = new JPanel(new PropertyLayout()); + panel4 = new JPanel(new PropertyLayout()); + panel5 = new JPanel(new PropertyLayout()); + panel6 = new JPanel(new PropertyLayout()); + panel7 = new JPanel(new PropertyLayout()); + scrollPane1 = new JScrollPane(); + scrollPane2 = new JScrollPane(); + button1 = new JButton("升版并同步"); + button2 = new JButton("提交工艺变更流程"); + addbutton = new JButton("+"); + delbutton = new JButton("-"); + button1.addActionListener(this); + button2.addActionListener(this); + addbutton.addActionListener(this); + delbutton.addActionListener(this); + JTextField field = new JTextField(30); + field.setText(ebomTarget.getStringProperty("object_string")); + field.setEnabled(false); + + table01 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return true; + } + }; + table01.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table01.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table01.getTableHeader().setReorderingAllowed(false); + + table02 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + };; + table02.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table02.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table02.getTableHeader().setReorderingAllowed(false); + scrollPane1.setViewportView(table01); + scrollPane2.setViewportView(table02); + scrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane1.setPreferredSize(new Dimension(800, 300)); + scrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane2.setPreferredSize(new Dimension(800, 300)); + createTable(); + + panel6.add("1.1.left.top",new JLabel("父级物料编号:")); + panel6.add("1.2.left.top",field); + panel6.add("1.3.right.top",new JLabel("依据EXCEL更改单录入条件")); + panel3.add("1.1.left.top",panel6); + panel3.add("2.1.left.top",scrollPane1); + + panel4.add("1.1.left.top",new JLabel(" ")); + panel4.add("2.1.left.top",addbutton); + panel4.add("3.1.left.top",delbutton); + + panel7.add("1.1.left.top",new JLabel("需要同步的MBOM:")); + panel7.add("1.2.left.top",button1); + panel7.add("1.3.left.top",button2); + panel5.add("1.1.left.top",panel7); + panel5.add("2.1.left.top",scrollPane2); + + panel1.add(panel3); + panel1.add(panel4); + panel2.add(panel5); + + mainPanel.add(panel1,BorderLayout.NORTH); + mainPanel.add(panel2,BorderLayout.CENTER); + + add(mainPanel); + setTitle("MBOM同步"); + pack(); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + } + + private void createTable() throws Exception{ + System.out.println("更新表格信息!"); + model01 = new DefaultTableModel(); + model01.setDataVector(null, tableheader1); + table01.setModel(model01); + MyUtil.FitTableColumns(table01); + updateTable02(); + + scrollPane1.revalidate(); + scrollPane1.repaint(); + mainPanel.revalidate(); + mainPanel.repaint(); + } + + private void updateTable02() throws Exception{ + System.out.println("更新下方表格信息!"); + //获取手动同步对象下标 + List indexList = new ArrayList(); + for(int row = 0; row(); + String[][] data2 = new String[indexList.size()][11]; + for(int i =0;i levelUpListIndex = new ArrayList();//可升版MBOM下标 + for(int i = 0;i0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + System.out.println("不存在id为"+newId+"的MBOM"); + errInfo.append("不存在id为"+newId+"的MBOM,请生成后再替换\n"); + if(levelUpListIndex.contains(j+""))levelUpListIndex.remove(j+""); + continue; + } + String ml8_ProcessingMode = targetChildRev.getStringProperty("ml8_ProcessingMode")!=null?targetChildRev.getStringProperty("ml8_ProcessingMode"):""; + String ml8_AddTrade = targetChildRev.getStringProperty("ml8_AddTrade")!=null?targetChildRev.getStringProperty("ml8_AddTrade"):""; + System.out.println(targetChildRev.toString()+"的加工方式为:"+ml8_ProcessingMode+",加贸为:"+ml8_AddTrade); + TCComponentItemRevision targetRev = conditionRevs.get(j); + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + if(oldId.contains("-"))oldId = oldId.split("-")[0]; + System.out.println("获取MBOM子级!"); + Map bomChildrenMap = MyUtil.getBomChildren(bomwin, targetRev); + + if(bomChildrenMap.containsKey(oldId)) { + System.out.println("找到子级中id为:"+oldId+"的对象!"); + TCComponentBOMLine targetLine = bomChildrenMap.get(oldId); + TCComponentItemRevision childRev = targetLine.getItemRevision(); +// String ml8_Factory = childRev.getStringProperty("ml8_Factory")!=null?childRev.getStringProperty("ml8_Factory"):""; +// String ml8_Line = childRev.getStringProperty("ml8_Line")!=null?childRev.getStringProperty("ml8_Line"):""; + String ml8_Factory = table02.getValueAt(j, 4).toString(); + String ml8_Line = table02.getValueAt(j, 5).toString(); +// TCComponent[] relatedComponents = childRev.getRelatedComponents("ML8_RelatedMBOM"); + System.out.println("搜索id:"+newId+"-"+ml8_Factory+"-"+ml8_Line); + search = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {newId+"-"+ml8_Factory+"-"+ml8_Line}); + if(search!=null&&search.length>0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + targetChildRev = null; + } + if(targetChildRev!=null) { +// System.out.println(targetRev.toString()+"删除"+targetLine.toString()+",新增"+targetChildRev.toString()); +// bomwin.lock(); +// targetLine.cut(); +// bomwin.save(); +// bomwin.unlock(); +// TCComponentBOMLine topLine = bomwin.setWindowTopLine(targetRev.getItem(), targetRev, null, null); +// bomwin.lock(); +// TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); +// System.out.println("设置bl_quantity属性为:"+num1); +// childLine.setStringProperty("bl_quantity", num1); +// bomwin.save(); +// bomwin.unlock(); + }else { + System.out.println(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM"); + errInfo.append(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM,请生成后再替换\n"); + if(levelUpListIndex.contains(j+""))levelUpListIndex.remove(j+""); + } + }else { + System.out.println("未找到子级中id为:"+oldId+"的对象!"); + } + }else { + if(oldId.contains("-"))oldId = oldId.split("-")[0]; + System.out.println("获取MBOM子级!"); + Map bomChildrenMap = MyUtil.getBomChildren(bomwin, targetRev); + if(bomChildrenMap.containsKey(oldId)) { + System.out.println("找到子级中id为:"+oldId+"的对象!"); + TCComponentBOMLine targetLine = bomChildrenMap.get(oldId); + TCComponentItemRevision childRev = targetLine.getItemRevision(); + if(targetChildRev!=null) { +// System.out.println(targetRev.toString()+"删除"+targetLine.toString()+",新增"+targetChildRev.toString()); +// bomwin.lock(); +// targetLine.cut(); +// bomwin.save(); +// bomwin.unlock(); +// TCComponentBOMLine topLine = bomwin.setWindowTopLine(targetRev.getItem(), targetRev, null, null); +// bomwin.lock(); +// TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); +// System.out.println("设置bl_quantity属性为:"+num1); +// childLine.setStringProperty("bl_quantity", num1); +// bomwin.save(); +// bomwin.unlock(); + } + }else { + System.out.println("未找到子级中id为:"+oldId+"的对象!"); + } + } + } + break; + case "新增": + System.out.println("新增"); + String num2 = table01.getValueAt(i, 6)!=null?table01.getValueAt(i, 6).toString():""; + if(num2.equals("")) { + int temp = i + 1; + errInfo.append("新增操作的的最后一列数量为必填项!第"+temp+"行操作未执行!\n"); + continue; + } + for(int j = 0;j < table02.getRowCount(); j++) { + TCComponentItemRevision targetChildRev = null; + System.out.println("搜索id:"+newId); + TCComponent[] search = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {newId}); + if(search!=null&&search.length>0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + System.out.println("不存在id为"+newId+"的MBOM"); + errInfo.append("不存在id为"+newId+"的MBOM,请生成后再新增\n"); + if(levelUpListIndex.contains(j+""))levelUpListIndex.remove(j+""); + continue; + } + String ml8_ProcessingMode = targetChildRev.getStringProperty("ml8_ProcessingMode")!=null?targetChildRev.getStringProperty("ml8_ProcessingMode"):""; + String ml8_AddTrade = targetChildRev.getStringProperty("ml8_AddTrade")!=null?targetChildRev.getStringProperty("ml8_AddTrade"):""; + System.out.println(targetChildRev.toString()+"的加工方式为:"+ml8_ProcessingMode+",加贸为:"+ml8_AddTrade); + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + String ml8_Factory = table02.getValueAt(j, 4).toString(); + String ml8_Line = table02.getValueAt(j, 5).toString(); + System.out.println("搜索id:"+newId+"-"+ml8_Factory+"-"+ml8_Line); + search = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {newId+"-"+ml8_Factory+"-"+ml8_Line}); + if(search!=null&&search.length>0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + targetChildRev = null; + } + if(targetChildRev!=null) { +// TCComponentItemRevision tempRev = conditionRevs.get(j); +// System.out.println(tempRev.toString()+"新增"+targetChildRev.toString()); +// TCComponentBOMLine topLine = bomwin.setWindowTopLine(tempRev.getItem(), tempRev, null, null); +// bomwin.lock(); +// TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); +// System.out.println("设置bl_quantity属性为:"+num2); +// childLine.setStringProperty("bl_quantity", num2); +// bomwin.save(); +// bomwin.unlock(); + }else { + System.out.println(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM"); + errInfo.append(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM,请生成后再新增\n"); + if(levelUpListIndex.contains(j+""))levelUpListIndex.remove(j+""); + } + }else { + if(targetChildRev!=null) { +// TCComponentItemRevision tempRev = conditionRevs.get(j); +// System.out.println(tempRev.toString()+"新增"+targetChildRev.toString()); +// TCComponentBOMLine topLine = bomwin.setWindowTopLine(tempRev.getItem(), tempRev, null, null); +// bomwin.lock(); +// TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); +// System.out.println("设置bl_quantity属性为:"+num2); +// childLine.setStringProperty("bl_quantity", num2); +// bomwin.save(); +// bomwin.unlock(); + } + } + } + break; +// case "删除": +// System.out.println("删除"); +// String num3 = table01.getValueAt(i, 6)!=null?table01.getValueAt(i, 6).toString():""; +// if(num3.equals("")) { +// int temp = i + 1; +// errInfo.append("删除操作的最后一列数量为必填项!第"+temp+"行操作未执行!\n"); +// continue; +// } +// for(int j = 0;j < conditionRevs.size(); j++) { +// TCComponentItemRevision targetRev = conditionRevs.get(j); +// System.out.println("获取MBOM子级!"); +// Map bomChildrenMap = MyUtil.getBomChildren(bomwin, targetRev); +// bomwin.lock(); +// for(Map.Entry entry:bomChildrenMap.entrySet()) { +// TCComponentBOMLine value = entry.getValue(); +// TCComponentItemRevision itemRevision = value.getItemRevision(); +// String item_id = itemRevision.getStringProperty("item_id"); +// if(item_id.contains(oldId)) { +//// String quantity = value.getStringProperty("bl_quantity"); +//// if(quantity==null||quantity.equals(""))quantity = "1"; +//// BigDecimal bigDecimal = new BigDecimal(quantity); +// if(num3.equals("0")) +// value.cut(); +// else { +// System.out.println("设置bl_quantity属性为:"+num3); +// value.setStringProperty("bl_quantity", num3); +// } +// System.out.println("删除"+value.toString()); +// } +// } +// bomwin.save(); +// bomwin.unlock(); +// } +// break; + + default: + break; + } + } + //升版 + for(int i =0;i0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + System.out.println("不存在id为"+newId+"的MBOM"); +// errInfo.append("不存在id为"+newId+"的MBOM,请生成后再替换\n"); + continue; + } + String ml8_ProcessingMode = targetChildRev.getStringProperty("ml8_ProcessingMode")!=null?targetChildRev.getStringProperty("ml8_ProcessingMode"):""; + String ml8_AddTrade = targetChildRev.getStringProperty("ml8_AddTrade")!=null?targetChildRev.getStringProperty("ml8_AddTrade"):""; + System.out.println(targetChildRev.toString()+"的加工方式为:"+ml8_ProcessingMode+",加贸为:"+ml8_AddTrade); + TCComponentItemRevision targetRev = conditionRevs.get(j); + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + if(oldId.contains("-"))oldId = oldId.split("-")[0]; + System.out.println("获取MBOM子级!"); + Map bomChildrenMap = MyUtil.getBomChildren(bomwin, targetRev); + + if(bomChildrenMap.containsKey(oldId)) { + System.out.println("找到子级中id为:"+oldId+"的对象!"); + TCComponentBOMLine targetLine = bomChildrenMap.get(oldId); + TCComponentItemRevision childRev = targetLine.getItemRevision(); +// String ml8_Factory = childRev.getStringProperty("ml8_Factory")!=null?childRev.getStringProperty("ml8_Factory"):""; +// String ml8_Line = childRev.getStringProperty("ml8_Line")!=null?childRev.getStringProperty("ml8_Line"):""; + String ml8_Factory = table02.getValueAt(j, 4).toString(); + String ml8_Line = table02.getValueAt(j, 5).toString(); +// TCComponent[] relatedComponents = childRev.getRelatedComponents("ML8_RelatedMBOM"); + System.out.println("搜索id:"+newId+"-"+ml8_Factory+"-"+ml8_Line); + search = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {newId+"-"+ml8_Factory+"-"+ml8_Line}); + if(search!=null&&search.length>0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + targetChildRev = null; + } + if(targetChildRev!=null) { + System.out.println(targetRev.toString()+"删除"+targetLine.toString()+",新增"+targetChildRev.toString()); + bomwin.lock(); + targetLine.cut(); + bomwin.save(); + bomwin.unlock(); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(targetRev.getItem(), targetRev, null, null); + bomwin.lock(); + TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); + System.out.println("设置bl_quantity属性为:"+num1); + childLine.setStringProperty("bl_quantity", num1); + bomwin.save(); + bomwin.unlock(); + }else { +// System.out.println(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM"); +// errInfo.append(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM,请生成后再替换\n"); + } + }else { + System.out.println("未找到子级中id为:"+oldId+"的对象!"); + } + }else { + if(oldId.contains("-"))oldId = oldId.split("-")[0]; + System.out.println("获取MBOM子级!"); + Map bomChildrenMap = MyUtil.getBomChildren(bomwin, targetRev); + if(bomChildrenMap.containsKey(oldId)) { + System.out.println("找到子级中id为:"+oldId+"的对象!"); + TCComponentBOMLine targetLine = bomChildrenMap.get(oldId); + TCComponentItemRevision childRev = targetLine.getItemRevision(); + if(targetChildRev!=null) { + System.out.println(targetRev.toString()+"删除"+targetLine.toString()+",新增"+targetChildRev.toString()); + bomwin.lock(); + targetLine.cut(); + bomwin.save(); + bomwin.unlock(); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(targetRev.getItem(), targetRev, null, null); + bomwin.lock(); + TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); + System.out.println("设置bl_quantity属性为:"+num1); + childLine.setStringProperty("bl_quantity", num1); + bomwin.save(); + bomwin.unlock(); + } + }else { + System.out.println("未找到子级中id为:"+oldId+"的对象!"); + } + } + } + break; + case "新增": + System.out.println("新增"); + String num2 = table01.getValueAt(i, 6)!=null?table01.getValueAt(i, 6).toString():""; + if(num2.equals("")) { + int temp = i + 1; + errInfo.append("新增操作的的最后一列数量为必填项!第"+temp+"行操作未执行!\n"); + continue; + } + for(int j = 0;j < table02.getRowCount(); j++) { + TCComponentItemRevision targetChildRev = null; + System.out.println("搜索id:"+newId); + TCComponent[] search = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {newId}); + if(search!=null&&search.length>0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + System.out.println("不存在id为"+newId+"的MBOM"); +// errInfo.append("不存在id为"+newId+"的MBOM,请生成后再新增\n"); + continue; + } + String ml8_ProcessingMode = targetChildRev.getStringProperty("ml8_ProcessingMode")!=null?targetChildRev.getStringProperty("ml8_ProcessingMode"):""; + String ml8_AddTrade = targetChildRev.getStringProperty("ml8_AddTrade")!=null?targetChildRev.getStringProperty("ml8_AddTrade"):""; + System.out.println(targetChildRev.toString()+"的加工方式为:"+ml8_ProcessingMode+",加贸为:"+ml8_AddTrade); + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + String ml8_Factory = table02.getValueAt(j, 4).toString(); + String ml8_Line = table02.getValueAt(j, 5).toString(); + System.out.println("搜索id:"+newId+"-"+ml8_Factory+"-"+ml8_Line); + search = session.search("零组件 ID", new String[] {"零组件 ID"}, new String[] {newId+"-"+ml8_Factory+"-"+ml8_Line}); + if(search!=null&&search.length>0) { + targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); + }else { + targetChildRev = null; + } + if(targetChildRev!=null) { + TCComponentItemRevision tempRev = conditionRevs.get(j); + System.out.println(tempRev.toString()+"新增"+targetChildRev.toString()); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(tempRev.getItem(), tempRev, null, null); + bomwin.lock(); + TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); + System.out.println("设置bl_quantity属性为:"+num2); + childLine.setStringProperty("bl_quantity", num2); + bomwin.save(); + bomwin.unlock(); + }else { +// System.out.println(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM"); +// errInfo.append(newId+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM,请生成后再新增\n"); + } + }else { + if(targetChildRev!=null) { + TCComponentItemRevision tempRev = conditionRevs.get(j); + System.out.println(tempRev.toString()+"新增"+targetChildRev.toString()); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(tempRev.getItem(), tempRev, null, null); + bomwin.lock(); + TCComponentBOMLine childLine = topLine.add(targetChildRev.getItem(),targetChildRev,null,false,""); + System.out.println("设置bl_quantity属性为:"+num2); + childLine.setStringProperty("bl_quantity", num2); + bomwin.save(); + bomwin.unlock(); + } + } + } + break; + case "删除": + System.out.println("删除"); + String num3 = table01.getValueAt(i, 6)!=null?table01.getValueAt(i, 6).toString():""; + if(num3.equals("")) { + int temp = i + 1; + errInfo.append("删除操作的最后一列数量为必填项!第"+temp+"行操作未执行!\n"); + continue; + } + for(int j = 0;j < conditionRevs.size(); j++) { + TCComponentItemRevision targetRev = conditionRevs.get(j); + System.out.println("获取MBOM子级!"); + Map bomChildrenMap = MyUtil.getBomChildren(bomwin, targetRev); + bomwin.lock(); + for(Map.Entry entry:bomChildrenMap.entrySet()) { + TCComponentBOMLine value = entry.getValue(); + TCComponentItemRevision itemRevision = value.getItemRevision(); + String item_id = itemRevision.getStringProperty("item_id"); + if(item_id.contains(oldId)) { +// String quantity = value.getStringProperty("bl_quantity"); +// if(quantity==null||quantity.equals(""))quantity = "1"; +// BigDecimal bigDecimal = new BigDecimal(quantity); + if(num3.equals("0")) + value.cut(); + else { + System.out.println("设置bl_quantity属性为:"+num3); + value.setStringProperty("bl_quantity", num3); + } + System.out.println("删除"+value.toString()); + } + } + bomwin.save(); + bomwin.unlock(); + } + break; + + default: + break; + } + } + String targetId = target.getStringProperty("item_id"); + for(int i =0;i right; + private TCComponentItemRevision target; + private JTable table2; + private final static String TEMPLATENAME = "624TCM_更改审批流程"; + private String synTypeStr; + + public CreateProcessOperation() { + + } + + public CreateProcessOperation(AbstractAIFUIApplication app, TCSession session,TCComponentItemRevision target,List right,JTable table2,String synTypeStr) { + this.app = app; + this.session = session; + this.target = target; + this.right = right; + this.table2 = table2; + this.synTypeStr = synTypeStr; + errInfo = ""; + } + + public String getErrInfo() { + return errInfo; + } + + public void setErrInfo(String errInfo) { + this.errInfo = errInfo; + } + + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在执行......"); + dia.setVisible(true); + boolean flag = false; +// try { + flag = createProcess(); +// } catch (TCException e) { +// e.printStackTrace(); +// } + if (flag) { + dia.setVisible(false); + MessageBox.post("执行完成!", "", MessageBox.INFORMATION); + } else { + dia.setVisible(false); + MessageBox.post(errInfo+"执行失败!", "", MessageBox.INFORMATION); + } + }; + }.start(); + } + + private boolean createProcess() { + try { + System.out.println("创建工艺变更通知单!"); + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + String newID = itemType.getNewID(); + String revString = itemType.getNewRev(null); + TCComponentItem item = itemType.create(newID, revString, "ML8_MCNotice", "工艺变更通知单", "", null); + TCComponentFolder folder = session.getUser().getNewStuffFolder(); + folder.add("contents", item); + folder.refresh(); + TCComponentItemRevision rev = item.getLatestItemRevision(); + //获取同步对象下标 + List indexList = new ArrayList(); +// switch (synTypeStr) { +// case "自动": +// for(int row = 0; row1) { + rev.add("ML8_GXBGQ", revlist[revlist.length-2]); + } + } + System.out.println("拷贝设计变更通知单到设计变更通知单关系"); + rev.add("ML8_RelatedECN", target); + rev.refresh(); + System.out.println("发起流程!"); + MyUtil.workflow(session, new String[] {rev.getUid()}, "自动创建的"+TEMPLATENAME, TEMPLATENAME); + + }catch(Exception e) { + e.printStackTrace(); + return false; + } + return true; + } + + + + + + + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/MyUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/MyUtil.java new file mode 100644 index 0000000..3608df0 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/MyUtil.java @@ -0,0 +1,143 @@ +package com.connor.ml.tcm.synchronization_MBOM_structure; + +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JTable; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableColumn; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.services.rac.workflow.WorkflowService; +import com.teamcenter.services.rac.workflow._2008_06.Workflow.ContextData; +import com.teamcenter.services.rac.workflow._2008_06.Workflow.InstanceInfo; + +public class MyUtil { + + public static TCComponentBOMWindow createBOMWindow(TCSession session) { + TCComponentBOMWindow window=null; + try { + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + window = winType.create(null); + } catch (TCException e) { + e.printStackTrace(); + } + return window; + } + + public static Map getBomChildren(TCComponentBOMWindow bomwin, TCComponentItemRevision rev) throws Exception{ + Map map = new HashMap(); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(rev.getItem(), rev, null, null); + AIFComponentContext[] children = topLine.getChildren(); + for(AIFComponentContext con:children) { + InterfaceAIFComponent comp = con.getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine childLine = (TCComponentBOMLine)comp; + TCComponentItemRevision revision = childLine.getItemRevision(); + String item_id = revision.getStringProperty("item_id"); + if(item_id.contains("-"))item_id = item_id.split("-")[0]; + map.put(item_id,childLine); + } + } + return map; + } + + public static void workflow(TCSession session,String[] uid,String workFlowName,String templateName) { + // String uid = rev.getUid(); + //创建流程 + WorkflowService wfService = WorkflowService.getService(session); + ContextData contextData = new ContextData(); + + String observerKey = ""; + String name = workFlowName; + String subject = ""; + String description = ""; + + contextData.processTemplate = templateName; // update with your own ProcessTemplate. + contextData.subscribeToEvents = false; + contextData.subscriptionEventCount = 0; + contextData.attachmentCount = uid.length; + contextData.attachments = uid ; + int [] types = new int[uid.length]; + for(int i = 0;i 0) { + System.out.println("开始清空"+topline.getItemRevision().toString()+"BOM"); + for (AIFComponentContext child : children3) { + TCComponentBOMLine childLine = (TCComponentBOMLine)child.getComponent(); + childLine.cut(); + } + } + } + bomwin.save(); + bomwin.unlock(); + } + + public static void FitTableColumns(JTable myTable) { //設置table的列寬隨內容調整 + + JTableHeader header = myTable.getTableHeader(); + + int rowCount = myTable.getRowCount(); + + Enumeration columns = myTable.getColumnModel().getColumns(); + + while (columns.hasMoreElements()) { + + TableColumn column = (TableColumn) columns.nextElement(); + + int col = header.getColumnModel().getColumnIndex( + + column.getIdentifier()); + + int width = (int) myTable.getTableHeader().getDefaultRenderer() + + .getTableCellRendererComponent(myTable, + + column.getIdentifier(), false, false, -1, col) + + .getPreferredSize().getWidth(); + + for (int row = 0; row < rowCount; row++){ + + int preferedWidth = (int) myTable.getCellRenderer(row, col) + + .getTableCellRendererComponent(myTable, + + myTable.getValueAt(row, col), false, false, + + row, col).getPreferredSize().getWidth(); + + width = Math.max(width, preferedWidth); + + } + + header.setResizingColumn(column); + + column.setWidth(width + myTable.getIntercellSpacing().width); + + } + + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/ShowBomDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/ShowBomDialog.java new file mode 100644 index 0000000..40b039a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/ShowBomDialog.java @@ -0,0 +1,184 @@ +package com.connor.ml.tcm.synchronization_MBOM_structure; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.PropertyLayout; + +public class ShowBomDialog extends JFrame{ + + private TCComponentItemRevision leftRev; + private TCComponentItemRevision rightRev; + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentBOMWindow bomwin; + + public ShowBomDialog() { + + } + + public ShowBomDialog(AbstractAIFUIApplication app, TCSession session, TCComponentItemRevision leftRev, TCComponentItemRevision rightRev) { + this.app = app; + this.session = session; + this.leftRev = leftRev; + this.rightRev = rightRev; + this.bomwin = MyUtil.createBOMWindow(session); + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void init() throws Exception { + JPanel mainPanel = new JPanel(new BorderLayout()); + JPanel panel1 = new JPanel(new PropertyLayout()); + JPanel panel2 = new JPanel(new PropertyLayout()); + JPanel panel3 = new JPanel(new FlowLayout(FlowLayout.LEADING)); + JPanel panel4 = new JPanel(new FlowLayout(FlowLayout.LEADING)); + JScrollPane scrollPane1 = new JScrollPane(); + JScrollPane scrollPane2 = new JScrollPane(); + JTextField leftText = new JTextField(40); + JTextField rightText = new JTextField(40); + JLabel leftLabel = new JLabel("EBOM物料编号:"); + JLabel rightLabel = new JLabel("MBOM物料编号:"); + + String leftString = leftRev.getStringProperty("object_string"); + String rightString = rightRev.getStringProperty("object_string"); + leftText.setText(leftString); + leftText.setEnabled(false); + rightText.setText(rightString); + rightText.setEnabled(false); + + JTable table1 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + };; + table1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table1.getTableHeader().setReorderingAllowed(false); + + JTable table2 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + };; + table2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table2.getTableHeader().setReorderingAllowed(false); + createTables(table1, table2); + scrollPane1.setViewportView(table1); + scrollPane2.setViewportView(table2); + scrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane1.setPreferredSize(new Dimension(600, 400)); + scrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane2.setPreferredSize(new Dimension(600, 400)); + + panel3.add(leftLabel); + panel3.add(leftText); + panel4.add(rightLabel); + panel4.add(rightText); + + panel1.add("1.1.left.top",panel3); + panel1.add("2.1.left.top",scrollPane1); + panel2.add("1.1.left.top",panel4); + panel2.add("2.1.left.top",scrollPane2); + + mainPanel.add(panel1,BorderLayout.WEST); + mainPanel.add(new JLabel(" "),BorderLayout.CENTER); + mainPanel.add(panel2,BorderLayout.EAST); + + add(mainPanel); + setTitle("BOM打开"); + pack(); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + } + + private void createTables(JTable table1, JTable table2) throws Exception { + DefaultTableModel model1 = new DefaultTableModel(); + DefaultTableModel model2 = new DefaultTableModel(); + String [] header = {"序号","物料编码","版本","名称","加工方式","数量"}; + String[][] data1 = null; + String[][] data2 = null; + + Map leftBomChildrenMap = MyUtil.getBomChildren(bomwin, leftRev); + Map rightBomChildrenMap = MyUtil.getBomChildren(bomwin, rightRev); + if(leftBomChildrenMap.size()>0) { + data1 = new String[leftBomChildrenMap.size()][6]; + } + if(rightBomChildrenMap.size()>0) { + data2 = new String[rightBomChildrenMap.size()][6]; + } + int i = 0; + for(Map.Entry entry:leftBomChildrenMap.entrySet()) { + TCComponentBOMLine childLine = entry.getValue(); + TCComponentItemRevision childRev = childLine.getItemRevision(); + String bl_quantity = childLine.getStringProperty("bl_quantity"); + System.out.println("bl_quantity"+bl_quantity); + if(bl_quantity==null||bl_quantity.trim().equals("")) { + bl_quantity = "1"; + } + data1[i][0] = childRev.getStringProperty("item_id")!=null?childRev.getStringProperty("item_id"):""; + data1[i][1] = childRev.getStringProperty("item_revision_id")!=null?childRev.getStringProperty("item_revision_id"):""; + data1[i][2] = childRev.getStringProperty("object_name")!=null?childRev.getStringProperty("object_name"):""; + data1[i][3] = childRev.getStringProperty("ml8_ProcessingMode")!=null?childRev.getStringProperty("ml8_ProcessingMode"):""; + data1[i][4] = childRev.getStringProperty("ml8_AddTrade")!=null?childRev.getStringProperty("ml8_AddTrade"):""; + data1[i][5] = bl_quantity; + i++; + } + int j =0; + for(Map.Entry entry:rightBomChildrenMap.entrySet()) { + TCComponentBOMLine childLine = entry.getValue(); + TCComponentItemRevision childRev = childLine.getItemRevision(); + String bl_quantity = childLine.getStringProperty("bl_quantity"); + if(bl_quantity==null||bl_quantity.trim().equals(""))bl_quantity = "1"; + data2[j][0] = childRev.getStringProperty("item_id")!=null?childRev.getStringProperty("item_id"):""; + data2[j][1] = childRev.getStringProperty("item_revision_id")!=null?childRev.getStringProperty("item_revision_id"):""; + data2[j][2] = childRev.getStringProperty("object_name")!=null?childRev.getStringProperty("object_name"):""; + data2[j][3] = childRev.getStringProperty("ml8_ProcessingMode")!=null?childRev.getStringProperty("ml8_ProcessingMode"):""; + data2[j][4] = childRev.getStringProperty("ml8_AddTrade")!=null?childRev.getStringProperty("ml8_AddTrade"):""; + data2[j][5] = bl_quantity; + j++; + } + model1.setDataVector(data1, header); + model2.setDataVector(data2, header); + table1.setModel(model1); + table2.setModel(model2); + } + + + + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureDialog.java new file mode 100644 index 0000000..5096de9 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureDialog.java @@ -0,0 +1,432 @@ +package com.connor.ml.tcm.synchronization_MBOM_structure; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableModel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.PropertyLayout; + +public class SynMBOMStructureDialog extends JFrame implements ActionListener{ + + private AbstractAIFUIApplication app; + private TCSession session; + private TCComponentItemRevision target; + private JTable table1; + private JTable table2; + private DefaultTableModel model1; + private DefaultTableModel model2; +// private JButton mbomInfoButton; + private JButton showBomButton; + private JButton autoSynButton; + private JButton conditionSynButton; + private JButton createHandlerButton; + private JPanel mainPanel; + private JPanel panel1; + private JPanel panel2; + private JPanel panel3; + private JScrollPane scrollPane1; + private JScrollPane scrollPane2; + private List left; + private List right; + private List bgqEBOM; + private TCComponentBOMWindow bomwin; + + public SynMBOMStructureDialog() { + + } + + public SynMBOMStructureDialog(AbstractAIFUIApplication app, TCSession session,TCComponentItemRevision target) { + this.app = app; + this.session = session; + this.target = target; + this.bomwin = MyUtil.createBOMWindow(session); + + + try { + init(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + + + public List getRight() { + return right; + } + + public void setRight(List right) { + this.right = right; + } + +// @Override +// public void run() { +// // TODO Auto-generated method stub +// try { +// init(); +// } catch (Exception e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// } +// } + + public void init() throws Exception{ + mainPanel = new JPanel(new BorderLayout()); + panel1 = new JPanel(new PropertyLayout()); + panel2 = new JPanel(new PropertyLayout()); + panel3 = new JPanel(new PropertyLayout()); + scrollPane1 = new JScrollPane(); + scrollPane2 = new JScrollPane(); +// mbomInfoButton = new JButton("1、MBOM同步分析"); + showBomButton = new JButton("1、BOM查看"); + autoSynButton = new JButton("2、BOM自动同步"); + conditionSynButton = new JButton("3、BOM条件同步"); + createHandlerButton = new JButton("4、提交工艺变更流程"); +// mbomInfoButton.addActionListener(this); + showBomButton.addActionListener(this); + autoSynButton.addActionListener(this); + conditionSynButton.addActionListener(this); + createHandlerButton.addActionListener(this); + + table1 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + };; + table1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table1.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table1.getTableHeader().setReorderingAllowed(false); + + table2 = new JTable(){ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + };; + table2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + table2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + table2.getTableHeader().setReorderingAllowed(false); + scrollPane1.setViewportView(table1); + scrollPane2.setViewportView(table2); + scrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane1.setPreferredSize(new Dimension(400, 400)); + scrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane2.setPreferredSize(new Dimension(800, 400)); + + panel1.add("1.1.left.top",new JLabel("EBOM变更(提取变更后物料对象)")); + panel1.add("2.1.left.top",scrollPane1); + + panel2.add("1.1.left.top",new JLabel("MBOM影响分析:")); + panel2.add("2.1.left.top",scrollPane2); + +// panel3.add("1.1.left.top",mbomInfoButton); + panel3.add("1.1.left.top",showBomButton); + panel3.add("2.1.left.top",autoSynButton); + panel3.add("3.1.left.top",conditionSynButton); + panel3.add("4.1.left.top",createHandlerButton); + + mainPanel.add(panel1,BorderLayout.WEST); + mainPanel.add(panel2,BorderLayout.CENTER); + mainPanel.add(panel3,BorderLayout.EAST); + updateTable1(); + + + add(mainPanel); + setTitle("BOM变更"); + pack(); + setLocationRelativeTo(null); + setAlwaysOnTop(true); + setVisible(true); + + } + + private void updateTable1() throws Exception { + System.out.println("更新左侧表格!"); + bgqEBOM = new ArrayList(); + left = new ArrayList(); + TCComponent[] relatedComponents = target.getRelatedComponents("ML8_GXBGH"); + TCComponent[] relatedComponents2 = target.getRelatedComponents("ML8_GXBGQ"); + for(TCComponent comp:relatedComponents) { + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + String ml8_ProcessingMode = rev.getStringProperty("ml8_ProcessingMode"); + String ml8_AddTrade = rev.getStringProperty("ml8_AddTrade"); + if(ml8_ProcessingMode==null) ml8_ProcessingMode = ""; + if(ml8_AddTrade==null) ml8_AddTrade = ""; + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + left.add(rev); + } + } + } + + for(TCComponent comp:relatedComponents2) { + if(comp instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)comp; + String ml8_ProcessingMode = rev.getStringProperty("ml8_ProcessingMode"); + String ml8_AddTrade = rev.getStringProperty("ml8_AddTrade"); + if(ml8_ProcessingMode==null) ml8_ProcessingMode = ""; + if(ml8_AddTrade==null) ml8_AddTrade = ""; + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + bgqEBOM.add(rev); + } + } + } + String[] header = {"序号","物料编码","版本","名称","加工方式","加贸"}; + String data[][] = new String[left.size()][6]; + for(int i = 0;i(); + + String[] header = {"序号","物料编码","当前版本","名称","制造厂","产线","是否发布","同步方式","同步状态","创建者","更改单号"}; + String data[][] = null; + if(table1.getSelectedRow()!=-1) { + TCComponentItemRevision rev = left.get(table1.getSelectedRow()); + TCComponent[] relatedComponents = rev.getRelatedComponents("ML8_RelatedMBOM"); + for(TCComponent comp: relatedComponents) { + if(comp instanceof TCComponentItem) { + TCComponentItem item = (TCComponentItem)comp; + TCComponentItemRevision revision = item.getLatestItemRevision(); + right.add(revision); + } + } + data = new String[right.size()][11]; + for(int i = 0;i leftBomChildrenMap = getBomChildren(left.get(table1.getSelectedRow())); + Map rightBomChildrenMap = getBomChildren(rightRev); + String ml8_Factory = rightRev.getStringProperty("ml8_Factory"); + String ml8_Line = rightRev.getStringProperty("ml8_Line"); + if(ml8_Factory == null)ml8_Factory = ""; + if(ml8_Line == null)ml8_Line = ""; + boolean isAuto = true; + System.out.println("变更前对象数量:"+bgqEBOM.size()); + t1:for(int i1 = 0; i1 < bgqEBOM.size(); i1++) { + TCComponentItemRevision bgqRev = bgqEBOM.get(i1); + String bgqId = bgqRev.getStringProperty("item_id"); + String rightId = rightRev.getStringProperty("item_id").split("-")[0]; + System.out.println("变更前id:"+bgqId); + System.out.println("MBOMid:"+rightId); + if(rightId.equals(bgqId)) { + System.out.println("比较"+bgqId+"的子级!"); + Map bgqBomChildrenMap = getBomChildren(bgqRev); + if(bgqBomChildrenMap.size()!=rightBomChildrenMap.size()) { + System.out.println("i:"+i+",与左侧子集数量不同!"); + isAuto = false; + break; + }else { + for(Map.Entry entry:rightBomChildrenMap.entrySet()) { + String key = entry.getKey(); + if(!bgqBomChildrenMap.containsKey(key)) { + System.out.println("i:"+i+"右侧存在子集id为"+key+"的对象,而"+bgqRev.toString()+"不存在!"); + isAuto = false; + break t1; + } + } + } + } + } + if(isAuto) { + for(Map.Entry entry:rightBomChildrenMap.entrySet()) { + TCComponentBOMLine rightChildLine = entry.getValue(); + TCComponentItemRevision rightChildRev = rightChildLine.getItemRevision(); + String ml8_ProcessingMode = rightChildRev.getStringProperty("ml8_ProcessingMode"); + String ml8_AddTrade = rightChildRev.getStringProperty("ml8_AddTrade"); + if(ml8_ProcessingMode == null)ml8_ProcessingMode = ""; + if(ml8_AddTrade == null)ml8_AddTrade = ""; + if(ml8_ProcessingMode.equals("自制")||ml8_ProcessingMode.equals("外协外购")&&ml8_AddTrade.equals("是")) { + String childFac = rightChildRev.getStringProperty("ml8_Factory"); + String childLin = rightChildRev.getStringProperty("ml8_Line"); + if(childFac == null)childFac = ""; + if(childLin == null)childLin = ""; + if(!childFac.equals(ml8_Factory)||!childLin.equals(ml8_Line)) { + System.out.println("i:"+i+"右侧存在工厂、产线与首行不一致的子集!子集id为:"+rightChildRev.getStringProperty("item_id")); + isAuto = false; + break; + } + } + + } + } + if(isAuto) { + data[i][7] = "自动"; + }else { + data[i][7] = "手动"; + } +// TCComponent[] release_status_list = rightRev.getReferenceListProperty("release_status_list"); +// +// if(release_status_list==null||release_status_list.length==0) { +// System.out.println(rightRev.toString()+"未发布!"); +// +// }else { +// System.out.println(rightRev.toString()+"已发布!"); +// +// } + String ml8_changeNO = rightRev.getStringProperty("ml8_changeNO")!=null?rightRev.getStringProperty("ml8_changeNO"):""; + String targetId = target.getStringProperty("item_id"); + System.out.println(rightRev.toString()+"的ml8_changeNO:"+ml8_changeNO); + System.out.println(target.toString()+"的item_id:"+targetId); + if(targetId.equals(ml8_changeNO)) { + data[i][8] = "已更新"; + }else { + data[i][8] = "未更新"; + } + data[i][9] = rightRev.getReferenceProperty("owning_user")!=null?rightRev.getReferenceProperty("owning_user").toString():""; + data[i][10] = target.getStringProperty("item_id")!=null?target.getStringProperty("item_id"):""; + } + + } + + model2 = new DefaultTableModel(); + model2.setDataVector(data, header); + table2.setModel(model2); + scrollPane2.revalidate(); + scrollPane2.repaint(); + mainPanel.revalidate(); + mainPanel.repaint(); + } + + public Map getBomChildren(TCComponentItemRevision rev) throws Exception{ + Map map = new HashMap(); + TCComponentBOMLine topLine = bomwin.setWindowTopLine(rev.getItem(), rev, null, null); + AIFComponentContext[] children = topLine.getChildren(); + for(AIFComponentContext con:children) { + InterfaceAIFComponent comp = con.getComponent(); + if(comp instanceof TCComponentBOMLine) { + TCComponentBOMLine childLine = (TCComponentBOMLine)comp; + TCComponentItemRevision revision = childLine.getItemRevision(); + String item_id = revision.getStringProperty("item_id"); + if(item_id.contains("-"))item_id = item_id.split("-")[0]; + map.put(item_id,childLine); + } + } + return map; + } + + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); +// if(source == mbomInfoButton) { +// try { +// updateTable2(); +// } catch (Exception e1) { +// // TODO Auto-generated catch block +// e1.printStackTrace(); +// } +// }else + if(source == showBomButton) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + System.out.println("当前左侧选中:"+table1.getSelectedRow()); + System.out.println("当前右侧选中:"+table2.getSelectedRow()); + TCComponentItemRevision leftTarget = left.get(table1.getSelectedRow()); + TCComponentItemRevision rightTarget = right.get(table2.getSelectedRow()); + new ShowBomDialog(app,session,leftTarget,rightTarget); + + } + }); + }else if(source == autoSynButton) { + SynMBOMStructureOperation operation = new SynMBOMStructureOperation(app, session, target, bomwin, table1, table2, left, right, this); + session.queueOperation(operation); + }else if(source == conditionSynButton) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + System.out.println("当前左侧选中:"+table1.getSelectedRow()); + System.out.println("当前右侧选中:"+table2.getSelectedRow()); + TCComponentItemRevision leftTarget = left.get(table1.getSelectedRow()); + TCComponentItemRevision rightTarget = right.get(table2.getSelectedRow()); + new ConditionSynBomDialog(app,session,target,left,right,table1,table2,SynMBOMStructureDialog.this); + + } + }); + }else if(source == createHandlerButton) { + CreateProcessOperation operation = new CreateProcessOperation(app,session,target,right,table2,"自动"); + session.queueOperation(operation); + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureHandler.java new file mode 100644 index 0000000..9d93206 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureHandler.java @@ -0,0 +1,46 @@ +package com.connor.ml.tcm.synchronization_MBOM_structure; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.connor.ml.tcm.synchronization_MBOM_prop.SynMBOMPropDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class SynMBOMStructureHandler extends AbstractHandler{ + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + InterfaceAIFComponent targetComponent = app.getTargetComponent(); + if(targetComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision rev = (TCComponentItemRevision)targetComponent; + String type = rev.getType(); + if(type.equals("ML8_CNoticeRevision")) { + new Thread() { + @Override + public void run() { + SynMBOMStructureDialog dialog = new SynMBOMStructureDialog(app, session,rev); + } + + }.start(); + + +// new Thread(dialog).start(); + }else { + MessageBox.post("请选择设计变更通知单版本!","",MessageBox.INFORMATION); + } + }else { + MessageBox.post("请选择设计变更通知单版本!","",MessageBox.INFORMATION); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureOperation.java new file mode 100644 index 0000000..661f475 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/synchronization_MBOM_structure/SynMBOMStructureOperation.java @@ -0,0 +1,278 @@ +package com.connor.ml.tcm.synchronization_MBOM_structure; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Label; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JTable; +import javax.swing.SwingConstants; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.util.MessageBox; + +public class SynMBOMStructureOperation extends AbstractAIFOperation{ + private AbstractAIFUIApplication app; + private TCSession session; + private String errInfo; + private TCComponentBOMWindow bomwin; + private JTable table1; + private JTable table2; + private List left; + private List right; + private SynMBOMStructureDialog dialog; + private TCComponentItemRevision target; + public SynMBOMStructureOperation() { + + } + + public SynMBOMStructureOperation(AbstractAIFUIApplication app, TCSession session,TCComponentItemRevision target, TCComponentBOMWindow bomwin, JTable table1, JTable table2, List left, List right, SynMBOMStructureDialog dialog) { + this.app = app; + this.session = session; + this.bomwin = bomwin; + this.table1 = table1; + this.table2 = table2; + this.left = left; + this.right = right; + this.dialog = dialog; + this.target = target; + errInfo = ""; + } + + public String getErrInfo() { + return errInfo; + } + + public void setErrInfo(String errInfo) { + this.errInfo = errInfo; + } + + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + new Thread() { + public void run() { + WaitingDialog dia = new WaitingDialog(app.getDesktop(), "INFOMATION", "正在同步......"); + dia.setVisible(true); + boolean flag = false; +// try { + flag = synBOM(); +// } catch (TCException e) { +// e.printStackTrace(); +// } + if (flag) { + dia.setVisible(false); + MessageBox.post("同步成功!", "", MessageBox.INFORMATION); + } else { + dia.setVisible(false); + MessageBox.post(errInfo+"同步失败!", "", MessageBox.INFORMATION); + } + }; + }.start(); + } + + private boolean synBOM() { + System.out.println("当前左侧选中:"+table1.getSelectedRow()); + TCComponentItemRevision leftTarget = left.get(table1.getSelectedRow()); + try { + //获取EBOM子列 + System.out.println("获取EBOM子列!"); + Map leftBomChildren = MyUtil.getBomChildren(bomwin, leftTarget); + List leftRevs = new ArrayList(); + for(Map.Entry entry:leftBomChildren.entrySet()) { + TCComponentBOMLine value = entry.getValue(); + TCComponentItemRevision rev = value.getItemRevision(); + leftRevs.add(rev); + } + + + //获取自动同步对象下标 + List indexList = new ArrayList(); + for(int row = 0; row newRight = new ArrayList(); + for(int i = 0;i 0) { +// targetChildRev = ((TCComponentItem)search[0]).getLatestItemRevision(); +// } +//// for(TCComponent comp:relatedComponents) { +//// if(comp instanceof TCComponentItem) { +//// TCComponentItem item = (TCComponentItem)comp; +//// TCComponentItemRevision revision = item.getLatestItemRevision(); +//// String childFac = revision.getStringProperty("ml8_Factory")!=null?revision.getStringProperty("ml8_Factory"):""; +//// String childLin = revision.getStringProperty("ml8_Line")!=null?revision.getStringProperty("ml8_Line"):""; +//// if(childFac.equals(ml8_Factory)&&childLin.equals(ml8_Line)) { +//// targetRevision = revision; +//// break; +//// } +//// } +//// } +// +// if(targetRevision!=null) { +//// //清空 +//// MyUtil.clearBom(bomwin, rev); +//// +// Map bomChildrenMap = MyUtil.getBomChildren(bomwin, targetRevision); +// List childRevs = new ArrayList(); +// for(Map.Entry entry:bomChildrenMap.entrySet()) { +// TCComponentBOMLine value = entry.getValue(); +// TCComponentItemRevision rev1 = value.getItemRevision(); +// childRevs.add(rev1); +// } +// bomwin.lock(); +// System.out.println("替换"+rev.toString()+"的EBOM!"); +// TCComponentBOMLine topLine2 = bomwin.setWindowTopLine(rev.getItem(), rev, null, null); +// for(TCComponentItemRevision rev1:childRevs) { +// topLine2.add(rev1.getItem(),rev1,null,false,""); +// } +// bomwin.save(); +// bomwin.unlock(); +//// //替换 +//// rev.remove("ML8_RelatedMBOM", targetRevision.getItem()); +//// rev.add("ML8_RelatedMBOM", newRev.getItem()); +// }else { +// System.out.println(rev.getStringProperty("item_id")+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM"); +// setErrInfo(errInfo+rev.getStringProperty("item_id")+"的MBOM关系下不存在工厂为"+ml8_Factory+",产线为"+ml8_Line+"的MBOM,请生成后再同步变更\n"); +// } +// +// } +// } + } + dialog.updateTable2(); + + if(!errInfo.equals(""))return false; + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return false; + } + return true; + } + + class WaitingDialog extends com.teamcenter.rac.aif.AbstractAIFDialog { + private static final long serialVersionUID = 1L; + public JPanel panel; + JProgressBar progressBar = null; + + public WaitingDialog(Frame arg0, String title, String message) { + super(arg0, title); + this.setModal(false); + + panel = new JPanel(new BorderLayout()); + + /* + * JLabel label = new JLabel(message); System.out.println("message:"+message); + * System.out.println("label:"+label); panel.add(label); + */ + + progressBar = new JProgressBar(SwingConstants.HORIZONTAL); + progressBar.setVisible(true); + progressBar.setIndeterminate(true); + + panel.add(BorderLayout.CENTER, new Label(message)); + panel.add(BorderLayout.SOUTH, progressBar); + + panel.setPreferredSize(new Dimension(350, 60)); + + this.getContentPane().add(panel); + + centerToScreen(); + + pack(); + + } + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/tcm.rar b/com.connor.ml.tcm/src/com/connor/ml/tcm/tcm.rar new file mode 100644 index 0000000..295b304 Binary files /dev/null and b/com.connor.ml.tcm/src/com/connor/ml/tcm/tcm.rar differ diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/test/test6.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/test/test6.java new file mode 100644 index 0000000..ecbbb48 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/test/test6.java @@ -0,0 +1,243 @@ +package com.connor.ml.tcm.test; + +import java.awt.Dimension; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.ListSelectionModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.DefaultMutableTreeNode; + +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; +import org.jdesktop.swingx.decorator.HighlighterFactory; +import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode; + +import com.connor.ml.tcm.ML_04.JTreeTable; +import com.connor.ml.tcm.ML_04.JTreeTableModel; + + +public class test6 { + + protected Shell shell; + private Table table; + private Text name; + private Text dept; + private Button query; + private Button ok; + private Button cancel; + private static JTreeTableModel map; + private static DefaultMutableTreeTableNode rootNode; + private CheckboxTableViewer checkboxTableViewer; + private TableItem item; + private static List isNotEditableRow = new ArrayList(); + public static void main(String[] args) { +// JDialog dialog=new JDialog(); +// String[] header = new String[] { "名称","选中", "类型","模板" }; +// dialog.setPreferredSize(new Dimension(600, 400)); +// JPanel totalPanel = new JPanel(); +// dialog.add(totalPanel); +// +// HF04NodeBean nodeBean = new HF04NodeBean(); +// rootNode = new DefaultMutableTreeTableNode("资源库"); +//// DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("油漆"); +// DefaultMutableTreeTableNode node1 = new DefaultMutableTreeTableNode("油漆"); +// rootNode.add(node1); +// DefaultMutableTreeTableNode node2 = new DefaultMutableTreeTableNode("刀具"); +// rootNode.add(node2); +// DefaultMutableTreeTableNode node3 = new DefaultMutableTreeTableNode("量具"); +// rootNode.add(node3); +// DefaultMutableTreeTableNode node4 = new DefaultMutableTreeTableNode("工具"); +// rootNode.add(node4); +// JTreeTable jTreeTable = getJTreeTable(null,null,header,null); +// totalPanel.add(jTreeTable); +// dialog.pack(); +// dialog. validate(); +//// designPanel.centerToScreen(); +// dialog.setVisible(true); + } + + public static JTreeTable getJTreeTable(JTreeTable partsTable, DefaultTableModel dtm, Object[] titleNames, + Object[][] values) { + int simpleLen = 100; + int totleLen = 1500; + if (partsTable == null) { + map = new JTreeTableModel(rootNode); + map.setIsNotEditableRow(isNotEditableRow); + + partsTable = new JTreeTable(map); + partsTable.setIsNotEditableRow(isNotEditableRow); + partsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + partsTable.setRowHeight(30); + partsTable.expandAll(); // 展开全部节点 + + +// partsTable.getColumnModel().getColumn(0).setPreferredWidth(500); +// partsTable.getColumnModel().getColumn(0).setPreferredWidth(50); + + partsTable.HiddenCell(2); +// partsTable.HiddenCell(3); + + partsTable.setHighlighters(HighlighterFactory.createSimpleStriping()); + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i).setPreferredWidth(simpleLen); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + public static String dealDateFormat(String oldDateStr) throws ParseException{ + //此格式只有 jdk 1.7才支持 yyyy-MM-dd'T'HH:mm:ss.SSSXXX + DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX"); //yyyy-MM-dd'T'HH:mm:ss.SSSZ + Date date = df.parse(oldDateStr); + DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd"); + return df2.format(date); + } + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID( String itemID) { + DecimalFormat df = new DecimalFormat("000"); + String newID = "010"; + // String idTemp = + try { + int i = 10; + while (itemID.compareTo(newID) != 0) { + i = i+1; + newID = df.format(i); + } + newID = df.format(i+10); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + public void open() { + Display display = Display.getDefault(); + createContents(); + addListeners(); + shell.open(); + shell.layout(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + } + + private void addListeners() { + table.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent arg0) { + if (table.getSelectionCount() == 1) { + TableItem item = table.getSelection()[0]; + item.setChecked(!item.getChecked()); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + + } + }); + query.addSelectionListener(new SelectionAdapter() {}); + cancel.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (name.getText().trim().equals("")) { + shell.dispose(); + } + } + }); + } + + protected void createContents() { + shell = new Shell(); + shell.setSize(300, 300); + shell.setText("SWT Application"); + shell.setLayout(new FillLayout(SWT.HORIZONTAL)); + + Composite composite = new Composite(shell, SWT.None); + composite.setLayout(new FillLayout(SWT.HORIZONTAL)); + + checkboxTableViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.FULL_SELECTION); + table = checkboxTableViewer.getTable(); + + Composite composite_1 = new Composite(shell, SWT.None); + GridLayout gridLayout1 = new GridLayout(); + gridLayout1.numColumns = 2; + composite_1.setLayout(gridLayout1); + + Label label1 = new Label(composite_1, SWT.PUSH); + label1.setText("姓名:"); + name = new Text(composite_1, SWT.BORDER); + + Label label2 = new Label(composite_1, SWT.PUSH); + label2.setText("部门:"); + dept = new Text(composite_1, SWT.BORDER); + + Composite composite_2 = new Composite(composite_1, SWT.None); + GridLayout gridLayout2 = new GridLayout(); + gridLayout2.numColumns = 3; + composite_2.setLayout(gridLayout2); + GridData griddata = new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1); + composite_2.setLayoutData(griddata); + + query = new Button(composite_2, SWT.NONE); + query.setText("查询"); + ok = new Button(composite_2, SWT.NONE); + ok.setText("确定"); + cancel = new Button(composite_2, SWT.NONE); + cancel.setText("取消"); + + table.setHeaderVisible(true); + table.setLinesVisible(true); + + // 创建表头的字符串数组 + String[] tableHeader = { "工号", "姓名", "部门" }; + for (int i = 0; i < tableHeader.length; i++) { + TableColumn tableColumn = new TableColumn(table, SWT.NONE); + tableColumn.setText(tableHeader[i]); + // 设置表头可移动,默认为false + tableColumn.setMoveable(true); + } + // 重新布局表格 + for (int i = 0; i < tableHeader.length; i++) { + table.getColumn(i).pack(); + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/SelectBOPLine.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/SelectBOPLine.java new file mode 100644 index 0000000..4fe99a9 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/SelectBOPLine.java @@ -0,0 +1,170 @@ +package com.connor.ml.tcm.turntobop; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.connor.ml.tcm.util.JAutoCompleteComboBox; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +public class SelectBOPLine extends AbstractAIFDialog implements ActionListener { + private TCSession session; + private JPanel titlePanel; + private JLabel titleLabel; + + private JLabel lineLabel; + private JAutoCompleteComboBox lineComBox; + private JLabel factoryLabel; + private JAutoCompleteComboBox factoryComBox; + + private JPanel rootPanel; + private JButton okButton; + private JButton celButton; + private TCComponentBOPLine bomline; + public SelectBOPLine(TCComponentBOPLine bomline, TCSession session) { + // TODO Auto-generated constructor stub + super(false); + this.session = session; + this.bomline = bomline; + + init(); + } + + private Map map2=new HashMap(); + + private void init() { + // TODO Auto-generated method stub + this.setTitle("选择产线"); + this.setPreferredSize(new Dimension(350, 180)); + // 初始化标题部分控件 + this.titlePanel = new JPanel(); + this.titleLabel = new JLabel("选择产线"); + this.titleLabel.setFont(new Font("宋体", 1, 18)); + this.titlePanel.add(titleLabel); + + JPanel panel = new JPanel(); + panel.add(this.titlePanel, BorderLayout.NORTH); + + this.lineLabel = new JLabel("门发线:"); + this.lineLabel.setPreferredSize(new Dimension(80, 30)); + + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringValues("ML_ProdProcessToPlantBOP"); + + List list=new ArrayList(); + Map map=new HashMap(); + + list.add(""); + for(String value:values) { + String[] split = value.split("\\|"); + String zzline = split[0].split(":")[0]; + String mfline = split[1].split(":")[0]; + map2.put(mfline, split[1].split(":")[1]); + map2.put(zzline, split[0].split(":")[1]); + map.put(zzline, mfline); + list.add(zzline); + } + this.lineComBox = new JAutoCompleteComboBox(new String[] {}); //ML8_LineLOV + + this.lineComBox.setPreferredSize(new Dimension(150, 30)); + + + this.factoryLabel = new JLabel("总装线:"); + this.factoryLabel.setPreferredSize(new Dimension(80, 30)); + + this.factoryComBox = new JAutoCompleteComboBox(list.toArray()); //MethodUtil.findLOVByName(session, "ML8_Factory_LOV") + this.factoryComBox.setPreferredSize(new Dimension(150, 30)); + + factoryComBox.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JComboBox source = (JComboBox) e.getSource(); + String provinces = (String) source.getSelectedItem(); + lineComBox.removeAllItems(); + System.out.println("provinces"+provinces); + if(map.containsKey(provinces)) { + String string = map.get(provinces); + lineComBox.addItem(string); + } + } + }); + + JPanel topPanel = new JPanel(new PropertyLayout()); + topPanel.add("1.1.left.top", factoryLabel); + topPanel.add("1.2.left.top", factoryComBox); + topPanel.add("2.1.left.top", lineLabel); + topPanel.add("2.2.left.top", lineComBox); + this.rootPanel = new JPanel(new FlowLayout()); + this.okButton = new JButton("确认"); + this.celButton = new JButton("取消"); + + this.rootPanel.add(okButton); + this.rootPanel.add(celButton); + + // 添加鼠标监听 + this.createActionEvent(); + this.setLayout(new BorderLayout()); + this.add(panel, BorderLayout.NORTH); + this.add(topPanel, BorderLayout.CENTER); + this.add(rootPanel, BorderLayout.SOUTH); + this.pack(); + this.setLocationRelativeTo(null); + this.show(); + } + + private void createActionEvent() { + // TODO Auto-generated method stub + this.okButton.addActionListener(this); + this.celButton.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object source = e.getSource(); + if (source.equals(this.okButton)) { + try { + // 获取选中的产线 + String faczzxId=""; + String selectedItem =(String) factoryComBox.getSelectedItem(); + if(map2.containsKey(selectedItem)) { + faczzxId = map2.get(selectedItem); + System.out.println(faczzxId); + } + + String lineString =(String) lineComBox.getSelectedItem(); + String mfline=""; + if(map2.containsKey(lineString)) { + mfline = map2.get(lineString); + System.out.println(mfline); + } + TurnTobopOperation operation=new TurnTobopOperation(session,bomline,selectedItem,faczzxId,lineString,mfline); + session.queueOperation(operation); + this.dispose(); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } else { + this.dispose(); + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/TurnToBopHandler.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/TurnToBopHandler.java new file mode 100644 index 0000000..320d7dd --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/TurnToBopHandler.java @@ -0,0 +1,54 @@ +package com.connor.ml.tcm.turntobop; + +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.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TurnToBopHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // TODO Auto-generated method stub + String id = AIFUtility.getCurrentPerspectiveDef().getId(); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + try { + + InterfaceAIFComponent target = app.getTargetComponent(); + if(target instanceof TCComponentBOPLine) { + TCComponentBOPLine bomBopLine=(TCComponentBOPLine)target; + int length = 1;//bomBopLine.getItemRevision().getRelatedComponents("release_status_list").length; + System.out.println(length); + if(length>0 && bomBopLine.getItem().getType().equals("ML8_ProdProcess")) {// + new Thread() { + @Override + public void run() { + SelectBOPLine dialogBopLine=new SelectBOPLine(bomBopLine,session); + + } + }.start(); + }else if(length==0){ + MessageBox.post("请选择已发布的","提示",2); + } + + System.out.println("bop"); + }else { + MessageBox.post("请在制造工艺规划器中选择","提示",2); + } +// CreateOrderProcessCommand command = new CreateOrderProcessCommand(app.getTargetComponent(),session); +// command.executeModal(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/TurnTobopOperation.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/TurnTobopOperation.java new file mode 100644 index 0000000..ad3e979 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/turntobop/TurnTobopOperation.java @@ -0,0 +1,263 @@ +package com.connor.ml.tcm.turntobop; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentBOPLine; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class TurnTobopOperation extends AbstractAIFOperation{ + + private TCSession session; + private TCComponentBOPLine bomline; +// private String selectedItem;// 总装线名称 + private String faczzxId;// 总装线id +// private String lineString;// 门发线名称 + private String mfline;// 门发线id + public TurnTobopOperation(TCSession session, TCComponentBOPLine bomline, String selectedItem, String faczzxId, + String lineString, String mfline) { + // Auto-generated constructor stub +// this.selectedItem=selectedItem; + this.session=session; + this.bomline=bomline; + this.faczzxId=faczzxId; +// this.lineString=lineString; + this.mfline=mfline; + } + + @Override + public void executeOperation() throws Exception { + // Auto-generated method stub + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("ML8_PlantBOP"); + // 获取对象名称 + String obj_name = bomline.getItemRevision().getStringProperty("object_name"); //产品工艺 转 bop + TCComponentItem item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), "ML8_PlantBOP", obj_name, "", null); + + getLineStep(); + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, item.getLatestItemRevision(), null, null); + + createBopRevision(topline,bomline); + + bomWindow.save(); + bomWindow.close(); + + TCComponentItemRevision revision = bomline.getItemRevision(); + + TCComponent[] relatedComponents = revision.getRelatedComponents("IMAN_METarget"); + + for(TCComponent com:relatedComponents) { + item.getLatestItemRevision().add("IMAN_METarget", com); + } + this.session.getUser().getNewStuffFolder().add("contents", item); + + Activator.getDefault().openPerspective("com.teamcenter.rac.cme.mpp.MSEPerspective"); + Activator.getDefault().openComponents("com.teamcenter.rac.cme.mpp.MSEPerspective", new InterfaceAIFComponent[] { item }); + + + if(!errorBuffer.toString().trim().equals("")) { + MessageBox.post(errorBuffer.toString(),"提示",2); + } + + } + public static TCComponent[] query(TCSession session, String queryName, String[] keys, String[] vals) + throws Exception { + System.out.println("Query: " + queryName); + System.out.println("keys = " + Arrays.toString(keys)); + System.out.println("vals = " + Arrays.toString(vals)); + TCComponentQueryType queryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery query = (TCComponentQuery) queryType.find(queryName); + if (query == null) { + System.out.println("null"+queryName); + } else { + query.clearCache(); + query.refresh(); + return query.execute(keys, vals); + } + return null; + } + private void getLineStep() throws Exception { + // Auto-generated method stub + + TCComponentItem totalLine = getItemById(faczzxId); + TCComponentItem mfLine = getItemById(mfline); + + if(totalLine!=null) { + getStep(totalLine); + } + if(mfLine!=null) { + getStep(mfLine); + } + } + Map> classMap=new HashMap>(); + + private void getStep(TCComponentItem totalLine) throws Exception { + // Auto-generated method stub + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(totalLine, totalLine.getLatestItemRevision(), null, null); + + AIFComponentContext[] children = topline.getChildren(); + for(AIFComponentContext context:children) { + TCComponentBOMLine component =(TCComponentBOMLine) context.getComponent(); //工厂 - 产线 + + AIFComponentContext[] children2 = component.getChildren(); + for(AIFComponentContext context2:children2) { + TCComponentBOMLine bzLine =(TCComponentBOMLine) context2.getComponent(); // 产线 - 班组 +// 获取班组名称 工位 存放map + String objName1 = bzLine.getStringProperty("bl_rev_object_name"); + + System.out.println("班组名称"+objName1); + Map gwLineMap=new HashMap(); + AIFComponentContext[] children3 = bzLine.getChildren(); + classMap.put(objName1, gwLineMap); + for(AIFComponentContext context3:children3) { + TCComponentBOMLine gwLine =(TCComponentBOMLine) context3.getComponent(); // 班组 - 工位 + TCComponentItemRevision itemRevision = gwLine.getItemRevision(); + + String objName = itemRevision.getStringProperty("object_name"); + + gwLineMap.put(objName, itemRevision); + + + } + } + } + + bomWindow.close(); + } + + private TCComponentItem getItemById(String itemId) throws Exception { + // Auto-generated method stub + String queryName = "Item ID"; + String[] keys = new String[]{getText(session, "ItemID")}; + String[] vals = new String[]{itemId}; + TCComponent[] res = query(session, queryName, keys, vals); + int len = res.length; + if (len == 0) { + return null; + } else if (len > 1) { + return (TCComponentItem) res[0]; + } else { + return (TCComponentItem) res[0]; + } + } + public static String getText(TCSession session, String str) throws Exception { + if (isEmpty(str)) { + return str; + } else { + String res = session.getTextService().getTextValue(str); + return !isEmpty(res) ? res : str; + } + }public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()); + } + + private String mlClassName; + private void createBopRevision(TCComponentBOMLine topline, TCComponentBOPLine bomline2) throws Exception { + // Auto-generated method stub + AIFComponentContext[] children = bomline2.getChildren(); + + for(AIFComponentContext context : children) { + TCComponentBOPLine component = (TCComponentBOPLine) context.getComponent(); + + TCComponentItem item = component.getItem(); + String type = item.getType(); + String objName = component.getStringProperty("bl_rev_object_name"); + + TCComponentBOMLine addLine = null; + if(type.equals("ML8_LineProcess")) { + addLine = createNewItemByType("ML8_ProcLine", topline,objName); + }else if(type.equals("ML8_StdProcess")){ + mlClassName = objName; + addLine = createNewItemByType("ML8_ProcClass", topline,objName); + }else if(type.equals("ML8_SpecProcess")){ +// mlClassName=objName; + addLine = createNewItemByType("ML8_ProcClass", topline,objName); + }else if(type.equals("ML8_StdOperation") || type.equals("ML8_DifOperation") || type.equals("ML8_SpecOp")){ + addLine = createNewItemByType("ML8_ProcStatn", topline, objName, "gx"); + + TCComponentItemRevision rev = addLine.getItemRevision(); + AIFComponentContext[] datas = component.getItemRevision().getChildren("ML8_3Dpdf"); + for(AIFComponentContext d : datas) { + InterfaceAIFComponent comp = d.getComponent(); + if(!(comp instanceof TCComponentDataset)) + continue; + rev.add("ML8_3Dpdf", (TCComponentDataset)comp); + } + }else if(type.endsWith("Step")) { +// 工步放到工位工艺下 + topline.add(item, component.getItemRevision(), null, false, ""); + } + if(addLine!=null) { + createBopRevision(addLine, component); + } + } +// topline.save(); + } + + private StringBuffer errorBuffer = new StringBuffer(); + + private TCComponentBOMLine createNewItemByType(String string, TCComponentBOMLine topline, String objName, String string2) throws Exception { + // Auto-generated method stub + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(string); + TCComponentItem item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), string, objName, "", null); + + TCComponentBOMLine addLine = topline.add(item, item.getLatestItemRevision(), null, false, ""); + + System.out.println("当前的工序名称 :"+objName+"当前装配工序名称 :"+mlClassName); + + if(classMap.containsKey(mlClassName)) { + + Map gwLineMap = classMap.get(mlClassName); + if(gwLineMap.containsKey(objName)) { + + System.out.println(objName+"产线下找到了对应的工位"); + + TCComponentItemRevision itemRev = gwLineMap.get(objName); + + TCComponentBOMLine add = addLine.add(itemRev.getItem(), itemRev, null, false, ""); +// bomLine.getStringProperty("bl_occ_type") + add.setStringProperty("bl_occ_type", "MEWorkArea"); + }else { + errorBuffer=errorBuffer.append("工序名称"); + errorBuffer=errorBuffer.append(objName); + errorBuffer=errorBuffer.append("没有找的匹配的工位\n"); + } + + }else { + errorBuffer=errorBuffer.append("工艺名称"); + errorBuffer=errorBuffer.append(mlClassName); + errorBuffer=errorBuffer.append("没有找的匹配的班组\n"); + } + + return addLine; + } + + private TCComponentBOMLine createNewItemByType(String string, TCComponentBOMLine topline, String objName) throws Exception { + // Auto-generated method stub + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent(string); + TCComponentItem item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), string, objName, "", null); + + TCComponentBOMLine addLine = topline.add(item, item.getLatestItemRevision(), null, false, ""); + + return addLine; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/Adapter.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/Adapter.java new file mode 100644 index 0000000..f949b9d --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/Adapter.java @@ -0,0 +1,299 @@ +package com.connor.ml.tcm.util; + +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.KeyStroke; + +/** + * Adapter 实现 JTables 中的复制粘贴 剪贴板功能。 适配器所用的剪贴板数据格式 与 Excel 所用的剪贴板格式兼容。这提供了 + * 支持的 JTables 和 Excel 间的互操作。 + */ +public class Adapter implements ActionListener { + private String rowstring, value; + private Clipboard system; + private StringSelection stsel; + private JTable jTable1; + private List> selectValue = new ArrayList>(); + + /** + * Excel 适配器由 JTable 构成, 它实现了 JTable 上的复制粘贴 功能,并充当剪贴板监听程序。 + */ + + public Adapter(JTable myJTable) { + jTable1 = myJTable; + KeyStroke copy = KeyStroke.getKeyStroke(KeyEvent.VK_C, + ActionEvent.CTRL_MASK, false); + + // 确定复制按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + KeyStroke paste = KeyStroke.getKeyStroke(KeyEvent.VK_V, + ActionEvent.CTRL_MASK, false); + + // 确定粘贴按键用户可以对其进行修改 + // 以实现其它按键组合的复制功能。 + + jTable1.registerKeyboardAction(this, "Copy", copy, + JComponent.WHEN_FOCUSED); + + jTable1.registerKeyboardAction(this, "Paste", paste, + JComponent.WHEN_FOCUSED); + + system = Toolkit.getDefaultToolkit().getSystemClipboard(); + } + + /** + * 此适配器运行图表的公共读方法。 + */ + public JTable getJTable() { + return jTable1; + } + + public void setJTable(JTable jTable1) { + this.jTable1 = jTable1; + } + + /** + * 在我们监听此实现的按键上激活这种方法。 此处,它监听复制和粘贴 ActionCommands。 包含不相邻单元格的选择导致选择无效, + * 而且此后复制动作无法执行。 粘贴的方法是将选定内容的左上角与 JTable 的当前选定内容的第一个元素对齐。 + */ + public void actionPerformed(ActionEvent e) { + if (e.getActionCommand().compareTo("Copy") == 0) { + StringBuffer sbf = new StringBuffer(); + + selectValue.clear(); + // 检查以确保我们仅选择了单元格的 + // 相邻块 + int numcols = jTable1.getSelectedColumnCount(); + int numrows = jTable1.getSelectedRowCount(); + int[] rowsselected = jTable1.getSelectedRows(); + int[] colsselected = jTable1.getSelectedColumns(); + +// if (!((numrows - 1 == rowsselected[rowsselected.length - 1] +// - rowsselected[0] && numrows == rowsselected.length) && (numcols - 1 == colsselected[colsselected.length - 1] +// - colsselected[0] && numcols == colsselected.length))) { +// JOptionPane.showMessageDialog(null, "Invalid Copy Selection", +// "Invalid Copy Selection", JOptionPane.ERROR_MESSAGE); +// +// return; +// } + + for (int i=0;i= 0) + { + sbf.append("\""); + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + sbf.append("\""); + } + else if(jTable1.getValueAt(rowsselected[i],colsselected[j]) == null) + { + sbf.append(""); + } + else + { + sbf.append(jTable1.getValueAt(rowsselected[i],colsselected[j])); + } + if (j= 0) + { + sb.append(values[i].replace("\n", " $")); + } + else + { + sb.append(values[i]); + } + //System.out.println(i+s[i]); + } + System.out.println("sb======"+sb.toString()); + String copyValue = sb.toString(); + String[] st1=copyValue.split("\\$"); //new StringTokenizer(sb.toString(),"$".toString()); + + + + int[] rows = jTable1.getSelectedRows(); + int[] columns = jTable1.getSelectedColumns(); + int startRow = rows[0]; + int startCol = columns[0]; + if(rows.length ==1 ) + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[k]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],startCol+k); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],startCol); + } + //} + //} + } + } + else //写入选中行内容 + { + for(int i=0;i= 0) + { + String[] cellValue = rowstring.split("\t"); + for(int j=0;j st1.length) + { + for (int i = 0; i < rows.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),rows[i],columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),rows[i],columns[j]); + } + } + } + } + else + { + for (int i = 0; i < st1.length; i++) { + for (int j = 0; j < columns.length; j++) { + rowstring=st1[(i+st1.length)%st1.length]; + System.out.println("rowstring============"+rowstring); + if(rowstring.indexOf("\t") >= 0) + { + String[] cellValue = rowstring.split("\t"); + for (int k = 0; k < cellValue.length; k++) { + value=(String)cellValue[(j+cellValue.length)%cellValue.length]; + System.out.println("value============"+value); + jTable1.setValueAt(value.trim(),startRow+i,columns[j]); + System.out.println("Putting "+ value+"atrow="+startRow+i+"column="+startCol+k); + } + } + else + { + jTable1.setValueAt(rowstring.trim(),startRow+i,columns[j]); + } + } + } + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + } + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/BigDecimalUtils.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/BigDecimalUtils.java new file mode 100644 index 0000000..79049aa --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/BigDecimalUtils.java @@ -0,0 +1,144 @@ +package com.connor.ml.tcm.util; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.NumberFormat; + +public class BigDecimalUtils { + + public static final int MONEY_POINT = 2; // 货币保留两位小数 + + /** + * 格式化精度 + * + * @param v + * @param point + * 小数位数 + * @return double + */ + @SuppressWarnings("deprecation") + public static Double format(double v, int point) { + BigDecimal b = new BigDecimal(v); + return b.setScale(point, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * + * @param v + * @param point + * @return + */ + public static Double formatRoundUp(double v, int point) { + NumberFormat nf = NumberFormat.getInstance(); + nf.setRoundingMode(RoundingMode.HALF_UP);// 设置四舍五入 + nf.setMinimumFractionDigits(point);// 设置最小保留几位小数 + nf.setMaximumFractionDigits(point);// 设置最大保留几位小数 + return Double.valueOf(nf.format(v)); + } + + /** + * 格式化金额。带千位符 + * + * @param v + * @return + */ + public static String moneyFormat(Double v) { + DecimalFormat formater = new DecimalFormat(); + formater.setMaximumFractionDigits(2); + formater.setGroupingSize(3); + formater.setRoundingMode(RoundingMode.FLOOR); + return formater.format(v.doubleValue()); + } + + /** + * 带小数的显示小数。不带小数的显示整数 + * @param d + * @return + */ + public static String doubleTrans(Double d) { + if (Math.round(d) - d == 0) { + return String.valueOf((long) d.doubleValue()); + } + return String.valueOf(d); + } + + /** + * BigDecimal 相加 + * + * @param v1 + * @param v2 + * @return double + */ + public static Double add(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.add(n2).doubleValue(); + } + + /** + * BigDecimal 相减 + * + * @param v1 + * @param v2 + * @return double + */ + public static Double subtract(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.subtract(n2).doubleValue(); + } + + /** + * BigDecimal 相乘 + * + * @param v1 + * @param v2 + * @return double + */ + public static Double multiply(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.multiply(n2).doubleValue(); + } + + /** + * BigDecimal 相除 + * + * @param v1 + * @param v2 + * @return double + */ + @SuppressWarnings("deprecation") + public static Double divide(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.divide(n2, 10, BigDecimal.ROUND_HALF_UP).doubleValue(); + } + + /** + * 比较大小 小于0:v1 < v2 大于0:v1 > v2 等于0:v1 = v2 + * + * @param v1 + * @param v2 + * @return + */ + public static int compare(double v1, double v2) { + BigDecimal n1 = new BigDecimal(Double.toString(v1)); + BigDecimal n2 = new BigDecimal(Double.toString(v2)); + return n1.compareTo(n2); + } + + /** + * + * @param args + */ + public static void main(String[] args) { + // System.out.println(divide(1, 8)); + // System.out.println(format(multiply(3.55, 2.44),2)); + // System.out.println(divide(1.0, 3.0)); + // System.out.println(add(2.79, -3.0)); + System.out.println(doubleTrans(10000.0)); + } + +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ClassProperty.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ClassProperty.java new file mode 100644 index 0000000..0265bbd --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ClassProperty.java @@ -0,0 +1,42 @@ +package com.connor.ml.tcm.util; + +/** + * @copyRight 浙江康勒科技有限公司 + * @author 作者 E-mail:hub@connor.net.cn + * @date 创建时间:2017-7-3 下午11:47:03 + * @version v1.0 + * @parameter + * @since + * @return + */ + +public class ClassProperty { + private int propertyID; + private String value; + + public ClassProperty() { + + } + + public ClassProperty(int propertyID, String value) { + this.propertyID = propertyID; + this.value = value; + } + + public int getPropertyID() { + return propertyID; + } + + public void setPropertyID(int propertyID) { + this.propertyID = propertyID; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/CreateItemDialog.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/CreateItemDialog.java new file mode 100644 index 0000000..3cbd4da --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/CreateItemDialog.java @@ -0,0 +1,1231 @@ +package com.connor.ml.tcm.util; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.BorderFactory; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTabbedPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.border.TitledBorder; +import javax.swing.table.DefaultTableModel; + +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; + +import com.connor.ml.tcm.bean.CreatePropBean; +import com.connor.ml.tcm.bean.ItemBean; +import com.connor.ml.tcm.bean.PropExplictBean; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentFormType; +import com.teamcenter.rac.kernel.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.TCComponentType; +import com.teamcenter.rac.kernel.TCComponentUnitOfMeasure; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.ui.common.RACUIUtil; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.services.rac.core.LOVService; +import com.teamcenter.services.rac.core._2013_05.LOV.InitialLovData; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVSearchResults; +import com.teamcenter.services.rac.core._2013_05.LOV.LOVValueRow; +import com.teamcenter.services.rac.core._2013_05.LOV.LovFilterData; + +public class CreateItemDialog extends AbstractAIFDialog implements + ActionListener { + private final String CUST_DELE_TYPE_PROP = "Cust_Del_Type_Props"; + private final String CUST_MODEL_AREA = "CUST_Model_Area"; + // private final String CUST_MODEL_AREA_TJ_NBTM = "CUST_Model_Area_TJ_NBTM"; + private JLabel newItemIDLabel; + private JLabel newItemRevIDLabel; + private JLabel newItemNameLabel; + private JLabel oldItemIDLabel; + private JLabel oldItemRevIDLabel; + private JLabel oldItemNameLabel; + private JLabel itemTypeLabel; + private JLabel itemUnitLabel; + + protected JTextField newItemIDText; + protected JTextField newItemRevIDText; + // protected JTextField newItemNameText; + protected JComboBox newItemNameText; + protected JTextField oldItemIDText; + protected JTextField oldItemRevIDText; + protected JTextField oldItemNameText; + protected JTextField itemTypeText; + protected JTextField itemUnitText; + + protected JButton okButton; + protected JButton celButton; + // 属性页面 + // protected JTable itemPropTable;// item属性table + // protected JTable itemFormPropTable;// itemform的属性table + // protected JTable revPropTable;// rev的属性table + // protected JTable revFormPropTable;// revform的属性table + protected List itemPropTable; + protected List itemFormPropTable; + protected List revPropTable; + protected List revFormPropTable; + + protected List itemPropList;// item属性列表 + protected List itemFormPropList;// itemform属性列表 + protected List revPropList;// 版本属性列表 + protected List revFormPropList;// 版本表单属性列表 + private DefaultTableModel dtm; + + private JPanel firstPanel; + private JPanel secondPanel; + private JPanel rootPanel; + + // ---需要用到的变量 + protected TCSession session; + protected AbstractAIFUIApplication app; + protected String title; + protected List itemList; + //protected List itemListMsgBean; + private String specCode; + //private Integer operateCode; + private ItemBean newItemBean; + private int index = 1; + private TCComponentFolder newStuffFolder; + //private TCComponentFolder parentFolder; + private List explictBeanList; + + // private List folderList; + + private HashMap> custDeleTypeProp; + + private HashMap nameValueMap; + private boolean DEBUG = true; + private String[] itemNames; + + private String itemType; + + public List bomList = new ArrayList(); + + + /** + * 获取上次创建此类型的时候设置的属性 + * + * @param compType + */ + private void getNameValueMap(String compType) { + nameValueMap = new HashMap<>(); + nameValueMap.put("tm2_material", ""); + nameValueMap.put("tm2_press_drawing", ""); + nameValueMap.put("tm2_mb", ""); + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + if (!file.exists()) { + return; + } + try { + FileReader reader = new FileReader(file); + + BufferedReader br = new BufferedReader(reader); + + String info = br.readLine(); + if (info != null) { + String[] values = info.split("\\|"); + if (values == null || values.length != 3) { + return; + } + for (int i = 0; i < values.length; i++) { + String[] nameValues = values[i].split("="); + if (nameValues == null || nameValues.length != 2) { + continue; + } + + if (nameValueMap.containsKey(nameValues[0])) { + nameValueMap.remove(nameValues[0]); + nameValueMap.put(nameValues[0], nameValues[1]); + } + } + + } + br.close(); + reader.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + private void setNameValueMap(String compType) { + String path = System.getenv("TEMP"); + String fileFullPath = path + "\\" + compType + "_PropValue.info"; + File file = new File(fileFullPath); + // if (!file.exists()) { + // return; + // } + + try { + FileWriter write = new FileWriter(file); + BufferedWriter bw = new BufferedWriter(write); + StringBuffer sb = new StringBuffer(); + + if (nameValueMap.containsKey("tm2_material")) { + sb.append("tm2_material"); + sb.append("="); + sb.append(nameValueMap.get("tm2_material")).append("|"); + } + if (nameValueMap.containsKey("tm2_press_drawing")) { + sb.append("tm2_press_drawing"); + sb.append("="); + sb.append(nameValueMap.get("tm2_press_drawing")).append("|"); + } + if (nameValueMap.containsKey("tm2_mb")) { + sb.append("tm2_mb"); + sb.append("="); + sb.append(nameValueMap.get("tm2_mb")); + + } + + bw.write(sb.toString()); + bw.close(); + write.close(); + } catch (IOException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + + } + + /** + * 获取需要隐藏的属性 + */ + private void getCustDeleTypeProp() { + custDeleTypeProp = new HashMap<>(); + TCPreferenceService service = this.session.getPreferenceService(); + String[] props = service.getStringArray( + TCPreferenceService.TC_preference_site, CUST_DELE_TYPE_PROP); + if (props != null) { + for (int i = 0; i < props.length; i++) { + String[] subStrs = props[i].split("\\:"); + if (subStrs == null || subStrs.length != 2) { + continue; + } + String[] propSubStrs = subStrs[1].split("\\/"); + if (propSubStrs == null || propSubStrs.length <= 0) { + continue; + } + custDeleTypeProp.put(subStrs[0], Arrays.asList(propSubStrs)); + } + } + } + + public CreateItemDialog(TCSession session, + AbstractAIFUIApplication app, String title, + List itemList, String specCode, String itemType) { + super(false); + this.app = app; + this.session = session; + this.title = title; + this.itemList = itemList; + this.specCode = specCode; + this.itemType = itemType; + //this.operateCode = operateCode; + this.newItemBean = new ItemBean(); + // this.folderList = new ArrayList<>(); + getCustDeleTypeProp(); + // 获取选取的ITEM的目标的信息 + //this.itemListMsgBean = MethodUtil.getTargetsMsg(itemList); + // 过滤掉所有不需要显示的属性 + this.explictBeanList = MethodUtil.getExplictPropList(this.session); + getItemName(); + init(); + try { + getItemInfo(0); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取信息 + * @throws TCException + */ + public void getItemInfo(int index) throws TCException { + + //ItemBean bean = null; +// if (itemListMsgBean != null && itemListMsgBean.size() != 0) +// bean = this.itemListMsgBean.get(index); +// else { +// this.dispose(); +// MessageBox.post("没有选取ITEM对象,请选择后执行此操作", "错误", MessageBox.ERROR); +// return; +// } + //this.parentFolder = bean.getFolder(); + this.oldItemIDText.setText(""); + this.oldItemNameText.setText(""); + // TCComponentItemType itemType = null; + + this.itemTypeText.setText(this.itemType); + this.newItemBean.setType(this.itemType); + getNameValueMap(this.itemType); + this.itemUnitText.setText(""); + // 获取ITEMID + TCComponentItemType itemType = (TCComponentItemType) this.session.getTypeComponent(this.itemType); + String newCode = itemType.getNewID(); + this.newItemIDText.setText(newCode); + this.newItemRevIDText.setText("00"); + this.newItemBean.setRevID("00"); + this.newItemNameText.setSelectedItem(""); + // this.newItemNameText.setText(bean.getName()); + } + + private void getItemName() { + TCPreferenceService service = this.session.getPreferenceService(); + String morderName = ""; +// switch (this.operateCode) { +// case FinalUtil.PRODUCT_CODE: +// morderName = FinalUtil.PRODUCT_ITEM_NAMES; +// break; +// default: +// break; +// } + if (morderName != null) { + String[] props = service.getStringArray( + TCPreferenceService.TC_preference_site, morderName); + if (props != null && props.length > 0) { + this.itemNames = props; + } else { + this.itemNames = new String[] { "" }; + } + } else { + MessageBox.post("未找到对象所对应的ITEM_NAME首选项!", "错误!", MessageBox.ERROR); + } + } + + /** + * 获取属性信息 + * + * @param itemType + * @throws TCException + */ + public void getPropMsg(String itemType) throws TCException { + this.itemPropList = new ArrayList<>(); + this.itemFormPropList = new ArrayList<>(); + this.revPropList = new ArrayList<>(); + this.revFormPropList = new ArrayList<>(); + String startStr = "ml8"; + TCComponentType type = null; + + List explictList = new ArrayList<>(); + +// type = this.session.getTypeComponent(itemType + "RevisionMaster"); +// explictList.clear(); +// for (PropExplictBean explictBean : this.explictBeanList) { +// if (explictBean.getType().equals(itemType + "RevisionMaster")) { +// explictList = explictBean.getPropList(); +// continue; +// } +// } +// if (type != null && type instanceof TCComponentFormType) { +// TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); +// for (TCPropertyDescriptor desc : descs) { +// if (desc.getName().startsWith(startStr) && desc.isModifiable() +// && desc.isDisplayable()) { +// if (custDeleTypeProp.containsKey(itemType +// + "RevisionMaster")) { +// if (custDeleTypeProp.get(itemType + "RevisionMaster") +// .contains(desc.getName())) { +// continue; +// } +// } +// if (explictList != null +// && explictList.contains(desc.getName())) { +// continue; +// } +// CreatePropBean bean = new CreatePropBean(); +// bean.setDescriptor(desc); +// bean.setDisplayName(desc.getDisplayName()); +// bean.setName(desc.getName()); +// this.revFormPropList.add(bean); +// } +// } +// } else { +// System.out.println("不是revMaster类型"); +// // return; +// } +// +// +// + + type = this.session.getTypeComponent(itemType); + explictList.clear(); + for (PropExplictBean explictBean : this.explictBeanList) { + if (explictBean.getType().equals(itemType)) { + explictList = explictBean.getPropList(); + continue; + } + } + if (type != null && type instanceof TCComponentItemType) { + TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + for (TCPropertyDescriptor desc : descs) { + if (desc.getName().startsWith(startStr) && desc.isModifiable() + && desc.isDisplayable()) { + if (custDeleTypeProp.containsKey(itemType)) { + if (custDeleTypeProp.get(itemType) + .contains(desc.getName())) { + continue; + } + } + if (explictList != null + && explictList.contains(desc.getName())) { + continue; + } + CreatePropBean bean = new CreatePropBean(); + bean.setDescriptor(desc); + bean.setDisplayName(desc.getDisplayName()); + bean.setName(desc.getName()); + this.itemPropList.add(bean); + } + } + } else { + System.out.println("不是对象类型"); + // return; + } + + type = this.session.getTypeComponent(itemType + "Revision"); + explictList.clear(); + for (PropExplictBean explictBean : this.explictBeanList) { + if (explictBean.getType().equals(itemType + "Revision")) { + explictList = explictBean.getPropList(); + continue; + } + } + if (type != null && type instanceof TCComponentItemRevisionType) { + TCPropertyDescriptor[] descs = type.getPropertyDescriptors(); + for (TCPropertyDescriptor desc : descs) { + if (desc.getName().startsWith(startStr) && desc.isModifiable() + && desc.isDisplayable()) { + if (custDeleTypeProp.containsKey(itemType + + "Revision")) { + if (custDeleTypeProp.get(itemType + "Revision") + .contains(desc.getName())) { + continue; + } + } + if (explictList != null + && explictList.contains(desc.getName())) { + continue; + } + CreatePropBean bean = new CreatePropBean(); + bean.setDescriptor(desc); + bean.setDisplayName(desc.getDisplayName()); + bean.setName(desc.getName()); + this.revPropList.add(bean); + } + } + } else { + System.out.println("不是版本类型"); + // return; + } + + + } + + /** + * 界面初始化 + */ + public void init() { + try { + newStuffFolder = session.getUser().getNewStuffFolder(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + this.setTitle(this.title); + this.setAutoRequestFocus(true); + this.setPreferredSize(new Dimension(530, 400)); + this.newItemIDLabel = new JLabel("新零组件ID"); + this.newItemRevIDLabel = new JLabel("版本ID"); + this.newItemNameLabel = new JLabel("名称"); + this.oldItemIDLabel = new JLabel("旧零组件ID"); + this.oldItemRevIDLabel = new JLabel("版本ID"); + this.oldItemNameLabel = new JLabel("名称"); + this.newItemIDText = new JTextField(20); + // this.newItemIDText.setEditable(false); + this.newItemRevIDText = new JTextField(6); + this.newItemRevIDText.setEnabled(false); + this.newItemNameText = new JAutoCompleteComboBox( + new DefaultComboBoxModel(itemNames)); + // this.newItemNameText = new JTextField(32); + this.oldItemIDText = new JTextField(20); + this.oldItemIDText.setEnabled(false); + this.oldItemRevIDText = new JTextField(6); + this.oldItemRevIDText.setEnabled(false); + this.oldItemNameText = new JTextField(32); + this.oldItemNameText.setEnabled(false); + this.okButton = new JButton("确定"); + this.okButton.addActionListener(this); + this.celButton = new JButton("取消"); + this.celButton.addActionListener(this); + // ------------------------------ + this.itemTypeLabel = new JLabel("类型"); + this.itemTypeText = new JTextField(12); + this.itemTypeText.setEditable(false); + this.itemTypeText.setText("类型"); + this.itemUnitLabel = new JLabel("单位"); + this.itemUnitText = new JTextField(12); + this.itemUnitText.setEnabled(false); + this.itemUnitText.setText("单位"); + + // PropertyLayout layout = new PropertyLayout(); + + // 添加显示 + JPanel newItemMsgPanel = new JPanel(new PropertyLayout()); + newItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), "新零件信息")); + newItemMsgPanel.add("1.1.left.top.preferred.preferred", newItemIDLabel); + newItemMsgPanel.add("1.2.left.top.preferred.preferred", + newItemRevIDLabel); + newItemMsgPanel.add("1.3.left.top.preferred.preferred", + newItemNameLabel); + // 添加输入 + newItemMsgPanel.add("2.1.left.top.preferred.preferred", newItemIDText); + newItemMsgPanel.add("2.2.left.top.preferred.preferred", + newItemRevIDText); + newItemMsgPanel + .add("2.3.left.top.preferred.preferred", newItemNameText); + JPanel typeAndUnitPanel = new JPanel(new PropertyLayout()); + // .setBorder(new TitledBorder(BorderFactory.createEtchedBorder(),"")); + typeAndUnitPanel.add("1.1.left.top.preferred.preferred", itemTypeLabel); + typeAndUnitPanel.add("1.2.left.top.preferred.preferred", itemTypeText); + typeAndUnitPanel.add("2.1.left.top.preferred.preferred", itemUnitLabel); + typeAndUnitPanel.add("2.2.left.top.preferred.preferred", itemUnitText); + // 添加显示 + JPanel oldItemMsgPanel = new JPanel(new PropertyLayout()); + oldItemMsgPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), "基于")); + oldItemMsgPanel.add("1.1.left.top.preferred.preferred", oldItemIDLabel); + oldItemMsgPanel.add("1.2.left.top.preferred.preferred", + oldItemRevIDLabel); + oldItemMsgPanel.add("1.3.left.top.preferred.preferred", + oldItemNameLabel); + // 添加输入 + oldItemMsgPanel.add("2.1.left.top.preferred.preferred", oldItemIDText); + oldItemMsgPanel.add("2.2.left.top.preferred.preferred", + oldItemRevIDText); + oldItemMsgPanel + .add("2.3.left.top.preferred.preferred", oldItemNameText); + // 动作 + this.secondPanel = new JPanel(new FlowLayout()); + this.secondPanel.add(okButton); + this.secondPanel.add(new JLabel(" ")); + this.secondPanel.add(celButton); + this.firstPanel = new JPanel(new PropertyLayout()); + this.firstPanel + .add("1.1.left.top.preferred.preferred", newItemMsgPanel); + this.firstPanel.add("2.1.left.top.preferred.preferred", + typeAndUnitPanel); + this.firstPanel + .add("3.1.left.top.preferred.preferred", oldItemMsgPanel); + // 属性页面------------------------------------------------------------ + getNameValueMap(this.itemType); + try { + getPropMsg(this.itemType); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + JPanel propPanel = new JPanel(new PropertyLayout()); + int propIndex = 1; + if (this.itemPropList != null && this.itemPropList.size() != 0) { + this.itemPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemPropList, this.itemPropTable, + propIndex, "对象属性"); + propIndex++; + } + if (this.itemFormPropList != null && this.itemFormPropList.size() != 0) { + this.itemFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.itemFormPropList, + this.itemFormPropTable, propIndex, "对象表单属性"); + propIndex++; + } + if (this.revPropList != null && this.revPropList.size() != 0) { + this.revPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revPropList, this.revPropTable, + propIndex, "版本属性"); + propIndex++; + } + if (this.revFormPropList != null && this.revFormPropList.size() != 0) { + // + this.revFormPropTable = new ArrayList<>(); + setPropPanel(propPanel, this.revFormPropList, + this.revFormPropTable, propIndex, "版本表单属性"); + propIndex++; + System.out.println("revFormPropTable count =" + + revFormPropTable.size()); + } + + // 添加页面 + JTabbedPane tabPane = new JTabbedPane(); + tabPane.add("零组件信息", firstPanel); + tabPane.add("属性", new JScrollPane(propPanel)); + + // 布局 + this.rootPanel = new JPanel(new BorderLayout()); + this.rootPanel.add(tabPane, BorderLayout.CENTER); + this.rootPanel.add(secondPanel, BorderLayout.SOUTH); + + this.add(rootPanel, "Center"); + this.pack(); + this.centerToScreen(); + this.showDialog(); + } + + /** + * 设置属性界面 + * + * @param propPanel + * @param beanList + * @param compList + * @param propIndex + */ + private void setPropPanel(JPanel propPanel, + List beanList, List compList, + int propIndex, String name) { + + JPanel itemPorpPanel = new JPanel(new PropertyLayout()); + itemPorpPanel.setBorder(new TitledBorder(BorderFactory + .createEtchedBorder(), name)); + + // //////////////////////////////////////////// + // compList = new ArrayList<>(); + String currentGroupName = null; + try { + currentGroupName = session.getCurrentGroup().getFullName(); + } catch (TCException e) { + // TODO Auto-generated catch block + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + } + + int indexx = currentGroupName.lastIndexOf("."); + // 获取当前组标识 + String groupName = currentGroupName.substring(indexx + 1, + currentGroupName.length()); + // 获取定义的组首选项和 +// String[] lovValue = session.getPreferenceService().getStringArray( +// TCPreferenceService.TC_preference_site, CUST_MODEL_AREA); +// if (null == lovValue || lovValue.length <= 0) { +// System.out.println("没有首选项" + CUST_MODEL_AREA); +// MessageBox.post("缺少首选项" + CUST_MODEL_AREA + ",请联系管理员", "错误", +// MessageBox.ERROR); +// return; +// } + // 获取到所有的定义 + Map groupLoV = new HashMap(); + // 装载 +// for (String string : lovValue) { +// String[] sp = string.split(":"); +// String group = sp[0]; +// String model = sp[1]; +// String[] x = model.split("-"); +// groupLoV.put(group, x); +// } + + for (int i = 0; i < beanList.size(); i++) { + JLabel disNameLabel = new JLabel(beanList.get(i).getDisplayName()); + String defaultValueInfo = null; + if (this.nameValueMap.containsKey(beanList.get(i).getName())) { + defaultValueInfo = this.nameValueMap.get(beanList.get(i) + .getName()); + } else { + defaultValueInfo = null; + } + TCPropertyDescriptor desc = beanList.get(i).getDescriptor(); + JComponent valueComp = null; + TCComponentListOfValues lobList = desc.getLOV(); + + if (lobList != null) { + //box.owner.setPropName(desc.getName()); + try { + // 获取LOV-------------------- + String[] valuesList; + String[] disValuesList = null; + + int index = -1; + if (lobList != null) { + + if("Fnd0ListOfValuesDynamic".equals(lobList.getProperty("lov_type"))) { + LOVService lovService = LOVService.getService(RACUIUtil.getTCSession()); + InitialLovData input = new InitialLovData(); + LovFilterData filter = new LovFilterData(); + filter.sortPropertyName = "object_name"; //lov的后台值 + filter.order = 1; + filter.numberToReturn = 10000; + filter.maxResults = 10000; + + + input.lov = lobList; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + + valuesList = new String[result.lovValues.length + 1]; + disValuesList = new String[result.lovValues.length + 1]; + valuesList[0] = ""; + disValuesList[0] = ""; + for (int j = 0; j < result.lovValues.length; j++) { + Map map = result.lovValues[j].propDisplayValues; + String disval=""; + String key1="object_name";//显示值第一列 + if (map.containsKey(key1)) { + disval=map.get(key1)[0]; + } + if (!disval.equals("")) { + valuesList[j + 1] = disval; + disValuesList[j + 1] = disval; + } + index = j; + } + } + else + { + //TCComponentUnitOfMeasure + ListOfValuesInfo info = lobList.getListOfValues(); + Object[] objectValues = info.getListOfValues();//.getStringListOfValues(); + valuesList = new String[objectValues.length + 1]; + disValuesList = new String[objectValues.length + 1]; + valuesList[0] = ""; + disValuesList[0] = ""; + for (int j = 0; j < objectValues.length; j++) { + if(objectValues[j] instanceof String) + { + valuesList[j] = objectValues[j].toString(); + } + else if(objectValues[j] instanceof TCComponentUnitOfMeasure) + { + TCComponentUnitOfMeasure componentUnitOfMeasure = (TCComponentUnitOfMeasure) objectValues[j]; + valuesList[j] = componentUnitOfMeasure.toDisplayString(); + } + String disPlayv = info.getDisplayableValue(valuesList[j]); + disValuesList[j] = disPlayv; + + index = j; + } + } + } + +// ListOfValuesInfo info = lobList.getListOfValues(); +// String[] valuesList; +// String[] disValuesList = null; +// if (groupLoV.containsKey(groupName) +// && "TM2_mb_lov".equals(info.toString())) { +// // 应该从首选项中获取 +// valuesList = groupLoV.get(groupName); +// disValuesList = new String[valuesList.length + 1]; +// +// } else { +// valuesList = info.getStringListOfValues(); +// disValuesList = new String[valuesList.length + 1]; +// } +// if (DEBUG) { +// for (String string : valuesList) { +// System.out.print(string + "\t"); +// } +// } +// disValuesList[0] = ""; +// box.setValues(valuesList); +// for (int w = 1; w < disValuesList.length; w++) { +// disValuesList[w] = info +// .getDisplayableValue(valuesList[w - 1]); +// if (defaultValueInfo != null +// && defaultValueInfo.equals(valuesList[w - 1])) { +// index = w; +// } +// } + JAutoCompleteComboBox box = new JAutoCompleteComboBox(new DefaultComboBoxModel(disValuesList)); + box.setEditable(true); + + //box.setModel(new DefaultComboBoxModel(disValuesList)); + if (index != -1) { + box.setSelectedIndex(0); + } else if (null == disValuesList || index == -1) { + box.getModel().setSelectedItem(""); + } else { + box.getModel().setSelectedItem(defaultValueInfo); + } + valueComp = box; + } catch (TCException e) { + MessageBox.post(e.toString(), "错误", MessageBox.ERROR); + e.printStackTrace(); + // box.setModel(new DefaultComboBoxModel(new String[] { "" + // })); + } + } else { + // JTextField fied = new JTextField(12); + MyJTextfield valueText = new MyJTextfield(32); + valueText.setText(beanList.get(i).getDescriptor() + .getDefaultValue()); + valueText.setPropName(beanList.get(i).getName()); + valueComp = valueText; + if (defaultValueInfo != null) { + valueText.setText(defaultValueInfo); + } + + } + + itemPorpPanel.add((i + 1) + ".1.left.top.preferred.preferred", + disNameLabel); + itemPorpPanel.add((i + 1) + ".2.left.top.preferred.preferred", + valueComp); + compList.add(valueComp); + } + propPanel.add(propIndex + ".1.left.top.preferred.preferred", + itemPorpPanel); + } + + /** + * 设置combox控件 + * + * @author hub + * + */ + + private class MyJCombox extends JComboBox { + private String[] values; + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + public String[] getValues() { + return values; + } + + public void setValues(String[] values) { + this.values = values; + } + + } + + /** + * + * @author hub + * + */ + private class MyJTextfield extends JTextField { + + public MyJTextfield(int len) { + super(len); + } + + private String propName; + + public String getPropName() { + return propName; + } + + public void setPropName(String propName) { + this.propName = propName; + } + + } + + /** + * JTABLE通用方法 + * + * @param partsTable + * @param titleNames + * @return + */ + public JTable getjTable(JTable partsTable, DefaultTableModel dtm, + Object[] titleNames, Object[][] values) { + int simpleLen = 105; + int totleLen = 900; + if (partsTable == null) { + partsTable = new JTable(getTableModel(dtm, titleNames, values)) { + public boolean isCellEditable(int row, int column) { + return false; + } + }; + + if (simpleLen * titleNames.length >= totleLen) { + for (int i = 0; i < titleNames.length; i++) { + partsTable.getColumnModel().getColumn(i) + .setPreferredWidth(105); + } + partsTable.setAutoResizeMode(0); + } else { + partsTable.setAutoResizeMode(1); + } + } + return partsTable; + } + + /** + * 设置table控件 + * + * @param dtm + * @param columNameObjects + * @param objects + * @return + */ + public DefaultTableModel getTableModel(DefaultTableModel dtm, + Object[] columNameObjects, Object[][] objects) { + // Object[] columNameObjects = this.titleNames; //// , + // Object[][] objects = getValues(this.valueLists); + if (dtm == null) { + dtm = new DefaultTableModel(objects, columNameObjects); + } + return dtm; + } + + /** + * 将属性转换为MAP + * + * @param listBean + * @return + */ + public HashMap getValues(List listBean) { + HashMap valueMap = null; + if (listBean != null && listBean.size() > 0) { + valueMap = new HashMap<>(); + for (int i = 0; i < listBean.size(); i++) { + JComponent bean = listBean.get(i); + if (bean instanceof MyJTextfield) { + + valueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + if (nameValueMap.containsKey(((MyJTextfield) bean) + .getPropName())) { + nameValueMap + .remove(((MyJTextfield) bean).getPropName()); + nameValueMap.put(((MyJTextfield) bean).getPropName(), + ((MyJTextfield) bean).getText()); + } + System.out.println(" ((MyJTextfield) bean).getPropName() =" + + ((MyJTextfield) bean).getPropName() + " | " + + "((MyJTextfield) bean).getText()" + + ((MyJTextfield) bean).getText()); + } else if (bean instanceof MyJCombox) { + + if (((MyJCombox) bean).getSelectedIndex() == -1) { + valueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel().getSelectedItem() + .toString()); + System.out.println(" tip text " + + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap.put(((MyJCombox) bean).getPropName(), + ((MyJCombox) bean).getModel() + .getSelectedItem().toString()); + } + } else { + + valueMap.put( + ((MyJCombox) bean).getPropName(), + (((MyJCombox) bean).getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean).getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + if (nameValueMap.containsKey(((MyJCombox) bean) + .getPropName())) { + nameValueMap.remove(((MyJCombox) bean) + .getPropName()); + nameValueMap + .put(((MyJCombox) bean).getPropName(), + (((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1]); + } + System.out + .println(" 123=" + + ((((MyJCombox) bean) + .getSelectedIndex() == 0) ? "" + : ((MyJCombox) bean) + .getValues()[((MyJCombox) bean) + .getSelectedIndex() - 1])); + } + + /* + * System.out .println((((MyJCombox) + * bean).getSelectedIndex() == -1 || ((MyJCombox) bean) + * .getSelectedIndex() == 0) ? ((MyJCombox) bean) + * .getToolTipText() : ((MyJCombox) bean) + * .getValues()[((MyJCombox) bean) .getSelectedIndex() - + * 1]); + */ + /* + * System.out .println("((MyJCombox) bean).getPropName() =" + * + ((MyJCombox) bean).getPropName() + " | " + + * "((MyJCombox) bean).getValues()[((MyJCombox) bean).getSelectedIndex()] =" + * + ((MyJCombox) bean).getValues()[((MyJCombox) bean) + * .getSelectedIndex()]); + */ + } + + } + } + + return valueMap; + + } + + private TCUserService userservice; + + public void setByPass(boolean val) throws TCException { + if (userservice == null) { + userservice = this.session.getUserService(); + } + Object[] obj = new Object[1]; + obj[0] = "origin"; + if (val) { + userservice.call("ORIGIN_set_bypass", obj); + } else { + userservice.call("ORIGIN_close_bypass", obj); + } + } + + /** + * 重新创建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItem item, + ArrayList itemlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(item, + item.getLatestItemRevision(), null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItem n_item : itemlists) { + TCComponentItemRevision revision = n_item.getLatestItemRevision(); + topline.add(n_item, revision, null, false, ""); + } + bomWindow.unlock(); + bomWindow.save(); + } + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + Object obj = e.getSource(); + if (obj.equals(this.okButton)) { + + TCComponentItem item = MethodUtil.createNewItemSoa( + this.session, this.newItemIDText.getText(), + this.newItemRevIDText.getText(), + this.newItemBean.getType(), this.newItemNameText.getSelectedItem().toString(), "", this.newItemBean + .getUnit(), getValues(itemPropTable), + getValues(revPropTable), getValues(revFormPropTable)); + + if (item != null) { + + if(this.bomList != null && bomList.size() > 0) + { + try { + TCComponentItemType componentItemType = (TCComponentItemType) session + .getTypeComponent("Item"); + //搭建BOM + ArrayList itemRevisions = new ArrayList(); + for (int i = 0; i < bomList.size(); i++) { + TCComponentItem componentItem = componentItemType.find(bomList.get(i)); + itemRevisions.add(componentItem.getLatestItemRevision()); + } + recreateBom(item.getLatestItemRevision(), itemRevisions, true); + } catch (Exception e2) { + // TODO: handle exception + e2.printStackTrace(); + } + } + + setNameValueMap(this.newItemBean.getType()); + //String msg = new String(); + this.rootPanel.setBackground(Color.GREEN); + MessageBox.post( + "创建对象[item_id= " + + this.newItemIDText.getText() + + " / rev =" + + this.newItemRevIDText.getText() + + " / name= " + + this.newItemNameText.getSelectedItem() + .toString() + "]成功", "成功,", + MessageBox.INFORMATION); +// if (msg != null && !msg.equals("")) { +// this.rootPanel.setBackground(Color.GREEN); +// MessageBox.post( +// "创建对象[item_id= " +// + this.newItemIDText.getText() +// + " / rev =" +// + this.newItemRevIDText.getText() +// + " / name= " +// + this.newItemNameText.getSelectedItem() +// .toString() + "]成功", "成功," + msg, +// MessageBox.INFORMATION); +// +// } + // 获取ITEMID + String newCode = ""; + this.newItemIDText.setText(newCode); + } else { + System.out.println("创建对象[item_id= " + + this.newItemIDText.getText() + " / rev =" + + this.newItemRevIDText.getText() + " / name= " + + this.newItemNameText.getSelectedItem().toString() + + "]失败"); + this.rootPanel.setBackground(Color.RED); +// MessageBox.post("创建对象[item_id= " + this.newItemIDText.getText() +// + " / rev =" + this.newItemRevIDText.getText() +// + " / name= " +// + this.newItemNameText.getSelectedItem().toString() +// + "]失败", "错误", MessageBox.ERROR); + + } + +// if (this.index < this.itemListMsgBean.size()) { +// +// getItemInfo(index); +// index++; +// this.okButton.setText("<继续创建>"); +// } else { +// this.okButton.setEnabled(false); +// } + + } else if (obj.equals(this.celButton)) { + this.dispose(); + } + } + + /** + * 重新搭建BOM + * + * @param item + * @param itemlists + * @throws TCException + */ + public void recreateBom(TCComponentItemRevision topItemRev, + ArrayList itemRevisionlists, boolean isDelete) + throws TCException { + TCComponentBOMWindow bomWindow = null; + try { + TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session + .getTypeComponent("BOMWindow"); + bomWindow = bomWindowType.create(null); + TCComponentBOMLine topline = bomWindow.setWindowTopLine(topItemRev.getItem(), + topItemRev, null, null); + bomWindow.lock(); + topline.lock(); + if (isDelete) { + if (topline.hasChildren()) { + AIFComponentContext[] childrens = topline.getChildren(); + for (AIFComponentContext children : childrens) { + ((TCComponentBOMLine) children.getComponent()).cut(); + } + } + } + for (TCComponentItemRevision n_itemRevision : itemRevisionlists) { + if(n_itemRevision != null) + { + boolean isHave = false; + if(!isDelete) + { + for (AIFComponentContext children : topline.getChildren()) { + if(n_itemRevision.getStringProperty("item_id").compareTo(children.getComponent().getProperty("bl_child_id")) == 0) + { + isHave = true; + } + } + } + if(!isHave) + { + topline.add(n_itemRevision.getItem(), n_itemRevision, null, false, ""); + } + } + } + topline.save(); + topline.unlock(); + topline.refresh(); + if(topline.getBOMView() != null) + { + topline.getBOMView().save(); + topline.getBOMView().refresh(); + } + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + bomWindow.save(); + bomWindow.unlock(); + bomWindow.refresh(); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/DbPool.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/DbPool.java new file mode 100644 index 0000000..03fea2f --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/DbPool.java @@ -0,0 +1,233 @@ +package com.connor.ml.tcm.util; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class DbPool { + + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + + private static DbPool instance = null; + + public static synchronized Connection getConnection() { + if (instance == null) { + instance = new DbPool(); + } + return instance._getConnection(); + } + + private Connection _getConnection() { + try { + String sDBDriver = null; + String sConnection = null; + String sUser = null; + String sPassword = null; +// Properties p = new Properties(); +// InputStream is = getClass().getResourceAsStream( +// "/sqlconn.properties"); +// p.load(is); +// sDBDriver = p.getProperty("DBDriver", "1"); +// sConnection = p.getProperty("Connection", "2"); +// sUser = p.getProperty("User", ""); +// sPassword = p.getProperty("Password", ""); + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String[] array = service.getStringValues("TC13_SqlServer_Link"); + //TCPreferenceService.TC_preference_site, "TC13_SqlServer_Link"); + + if (array != null) + { + for (String str : array) { +// System.out.println(" ORACLE = " + str); + if (str != null && str.startsWith("DBDriver=")) { + sDBDriver = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null && str.startsWith("Connection=")) { + sConnection = str.substring(str.indexOf("=") + 1, str.length()); + } else if (str != null && str.startsWith("User=")) { + sUser = str.substring(str.indexOf("=") + 1, + str.length()); + } else if (str != null + && str.startsWith("Password=")) { + sPassword = str.substring(str.indexOf("=") + 1, + str.length()); + } + } + } + // String driver_temp = reg.getString("ORACEL_DRIVER"); + // String url = reg.getString("ORACEL_URL");// getProperties("URL"); + // String dbName = reg.getString("ORACEL_NAME");// + // Util.getProperties("dbName"); + // String dbPassword = reg.getString("ORACEL_PASSWORD");// + // Util.getProperties("dbPassword"); + + if (sDBDriver == null || sConnection == null || sUser == null + || sPassword == null) { + + MessageBox.post("请检查数据库首选项是否配置正确", "错误提示", MessageBox.ERROR); + + } + + Class.forName(sDBDriver); + connection = DriverManager.getConnection(sConnection, sUser, + sPassword); + return connection; + } catch (Exception se) { + System.out.println(se); + } + return null; + } + + public static void executeUpdateSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + System.out.println("sql===" + sql); + st.executeUpdate(sql); + } catch (SQLException e) { +// System.out.println(e.getMessage()); + e.printStackTrace(); + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + // connection.close(); + } + + } + + public static void executeDeleteSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + System.out.println("sql===" + sql); + st.executeUpdate(sql); + connection.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } finally { + if (st != null) + st.close(); + connection.close(); + } + + } + + public static ResultSet executeSelectSql(String sql) throws SQLException { + Statement st = connection.createStatement(); + try { + connection.setAutoCommit(false); + System.out.println("sql===" + sql); + rs = st.executeQuery(sql); + // conn.commit(); + } catch (SQLException e) { + if (st != null) + st.close(); + connection.rollback(); + connection.close(); + } + return rs; + + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * 释放资源 + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * 释放资源 + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * 释放资源(不传参数默认部分) + */ + public final static void free() { + free(DbPool.rs, DbPool.ps); + } + + /** + * 释放资源(全部释放) + */ + public final static void freeAll() { + free(DbPool.rs, DbPool.ps, DbPool.connection); + } + + /** + * 释放资源(传满参数也要全部释放) + */ + public final static void free(ResultSet resultSet, Statement statement, + Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ExcelUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ExcelUtil.java new file mode 100644 index 0000000..b1eef18 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ExcelUtil.java @@ -0,0 +1,1047 @@ +package com.connor.ml.tcm.util; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +import javax.imageio.ImageIO; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; +import org.apache.poi.hssf.usermodel.HSSFName; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFRichTextString; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; + +/** + * Excel 签名 + * + * @author hub 2015-09-06 + */ +public class ExcelUtil { + // private static Registry reg = Registry.getRegistry(this); + // private static HSSFSheet sheet; + // private static final int MY_ROWS = 46; + private SimpleDateFormat dateFormat = new SimpleDateFormat( + "yyyy-M-dd HH:mm"); + + /** + * 读取EXCEL表 + * + * @param File + * excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(File excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + HSSFWorkbook workBook = new HSSFWorkbook( + new FileInputStream(excel_file)); + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(workBook); + HSSFSheet sheet = workBook.getSheetAt(0); + HSSFRow title_row = sheet.getRow(0); + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + HSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < col_count; i++) { + String value = getStringCellValue(evaluator, + row.getCell((short) i)); + line_msg.add(value); + } + lines_msg.add(line_msg); + } + // insertRow(sheet,4,1); + return lines_msg; + } + + public void writeSignName(String intExcelFilePath, String outExcelFilePath, + String signName, String msgValue, int sheetIndex, int rowIndex, + int cellIndex) throws IOException { + // 输出文件的路径 + FileOutputStream outPut = new FileOutputStream(new File( + outExcelFilePath)); + // 输入文件的路径 + FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); + HSSFWorkbook wb = new HSSFWorkbook(inPut); + wb.getName(""); + AreaReference[] areaR2 = AreaReference.generateContiguous(wb + .getName("").getRefersToFormula()); + AreaReference areaR = null; + CellReference[] cellR = areaR.getAllReferencedCells(); + cellR[0].getSheetName();// s + cellR[0].getCol();// + cellR[0].getRow();// + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFSheet sheet = wb.getSheetAt(sheetIndex); + HSSFRow row = sheet.getRow(rowIndex); + + HSSFCell cell = row.getCell(cellIndex); + String value = getStringCellValue(evaluator, cell); + if (value.startsWith(signName)) { + value = value.substring(0, signName.length()); + } + + cell.setCellValue(value + msgValue); + wb.write(outPut); + inPut.close(); + outPut.close(); + } + + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont(HSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + HSSFFont font1 = (HSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + HSSFFont font = (HSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s + * 内容 + * @param firstIndex + * 起始位置 + * @param lastIndex + * 结束位置 + * @param fontSize + * 字体大小 + * @param FontName + * 字体样式 + * @return + */ + public static HSSFRichTextString setCellFont_XSSF(XSSFWorkbook wb, String s, + int firstIndex, int lastIndex, int fontSize, String FontName) { + HSSFRichTextString ts = new HSSFRichTextString(s); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine(HSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine_XSSF(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion(new CellRangeAddress(rows[0], + rows[rows.length - 1], columns[0], + columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex(HSSFWorkbook wb, String cellName) + throws IOException { + int index = -1; + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex_XSSF(XSSFWorkbook wb, String cellName) + throws IOException { + int index = -1; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + + /** + * 添加命名的引用 + * + * @param session + * @param item + * 对象的版本 + * @param tcResource + * 文件的物理路径 + * @param relationName + * 关系名称 + */ + public static void setExcelToItem(TCSession session, + TCComponentItemRevision item, String tcResource, String fileName, + boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { "MSExcel" }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType + .create(fileName, "excel", "MSExcel"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if ("MSExcel".equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren + .getComponent(); + zyzdsRev.remove("TC_Attaches", dateSet); + dateSet.delete(); + } + } + item.add("TC_Attaches", tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static String getNamedCellValue(HSSFWorkbook wb, String cellName) + throws IOException { + String value = null; + HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb); + HSSFName name = wb.getName(cellName); + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + HSSFCell cell = row.getCell(colIndex); + value = getStringCellValue(evaluator, cell); + } + } + } + return value; + } + + // 导出Excel + public void writeExcel(String xls_write_Address, InputStream stream, + Vector> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + Vector ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + if (ls2.get(cols) instanceof Date) { + String date = ls2.get(cols) == null ? "" + : dateFormat.format(ls2.get(cols)); + cell.setCellValue(date);// 写入内容 + } else { + cell.setCellValue(ls2.get(cols) == null ? "" : ls2 + .get(cols).toString());// 写入内容 + } + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void writeExcel(String xls_write_Address, InputStream stream, + ArrayList> ls, String[] sheetnames) { + FileOutputStream outStream; + try { + outStream = new FileOutputStream(new File(xls_write_Address)); + /* + * HSSFWorkbook workbook=new HSSFWorkbook(); HSSFSheet + * sheet=workbook.getSheetAt(0); for (int i = 0; i < + * this.resuList.size(); i++) { HSSFRow row = sheet.createRow(i); + * String[] s=this.resuList.get(i); for (int j = 0; j < s.length; + * j++) { HSSFCell cell=row.createCell(i); + * cell.setCellType(XSSFCell.CELL_TYPE_STRING); + * cell.setCellValue(s[i]); } } + */ + XSSFWorkbook workbook = new XSSFWorkbook(stream); + XSSFCellStyle style = workbook.createCellStyle(); + for (int sn = 0; sn < sheetnames.length; sn++) { + XSSFSheet sheet = workbook.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + XSSFRow row = sheet.createRow(i + 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + cell.setCellValue(ls2.get(cols));// 写入内容 + } + } + } + workbook.write(outStream); + outStream.close(); + System.out.println("成功!"); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel5(String xls_write_Address, InputStream stream, + ArrayList> ls, String[] sheetnames) + throws IOException { + FileOutputStream output = new FileOutputStream(new File( + xls_write_Address)); // 读取的文件路径 + HSSFWorkbook wb = new HSSFWorkbook(stream);// (new + // BufferedInputStream(output)); + HSSFCellStyle style = wb.createCellStyle(); + for (int sn = 0; sn < sheetnames.length; sn++) { + HSSFSheet sheet = wb.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + HSSFRow row = sheet.createRow(i + 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + HSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellStyle(style);// 添加边框 + cell.setCellValue(ls2.get(cols));// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel(String xls_write_Address, ArrayList ls, + String[] sheetnames) throws IOException { + FileOutputStream output = new FileOutputStream(new File( + xls_write_Address)); // 读取的文件路径 + HSSFWorkbook wb = new HSSFWorkbook();// (new + // BufferedInputStream(output)); + for (int sn = 0; sn < ls.size(); sn++) { + HSSFSheet sheet = wb.createSheet(String.valueOf(sn)); + wb.setSheetName(sn, sheetnames[sn]); + ArrayList ls2 = ls.get(sn); + for (int i = 0; i < ls2.size(); i++) { + HSSFRow row = sheet.createRow(i); + String[] s = ls2.get(i); + for (int cols = 0; cols < s.length; cols++) { + HSSFCell cell = row.createCell(cols); + cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellValue(s[cols]);// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /** + * 根据单元格的名字来找到单元格的内容 + * + * @param inputFilePath + * @param cellName + * @return + */ + public static List getExcelNamedCellValue(String inputFilePath, + String[] cellNames) { + List valueList = new ArrayList(); + try { + FileInputStream is = new FileInputStream(new File(inputFilePath)); + HSSFWorkbook wb = new HSSFWorkbook(is); + for (String name : cellNames) + valueList.add(getNamedCellValue(wb, name)); + is.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return valueList; + } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcel(String outPath, InputStream input, + * List beanListAll) throws IOException { int + * rowsCount = 5; + * + * // insertRow(); + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // + * 读取的文件路径 // FileInputStream input= new FileInputStream(); HSSFWorkbook wb + * = new HSSFWorkbook(input);// (new HSSFSheet sheet = wb.getSheetAt(0); for + * (int i = 0; i < (beanListAll.size() - rowsCount); i++) insertRow(sheet, + * 4, 1); int startRow = 2; for (int i = 0; i < beanListAll.size(); i++) { + * JFomProjectChangeBean bean = beanListAll.get(i); HSSFRow row = null; + * Boolean isCreat = false; if ((i + startRow) > sheet.getLastRowNum()) { + * row = sheet.createRow(i + startRow); isCreat = true; } else { row = + * sheet.getRow(i + startRow); isCreat = false; } + * + * for (int cols = 0; cols < 12; cols++) { HSSFCell cell = null; if + * (isCreat) { cell = row.createCell(cols); } else { cell = + * row.getCell(cols); } if (cell == null) cell = row.createCell(cols); + * cell.setCellType(HSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: + * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: + * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: + * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: + * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: + * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: + * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: + * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: + * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: + * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// + * 写入内容 break; } } } + * + * // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + public void insertPicture(HSSFWorkbook wb, HSSFSheet sheet1, + String picPath, short colIndex, int rowIndex) { + + // FileOutputStream fileOut = null; + BufferedImage bufferImg = null; + // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray + try { + if (!new File(picPath).exists()) { + return; + } + String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, + picPath.length()); + + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + System.out.println(picPath); + bufferImg = ImageIO.read(new File(picPath)); + ImageIO.write(bufferImg, dexStr, byteArrayOut); + // HSSFWorkbook wb = new HSSFWorkbook(); + // HSSFSheet sheet1 = wb.createSheet("test picture"); + // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) + HSSFPatriarch patriarch = sheet1.createDrawingPatriarch(); + // anchor主要用于设置图片的属性 + HSSFClientAnchor anchor = new HSSFClientAnchor(13, 13, 0, 0, + (short) colIndex, rowIndex, (short) (colIndex + 1), + rowIndex + 1); + //anchor.setAnchorType(3); + // 插入图片 + patriarch + .createPicture(anchor, wb.addPicture( + byteArrayOut.toByteArray(), + HSSFWorkbook.PICTURE_TYPE_JPEG)); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue(HSSFWorkbook wb, String cellName, + String cellValue) throws IOException { + String value = null; + HSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + HSSFSheet sheet = wb.getSheet(sheetName); + HSSFRow row = sheet.getRow(rowIndex); + HSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue_XSSF(XSSFWorkbook wb, String cellName, + String cellValue) throws IOException { + String value = null; + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name + .getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + + /** + * 移除合并的单元格 + * + * @param startRow + * @param endRow + * @return + */ + public static boolean removeMergen(HSSFSheet sheet, int startRow, int endRow) { + boolean isOK = false; + int count = sheet.getNumMergedRegions(); + for (int i = 0; i < count; i++) { + CellRangeAddress address = sheet.getMergedRegion(i); + System.out.println(address.getFirstRow() + "|" + + address.getLastRow()); + if (address.getFirstRow() == startRow + && address.getLastRow() == endRow) { + sheet.removeMergedRegion(i); + isOK = true; + break; + } + } + return isOK; + } + + /** + * 截取字符串 + * + * @param inStr + * @return + */ + public static String changeStringToInt(String inStr) { + int index = inStr.indexOf("."); + System.out.println(index); + String outStr = null; + if (index != -1) { + + outStr = inStr.substring(0, index); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 截取一定长度的字符串 + * + * @param inStr + * @param inLen + * @return + */ + public static String changeStringToInt(String inStr, int inLen) { + int index = inStr.indexOf("."); + inLen++; + System.out.println(index); + String outStr = null; + if (index != -1 && (inStr.length() - index) >= inLen) { + + outStr = inStr.substring(0, index + inLen); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 将float转换成保留两位的字符串 + * + * @param f + * 需要转换的float数 + * @return + */ + public static String changeFloatToStr(float f) { + DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. + String str = decimalFormat.format(f);// format 返回的是字符串 + return str; + } + + /** + * 将字符串转换成int + * + * @param str + * @return + */ + public static float changeStrToFloat(String str) { + float temp_int = 0; + try { + temp_int = Float.parseFloat(str.trim()); + return temp_int; + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return -1; + } + } + + /** + * 设置formual的时候用来替换原有的单元格号到新的单元格号 + * + * @param originStr + * @param subStr + * @param index + * @param index2 + * @return + */ + public static String replaceSubString(String originStr, String subStr, + int index, int index2) { + StringBuffer sbO = new StringBuffer(); + sbO.append(subStr); + sbO.append(index); + StringBuffer sbR = new StringBuffer(); + sbR.append(subStr); + sbR.append(index2); + String resultStr = originStr.replace(sbO.toString(), sbR.toString()); + return resultStr; + } + + /** + * 读取EXCEL信息 + * + * @param String + * excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(String excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null) { + return null; + } + File file = new File(excel_file); + return readExcel(file); + } + + /** + * 获取单元格数据内容为字符串类型的数据 + * + * @param cell + * Excel单元格 + * @return String 单元格数据内容 + */ + private static String getStringCellValue(HSSFFormulaEvaluator evaluator, + HSSFCell cell) { + if (cell == null) { + return ""; + } + String strCell = ""; + switch (cell.getCellType()) { + case HSSFCell.CELL_TYPE_STRING: + strCell = cell.getStringCellValue(); + break; + case HSSFCell.CELL_TYPE_NUMERIC: + strCell = "" + cell.getNumericCellValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + break; + case HSSFCell.CELL_TYPE_BOOLEAN: + strCell = String.valueOf(cell.getBooleanCellValue()); + break; + case HSSFCell.CELL_TYPE_BLANK: + strCell = ""; + break; + case HSSFCell.CELL_TYPE_ERROR: + strCell = String.valueOf(cell.getErrorCellValue()); + break; + case HSSFCell.CELL_TYPE_FORMULA: + CellValue value = evaluator.evaluate(cell); + try { + strCell = value.getStringValue(); + if (strCell == null) { + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + } catch (Exception e) { + + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + break; + default: + strCell = ""; + break; + } + if (strCell.equals("") || strCell == null) { + return ""; + } + return strCell; + } + + // public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + // HSSFRow sourceRow = sheet.getRow(starRow); + // sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + // // starRow = starRow -1; + // for (int i = 0; i < rows; i++) { + // // sheet.shiftRows(starRow + i, sheet.getLastRowNum(), 1, true, + // // false); + // HSSFRow targetRow = null; + // HSSFCell sourceCell = null; + // HSSFCell targetCell = null; + // short m; + // targetRow = sheet.createRow(starRow + 1); + // targetRow.setHeight(sourceRow.getHeight()); + // System.out.println(sourceRow.getLastCellNum()); + // for (m = sourceRow.getFirstCellNum(); m < sourceRow + // .getLastCellNum(); m++) { + // System.out.println(m); + // sourceCell = sourceRow.getCell(m); + // targetCell = targetRow.createCell(m); + // // System.out.println(" ===== " + sourceCell + " " + + // // targetCell); + // // targetCell.setEncoding(sourceCell.get); + // targetCell.setCellStyle(sourceCell.getCellStyle()); + // targetCell.setCellType(sourceCell.getCellType()); + // // targetCell.setCellValue("11111"); + // } + // } + // } + + /** + * 插入行数 + * + * @param starRow + * @param rows + */ + public static void insertRow(HSSFSheet sheet, int starRow, int rows) { + HSSFRow sourceRow = sheet.getRow(starRow); + sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(starRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + + /*** + * 向sheet中插入一行 + * + * @param sheet + * @param startRow + * @param rows + * @return + */ + public static HSSFSheet insertRows(HSSFSheet sheet, int startRow, int rows) { + HSSFRow sourceRow = sheet.getRow(startRow); + sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + HSSFRow targetRow = null; + HSSFCell sourceCell = null; + HSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(startRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow + .getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + return sheet; + } + + /** + * 检查单元格内容是否是数字 + * + * @param value + * @return + */ + public static boolean CheckCellValueIsNumber(String value) { + boolean is_ok = false; + if (value.equals("")) { + return false; + } + try { + Float.parseFloat(value); + } catch (NumberFormatException e) { + e.printStackTrace(); + System.out.println("===>" + value); + is_ok = true; + } + return is_ok; + } + + public static void setFlowChart(Map valueMap, File file) { + // TODO Auto-generated method stub + file.setWritable(true); + try { + InputStream is = new FileInputStream(file); + HSSFWorkbook wb = new HSSFWorkbook(is);// ( + //HSSFSheet sheet = wb.getSheetAt(0); + + Iterator> it = valueMap.entrySet() + .iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + setNamedCellValue(wb, entry.getKey(), entry.getValue()); + } + FileOutputStream output = new FileOutputStream(file); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + //file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ExcelUtil07.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ExcelUtil07.java new file mode 100644 index 0000000..0b148c7 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ExcelUtil07.java @@ -0,0 +1,2546 @@ +package com.connor.ml.tcm.util; + +import java.awt.Graphics; +import java.awt.GraphicsConfiguration; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import java.awt.HeadlessException; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.tree.DefaultMutableTreeNode; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.Name; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.AreaReference; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFClientAnchor; +import org.apache.poi.xssf.usermodel.XSSFDrawing; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; +import org.apache.poi.xssf.usermodel.XSSFName; +import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.FileUtility; +import com.teamcenter.rac.util.MessageBox; + +/** + * Excel Toolling + * + * @author hub 2015-09-06 + */ +public class ExcelUtil07 { + // private static Registry reg = Registry.getRegistry(this); + // private static XSSFSheet sheet; + // private static final int MY_ROWS = 46; + private static Map map = new HashMap(); + private static final String EXCEL_XLS = "xls"; + private static final String EXCEL_XLSX = "xlsx"; + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(File excel_file) throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < col_count; i++) { + String value = getStringCellValue(evaluator, row.getCell((short) i)); + line_msg.add(value); + } + lines_msg.add(line_msg); + } + // insertRow(sheet,4,1); + return lines_msg; + } + + /** + * 读取控制计划EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readControlPlanExcel(File excel_file) throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + int startRow = 1; + // 获取合并单元格 + Map regionCellMap = getRegionCell(sheet); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = startRow; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < 18; i++) { + String value = getStringCellValue(evaluator, row.getCell((short) i)); + if (value == null || value.equals("")) { + line_msg.add(getRegionValue(workBook, sheet, j, i)); + } else { + line_msg.add(value); + } + } + // 行号 + line_msg.add(((Integer) (j - startRow)).toString()); + // 合并单元格 + line_msg.add(toControlPlanRegionCell(regionCellMap, j)); + if (line_msg.get(0) != null) { + lines_msg.add(line_msg); + } + } + // insertRow(sheet,4,1); + return lines_msg; + } + + /** + * 读取委托内容EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readEntrustingContentExcel(File excel_file) + throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List> lines_msg = new ArrayList>(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + int startRow = 0; + // 获取合并单元格 + Map regionCellMap = getEntrustingContentRegionCell(sheet); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + System.out.println(" SHEET COL COUNT " + col_count); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + System.out.println(" SHEET ROW COUNT " + row_count); + for (int j = startRow; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + List line_msg = new ArrayList(); + for (int i = 0; i < 3; i++) { + String value = getStringCellValue(evaluator, row.getCell((short) i)); + if (value == null || value.equals("")) { + line_msg.add(getRegionValue(workBook, sheet, j, i)); + } else { + line_msg.add(value); + } + } + // 合并单元格 + line_msg.add(toEntrustingContentRegionCell(regionCellMap, j)); + if (line_msg.get(0) != null) { + lines_msg.add(line_msg); + } + } + // insertRow(sheet,4,1); + return lines_msg; + } + + public static void main(String[] args) { + try { + List> strList = readExcel(new File("F:\\Connor(项目管理)\\东睦项目\\东睦系统\\控制计划\\生产控制计划模板3.xlsx")); + for (List list : strList) { + for (String str : list) { + System.out.print(str + "|"); + } + System.out.println(); + } + + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void writeSignName(String intExcelFilePath, String outExcelFilePath, String signName, String msgValue, + int sheetIndex, int rowIndex, int cellIndex) throws IOException { + // 输出文件的路径 + FileOutputStream outPut = new FileOutputStream(new File(outExcelFilePath)); + // 输入文件的路径 + FileInputStream inPut = new FileInputStream(new File(intExcelFilePath)); + XSSFWorkbook wb = new XSSFWorkbook(inPut); + wb.getName(""); + AreaReference[] areaR2 = AreaReference.generateContiguous(wb.getName("").getRefersToFormula()); + AreaReference areaR = null; + CellReference[] cellR = areaR.getAllReferencedCells(); + cellR[0].getSheetName();// s + cellR[0].getCol();// + cellR[0].getRow();// + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFSheet sheet = wb.getSheetAt(sheetIndex); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(cellIndex); + String value = getStringCellValue(evaluator, cell); + if (value.startsWith(signName)) { + value = value.substring(0, signName.length()); + } + cell.setCellValue(value + msgValue); + wb.write(outPut); + inPut.close(); + outPut.close(); + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param beanListAll + * @param sheetnames + * @throws IOException + */ + /* + * public void writeExcel(String xls_write_Address, String path, + * List beanListAll, int index) throws IOException { + * FileOutputStream output = new FileOutputStream(new File(path)); // 读取的文件路径 + * FileInputStream input = new FileInputStream(new File(xls_write_Address)); + * XSSFWorkbook wb = new XSSFWorkbook(input);// (new XSSFSheet sheet = + * wb.getSheetAt(0); for (int i = 0; i < beanListAll.size(); i++) { + * JFomPasteBean bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat + * = false; if ((i + 3) > sheet.getLastRowNum()) { row = sheet.createRow(i + 3); + * isCreat = true; } else { row = sheet.getRow(i + 3); isCreat = false; } + * + * for (int cols = 0; cols < 7; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getProductName());// 写入内容 break; case 2: // + * cell.setCellValue(bean.getPicturePath());// 写入内容 insertPicture(wb, sheet, + * bean.getPicturePath(), (short) 2, (i + 3)); break; case 3: + * cell.setCellValue(bean.getDatasetName());// 写入内容 break; case 4: + * cell.setCellValue(bean.getItemRevisionId());// 写入内容 break; case 5: + * cell.setCellValue("");// 写入内容 + * + * break; case 6: // cell.setCellType(XSSFCell.CELL_TYPE_);// 文本格式 + * cell.setCellValue(bean.getReleaseDateStr());// 写入内容 break; + * + * } } } // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + /** + * 获取单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static String getNamedCellValue(XSSFWorkbook wb, String cellName) throws IOException { + String value = null; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return ""; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + value = getStringCellValue(evaluator, cell); + } + } + } + return value; + } + + /** + * 设置单个的命名单元格的内容 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static void setNamedCellValue(XSSFWorkbook wb, String cellName, String cellValue) throws IOException { + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFCell cell = row.getCell(colIndex); + cell.setCellValue(cellValue); + } + } + } + } + } + + /** + * 插入图片到指定的单元格中 + * + * @param wb + * @param sheet1 + * @param picPath + * @param colIndex + * @param rowIndex + */ + public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, ImageIcon imageIcon, String cellName, + int columns, int rows) { + + // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray + try { + if (imageIcon == null) { + return; + } + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + ImageIO.write(toBufferedImage(imageIcon.getImage()), "jpg", byteArrayOut); + // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) + XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); + // anchor主要用于设置图片的属性 + XSSFName name = wb.getName(cellName); + if (name == null) { + return; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, + (short) (colIndex + columns), rowIndex + rows); + //anchor.setAnchorType(3); + // 插入图片 + patriarch.createPicture(anchor, + wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * 将Image转BufferedImage + * + * @param image + * @return + */ + public static BufferedImage toBufferedImage(Image image) { + if (image instanceof BufferedImage) { + return (BufferedImage) image; + } + + // This code ensures that all the pixels in the image are loaded + image = new ImageIcon(image).getImage(); + + // Determine if the image has transparent pixels; for this method's + // implementation, see e661 Determining If an Image Has Transparent Pixels + // boolean hasAlpha = hasAlpha(image); + + // Create a buffered image with a format that's compatible with the screen + BufferedImage bimage = null; + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + try { + // Determine the type of transparency of the new buffered image + int transparency = Transparency.OPAQUE; + /* + * if (hasAlpha) { transparency = Transparency.BITMASK; } + */ + + // Create the buffered image + GraphicsDevice gs = ge.getDefaultScreenDevice(); + GraphicsConfiguration gc = gs.getDefaultConfiguration(); + bimage = gc.createCompatibleImage(image.getWidth(null), image.getHeight(null), transparency); + } catch (HeadlessException e) { + // The system does not have a screen + } + + if (bimage == null) { + // Create a buffered image using the default color model + int type = BufferedImage.TYPE_INT_RGB; + // int type = BufferedImage.TYPE_3BYTE_BGR;//by wang + /* + * if (hasAlpha) { type = BufferedImage.TYPE_INT_ARGB; } + */ + bimage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); + } + + // Copy image to buffered image + Graphics g = bimage.createGraphics(); + + // Paint the image onto the buffered image + g.drawImage(image, 0, 0, null); + g.dispose(); + + return bimage; + } + + /*** + * 写入到EXCEL数据 (写入单种数据) + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @throws IOException + */ + public void writeExcel(String xls_write_Address, ArrayList ls, String[] sheetnames) throws IOException { + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 + XSSFWorkbook wb = new XSSFWorkbook();// (new + // BufferedInputStream(output)); + for (int sn = 0; sn < ls.size(); sn++) { + XSSFSheet sheet = wb.createSheet(String.valueOf(sn)); + wb.setSheetName(sn, sheetnames[sn]); + ArrayList ls2 = ls.get(sn); + for (int i = 0; i < ls2.size(); i++) { + XSSFRow row = sheet.createRow(i); + String[] s = ls2.get(i); + for (int cols = 0; cols < s.length; cols++) { + XSSFCell cell = row.createCell(cols); + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 + cell.setCellValue(s[cols]);// 写入内容 + } + } + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /** + * 根据单元格的名字来找到单元格的内容 + * + * @param inputFilePath + * @param cellName + * @return + */ + public static List getExcelNamedCellValue(String inputFilePath, String[] cellNames) { + List valueList = new ArrayList(); + if (!new File(inputFilePath).exists()) { + for (int i = 0; i < cellNames.length; i++) + valueList.add(""); + return valueList; + } + try { + FileInputStream is = new FileInputStream(new File(inputFilePath)); + XSSFWorkbook wb = new XSSFWorkbook(is); + for (String name : cellNames) + valueList.add(getNamedCellValue(wb, name)); + is.close(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return valueList; + } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcel(String outPath, InputStream input, + * List beanListAll) throws IOException { + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 + * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new + * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow + * = 2; for (int i = 0; i < beanListAll.size(); i++) { JFomProjectChangeBean + * bean = beanListAll.get(i); XSSFRow row = null; Boolean isCreat = false; if + * ((i + startRow) > sheet.getLastRowNum()) { row = sheet.createRow(i + + * startRow); isCreat = true; } else { row = sheet.getRow(i + startRow); isCreat + * = false; } + * + * for (int cols = 0; cols < 12; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexStr());// 写入内容 break; case 1: + * cell.setCellValue(bean.getECRCode());// 写入内容 break; case 2: + * cell.setCellValue(bean.getInternalCode());// 写入内容 break; case 3: + * cell.setCellValue(bean.getDrawingNo());// 写入内容 break; case 4: + * cell.setCellValue(bean.getPartStatus());// 写入内容 break; case 5: + * cell.setCellValue(bean.getInitiator());// 写入内容 break; case 6: + * cell.setCellValue(bean.getSureDate());// 写入内容 break; case 7: + * cell.setCellValue(bean.getChangeMsgBef());// 写入内容 break; case 8: + * cell.setCellValue(bean.getChangeMsg());// 写入内容 break; case 9: + * cell.setCellValue(bean.getChargePerson());// 写入内容 break; case 10: + * cell.setCellValue("");// 写入内容 break; case 11: cell.setCellValue("");// 写入内容 + * break; } } } // } wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(XSSFRow row1, int index, String str) { + XSSFCell cell = row1.getCell(index); + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + + /** + * 设置单元格 + * + * @param row1 + * @param index + * @param str + */ + public static void setCellValue(Row row1, int index, String str) { + Cell cell = row1.getCell(index); + cell.setCellType(XSSFCell.CELL_TYPE_STRING); + cell.setCellValue(str); + } + + /** + * 针对工程变更的信息写入 + * + * @param xls_write_Address + * @param ls + * @throws IOException + */ + /* + * public static void writeExcelBomExport(String outPath, InputStream input, + * List beanListAll, JFomBomExportProjBean projBean) throws + * IOException { + * + * FileOutputStream output = new FileOutputStream(new File(outPath)); // 读取的文件路径 + * // FileInputStream input= new FileInputStream(); XSSFWorkbook wb = new + * XSSFWorkbook(input);// (new XSSFSheet sheet = wb.getSheetAt(0); int startRow + * = 4; if (projBean != null) { XSSFRow row1 = sheet.getRow(0); + * setCellValue(row1, 11, projBean.getPROJ_NAME()); setCellValue(row1, 14, + * projBean.getPROJ_MODE()); setCellValue(row1, 16, projBean.getPRODUCT_LIFE()); + * row1 = sheet.getRow(1); setCellValue(row1, 11, projBean.getPROJ_CUSTOMER()); + * setCellValue(row1, 14, projBean.getPROJ_MEMBER()); } for (int i = 0; i < + * beanListAll.size(); i++) { JFomBomExportBean bean = beanListAll.get(i); + * XSSFRow row = null; Boolean isCreat = false; if ((i + startRow) > + * sheet.getLastRowNum()) { row = sheet.createRow(i + startRow); isCreat = true; + * } else { row = sheet.getRow(i + startRow); isCreat = false; } + * + * for (int cols = 0; cols < 22; cols++) { XSSFCell cell = null; if (isCreat) { + * cell = row.createCell(cols); } else { cell = row.getCell(cols); } + * cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 int indexStr = + * bean.getIndexStr(); if (cols == (indexStr + 1)) { + * cell.setCellValue(JFomUtil.JF3_INDEX_STR);// 写入内容 } + * + * switch (cols) { + * + * case 0: cell.setCellValue(bean.getIndexExt());// 写入内容 break; case 7: + * cell.setCellValue(bean.getWlNumber());// 写入内容 break; case 8: + * cell.setCellValue(bean.getMPS()); break; case 9: + * cell.setCellValue(bean.getCustomerNo()); break; case 10: + * cell.setCellValue(bean.getWlName()); break; case 11: + * cell.setCellValue(bean.getK3code()); break; case 12: insertPicture(wb, sheet, + * bean.getPicturePath(), (short) 14, i + startRow); break; case 13: + * cell.setCellValue(bean.getMaterialName()); break; case 14: + * cell.setCellValue(bean.getMaterialSize()); break; case 15: + * cell.setCellValue(bean.getMaterialStander()); break; case 16: + * cell.setCellValue(bean.getMaterialPark()); break; case 17: + * cell.setCellValue(bean.getJingzhong()); break; case 18: + * cell.setCellValue(bean.getMaozhong()); break; case 19: + * cell.setCellValue(bean.getGongyi()); break; case 20: + * cell.setCellValue(bean.getGongyingshang()); break; default: break; } } } // } + * wb.write(output); output.close(); input.close(); + * System.out.println("-------WRITE EXCEL OVER-------"); } + */ + public static void insertPicture(XSSFWorkbook wb, XSSFSheet sheet1, String picPath, short colIndex, int rowIndex) { + + // FileOutputStream fileOut = null; + BufferedImage bufferImg = null; + // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray + try { + if (!new File(picPath).exists()) { + return; + } + String dexStr = picPath.substring(picPath.lastIndexOf(".") + 1, picPath.length()); + ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); + System.out.println(picPath); + bufferImg = ImageIO.read(new File(picPath)); + ImageIO.write(bufferImg, dexStr, byteArrayOut); + // XSSFWorkbook wb = new XSSFWorkbook(); + // XSSFSheet sheet1 = wb.createSheet("test picture"); + // 画图的顶级管理器,一个sheet只能获取一个(一定要注意这点) + XSSFDrawing patriarch = sheet1.createDrawingPatriarch(); + // anchor主要用于设置图片的属性 + XSSFClientAnchor anchor = new XSSFClientAnchor(13, 13, 0, 0, (short) colIndex, rowIndex, + (short) (colIndex + 1), rowIndex + 1); + //anchor.setAnchorType(3); + // 插入图片 + patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG)); + + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 移除合并的单元格 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean removeMergen(XSSFSheet sheet, int startRow, int endRow) { + boolean isOK = false; + int count = sheet.getNumMergedRegions(); + for (int i = 0; i < count; i++) { + CellRangeAddress address = sheet.getMergedRegion(i); + System.out.println(address.getFirstRow() + "|" + address.getLastRow()); + if (address.getFirstRow() == startRow && address.getLastRow() == endRow) { + sheet.removeMergedRegion(i); + isOK = true; + break; + } + } + return isOK; + } + + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine(XSSFSheet sheet, int[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion( + new CellRangeAddress(rows[0], rows[rows.length - 1], columns[0], columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + + /** + * 合并单元格sheet.addMergedRegion(new CellRangeAddress(check_index-1, + * check_index+12+check_rows, 0, 0)); + * + * @param startRow + * @param endRow + * @return + */ + public static boolean combine(XSSFSheet sheet, Integer[] rows, int[] columns) { + boolean isOK = false; + if (rows.length > 0 && columns.length > 0) { + sheet.addMergedRegion( + new CellRangeAddress(rows[0], rows[rows.length - 1], columns[0], columns[columns.length - 1])); + isOK = true; + } + return isOK; + } + + + /** + * 截取字符串 + * + * @param inStr + * @return + */ + public static String changeStringToInt(String inStr) { + int index = inStr.indexOf("."); + System.out.println(index); + String outStr = null; + if (index != -1) { + + outStr = inStr.substring(0, index); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 截取一定长度的字符串 + * + * @param inStr + * @param inLen + * @return + */ + public static String changeStringToInt(String inStr, int inLen) { + int index = inStr.indexOf("."); + inLen++; + System.out.println(index); + String outStr = null; + if (index != -1 && (inStr.length() - index) >= inLen) { + + outStr = inStr.substring(0, index + inLen); + } else { + outStr = inStr; + + } + // System.out.println(outStr); + return outStr; + } + + /** + * 将float转换成保留两位的字符串 + * + * @param f 需要转换的float数 + * @return + */ + public static String changeFloatToStr(float f) { + DecimalFormat decimalFormat = new DecimalFormat(".0");// 构造方法的字符格式这里如果小数不足2位,会以0补足. + String str = decimalFormat.format(f);// format 返回的是字符串 + return str; + } + + /** + * 将字符串转换成int + * + * @param str + * @return + */ + public static float changeStrToFloat(String str) { + float temp_int = 0; + try { + temp_int = Float.parseFloat(str.trim()); + return temp_int; + } catch (NumberFormatException e) { + System.out.println(e.getMessage()); + return -1; + } + } + + /** + * 设置formual的时候用来替换原有的单元格号到新的单元格号 + * + * @param originStr + * @param subStr + * @param index + * @param index2 + * @return + */ + public static String replaceSubString(String originStr, String subStr, int index, int index2) { + StringBuffer sbO = new StringBuffer(); + sbO.append(subStr); + sbO.append(index); + StringBuffer sbR = new StringBuffer(); + sbR.append(subStr); + sbR.append(index2); + String resultStr = originStr.replace(sbO.toString(), sbR.toString()); + return resultStr; + } + + /** + * 读取EXCEL信息 + * + * @param String excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List> readExcel(String excel_file) throws FileNotFoundException, IOException { + if (excel_file == null) { + return null; + } + File file = new File(excel_file); + // 获取EXCEL数据的具体逻辑的函数 + return readExcel(file); + } + + public static String combinationString(String s) { + String result = ""; + List sList = new ArrayList(); + List sList2 = new ArrayList(); + if (s.indexOf("&") > -1) { + String[] ss = s.split("&"); + if (ss[0].indexOf("/") > -1) { + String[] sss = ss[0].split("/"); + for (int i = 0; i < sss.length; i++) { + sList.add(sss[i]); + } + } else { + sList.add(ss[0]); + } + if (ss[1].indexOf("/") > -1) { + String[] sss = ss[1].split("/"); + for (int i = 0; i < sss.length; i++) { + sList2.add(sss[i]); + } + } else { + sList2.add(ss[1]); + } + + if (sList.size() == sList2.size()) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < sList.size(); i++) { + sb.append(sList.get(i) + "/" + sList2.get(i) + "&"); + } + if (sb != null && sb.length() != 0) { + result = sb.substring(0, sb.length() - 1); + } + } + } + return result; + + } + + /** + * 读取控制计划信息 + * + * @param String excel_file + * @return List> 返回信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static Map> readExcel(String excel_file, String cellName) + throws FileNotFoundException, IOException { + if (excel_file == null) { + return null; + } + File file = new File(excel_file); + XSSFWorkbook xwb = new XSSFWorkbook(new FileInputStream(file)); + Map> result = new LinkedHashMap>(); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(xwb); + XSSFSheet sheet = xwb.getSheetAt(0); + XSSFRow row; + String cell; + for (int i = sheet.getFirstRowNum(); i < sheet.getPhysicalNumberOfRows(); i = i + 2) { + + row = sheet.getRow(i); + if (getRegionValue(xwb, sheet, i, 1).toString().equals(cellName)) { + List rowValue = new ArrayList(); + int lastRow = getRegionIndex(sheet, i, 1, cellName); + for (int j = row.getFirstCellNum(); j < row.getLastCellNum(); j++) { + if (j == 10) { + continue; + } + if ((row.getCell(j) == null || row.getCell(j).toString().equals("")) && i <= lastRow) { + String s = getRegionValue(xwb, sheet, i, j); + if (s == null) { + cell = ""; + } else { + if (j == 9) { + if (row.getCell(10) != null && !row.getCell(10).toString().equals("")) { + s = s + "/" + sheet.getRow(i - 1).getCell(10).toString() + "/" + + row.getCell(10).toString(); + } + } + cell = s; + } + } else { + cell = getStringCellValue(evaluator, row.getCell(j)); + } + System.out.print(cell + ","); + rowValue.add(cell); + } + result.put((int) Float.parseFloat(rowValue.get(3)), rowValue); + } + System.out.println("**********************"); + } + return result; + } + + /** + * 获取单个的命名单元格的位置 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int[] getNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { + int[] index = new int[2]; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return null; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) { + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + index[0] = cellR.getCol(); + index[1] = cellR.getRow(); + // colIndex = cellR.getCol(); + // rowIndex = cellR.getRow(); + } + } + } + } + return index; + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getNamedColumnIndex(XSSFWorkbook wb, String cellName) throws IOException { + int index = -1; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + + /** + * 获取合并单元格内容 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static String getRegionValue(XSSFWorkbook workbook, XSSFSheet sheet, int rowIndex, int cellIndex) { + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook); + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); + if (rowIndex <= lastRowNum && rowIndex >= rowNum && cellIndex <= lastColIndex && cellIndex >= colIndex) { + return getStringCellValue(evaluator, sheet.getRow(rowNum).getCell((short) colIndex)); + } + } + return null; + } + + /** + * 获取EXCEL合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static Map getRegionCell(XSSFSheet sheet) { + Map regionCellMap = new HashMap(); + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + if (rowNum >= 13) { + // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); + // 行集合 + int[] rows = new int[lastRowNum - (rowNum - 1)]; + // 列集合 + for (int j = 0; j < rows.length; j++) { + rows[j] = rowNum + j; + } + int[] columns = new int[lastColIndex - (colIndex - 1)]; + for (int j = 0; j < columns.length; j++) { + columns[j] = colIndex + j + 1; + } + regionCellMap.put(rows, columns); + } + } + return regionCellMap; + } + + /** + * 获取EXCEL合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static Map getEntrustingContentRegionCell(XSSFSheet sheet) { + Map regionCellMap = new HashMap(); + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + if (rowNum >= 0) { + // System.out.println(rowNum+"+++++++"+colIndex+"++++++++++"+lastRowNum+"++++++++++++"+lastColIndex); + // 行集合 + int[] rows = new int[lastRowNum - (rowNum - 1)]; + // 列集合 + for (int j = 0; j < rows.length; j++) { + rows[j] = rowNum + j; + } + int[] columns = new int[lastColIndex - (colIndex - 1)]; + for (int j = 0; j < columns.length; j++) { + columns[j] = colIndex + j + 1; + } + regionCellMap.put(rows, columns); + } + } + return regionCellMap; + } + + /** + * 转换为控制计划合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static String toControlPlanRegionCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k] - 13); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k]); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) + + "-"); + } + } + if (sb.length() > 0) { + return sb.toString().substring(0, sb.length() - 1); + } else { + return ""; + } + } + + /** + * 转换为委托内容合并单元格 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @return + */ + public static String toEntrustingContentRegionCell(Map regionCell, int row) { + Iterator> it = regionCell.entrySet().iterator(); + StringBuffer sb = new StringBuffer(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + StringBuffer rowSb = new StringBuffer(); + StringBuffer columnSb = new StringBuffer(); + for (int k = 0; k < entry.getKey().length; k++) { + rowSb.append(entry.getKey()[k]); + rowSb.append(","); + } + for (int k = 0; k < entry.getValue().length; k++) { + columnSb.append(entry.getValue()[k] - 1); + columnSb.append(","); + } + if (entry.getKey()[0] == row) { + sb.append(rowSb.substring(0, rowSb.length() - 1) + "/" + columnSb.substring(0, columnSb.length() - 1) + + "-"); + } + } + if (sb.length() > 0) { + return sb.toString().substring(0, sb.length() - 1); + } else { + return ""; + } + } + + /** + * 设置单元格中指定字体的样式 + * + * @param wb + * @param s 内容 + * @param firstIndex 起始位置 + * @param lastIndex 结束位置 + * @param fontSize 字体大小 + * @param FontName 字体样式 + * @return + */ + public static XSSFRichTextString setCellFont(XSSFWorkbook wb, String s, int firstIndex, int lastIndex, int fontSize, + String FontName) { + XSSFRichTextString ts = new XSSFRichTextString(s); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 8); // 字体高度 + font1.setFontName("宋体"); // 字体 + // font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) fontSize); // 字体高度 + font.setFontName(FontName); // 字体 + // font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); // 宽度 + ts.applyFont(firstIndex, lastIndex, font); + ts.applyFont(lastIndex, ts.length(), font1); + return ts; + } + + /** + * 获取单元格大小 + * + * @param sheet + * @param rowIndex + * @param cellIndex + * @param cellValue + */ + public static int getRegionIndex(XSSFSheet sheet, int rowIndex, int cellIndex, String cellValue) { + int lastRow = 0; + for (int i = 0; i < sheet.getNumMergedRegions(); i++) { + CellRangeAddress region = sheet.getMergedRegion(i); + int colIndex = region.getFirstColumn(); + int lastColIndex = region.getLastColumn(); + int rowNum = region.getFirstRow(); + int lastRowNum = region.getLastRow(); + if (sheet.getRow(rowNum).getCell(colIndex).toString().equals(cellValue)) { + lastRow = lastRowNum; + } + } + return lastRow; + } + + /** + * 获取单元格数据内容为字符串类型的数据 + * + * @param cell Excel单元格 + * @return String 单元格数据内容 + */ + private static String getStringCellValue(XSSFFormulaEvaluator evaluator, XSSFCell cell) { + if (cell == null) { + return ""; + } + String strCell = ""; + switch (cell.getCellType()) { + case XSSFCell.CELL_TYPE_STRING: + strCell = cell.getStringCellValue(); + break; + case XSSFCell.CELL_TYPE_NUMERIC: + // strCell = cell.getStringCellValue(); + if (DateUtil.isCellDateFormatted(cell)) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); + Date date = cell.getDateCellValue(); + if (date != null) + strCell = sdf.format(date); + } else { + + strCell = "" + cell.getNumericCellValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + break; + case XSSFCell.CELL_TYPE_BOOLEAN: + strCell = String.valueOf(cell.getBooleanCellValue()); + break; + case XSSFCell.CELL_TYPE_BLANK: + strCell = ""; + break; + case XSSFCell.CELL_TYPE_ERROR: + strCell = String.valueOf(cell.getErrorCellValue()); + break; + case XSSFCell.CELL_TYPE_FORMULA: + CellValue value = evaluator.evaluate(cell); + try { + strCell = value.getStringValue(); + if (strCell == null) { + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + } catch (Exception e) { + + strCell = "" + value.getNumberValue(); + if (strCell.endsWith(".0")) { + strCell = strCell.substring(0, strCell.indexOf(".0")); + } + } + break; + + default: + strCell = ""; + break; + } + if (strCell.equals("") || strCell == null) { + return ""; + } + // System.out.println(" === Type =" + cell.getCellType() + " Value =" + + // strCell); + return strCell; + } + + /** + * 插入行数 + * + * @param starRow + * @param rows + */ + public static void insertRow(XSSFSheet sheet, int starRow, int rows) { + XSSFRow sourceRow = sheet.getRow(starRow); + sheet.shiftRows(starRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + XSSFRow targetRow = null; + XSSFCell sourceCell = null; + XSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(starRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + } + + /*** + * 向sheet中插入一行 + * + * @param sheet + * @param startRow + * @param rows + * @return + */ + public static XSSFSheet insertRows(XSSFSheet sheet, int startRow, int rows) { + XSSFRow sourceRow = sheet.getRow(startRow); + sheet.shiftRows(startRow + 1, sheet.getLastRowNum(), rows, true, false); + for (int i = 0; i < rows; i++) { + XSSFRow targetRow = null; + XSSFCell sourceCell = null; + XSSFCell targetCell = null; + short m; + targetRow = sheet.createRow(startRow + 1); + targetRow.setHeight(sourceRow.getHeight()); + System.out.println(sourceRow.getLastCellNum()); + for (m = sourceRow.getFirstCellNum(); m < sourceRow.getLastCellNum(); m++) { + System.out.println(m); + sourceCell = sourceRow.getCell(m); + targetCell = targetRow.createCell(m); + targetCell.setCellStyle(sourceCell.getCellStyle()); + targetCell.setCellType(sourceCell.getCellType()); + } + } + return sheet; + } + + /** + * 检查单元格内容是否是数字 + * + * @param value + * @return + */ + public static boolean CheckCellValueIsNumber(String value) { + boolean is_ok = false; + if (value.equals("")) { + return false; + } + try { + Float.parseFloat(value); + } catch (NumberFormatException e) { + e.printStackTrace(); + System.out.println("===>" + value); + is_ok = true; + } + return is_ok; + } + +// /** +// * 拼接麦格纳的联系人和联系电话 +// * +// * @param persion +// * @param phone +// * @return +// */ +// public static String connectPhoneAndPersion(String persion, String phone) { +// StringBuffer persionPhoneSb = new StringBuffer(); +// if (persion != null && phone != null) { +// +// String[] persions = null; +// String[] phones = null; +// if (persion.contains("、")) { +// persions = persion.split("、"); +// } else if (persion.contains("\\/")) { +// persions = persion.split("\\/"); +// } else if (persion.contains(",")) { +// persions = persion.split(","); +// } else { +// persions = new String[] { persion }; +// } +// +// if (phone.contains("、")) { +// phones = phone.split("、"); +// } else if (phone.contains("\\/")) { +// phones = phone.split("\\/"); +// } else if (phone.contains(",")) { +// phones = phone.split(","); +// } else { +// phones = new String[] { phone }; +// } +// +// if (persions != null && phones != null) { +// int persionCount = persions.length; +// int phonesCount = phones.length; +// if (persionCount == phonesCount) { +// for (int i = 0; i < persionCount; i++) { +// persionPhoneSb.append(persions[i]).append("/") +// .append(phones[i]).append(" "); +// +// } +// } +// } +// } +// +// return persionPhoneSb.toString(); +// } + + /*** + * 输出成形作业指导书 + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @param row_num + * @param col_num + * @throws IOException + * + */ + public static void writeExcelForCX(String xls_write_Address, File file, ArrayList> ls, + int row_num, int col_num) throws IOException { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// (new + is.close(); + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 + XSSFCellStyle style = wb.createCellStyle(); +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); + XSSFFont font = wb.createFont(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + XSSFSheet sheet = wb.getSheetAt(0); + sheet.setForceFormulaRecalculation(true); + if (ls != null) + for (int i = 0; i < ls.size(); i++) { + if (i % 27 == 0 && i != 0) { + row_num += 11; + } + XSSFRow row = sheet.getRow(i + row_num - 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = row.getCell(cols + col_num - 1); + if (cell == null) { + cell = row.createCell(cols + col_num - 1); + } +// cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// cell.setCellStyle(style);// 添加边框 + if (cols + col_num == 9) { + String cpgc = ls2.get(cols); + System.out.println(cpgc); + String[] strs = cpgc.split("special"); + System.out.println("strs.length=>" + strs.length); + if (cpgc != null && cpgc != "") { + if (!" ".equals(strs[1])) { + String special = strs[1]; + if (special.indexOf("|") <= 0) { + if ("产品/过程/规格/公差".equals(special.split("-")[0])) { + int index = Integer.valueOf(special.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + + } else { + String[] tstxs = special.split("\\|"); + for (String str : tstxs) { + if ("产品/过程/规格/公差".equals(str.split("-")[0])) { + int index = Integer.valueOf(str.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue( + setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + } + } + } else { + // 直接写入strs[0] + cell.setCellValue(strs[0]); + } + } + } else + cell.setCellValue(ls2.get(cols));// 写入内容 + } + + } + else + MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + /** + * 输出整形作业指导书 + * + * @param string + * @param is + * @param zx + * @param strings + * @param i + * @param j + */ + public static void writeExcelForZX(String xls_write_Address, File file, ArrayList> ls, + int row_num, int col_num) throws IOException { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// (new + is.close(); + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 + XSSFCellStyle style = wb.createCellStyle(); + XSSFFont font = wb.createFont(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + XSSFSheet sheet = wb.getSheetAt(0); + for (int i = 0; i < ls.size(); i++) { + if (i % 30 == 0 && i != 0) { + row_num += 10; + } + XSSFRow row = sheet.getRow(i + row_num - 1); + ArrayList ls2 = ls.get(i); + for (int cols = 0; cols < ls2.size(); cols++) { + XSSFCell cell = null; + if (cols == ls2.size() - 1) + cell = row.getCell(cols + col_num - 1); + else + cell = row.getCell(cols + col_num - 1); + cell.setCellType(XSSFCell.CELL_TYPE_STRING);// 文本格式 +// cell.setCellStyle(style);// 添加边框 + if (cols + col_num == 11) { + String cpgc = ls2.get(cols); + System.out.println(cpgc); + String[] strs = cpgc.split("special"); + System.out.println("strs.length=>" + strs.length); + if (cpgc != null && cpgc != "") { + if (!" ".equals(strs[1])) { + String special = strs[1]; + if (special.indexOf("|") <= 0) { + if ("产品/过程/规格/公差".equals(special.split("-")[0])) { + int index = Integer.valueOf(special.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + + } else { + String[] tstxs = special.split("\\|"); + for (String str : tstxs) { + if ("产品/过程/规格/公差".equals(str.split("-")[0])) { + int index = Integer.valueOf(str.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + } + } + } else { + // 直接写入strs[0] + cell.setCellValue(strs[0]); + } + } + } else + cell.setCellValue(ls2.get(cols));// 写入内容 + } + + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + + } + + /** + * 输出烧结作业指导书 + * + * @param string + * @param is + * @param zx + * @param strings + * @param i + * @param j + */ + public static void writeExcelForSJ(String xls_write_Address, File file, ArrayList> ls, + List productNameList24, List productNameList18) throws IOException { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// (new + is.close(); + FileOutputStream output = new FileOutputStream(new File(xls_write_Address)); // 读取的文件路径 +// writeExcelWithOneCellName(wb, "生产设备", rb3_jqsb); + XSSFCellStyle style = wb.createCellStyle(); + XSSFFont font = wb.createFont(); + font.setFontHeightInPoints((short) 8); + style.setFont(font); + XSSFSheet s = wb.getSheetAt(0); + s.setForceFormulaRecalculation(true); + if (productNameList24 != null) { + setNamedCellValue(wb, "二十四寸", + productNameList24.toString().substring(1, productNameList24.toString().length() - 1)); + } + if (productNameList18 != null) { + setNamedCellValue(wb, "十八寸", + productNameList18.toString().substring(1, productNameList18.toString().length() - 1)); + } + int[] indexs = getNamedCellIndex(wb, "设备"); + int startRow = indexs[1] + 1; + int startColumn = indexs[0]; + for (int i = 0; i < productNameList24.size(); i++) { + + Row r = s.getRow(startRow + i); + setCellValue(r, startColumn, productNameList24.get(i)); + } + for (int i = 0; i < productNameList18.size(); i++) { + Row r = s.getRow(startRow + productNameList24.size() + i); + setCellValue(r, startColumn, productNameList18.get(i)); + } + + int row_num = 0; + int t = 0; + for (int i = 0; i < ls.size(); i++) { + if (t % 12 == 0 && i != 0) { + t = 0; + row_num += 29; + } + + ArrayList ls2 = ls.get(i); + System.out.println("SJ_data.size===============>" + ls2.size()); + System.out.println("SJ_data====================>" + ls2.toString()); + for (int j = 0; j < ls2.size() + 1; j++) { + int namedCellIdx = wb.getNameIndex("head" + String.valueOf(j + 1)); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + CellReference[] crefs = arefs[0].getAllReferencedCells(); + for (int k = 0; k < crefs.length; k++) { + Row r = s.getRow(crefs[k].getRow() + row_num + 1); + Cell c = r.getCell(crefs[k].getCol()); + if (j == 2) { + toSpecial(j, wb, c, ls2); + } else if (namedCellIdx != wb.getNameIndex("head7")) + c.setCellValue(ls2.get(j)); + else + c.setCellValue("√"); + } + } + + } + t++; + row_num++; + } + wb.write(output); + output.close(); + System.out.println("-------WRITE EXCEL OVER-------"); + + } + + // 20181220-ReinhartEdit + /*** + * 输出热处理作业指导书 + * + * @param xls_write_Address + * @param ls + * @param sheetnames + * @param row_num + * @param col_num + * @throws IOException + * + */ + public static void writeExcelForRCL(String xls_write_Address, File file, ArrayList> ls, + int row_num, int col_num) throws IOException { + // InputStream is = new FileInputStream(file); + // XSSFWorkbook wb = new XSSFWorkbook(is);// (new + // is.close(); + // FileOutputStream output = new FileOutputStream(new File( + // xls_write_Address)); // 读取的文件路径 + + // XSSFCellStyle style = wb.createCellStyle(); + // MessageBox.post("In Processing", "Step", MessageBox.WARNING); + + // MessageBox.post(xls_write_Address, "Step", MessageBox.WARNING); + + // 读取Excel文档 + // File finalXlsxFile = new File("D:/NBTM热处理工艺指导书.xlsx"); + File finalXlsxFile = new File(xls_write_Address); + Workbook workBook = getWorkbok(finalXlsxFile); + // sheet 对应一个工作页 + Sheet getSheet = workBook.getSheetAt(0); + +// style.setBorderBottom(XSSFCellStyle.BORDER_THIN); +// style.setBorderTop(XSSFCellStyle.BORDER_THIN); +// style.setBorderRight(XSSFCellStyle.BORDER_THIN); +// style.setAlignment(XSSFCellStyle.ALIGN_CENTER); + // XSSFFont font = wb.createFont(); + /// font.setFontHeightInPoints((short) 8); + // style.setFont(font); + + if (ls != null) { + + int rowNumber = getSheet.getLastRowNum(); // 第一行从0开始算 + System.out.println("原始数据总行数:" + ls.size()); + + // 先把模板文件内容清空了 + for (int i = 0; i < 10; i++) { + Row row = getSheet.getRow(i + 26); + + if (row == null) { + row = getSheet.createRow(i + 26); + } + try { + Cell Itemcell = row.getCell(2); + if (Itemcell == null) { + Itemcell = row.createCell(2); + } + Itemcell.setCellValue("");// 写入内容 + + Cell Valuecell = row.getCell(6); + if (Valuecell == null) { + Valuecell = row.createCell(6); + } + Valuecell.setCellValue("");// 写入内容 + + Cell Processcell = row.getCell(10); + if (Processcell == null) { + Processcell = row.createCell(10); + } + Processcell.setCellValue("");// 写入内容 + + Cell Doublecell = row.getCell(14); + if (Doublecell == null) { + Doublecell = row.createCell(14); + } + Doublecell.setCellValue("");// 写入内容 + + } catch (Exception ex) { + System.out.println(ex.toString()); + MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); + + return; + } + + } + // System.out.println("先把模板文件内容清空了" ); + + // 先把模板文件内容清空了 + // 写入参数数据 + // System.out.println(ls.size()); + for (int i = 0; i < ls.size(); i++) { + + System.out.println("写入实际数据!"); + Row row = getSheet.getRow(i + 26); + + if (row == null) { + row = getSheet.createRow(i + 26); + } + + ArrayList ls2 = ls.get(i); + // System.out.println(ls2.get(i)); + // MessageBox.post(ls2.get(0), "Step", MessageBox.WARNING); + + try { + + Cell Itemcell = row.getCell(2); + if (Itemcell == null) { + Itemcell = row.createCell(2); + } + System.out.println(ls2.get(1)); + Itemcell.setCellValue(ls2.get(1));// 写入内容 + + Cell Valuecell = row.getCell(6); + if (Valuecell == null) { + Valuecell = row.createCell(6); + } + System.out.println(ls2.get(2)); + Valuecell.setCellValue(ls2.get(2));// 写入内容 + + Cell Processcell = row.getCell(10); + if (Processcell == null) { + Processcell = row.createCell(10); + } + System.out.println(ls2.get(3)); + Processcell.setCellValue(ls2.get(3));// 写入内容 + + Cell Doublecell = row.getCell(14); + if (Doublecell == null) { + Doublecell = row.createCell(14); + } + System.out.println(ls2.get(4)); + Doublecell.setCellValue(ls2.get(4));// 写入内容 + + } catch (Exception ex) { + System.out.println(ex.toString()); + MessageBox.post(ex.toString(), "Error", MessageBox.ERROR); + + return; + } + + } + // 写入参数数据 + + // FileOutputStream output = new FileOutputStream("D:/MY热处理工艺指导书.xlsx"); // + // 读取的文件路径 + FileOutputStream output = new FileOutputStream(xls_write_Address); // 读取的文件路径 + + workBook.write(output); + // wb.write(output); + + if (output != null) { + output.flush(); + output.close(); + } + + // System.out.println("Start output data to Excel end!!!!!"); + // MessageBox.post(" output data to Excel end!!!!!", "Step", + // MessageBox.WARNING); + + } else { + MessageBox.post("请完善控制计划!", "警告", MessageBox.WARNING); + } + + System.out.println("-------WRITE EXCEL OVER-------"); + } + + public static void toSpecial(int cols, XSSFWorkbook wb, Cell cell, ArrayList cell_Date) { + String cpgc = cell_Date.get(cols); +// System.out.println(cpgc); + String[] strs = cpgc.split("special"); +// System.out.println(strs.length); + if (cpgc != null || cpgc != "") { + if (!"null".equals(strs[1]) && !" ".equals(strs[1])) { + String special = strs[1]; + if (special.indexOf("|") <= 0) { + if ("产品/过程/规格/公差".equals(special.split("-")[0])) { + int index = Integer.valueOf(special.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + + } else { + String[] tstxs = special.split("\\|"); + for (String str : tstxs) { + if ("产品/过程/规格/公差".equals(str.split("-")[0])) { + int index = Integer.valueOf(str.split("-")[1]); + if (strs[0] != null && strs[0] != "") { + cell.setCellValue(setCellFont(wb, strs[0], index, index + 1, 8, "Y14.5M")); + } + } + } + } + } else { + // 直接写入strs[0] + cell.setCellValue(strs[0]); + } + } + + } + + public static void writeExcelWithOneCellName(XSSFWorkbook wb, String cellName, String value) { + + int namedCellIdx = wb.getNameIndex(cellName); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + for (int i = 0; i < arefs.length; i++) { + CellReference[] crefs = arefs[i].getAllReferencedCells(); + for (int j = 0; j < crefs.length; j++) { + Sheet s = wb.getSheet(crefs[j].getSheetName()); + Row r = s.getRow(crefs[j].getRow()); + Cell c = r.getCell(crefs[j].getCol()); + c.setCellValue(value); + } + } + } + } + + /** + * 将对象属性值写入到Excel中 + * + * @param output + * @param file + * @param cellName + * @param cellValue + */ + public static void writeExcelWithCellName(File file, String fileOutUrl, Map map, int code, + String meop_name) { + try { + InputStream is = new FileInputStream(file); + Workbook wb = new XSSFWorkbook(is);// retrieve workbook + is.close(); + FileOutputStream output = new FileOutputStream(new File(fileOutUrl)); + boolean is_first = true; + for (String key : map.keySet()) { + if (is_first && "产品代号".equals(key) && (code == 3 || code == 4 || code == 5)) { + int a1CellIndex = wb.getNameIndex("head"); + if (a1CellIndex != -1) { + Name a1NameCell = wb.getNameAt(a1CellIndex); + AreaReference[] a1ARF = AreaReference.generateContiguous(a1NameCell.getRefersToFormula()); + CellReference[] a1CRF = a1ARF[0].getAllReferencedCells(); + Sheet s = wb.getSheet(a1CRF[0].getSheetName()); + Row r = s.getRow(a1CRF[0].getRow()); + Cell c = r.getCell(a1CRF[0].getCol()); + System.out.println(key + ":" + c.getStringCellValue()); + c.setCellValue(c.getStringCellValue() + map.get(key)); + is_first = false; + } + } + + if ("工艺流程".equals(key)) { + SetFont(wb, map.get(key), meop_name); + } + + else { + + int namedCellIdx = wb.getNameIndex(key); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + for (int i = 0; i < arefs.length; i++) { + CellReference[] crefs = arefs[i].getAllReferencedCells(); + + for (int j = 0; j < crefs.length; j++) { + + Sheet s = wb.getSheet(crefs[j].getSheetName()); + Row r = s.getRow(crefs[j].getRow()); + Cell c = r.getCell(crefs[j].getCol()); + if (code == 2) { + c.setCellValue(map.get(key).split("/")[0]); + } else + c.setCellValue(map.get(key)); + } + } + } + } + } + wb.write(output); + output.close(); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 设置str1中str2的字体 + * + * @param wb + * @param str1 + * @param str2 + * @throws IOException + */ + private static void SetFont(Workbook wb, String str1, String str2) throws IOException { + int index = 0; + int start_index = 0; + int end_index = str1.length(); + String meop_name = str2.split("/")[0]; + if (str1.indexOf("成形") != -1) + start_index = str1.indexOf("成形"); + if (str1.lastIndexOf("包装") != -1) + end_index = str1.lastIndexOf("包装") + 2; + str1 = str1.substring(start_index, end_index); + while ((index = str1.indexOf(meop_name, index)) != -1) { + int next_index = index + meop_name.length(); + boolean begin = index - 1 < 0 || str1.charAt(index - 1) == '-'; + boolean end = next_index > str1.length() || next_index + 1 > str1.length() ? true + : str1.charAt(next_index) == '-'; + if (begin && end) + break; + else + index = index + meop_name.length(); + } + XSSFRichTextString ts = new XSSFRichTextString(str1); + XSSFFont font1 = (XSSFFont) wb.createFont(); + font1.setFontHeightInPoints((short) 10); // 字体高度 + font1.setFontName("仿宋"); // 字体 + XSSFFont font = (XSSFFont) wb.createFont(); + font.setFontHeightInPoints((short) 12); // 字体高度 + font.setFontName("仿宋"); + ts.applyFont(index, index + meop_name.length(), font); + ts.applyFont(index + meop_name.length(), ts.length(), font1); +// XSSFFont font = (XSSFFont) wb.createFont(); +// +// font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD); +// ts.applyFont(index, index+str2.length(), font); + int namedCellIdx = wb.getNameIndex("工艺流程"); + if (namedCellIdx != -1) { + Name aNamedCell = wb.getNameAt(namedCellIdx); + AreaReference[] arefs = AreaReference.generateContiguous(aNamedCell.getRefersToFormula()); + for (int i = 0; i < arefs.length; i++) { + CellReference[] crefs = arefs[i].getAllReferencedCells(); + for (int j = 0; j < crefs.length; j++) { + Sheet s = wb.getSheet(crefs[j].getSheetName()); + Row r = s.getRow(crefs[j].getRow()); + Cell c = r.getCell(crefs[j].getCol()); + c.setCellValue(ts); + } + } + } + } + + /** + * 添加命名的引用 + * + * @param session + * @param item 对象的版本 + * @param tcResource 文件的物理路径 + * @param relationType 关系名称 + * @param fileName 文件名 + */ + public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String tcResource, + String fileName, String relationType, String excelType, boolean isDelete) { + try { + String as1[] = { tcResource };// 文件的物理路径 + String as2[] = { "excel" }; + String as3[] = { excelType }; + String as4[] = { "Plain" }; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType) session + .getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", excelType); + tccomponentDataset.setFiles(as1, as3, as4, as2); + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + for (AIFComponentContext zyzdsChildren : zyzdsChildrens) { + if (excelType.equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren.getComponent(); + if (dateSet.getStringProperty("object_name").equals(fileName)) { + dateSet.delete(); + zyzdsRev.remove(relationType, dateSet); + } + } + } + item.add(relationType, tccomponentDataset); + if (isDelete) { + new File(tcResource).delete(); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * 获取命名的引用返回所有对象 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset[] getComponentToDatasets(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + TCComponentDataset[] Childrens = new TCComponentDataset[zyzdsChildrens.length]; + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (int ii = 0; ii < zyzdsChildrens.length; ii++) { + + if (zyzdsChildrens[ii] instanceof TCComponentDataset) { + // + + Childrens[ii] = (TCComponentDataset) zyzdsChildrens[ii]; + + // + } + +// + + } + + return Childrens; + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + + public static TCComponentDataset getComponentToDataset(TCSession session, TCComponentItemRevision item, + String relationType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + + return (TCComponentDataset) zyzdsChildren; +// + + } + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static TCComponentDataset getExcelToDataset(TCSession session, TCComponentItemRevision item, + String relationType, String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + return (TCComponentDataset) zyzdsChildren; +// TCComponentTcFile[] tcFile = dateSet.getTcFiles(); +// return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取命名的引用 + * + * @param session + * @param item 对象的版本 + * @param relationType 关系名称 + */ + public static File getExcelToItem(TCSession session, TCComponentItemRevision item, String relationType, + String fileType) { + try { + TCComponent[] zyzdsChildrens = item.getRelatedComponents(relationType); + if (zyzdsChildrens == null || zyzdsChildrens.length < 1) { + return null; + } + for (TCComponent zyzdsChildren : zyzdsChildrens) { + if (fileType.equals(zyzdsChildren.getType())) { + TCComponentDataset dateSet = (TCComponentDataset) zyzdsChildren; + TCComponentTcFile[] tcFile = dateSet.getTcFiles(); + return tcFile[0].getFmsFile(); + } + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + /** + * 获取合并单元格 + * + * @param value 值 + * @param startIndex 起始行 + * @return + */ + public static void getCombineRow(String value, int startIndex) { + // TODO Auto-generated method stub + String[] sombines = null; + if (value != null && !value.equals("")) { + if (value.indexOf("-") >= 0) { + sombines = value.split("-"); + } else { + sombines = new String[] { value }; + } + } + for (int j = 0; j < sombines.length; j++) { + if (sombines[j].indexOf("/") >= 0) { + int[] row; + int[] cloumn; + String[] cells = sombines[j].split("/"); + if (cells[0].indexOf(",") >= 0) { + String[] rows = cells[0].split(","); + row = new int[rows.length]; + for (int k = 0; k < rows.length; k++) { + row[k] = Integer.parseInt(rows[k]) + startIndex; + } + } else { + row = new int[] { Integer.parseInt(cells[0]) + startIndex }; + } + if (cells[1].indexOf(",") >= 0) { + String[] cloumns = cells[1].split(","); + cloumn = new int[cloumns.length]; + for (int k = 0; k < cloumns.length; k++) { + cloumn[k] = Integer.parseInt(cloumns[k]) - 1; + } + } else { + cloumn = new int[] { Integer.parseInt(cells[1]) - 1 }; + } + map.put(row, cloumn); + } + } + } + + /** + * 获取单个的命名单元格的列 + * + * @param wb + * @param cellName + * @return + * @throws IOException + */ + public static int getOneNamedCellIndex(XSSFWorkbook wb, String cellName) throws IOException { + int index = -1; + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + XSSFName name = wb.getName(cellName); + if (name == null) { + return -1; + } + AreaReference[] areaRs = AreaReference.generateContiguous(name.getRefersToFormula()); + if (areaRs != null) + for (AreaReference areaR : areaRs) { + CellReference[] cellRs = areaR.getAllReferencedCells(); + if (cellRs != null) { + for (CellReference cellR : cellRs) { + String sheetName = cellR.getSheetName(); + short colIndex = cellR.getCol(); + int rowIndex = cellR.getRow(); + XSSFSheet sheet = wb.getSheet(sheetName); + XSSFRow row = sheet.getRow(rowIndex); + return colIndex; + } + } + } + return index; + } + + /** + * 改变数据集的命名引用 + * + * @param tccomponentDataset + * @param quote + * @param type + * @param path + * @throws TCException + */ + public static void changeDataSet(TCComponentDataset tccomponentDataset, String quote, String type, String path) + throws TCException { + String myPath[] = { path }; + String myQuote[] = { quote };// 引用"excel" + String myType[] = { type };// 类型"MSExcelX" + String myPlain[] = { "Plain" }; + + // 删除数据集的引用 + deleDateSetRef(tccomponentDataset); + // 数据集的替换 + tccomponentDataset.setFiles(myPath, myType, myPlain, myQuote); + + } + + /** + * 删除数据集的命名引用 + * + * @param dataset + * @throws TCException + */ + private static void deleDateSetRef(TCComponentDataset dataset) throws TCException { + + TCComponentTcFile[] tcFiles = dataset.getTcFiles(); + for (int i = 0; i < tcFiles.length; i++) { + // 得到数据集的引用类型 + String str_temp = getNamedRefType(dataset, tcFiles[i]); + // 删除引用 + dataset.removeNamedReference(str_temp); + } + + } + + /** + * 得到数据集的引用类型 + * + * @param datasetComponent + * @param tccomponent + * @return + * @throws TCException + */ + private static String getNamedRefType(TCComponentDataset datasetComponent, TCComponentTcFile tccomponent) + throws TCException { + String s; + s = ""; + TCProperty tcproperty; + TCProperty tcproperty1; + TCComponent atccomponent[]; + String as[]; + int i; + int j; + int k; + try { + tcproperty = datasetComponent.getTCProperty("ref_list"); + tcproperty1 = datasetComponent.getTCProperty("ref_names"); + if (tcproperty == null || tcproperty1 == null) + return s; + } catch (TCException tcexception) { + return s; + } + atccomponent = tcproperty.getReferenceValueArray(); + as = tcproperty1.getStringValueArray(); + if (atccomponent == null || as == null) + return s; + i = atccomponent.length; + if (i != as.length) + return s; + j = -1; + k = 0; + do { + if (k >= i) + break; + if (tccomponent == atccomponent[k]) { + j = k; + break; + } + k++; + } while (true); + if (j != -1) + s = as[j]; + return s; + } + + /** + * 下载文件 + * + * @param comps + * @return + * @throws TCException + * @throws IOException + */ + public static String downLoadFile(TCComponentDataset dateSet, String compType) throws TCException, IOException { + String value = ""; + String tempPath = System.getenv("TEMP"); + // MessageBox.post(" tempPath = "+tempPath,"INFO",MessageBox.INFORMATION); + if (tempPath == null) { + tempPath = ""; + } else if (!tempPath.endsWith("\\")) { + tempPath = tempPath + "\\"; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyymmdd"); + TCComponentTcFile[] tcFiles = dateSet.getTcFiles(); + File file = null; + if (tcFiles != null) { + file = tcFiles[0].getFmsFile(); + String fileName = file.getName(); + String fileDix = fileName.substring(fileName.lastIndexOf("."), fileName.length()); + fileName = tempPath + sdf.format(new Date()) + fileDix; + File dirFile = new File(fileName); + FileUtility.copyFile(file, dirFile); +// if (compType.equals("MSExcelX")) { +// this.excelDataset = (TCComponentDataset) comp; +// } + return fileName; + } + return value; + } + + public static void setFlowChart(Map valueMap, File file) { + // TODO Auto-generated method stub + file.setWritable(true); + try { + InputStream is = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(is);// ( + XSSFSheet sheet = wb.getSheetAt(0); + + Iterator> it = valueMap.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + setNamedCellValue(wb, entry.getKey(), entry.getValue()); + } + FileOutputStream output = new FileOutputStream(file); + wb.write(output); + output.close(); + is.close(); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + } + // file.setReadOnly(); + System.out.println("-------WRITE EXCEL OVER-------"); + } + + public static Workbook getWorkbok(File file) throws IOException { + Workbook wb = null; + FileInputStream in = new FileInputStream(file); + System.out.println(file.getName()); + + if (file.getName().endsWith(EXCEL_XLS)) { // Excel 2003 + wb = new HSSFWorkbook(in); + } else if (file.getName().endsWith(EXCEL_XLSX)) { // Excel 2007/2010 + System.out.println("OK"); + wb = new XSSFWorkbook(in); + } + return wb; + } + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static List readExcelByEntrustment(File excel_file, String type) + throws FileNotFoundException, IOException { + if (excel_file == null || !excel_file.exists()) { + return null; + } + // 用来返回的所有的行的信息 + List lines_msg = new ArrayList(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + boolean isSelectType = false;// 判断是否找到指定的类型 + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + if (row == null) { + isSelectType = false; + continue; + } + // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); + if (getStringCellValue(evaluator, row.getCell((short) 0)) == null + || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { + isSelectType = false; + } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { + isSelectType = true; + if (row.getCell((short) 2) != null) { + String value = getStringCellValue(evaluator, row.getCell((short) 1)); + lines_msg.add(value); + } + } else { + continue; + } + + } + // insertRow(sheet,4,1); + return lines_msg; + } + + /** + * 读取EXCEL表 + * + * @param File excel_file + * @return List> 返回的信息 + * @throws IOException + * @throws FileNotFoundException + */ + public static DefaultMutableTreeNode readExcelNodeByEntrustment(File excel_file, String type) + throws FileNotFoundException, IOException { + DefaultMutableTreeNode node = new DefaultMutableTreeNode("应用领域"); + if (excel_file == null || !excel_file.exists()) { + return node; + } + // 用来返回的所有的行的信息 + //List lines_msg = new ArrayList(); + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workBook); + XSSFSheet sheet = workBook.getSheetAt(0); + XSSFRow title_row = sheet.getRow(0); + + // 得到列的数目 + int col_count = title_row.getPhysicalNumberOfCells(); + // 得到行的数目 + int row_count = sheet.getLastRowNum(); + boolean isSelectType = false;// 判断是否找到指定的类型 + String no1 = ""; + String no2 = ""; + DefaultMutableTreeNode no1Node = null; + DefaultMutableTreeNode no2Node = null; + for (int j = 0; j < row_count + 1; j++) { + // 用来返回单行的信息 + XSSFRow row = sheet.getRow(j); + if (row == null) { + isSelectType = false; + continue; + } + // System.out.println(getStringCellValue(evaluator, row.getCell((short) 0))); + if (getStringCellValue(evaluator, row.getCell((short) 0)) == null + || getStringCellValue(evaluator, row.getCell((short) 0)).isEmpty()) { + isSelectType = false; + } else if (isSelectType || type.compareTo(getStringCellValue(evaluator, row.getCell((short) 0))) == 0) { + isSelectType = true; + if (row.getCell((short) 4) != null) { + String value1 = getStringCellValue(evaluator, row.getCell((short) 1)); + String value2 = getStringCellValue(evaluator, row.getCell((short) 2)); + //String value = getStringCellValue(evaluator, row.getCell((short) 3)); + String value4 = getStringCellValue(evaluator, row.getCell((short) 4)); + if(!value1.isEmpty() && value1.compareTo(no1) != 0) + { + no1Node = new DefaultMutableTreeNode(value1); + node.add(no1Node); + no2Node = new DefaultMutableTreeNode(value2); + no1Node.add(no2Node); + } + else if(!value2.isEmpty() && value2.compareTo(no2) != 0) { + no2Node = new DefaultMutableTreeNode(value2); + no1Node.add(no2Node); + } + + no2Node.add(new DefaultMutableTreeNode(value4)); + + //lines_msg.add(value); + } + } else { + continue; + } + + } + // insertRow(sheet,4,1); + return node; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/FinalUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/FinalUtil.java new file mode 100644 index 0000000..3e549d8 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/FinalUtil.java @@ -0,0 +1,10 @@ +package com.connor.ml.tcm.util; + +public class FinalUtil { + // ---------------ML_07---------------------------------------------- + + + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JAutoCompleteComboBox.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JAutoCompleteComboBox.java new file mode 100644 index 0000000..1c0eab5 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JAutoCompleteComboBox.java @@ -0,0 +1,160 @@ +package com.connor.ml.tcm.util; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +@SuppressWarnings({ "serial", "rawtypes", "unchecked" }) +public class JAutoCompleteComboBox extends JComboBox { + private AutoCompleter completer; + + public JAutoCompleteComboBox() { + super(); + addCompleter(); + } + + public JAutoCompleteComboBox(ComboBoxModel cm) { + super(cm); + addCompleter(); + } + + public JAutoCompleteComboBox(Object[] items) { + super(items); + addCompleter(); + } + + public JAutoCompleteComboBox(List v) { + super((Vector) v); + addCompleter(); + } + + private void addCompleter() { + setEditable(true); + completer = new AutoCompleter(this); + } + + public void autoComplete(String str) { + this.completer.autoComplete(str, str.length()); + } + + public String getText() { + return ((JTextField) getEditor().getEditorComponent()).getText(); + } + + public void setText(String text) { + ((JTextField) getEditor().getEditorComponent()).setText(text); + } + + public boolean containsItem(String itemString) { + for (int i = 0; i < this.getModel().getSize(); i++) { + String _item = " " + this.getModel().getElementAt(i); + if (_item.equals(itemString)) + return true; + } + return false; + } + +} + +@SuppressWarnings({"rawtypes"}) +class AutoCompleter implements KeyListener, ItemListener { + + private JComboBox owner = null; + private JTextField editor = null; + + private ComboBoxModel model = null; + + public AutoCompleter(JComboBox comboBox) { + owner = comboBox; + editor = (JTextField) comboBox.getEditor().getEditorComponent(); + editor.addKeyListener(this); + model = comboBox.getModel(); + owner.addItemListener(this); + } + + public void keyTyped(KeyEvent e) { + } + + public void keyPressed(KeyEvent e) { + } + + @SuppressWarnings("unused") + public void keyReleased(KeyEvent e) { + char ch = e.getKeyChar(); + // if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch) + // || ch == KeyEvent.VK_DELETE) + // return; + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int caretPosition = editor.getCaretPosition(); + String str = editor.getText(); + if (str.length() == 0) + return; + autoComplete(str, caretPosition); + } + } + + @SuppressWarnings({ "unchecked", "unused" }) + protected void autoComplete(String strf, int caretPosition) { + Object[] opts; + opts = getMatchingOptions(strf.substring(0, caretPosition)); + if (owner != null) { + model = new DefaultComboBoxModel(opts); + owner.setModel(model); + } + if (opts.length > 0) { + String str = opts[0].toString(); + editor.setCaretPosition(caretPosition); + if (owner != null) { + try { + owner.showPopup(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + } + + @SuppressWarnings("unchecked") + protected Object[] getMatchingOptions(String str) { + List v = new Vector(); + List v1 = new Vector(); + // v.add(str); + for (int k = 0; k < model.getSize(); k++) { + Object itemObj = model.getElementAt(k); + if (itemObj != null) { + String item = itemObj.toString().toLowerCase(); + if (item.indexOf((str.toLowerCase())) > -1) + v.add(model.getElementAt(k)); + else + v1.add(model.getElementAt(k)); + } else + v1.add(model.getElementAt(k)); + } + for (int i = 0; i < v1.size(); i++) { + v.add(v1.get(i)); + } + // if (v.isEmpty()) + return v.toArray(); + } + + public void itemStateChanged(ItemEvent event) { + if (event.getStateChange() == ItemEvent.SELECTED) { + int caretPosition = editor.getCaretPosition(); + if (caretPosition != -1) { + try { + editor.moveCaretPosition(caretPosition); + } catch (IllegalArgumentException ex) { + ex.printStackTrace(); + } + } + } + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JProTextField.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JProTextField.java new file mode 100644 index 0000000..cae50d3 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JProTextField.java @@ -0,0 +1,16 @@ +package com.connor.ml.tcm.util; + +import javax.swing.JTextField; + +public class JProTextField extends JTextField { + private String realName; + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JaxbUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JaxbUtil.java new file mode 100644 index 0000000..088dc99 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/JaxbUtil.java @@ -0,0 +1,69 @@ +package com.connor.ml.tcm.util; + + +import java.io.File; +import java.io.FileNotFoundException; + +import javax.xml.XMLConstants; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; + +public class JaxbUtil { + + public static boolean validate(final String xmlPath, final String xsdPath) { + boolean result = true; + try { + final String language = "http://www.w3.org/2001/XMLSchema"; + final SchemaFactory factory = SchemaFactory.newInstance(language); + final Schema schema = factory.newSchema(new File(xsdPath)); + final Validator validator = schema.newValidator(); + validator.validate(new StreamSource(xmlPath)); + } catch (final Exception e) { + result = false; + } + return result; + } + + /** + * 序列化 + * @param clazz + * @param object + * @param path + * @throws JAXBException + */ + public static void marshall(final Class clazz, final Object object, final String path) throws JAXBException { + // 通过映射的类创建XMLContext上下文对象,其中参数为映射的类。 + JAXBContext jaxbContext = JAXBContext.newInstance(clazz); + // 通过JAXBComtext上下文对象的createMarshaller()方法,创建一个对象java格式转化成XML的格式 + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); + // 最后,将JAVA对象转换到制定的输出位置,其中的object为java对象。 + marshaller.marshal(object, new File(path)); + } + + /** + * 解析 + * @param clazz + * @param path + * @return + * @throws Exception + */ + public static Object unmarshaller(final Class clazz, final String path) throws Exception { + if (path == null || !new File(path).exists()) { + throw new FileNotFoundException(); + } + // 通过映射的类创建XMLComtext上下文对象,其中参数为映射的类。 + JAXBContext jaxbContext = JAXBContext.newInstance(clazz); + // 通过JAXBContext上下文对象创建createUnmarshaller()方法,创建XML转换成JAVA对象的格式。 + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + // 最后,将XML转换成对映的类,转换后需要强制性转换成映射的类 + Object object = unmarshaller.unmarshal(new File(path)); + return object; + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLRequestEntity.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLRequestEntity.java new file mode 100644 index 0000000..d9f09a0 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLRequestEntity.java @@ -0,0 +1,32 @@ +package com.connor.ml.tcm.util; + +public class MLRequestEntity { + + private String errcode; + private String errmsg; + private String result; + public String getErrcode() { + return errcode; + } + public void setErrcode(String errcode) { + this.errcode = errcode; + } + public String getErrmsg() { + return errmsg; + } + public void setErrmsg(String errmsg) { + this.errmsg = errmsg; + } + public String getResult() { + return result; + } + public void setResult(String result) { + this.result = result; + } + @Override + public String toString() { + return "MLRequestEntity [errcode=" + errcode + ", errmsg=" + errmsg + ", result=" + result + "]"; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLtoERPEntity.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLtoERPEntity.java new file mode 100644 index 0000000..52010b2 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLtoERPEntity.java @@ -0,0 +1,57 @@ +package com.connor.ml.tcm.util; + +import java.util.List; + +public class MLtoERPEntity { + + private String infotype; + private String infocode; + private String infoname; + private String infodesc; + private List data; + private List list; + public String getInfotype() { + return infotype; + } + public void setInfotype(String infotype) { + this.infotype = infotype; + } + public String getInfocode() { + return infocode; + } + public void setInfocode(String infocode) { + this.infocode = infocode; + } + public String getInfoname() { + return infoname; + } + public void setInfoname(String infoname) { + this.infoname = infoname; + } + public String getInfodesc() { + return infodesc; + } + public void setInfodesc(String infodesc) { + this.infodesc = infodesc; + } + public List getData() { + return data; + } + public void setData(List data) { + this.data = data; + } + public List getList() { + return list; + } + public void setList(List list) { + this.list = list; + } + @Override + public String toString() { + return "MLtoERPEntity [infotype=" + infotype + ", infocode=" + infocode + ", infoname=" + infoname + + ", infodesc=" + infodesc + ", data=" + data + ", list=" + list + "]"; + } + + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLtoERPEntity2.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLtoERPEntity2.java new file mode 100644 index 0000000..cd61df7 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MLtoERPEntity2.java @@ -0,0 +1,24 @@ +package com.connor.ml.tcm.util; + +public class MLtoERPEntity2 { + + private String field; + private String value; + public String getField() { + return field; + } + public void setField(String field) { + this.field = field; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + @Override + public String toString() { + return "MLtoERPEntity2 [field=" + field + ", value=" + value + "]"; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MethodUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MethodUtil.java new file mode 100644 index 0000000..edc8d02 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MethodUtil.java @@ -0,0 +1,1816 @@ +package com.connor.ml.tcm.util; + +import com.connor.ml.tcm.ML_08.SendProductRevDialog; +import com.connor.ml.tcm.ML_18.ScreenShotTest; +import com.connor.ml.tcm.bean.ComboBoxItemBean; +import com.connor.ml.tcm.bean.ItemBean; +import com.connor.ml.tcm.bean.PropExplictBean; +import com.connor.ml.tcm.bean.SendSAPProductRevBean; +import com.connor.ml.tcm.cloneProcess.WebApiUtil; +import com.google.gson.Gson; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentDatasetType; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProcess; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; +import com.teamcenter.rac.kernel.ics.ICSKeyLov; +import com.teamcenter.rac.kernel.ics.ICSPropertyDescription; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2006_03.DataManagement.CreateItemsResponse; +import com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes; +import com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties; +import java.awt.Component; +import java.awt.Dimension; +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; +import java.util.Map.Entry; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +public class MethodUtil { + private static final String SEP1 = ","; + + public static void sendBom(TCSession session, TCComponentItemRevision itemRevision) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[]{itemRevision}; + userservice.call("Super_Bom_Appent_Data", obj); + } + + public static String getRuleItemID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000"); + String newID = oldItemID + "-001"; + + try { + TCComponentItemType tccomponentitemtype = (TCComponentItemType)session.getTypeComponent("Item"); + tccomponentitemtype.getNewID(); + + for(int i = 1; tccomponentitemtype.find(newID) != null; newID = oldItemID + "-" + df.format((long)i)) { + ++i; + } + } catch (TCException var6) { + var6.printStackTrace(); + } + + return newID; + } + + public static String ListToString(List list) { + StringBuffer sb = new StringBuffer(); + if (list != null && list.size() > 0) { + for(int i = 0; i < list.size(); ++i) { + if (list.get(i) != null && list.get(i) != "") { + if (list.get(i) instanceof List) { + sb.append(ListToString((List)list.get(i))); + sb.append(","); + } else { + sb.append(list.get(i)); + sb.append(","); + } + } + } + } + + return sb.toString(); + } + + public static String getGroupLov(TCSession session, String lovName, String key) { + try { + TCComponentListOfValues rtlistOfValues = TCLOVUtil.findLOVByName(session, "TM2_GROUP"); + ListOfValuesInfo rtlistOfValuesInfo = rtlistOfValues.getListOfValues(); + String[] groupName = rtlistOfValuesInfo.getStringListOfValues(); + String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); + + for(int i = 0; i < groupName.length; ++i) { + if (groupName[i].equals(key)) { + return groupDisplayName[i]; + } + } + } catch (TCException var8) { + MessageBox.post("获取组的LOV错误!请联系系统管理员!", "错误!", 1); + var8.printStackTrace(); + } + + return ""; + } + + public static File getFile(TCSession session, String fileName, String Filetype) { + try { + TCPreferenceService service = session.getPreferenceService(); + String[] modelFiles = service.getStringValues("ML_Doc_Teamplate"); + if (modelFiles == null) { + System.out.println("未找到首选项"); + return null; + } + + String itemId = ""; + + for(int i = 0; i < modelFiles.length; ++i) { + if (modelFiles[i].split(":")[0].equals(fileName)) { + itemId = modelFiles[i].split(":")[1]; + } + } + + TCComponentItemType itemType = (TCComponentItemType)session.getTypeComponent("Item"); + TCComponentItem fileItem = itemType.find(itemId); + TCComponentDataset dat = null; + TCComponentItemRevision fileItemLastRev = getLastItemRevision(fileItem); + TCComponent[] comps = fileItemLastRev.getReferenceListProperty("IMAN_specification"); + System.out.println("count =" + comps == null ? "null" : comps.length); + TCComponent[] var14 = comps; + int var13 = comps.length; + + for(int var12 = 0; var12 < var13; ++var12) { + TCComponent compt = var14[var12]; + String type = compt.getType(); + System.out.println(" TYPE = " + type); + if (type.equals(type)) { + dat = (TCComponentDataset)compt; + } + } + + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if (tcFile == null || tcFile.length != 0) { + return tcFile[0].getFmsFile(); + } + + System.out.println("未找到配置文件"); + } catch (Exception var16) { + var16.printStackTrace(); + } + + return null; + } + + public static TCComponentItemRevision getLastItemRevision(TCComponentItem item) { + try { + TCComponentItemRevision[] items = item.getReleasedItemRevisions(); + int revId = 0; + TCComponentItemRevision itemRevision = null; + + for(int i = 0; i < items.length; ++i) { + String revisionId = items[i].getStringProperty("item_revision_id"); + if (letterToNumber(revisionId) >= revId) { + itemRevision = items[i]; + revId = letterToNumber(revisionId); + } + } + + return itemRevision; + } catch (TCException var6) { + var6.printStackTrace(); + return null; + } + } + + public static int letterToNumber(String letter) { + int length = letter.length(); + int num = 0; + int number = 0; + + for(int i = 0; i < length; ++i) { + char ch = letter.charAt(length - i - 1); + num = ch - 65 + 1; + num = (int)((double)num * Math.pow(26.0D, (double)i)); + number += num; + } + + return number; + } + + public static ComboBoxItemBean[] findLOVByName(TCSession tcsession, String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + ComboBoxItemBean[] comboBoxItemBeans = null; + + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType)tcsession.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] atccomponentlistofvalues = tccomponentlistofvaluestype.find(s); + if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) { + tccomponentlistofvalues = atccomponentlistofvalues[0]; + ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); + String[] groupName = rtlistOfValuesInfo.getStringListOfValues(); + String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); + comboBoxItemBeans = new ComboBoxItemBean[groupName.length + 1]; + ComboBoxItemBean comboBoxItem = new ComboBoxItemBean("", ""); + comboBoxItemBeans[0] = comboBoxItem; + + for(int i = 0; i < groupName.length; ++i) { + ComboBoxItemBean comboBoxItemBean = new ComboBoxItemBean(groupName[i], groupDisplayName[i]); + comboBoxItemBeans[i + 1] = comboBoxItemBean; + } + } + } catch (TCException var12) { + tccomponentlistofvalues = null; + } + + return comboBoxItemBeans; + } + + public static String findLovValueByKey(TCSession tcsession, String s, String key) { + TCComponentListOfValues tccomponentlistofvalues = null; + String resultValue = null; + + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType)tcsession.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] atccomponentlistofvalues = tccomponentlistofvaluestype.find(s); + if (atccomponentlistofvalues != null && atccomponentlistofvalues.length > 0) { + tccomponentlistofvalues = atccomponentlistofvalues[0]; + ListOfValuesInfo rtlistOfValuesInfo = tccomponentlistofvalues.getListOfValues(); + String[] groupName = rtlistOfValuesInfo.getStringListOfValues(); + String[] groupDisplayName = rtlistOfValuesInfo.getLOVDisplayValues(); + + for(int i = 0; i < groupName.length; ++i) { + if (groupName[i].equals(key)) { + resultValue = groupDisplayName[i]; + } + } + } + } catch (TCException var11) { + tccomponentlistofvalues = null; + } + + return resultValue; + } + + public static void setProcess(TCSession session, TCComponentProcess process, String processUser, String arctic) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[]{process, processUser, arctic}; + userservice.call("DMU_Review_Process", obj); + } + + public static void setRemodelProcess(TCSession session, TCComponentProcess process, String processUser, String arctic) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[]{process, processUser, arctic}; + userservice.call("Create_Remodel_Process", obj); + } + + public static String getPrefStr(String prefName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + TCPreferenceService service = session.getPreferenceService(); + String str = service.getString(4, prefName); + if (str == null) { + str = new String(""); + } + + return str; + } + + public static String[] getPreferenceValues(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + if (preferenceName != null && session != null) { + String[] values = null; + TCPreferenceService service = session.getPreferenceService(); + values = service.getStringArray(4, preferenceName); + String[] resultValues = new String[values.length]; + + for(int i = 0; i < values.length; ++i) { + if (values[i].indexOf("\\n") >= 0) { + resultValues[i] = values[i].replace("\\n", "\n"); + } else { + resultValues[i] = values[i]; + } + } + + return resultValues; + } else { + System.out.println(""); + return null; + } + } + + public static String getPreferenceValue(String preferenceName) { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + if (preferenceName != null && session != null) { + TCPreferenceService service = session.getPreferenceService(); + return service.getString(4, preferenceName); + } else { + System.out.println(""); + return null; + } + } + + public static void setByPass(boolean val, TCSession session) { + try { + TCUserService userservice = session.getUserService(); + userservice.call(val ? "CONNOR_open_bypass" : "CONNOR_close_bypass", new Object[]{""}); + System.out.println(val ? "Open Bypass" : "Close Bypass"); + } catch (Exception var3) { + var3.printStackTrace(); + } + + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[]{"origin"}; + userservice.call("ORIGIN_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[]{"origin"}; + userservice.call("ORIGIN_close_bypass", obj); + } + + public static void setProperty(TCSession session, TCComponent[] items, String propname, String propvalue) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[]{items, propname, propvalue}; + userservice.call("connor_set_prop_value", obj); + } + + public static void sendObjToClassficationByWebService(String codeRemark, TCComponentItemRevision rev, List propList) { + try { + if (!codeRemark.equals("") && rev != null) { + System.out.println("111"); + SoaServerUtil so = new SoaServerUtil(); + String json = so.objectToJson(propList); + System.out.println("222"); + SoaServerUtil.sendToClass(rev.getUid(), codeRemark, json); + System.out.println("333"); + } + } catch (Exception var5) { + var5.printStackTrace(); + } + + } + + public static void deleteObjToClassficationByWebService(String codeRemark) { + try { + if (!codeRemark.equals("")) { + System.out.println("111"); + SoaServerUtil so = new SoaServerUtil(); + System.out.println("222"); + so.deleteToClass(codeRemark); + System.out.println("333"); + } + } catch (Exception var2) { + var2.printStackTrace(); + } + + } + + public static String getClassficationId(String matnr, String ddlx, String type) { + String classId = ""; + String t; + int var7; + int var8; + String[] var9; + String[] split; + if (!ddlx.equals("车身") && !ddlx.equals("KD")) { + if (ddlx.equals("配件")) { + classId = "jlcs01010201"; + String name = matnr.substring(0, 2) + "配件"; + String[] values = getPreferenceValues("JL_name_to_id"); + var9 = values; + var8 = values.length; + + for(var7 = 0; var7 < var8; ++var7) { + t = var9[var7]; + split = t.split("="); + if (split[0].equals(name)) { + if (type.equals("历史订单")) { + classId = split[1]; + } else if (type.equals("流程中订单")) { + classId = split[2]; + } else if (type.equals("废弃订单")) { + classId = split[3]; + } + } + } + } + } else { + String[] values = getPreferenceValues("JL_number_to_className"); + String className = null; + var9 = values; + var8 = values.length; + + for(var7 = 0; var7 < var8; ++var7) { + t = var9[var7]; + split = t.split("="); + if (split[0].equals(matnr)) { + className = split[1]; + break; + } + } + + String[] values2 = getPreferenceValues("JL_name_to_id"); + split = values2; + int var16 = values2.length; + + for(var8 = 0; var8 < var16; ++var8) { + String t1 = split[var8]; + String[] split1 = t1.split("="); + if (split1[0].equals(className)) { + if (type.equals("历史订单")) { + classId = split1[1]; + } else if (type.equals("流程中订单")) { + classId = split1[2]; + } else if (type.equals("废弃订单")) { + classId = split1[3]; + } + } + } + } + + return classId; + } + + public static String getClassDisplayableValue(String value, ICSPropertyDescription icsD) { + String result = ""; + ICSKeyLov lov1 = icsD.getFormat().getKeyLov(); + if (lov1 != null) { + String[] keys = lov1.getKeys(); + String[] var8 = keys; + int var7 = keys.length; + + for(int var6 = 0; var6 < var7; ++var6) { + String key = var8[var6]; + if (value.equals(key)) { + result = lov1.getValueOfKey(key); + return result; + } + } + } + + return result; + } + + public static boolean isDouble(String value) { + try { + Double.parseDouble(value); + return true; + } catch (Exception var1) { + return false; + } + } + + public static boolean havePrivilege(TCSession session, String commandName, String userId) { + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringArray(4, "JL_User_Rights"); + if (values != null && values.length != 0) { + String[] var8 = values; + int var7 = values.length; + + for(int var6 = 0; var6 < var7; ++var6) { + String value = var8[var6]; + String[] split = value.split("——"); + if (split[0].equals(commandName)) { + if (split.length == 1) { + return true; + } + + if (split[1].indexOf(userId) >= 0) { + return true; + } + + return false; + } + } + + return false; + } else { + MessageBox.post("请配置首选项(管理权限)!请联系管理员", "错误", 1); + return false; + } + } + + public static int getCount(String mainStr, String subStr) { + int minLength = mainStr.length(); + int subLength = subStr.length(); + int count = 0; + int index = 0; + if (minLength < subLength) { + return 0; + } else { + while((index = mainStr.indexOf(subStr, index)) != -1) { + ++count; + index += subLength; + } + + return count; + } + } + + public static void setExcelToItem(TCSession session, TCComponentItemRevision item, String fileName, String tcResource, boolean isDelete, boolean isReplace) { + try { + String[] as1 = new String[]{tcResource}; + String[] as2 = new String[]{"excel"}; + String[] as3 = new String[]{"MSExcelX"}; + String[] as4 = new String[]{"Plain"}; + TCComponentDatasetType tccomponentDatasetType = (TCComponentDatasetType)session.getTypeComponent("Dataset"); + TCComponentDataset tccomponentDataset = tccomponentDatasetType.create(fileName, "excel", "MSExcelX"); + tccomponentDataset.setFiles(as1, as3, as4, as2); + if (isReplace) { + AIFComponentContext[] zyzdsChildrens = item.getChildren(); + TCComponentItemRevision zyzdsRev = item; + AIFComponentContext[] var17 = zyzdsChildrens; + int var16 = zyzdsChildrens.length; + + for(int var15 = 0; var15 < var16; ++var15) { + AIFComponentContext zyzdsChildren = var17[var15]; + if ("MSExcelX".equals(zyzdsChildren.getComponent().getType())) { + TCComponentDataset dateSet = (TCComponentDataset)zyzdsChildren.getComponent(); + zyzdsRev.remove("IMAN_specification", dateSet); + dateSet.delete(); + } + } + } + + item.add("IMAN_specification", tccomponentDataset); + if (isDelete) { + (new File(tcResource)).delete(); + } + } catch (Exception var19) { + var19.printStackTrace(); + } + + } + + public static Object getTCPropertyValue(TCComponent item, String propertyName) { + Object result = ""; + + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + if (tcProperty == null) { + System.out.println("未获取属性:" + propertyName); + return result; + } + + switch(tcProperty.getPropertyType()) { + case 2: + result = tcProperty.getDateValue(); + break; + case 3: + result = tcProperty.getDoubleValue(); + case 4: + case 6: + case 7: + default: + break; + case 5: + result = tcProperty.getIntValue(); + break; + case 8: + result = tcProperty.getStringValue(); + } + } catch (TCException var4) { + var4.printStackTrace(); + } + + return result; + } + + public static void setTCPropertyValue(TCComponent item, String propertyName, Object value) { + try { + TCProperty tcProperty = item.getTCProperty(propertyName); + switch(tcProperty.getPropertyType()) { + case 2: + if (value instanceof Date) { + tcProperty.setDateValue((Date)value); + } else { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + tcProperty.setDateValue(sdf.parse(value.toString())); + } + break; + case 3: + if (value instanceof Double) { + tcProperty.setDoubleValue((Double)value); + } else { + tcProperty.setDoubleValue(Double.parseDouble(value.toString())); + } + case 4: + case 6: + case 7: + default: + break; + case 5: + if (value instanceof Integer) { + tcProperty.setDoubleValue((double)(Integer)value); + } else { + tcProperty.setDoubleValue((double)Integer.parseInt(value.toString())); + } + break; + case 8: + tcProperty.setStringValue(value.toString()); + } + } catch (Exception var5) { + var5.printStackTrace(); + } + + } + + public static List getTargetsMsg(List itemList) { + if (itemList == null) { + return null; + } else { + ArrayList beanList = new ArrayList(); + + try { + TCProperty[][] props = TCComponentType.getTCPropertiesSet(itemList, new String[]{"object_name", "object_type", "uom_tag", "item_id"}); + + for(int i = 0; i < props.length; ++i) { + TCProperty[] prop = props[i]; + ItemBean bean = new ItemBean(); + bean.setItem((TCComponentItem)itemList.get(i)); + if (prop[0] != null) { + bean.setName(prop[0].getDisplayValue()); + } + + bean.setFolder(getParentFolder((TCComponentItem)itemList.get(i), bean.getName())); + if (prop[1] != null) { + bean.setTypeDis(prop[1].getDisplayValue()); + bean.setType(((TCComponentItem)itemList.get(i)).getType()); + } + + if (prop[2] != null) { + bean.setUnit(prop[2].getDisplayableValue()); + bean.setUnitDis(prop[2].getDisplayValue()); + } + + if (prop[3] != null) { + bean.setItemID(prop[3].getDisplayValue()); + } + + beanList.add(bean); + } + } catch (TCException var6) { + var6.printStackTrace(); + } + + return beanList; + } + } + + public static TCComponentFolder getParentFolder(TCComponentItem item, String name) { + TCComponentFolder folder = null; + + try { + AIFComponentContext[] comtexts = item.whereReferenced(); + if (comtexts != null) { + for(int i = 0; i < comtexts.length; ++i) { + if (comtexts[i].getComponent() instanceof TCComponentFolder) { + String nameT = ((TCComponentFolder)comtexts[i].getComponent()).getStringProperty("object_name"); + if (name.equals("工艺图纸") && nameT.equals("工艺图纸")) { + folder = (TCComponentFolder)comtexts[i].getComponent(); + } else if (nameT.equals(name)) { + folder = (TCComponentFolder)comtexts[i].getComponent(); + } + } + } + } + } catch (TCException var6) { + var6.printStackTrace(); + } + + return folder; + } + + public static List getExplictPropList(TCSession session) { + List beanList = new ArrayList(); + TCPreferenceService service = session.getPreferenceService(); + String[] values = service.getStringArray(4, "Cust_prop_explict_mapping"); + if (values != null) { + for(int i = 0; i < values.length; ++i) { + String[] types = values[i].split("\\|"); + if (types.length == 2) { + String[] props = types[1].split("\\;"); + if (props.length != 0) { + List list = new ArrayList(); + String[] var11 = props; + int var10 = props.length; + + for(int var9 = 0; var9 < var10; ++var9) { + String str = var11[var9]; + list.add(str); + } + + PropExplictBean bean = new PropExplictBean(); + bean.setType(types[0]); + bean.setPropList(list); + beanList.add(bean); + } + } + } + } + + return beanList; + } + + /** + * 通过SOA创建ITEM对象 + * + * @param session 会话 + * @param itemID 创建对象的ID + * @param itemRev 创建对象的版本 + * @param itemType 创建对象的类型 + * @param itemName 创建对象的名称 + * @param itemDesc 创建对象的描述 + * @param unit 创建对象的单位 + * @param itemPropMap 创建对象的ITEM属性 + * @param itemRevPropMap 创建对象的版本属性 + * @param itemRevMasterPropMap 创建对象的版本表单属性 + */ + public static TCComponentItem createNewItemSoa(TCSession session, String itemID, String itemRev, String itemType, + String itemName, String itemDesc, String unit, Map itemPropMap, + Map itemRevPropMap, Map itemRevMasterPropMap) { + TCComponentItem newComp = null; + try { + DataManagementService datamanagementservice = DataManagementService.getService(session); + com.teamcenter.services.rac.core._2006_03.DataManagement.CreateItemsResponse createitemsresponse = null; + // 设置创建对象的主要属性 + com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties aitemproperties[] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties[1]; + aitemproperties[0] = new com.teamcenter.services.rac.core._2006_03.DataManagement.ItemProperties(); + aitemproperties[0].clientId = Integer.toString(1); + aitemproperties[0].description = itemDesc; + aitemproperties[0].itemId = itemID; + aitemproperties[0].name = itemName; + aitemproperties[0].revId = itemRev; + aitemproperties[0].type = itemType; + aitemproperties[0].uom = unit;// == null ? "" : uomComp.toString(); + // 设置扩展属性 + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes + // extendedattributes[] = new + // com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[3]; + ArrayList list = new ArrayList(); + // 设置item对象的扩展属性 +// if (itemPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.RevisionIds revids = null; +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesItem = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesItem.objectType = itemType; +// extendedattributesItem.attributes = itemPropMap; +// list.add(extendedattributesItem); +// } +// // 设置REV的扩展属性 +// if (itemRevPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRev = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRev.objectType = itemType + "Revision"; +// extendedattributesRev.attributes = itemRevPropMap; +// list.add(extendedattributesRev); +// } +// // 设置REVMASTER的扩展属性 +// if (itemRevMasterPropMap != null) { +// com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRevMaster = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes(); +// extendedattributesRevMaster.objectType = itemType +// + "RevisionMaster"; +// extendedattributesRevMaster.attributes = itemRevMasterPropMap; +// list.add(extendedattributesRevMaster); +// } + // 添加扩展属性 + if (list.size() != 0) { + com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes extendedattributes[] = null; + extendedattributes = new com.teamcenter.services.rac.core._2006_03.DataManagement.ExtendedAttributes[list + .size()]; + for (int i = 0; i < list.size(); i++) { + extendedattributes[i] = list.get(i); + } + aitemproperties[0].extendedAttributes = extendedattributes; + } + TCComponent tccomponent1 = null; + String s1 = ""; + createitemsresponse = datamanagementservice.createItems(aitemproperties, tccomponent1, s1); + if (createitemsresponse.serviceData.sizeOfPartialErrors() == 0) { + newComp = createitemsresponse.output[0].item; + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + System.out.println("创建对象[item_id= " + itemID + " / rev =" + itemRev + " / name= " + itemName + "]失败"); + } + return newComp; + } + + public static String sendPost(String url, String data) { + String response = null; + + try { + CloseableHttpClient httpclient = null; + CloseableHttpResponse httpresponse = null; + + try { + httpclient = HttpClients.createDefault(); + HttpPost httppost = new HttpPost(url); + StringEntity stringentity = new StringEntity(data, "UTF-8"); + httppost.setHeader("Content-type", "application/json"); + httppost.setEntity(stringentity); + httpresponse = httpclient.execute(httppost); + response = EntityUtils.toString(httpresponse.getEntity()); + } finally { + if (httpclient != null) { + httpclient.close(); + } + + if (httpresponse != null) { + httpresponse.close(); + } + + } + } catch (Exception var11) { + var11.printStackTrace(); + } + + return response; + } + + public static void CreateProcess(TCSession session, TCComponent target, String processName) throws TCException { + try { + TCComponentProcessType processType = (TCComponentProcessType)session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType)session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0); + if (taskTemplate != null) { + String name = target.getProperty("object_string"); + processType.create(processName + ":" + name, "", taskTemplate, new TCComponent[]{target}, new int[]{1}); + } + } catch (TCException var7) { + var7.printStackTrace(); + throw var7; + } + } + + public static void CreateProcess(TCSession session, TCComponent[] targets, int[] type, String processName) throws TCException { + try { + TCComponentProcessType processType = (TCComponentProcessType)session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType)session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(processName, 0); + if (taskTemplate != null) { + String name = targets[0].getProperty("object_string"); + processType.create(processName + ":" + name, "", taskTemplate, targets, type); + } + } catch (TCException var8) { + var8.printStackTrace(); + throw var8; + } + } + + public static void sendObjToClassficationByWebService(TCComponentItem item, String classId) { + try { + if (!classId.replace(" ", "").equals("") && item != null) { + TCComponentItemRevision rev = item.getLatestItemRevision(); + SoaServerUtil.sendToClass(rev.getUid(), classId, ""); + } + } catch (TCException var3) { + var3.printStackTrace(); + } + + } + + public static String[] getProcessOther(String typeName, String groupName) { + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + String value = null; + TCPreferenceService service = session.getPreferenceService(); + value = service.getString(4, "ML_Process_TypeFile"); + TCComponentDataset dat = (TCComponentDataset)session.stringToComponent(value); + File modelFile = null; + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if (tcFile != null && tcFile.length == 0) { + return null; + } else { + modelFile = tcFile[0].getFmsFile(); + List typeList = readExcelStringOther(modelFile, typeName, groupName); + return typeList != null && typeList.size() > 0 ? (String[])typeList.toArray(new String[0]) : new String[]{""}; + } + } catch (Exception var10) { + var10.printStackTrace(); + return new String[]{""}; + } + } + + public static List readExcelStringOther(File excel_file, String type, String groupName) throws FileNotFoundException, IOException { + if (excel_file != null && excel_file.exists()) { + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFSheet sheet = workBook.getSheetAt(0); + List typeList = new ArrayList(); + int row_count = sheet.getLastRowNum(); + + for(int j = 1; j < row_count + 1; ++j) { + XSSFRow row = sheet.getRow(j); + if (row != null && groupName.compareTo(getValue(row, 1)) == 0 && type.compareTo(getValue(row, 2)) == 0) { + typeList.add(getValue(row, 3)); + typeList.add(getValue(row, 4)); + typeList.add(getValue(row, 5)); + typeList.add(getValue(row, 6)); + typeList.add(getValue(row, 7)); + } + } + + workBook.close(); + return typeList; + } else { + return null; + } + } + + public static String[] getProcessGroup(String typeName) { + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + String value = null; + TCPreferenceService service = session.getPreferenceService(); + value = service.getString(4, "ML_Process_TypeFile"); + TCComponentDataset dat = (TCComponentDataset)session.stringToComponent(value); + File modelFile = null; + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if (tcFile != null && tcFile.length == 0) { + return null; + } else { + modelFile = tcFile[0].getFmsFile(); + List typeList = readExcelStringGroup(modelFile, typeName); + return typeList != null && typeList.size() > 0 ? (String[])typeList.toArray(new String[0]) : new String[]{""}; + } + } catch (Exception var9) { + var9.printStackTrace(); + return new String[]{""}; + } + } + + public static List readExcelStringGroup(File excel_file, String type) throws FileNotFoundException, IOException { + if (excel_file != null && excel_file.exists()) { + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFSheet sheet = workBook.getSheetAt(0); + List typeList = new ArrayList(); + int row_count = sheet.getLastRowNum(); + + for(int j = 1; j < row_count + 1; ++j) { + XSSFRow row = sheet.getRow(j); + if (row != null && !typeList.contains(getValue(row, 1)) && type.compareTo(getValue(row, 2)) == 0) { + typeList.add(getValue(row, 1)); + } + } + + workBook.close(); + return typeList; + } else { + return null; + } + } + + public static String[] getProcessType() { + try { + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession)app.getSession(); + String value = null; + TCPreferenceService service = session.getPreferenceService(); + value = service.getString(4, "ML_Process_TypeFile"); + TCComponentDataset dat = (TCComponentDataset)session.stringToComponent(value); + File modelFile = null; + TCComponentTcFile[] tcFile = dat.getTcFiles(); + if (tcFile != null && tcFile.length == 0) { + return null; + } else { + modelFile = tcFile[0].getFmsFile(); + List typeList = readExcelStringType(modelFile); + return typeList != null && typeList.size() > 0 ? (String[])typeList.toArray(new String[0]) : new String[]{""}; + } + } catch (Exception var8) { + var8.printStackTrace(); + return new String[]{""}; + } + } + + public static List readExcelStringType(File excel_file) throws FileNotFoundException, IOException { + if (excel_file != null && excel_file.exists()) { + XSSFWorkbook workBook = new XSSFWorkbook(new FileInputStream(excel_file)); + XSSFSheet sheet = workBook.getSheetAt(0); + List typeList = new ArrayList(); + int row_count = sheet.getLastRowNum(); + + for(int j = 1; j < row_count + 1; ++j) { + XSSFRow row = sheet.getRow(j); + if (row != null && !typeList.contains(getValue(row, 2))) { + typeList.add(getValue(row, 2)); + } + } + + workBook.close(); + return typeList; + } else { + return null; + } + } + + public static String getValue(XSSFRow titleRow, int i) { + XSSFCell cell = titleRow.getCell(i); + if (cell == null) { + return ""; + } else { + return cell.getCellType() == 0 ? String.valueOf(cell.getNumericCellValue()) : cell.getStringCellValue(); + } + } + + public static void sendToSap(String url, String json) { + try { + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("JT0001"); + sc.setOptions(opts); + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("JT0001", omNs); + OMElement value = fac.createOMElement("json", omNs); + value.setText(json); + method.addChild(value); + OMElement res = sc.sendReceive(method); + res.getFirstElement().getText(); + } catch (AxisFault var10) { + var10.printStackTrace(); + } + + } + + public static void sendProductRev(List> dataTableList, TCSession session) { + BufferedInputStream input = null; + + try { + input = new BufferedInputStream(MethodUtil.class.getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + StringBuffer messageString = new StringBuffer(); + System.out.println("---=---sendProductRev"); + + for(int i = 0; i < dataTableList.size(); ++i) { + List list = (List)dataTableList.get(i); + SendSAPProductRevBean sendSAPProductRevBean = new SendSAPProductRevBean(); + sendSAPProductRevBean.setMSGID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setBUSID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setTLGID("JT0001"); + sendSAPProductRevBean.setTLGNAME("维护生产版本接口"); + sendSAPProductRevBean.setDTSEND(sdf.format(new Date())); + sendSAPProductRevBean.setSENDER("TCM"); + sendSAPProductRevBean.setRECEIVER("SAP"); + sendSAPProductRevBean.setFREEUSE(""); + sendSAPProductRevBean.setMATNR(list.get(0) == null ? "" : (String)list.get(0)); + sendSAPProductRevBean.setWERKS(list.get(1) == null ? "" : (String)list.get(1)); + sendSAPProductRevBean.setVERID(list.get(2) == null ? "" : (String)list.get(2)); + sendSAPProductRevBean.setTEXT1(list.get(3) == null ? "" : (String)list.get(3)); + sendSAPProductRevBean.setADATU(list.get(4) == null ? "" : (String)list.get(4)); + sendSAPProductRevBean.setBDATU(list.get(5) == null ? "" : (String)list.get(5)); + sendSAPProductRevBean.setSTLAL(list.get(6) == null ? "" : (String)list.get(6)); + sendSAPProductRevBean.setSTLAN(list.get(7) == null ? "" : (String)list.get(7)); + sendSAPProductRevBean.setPLNNR(list.get(8) == null ? "" : (String)list.get(8)); + sendSAPProductRevBean.setALNAL(list.get(9) == null ? "" : (String)list.get(9)); + sendSAPProductRevBean.setMDV01(list.get(10) == null ? "" : (String)list.get(10)); + sendSAPProductRevBean.setALORT(list.get(11) == null ? "" : (String)list.get(11)); + sendSAPProductRevBean.setELPRO(list.get(12) == null ? "" : (String)list.get(12)); + sendSAPProductRevBean.setKZ(list.get(13) == null ? "" : (String)list.get(13)); + System.out.println("setMATNR" + sendSAPProductRevBean.getMATNR()); + System.out.println("setWERKS" + sendSAPProductRevBean.getWERKS()); + System.out.println("setVERID" + sendSAPProductRevBean.getVERID()); + System.out.println("setTEXT1" + sendSAPProductRevBean.getTEXT1()); + System.out.println("setADATU" + sendSAPProductRevBean.getADATU()); + System.out.println("setBDATU" + sendSAPProductRevBean.getBDATU()); + System.out.println("setSTLAL" + sendSAPProductRevBean.getSTLAL()); + System.out.println("setSTLAN" + sendSAPProductRevBean.getSTLAN()); + System.out.println("setPLNNR" + sendSAPProductRevBean.getPLNNR()); + System.out.println("setALNAL" + sendSAPProductRevBean.getALNAL()); + System.out.println("setMDV01" + sendSAPProductRevBean.getMDV01()); + System.out.println("setALORT" + sendSAPProductRevBean.getALORT()); + System.out.println("setELPRO" + sendSAPProductRevBean.getELPRO()); + System.out.println("setKZ" + sendSAPProductRevBean.getKZ()); + InputStream in = ScreenShotTest.class.getResourceAsStream("/toERP.properties"); + Properties p = new Properties(); + p.load(in); + String url = "http://mlapp.meiling.com/plmwebapi/sap/setinfo"; + MLtoERPEntity mLtoERPEntity = new MLtoERPEntity(); + mLtoERPEntity.setInfotype("生产版本"); + mLtoERPEntity.setInfocode(session.getUser().getUserId()); + mLtoERPEntity.setInfoname(p.getProperty("infoname")); + mLtoERPEntity.setInfodesc(""); + List list1 = new ArrayList(); + List list2 = new ArrayList(); + MLtoERPEntity2 field1 = new MLtoERPEntity2(); + field1.setField("MATNR"); + field1.setValue(sendSAPProductRevBean.getMATNR()); + list1.add(field1); + MLtoERPEntity2 field2 = new MLtoERPEntity2(); + field2.setField("WERKS"); + field2.setValue(sendSAPProductRevBean.getWERKS()); + list1.add(field2); + MLtoERPEntity2 field3 = new MLtoERPEntity2(); + field3.setField("VERID"); + field3.setValue(sendSAPProductRevBean.getVERID()); + list1.add(field3); + MLtoERPEntity2 field4 = new MLtoERPEntity2(); + field4.setField("TEXT1"); + field4.setValue(sendSAPProductRevBean.getTEXT1()); + list1.add(field4); + MLtoERPEntity2 field5 = new MLtoERPEntity2(); + field5.setField("ADATU"); + field5.setValue(sendSAPProductRevBean.getADATU()); + list1.add(field5); + MLtoERPEntity2 field6 = new MLtoERPEntity2(); + field6.setField("BDATU"); + field6.setValue(sendSAPProductRevBean.getBDATU()); + list1.add(field6); + MLtoERPEntity2 field7 = new MLtoERPEntity2(); + field7.setField("STLAL"); + field7.setValue(sendSAPProductRevBean.getSTLAL()); + list1.add(field7); + MLtoERPEntity2 field8 = new MLtoERPEntity2(); + field8.setField("STLAN"); + field8.setValue(sendSAPProductRevBean.getSTLAN()); + list1.add(field8); + MLtoERPEntity2 field9 = new MLtoERPEntity2(); + field9.setField("PLNNR"); + field9.setValue(sendSAPProductRevBean.getPLNNR()); + list1.add(field9); + MLtoERPEntity2 field10 = new MLtoERPEntity2(); + field10.setField("ALNAL"); + field10.setValue(sendSAPProductRevBean.getALNAL()); + list1.add(field10); + MLtoERPEntity2 field11 = new MLtoERPEntity2(); + field11.setField("MDV01"); + field11.setValue(sendSAPProductRevBean.getMDV01()); + list1.add(field11); + MLtoERPEntity2 field12 = new MLtoERPEntity2(); + field12.setField("ALORT"); + field12.setValue(sendSAPProductRevBean.getALORT()); + list1.add(field12); + MLtoERPEntity2 field13 = new MLtoERPEntity2(); + field13.setField("ELPRO"); + field13.setValue(sendSAPProductRevBean.getELPRO()); + list1.add(field13); + MLtoERPEntity2 field14 = new MLtoERPEntity2(); + field14.setField("KZ"); + field14.setValue(sendSAPProductRevBean.getKZ()); + list1.add(field14); + mLtoERPEntity.setData(list1); + mLtoERPEntity.setList(list2); + Gson gson = new Gson(); + String json = gson.toJson(mLtoERPEntity); + System.out.println(json); + String doPostResult = WebApiUtil.doPost(url, json); + MLRequestEntity resultEntity = (MLRequestEntity)gson.fromJson(doPostResult, MLRequestEntity.class); + String status = resultEntity.getErrcode(); + String result = resultEntity.getResult(); + JSONObject fromObject = JSONObject.fromObject(result); + if (status.equals("0") || status.equals("1")) { + try { + System.out.println(pro.getProperty("ML_TCMPRODUCTREVINSERTSQL")); + String insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVINSERTSQL"), UUID.randomUUID().toString().replace("-", ""), sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), sendSAPProductRevBean.getTLGID(), sendSAPProductRevBean.getTLGNAME(), sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getSENDER(), sendSAPProductRevBean.getRECEIVER(), sendSAPProductRevBean.getFREEUSE(), sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), sendSAPProductRevBean.getVERID(), sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), sendSAPProductRevBean.getBDATU(), sendSAPProductRevBean.getSTLAL(), sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), status, resultEntity.getErrmsg()); + if (sendSAPProductRevBean.getKZ().equals("U")) { + insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVUPDATESQL"), sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getVERID(), sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), sendSAPProductRevBean.getBDATU(), sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), status, resultEntity.getErrmsg(), sendSAPProductRevBean.getSTLAL(), sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getVERID()); + } + + System.out.println(insertSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception var53) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", 1); + var53.printStackTrace(); + } finally { + DbPool.freeAll(); + } + } + + if (resultEntity.getErrmsg() != null && !resultEntity.getErrmsg().isEmpty() && status.equals("1")) { + messageString.append("【物料代码】:" + fromObject.getString("MATNR").toString()); + messageString.append("【工厂】:" + fromObject.getString("WERKS").toString()); + messageString.append("【生产版本】:" + fromObject.getString("VERID").toString()); + messageString.append("【发送失败】:" + resultEntity.getErrmsg()); + messageString.append("\n"); + } + + System.out.println(messageString); + } + + MessageBox.post("发送成功!", "成功", 2); + } catch (Exception var55) { + var55.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException var52) { + var52.printStackTrace(); + } + } + + } + + } + + public static void GetProductRev(String result, final TCSession session, final boolean isProcess, HashMap groupMap) { + BufferedInputStream input = null; + + try { + System.out.println(result); + input = new BufferedInputStream(MethodUtil.class.getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String option = session.getPreferenceService().getStringValue("ML_Process&ProductRev"); + if (option != null && !option.isEmpty()) { + TCComponent dataset = session.stringToComponent(option); + if (dataset.isTypeOf("MSExcelX")) { + String dateStr = session.getPreferenceService().getStringValue("ML_Process&Product_Data"); + FileInputStream inpu = null; + XSSFWorkbook wb = null; + final ArrayList excelMap = new ArrayList(); + + try { + File file = ((TCComponentDataset)dataset).getTcFiles()[0].getFile(System.getProperty("java.io.tmpdir")); + inpu = new FileInputStream(file); + wb = new XSSFWorkbook(inpu); + XSSFSheet sheet = wb.getSheetAt(0); + + for(int i = 1; i < sheet.getLastRowNum(); ++i) { + XSSFRow row = getRow(sheet, i); + String rev = getValue(getCell(row, 7)); + if (!rev.isEmpty()) { + excelMap.add(new String[]{rev, getValue(getCell(row, 0)), getValue(getCell(row, 1)), getValue(getCell(row, 3)), getValue(getCell(row, 4)), getValue(getCell(row, 5)), getValue(getCell(row, 6)), getValue(getCell(row, 8))}); + } + } + } catch (Exception var159) { + var159.printStackTrace(); + MessageBox.post(AIFUtility.getActiveDesktop(), "错误:" + var159.getMessage(), "ERROR", 1); + return; + } finally { + if (wb != null) { + wb.close(); + } + + if (inpu != null) { + inpu.close(); + } + + } + + JSONObject resultJson = JSONObject.fromObject(result); + JSONArray jsonArray = resultJson.getJSONArray("list"); + final List> dataList = new ArrayList(); + List> haveList = new ArrayList(); + + for(int i = 0; i < jsonArray.size(); ++i) { + String itemId = ""; + String objectName = ""; + String factory = ""; + String bom = ""; + JSONObject jsonObject = jsonArray.getJSONObject(i); + Iterator iter = jsonObject.entrySet().iterator(); + + while(iter.hasNext()) { + Entry entry = (Entry)iter.next(); + String var24; + switch((var24 = entry.getKey().toString()).hashCode()) { + case 766525: + if (var24.equals("工厂")) { + factory = entry.getValue().toString(); + } + break; + case 898372177: + if (var24.equals("物料描述")) { + objectName = entry.getValue().toString(); + } + break; + case 898582523: + if (var24.equals("物料编码")) { + itemId = entry.getValue().toString(); + } + break; + case 1571420566: + if (var24.equals("可选的BOM")) { + bom = entry.getValue().toString(); + } + } + } + + String[] groups = null; + if (isProcess) { + if (!groupMap.containsKey(itemId)) { + continue; + } + + groups = (String[])groupMap.get(itemId); + } + + if (itemId.indexOf("-") > 0) { + itemId = itemId.split("-")[0]; + } + + List> classValueList = new ArrayList(); + String productionRev = ""; + String lineName = ""; + String groupNo = ""; + String workCenter = ""; + String receiveLocation = ""; + String storageLocation = ""; + String groupName = ""; + List productionRevList = new ArrayList(); + Iterator input2; + boolean isHave; + String selectSql; + ArrayList valuesList; + ResultSet rs; + if (isProcess) { + System.out.println("get:" + itemId); + input2 = excelMap.iterator(); + + while(input2.hasNext()) { + String[] excels = (String[])input2.next(); + if (excels[1].equals(factory) && excels[2].equals(groups[0])) { + List valueList = new ArrayList(); + valueList.add(excels[2]); + valueList.add(excels[0]); + valueList.add(excels[7]); + valueList.add(excels[4]); + valueList.add(excels[3]); + valueList.add(excels[5]); + valueList.add(excels[6]); + classValueList.add(valueList); + } + } + + for(int ii = 0; ii < classValueList.size(); ++ii) { + List valueList = (List)classValueList.get(ii); + groupName = (String)valueList.get(0); + productionRev = (String)valueList.get(1); + lineName = (String)valueList.get(2); + groupNo = (String)valueList.get(3); + workCenter = (String)valueList.get(4); + receiveLocation = (String)valueList.get(5); + storageLocation = (String)valueList.get(6); + if (!productionRevList.contains(productionRev)) { + productionRevList.add(productionRev); + String processGroup = groups[1]; + rs = null; + isHave = false; + selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL"), itemId, factory, groupNo, productionRev); + + try { + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + if (rs != null && rs.next()) { + valuesList = new ArrayList(); + valuesList.add(groupName); + valuesList.add(itemId); + valuesList.add(objectName); + valuesList.add(factory); + valuesList.add(productionRev); + valuesList.add(lineName); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add(bom); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(groupNo); + valuesList.add(workCenter); + valuesList.add(receiveLocation); + valuesList.add(storageLocation); + valuesList.add("U"); + dataList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } catch (Exception var154) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", 1); + var154.printStackTrace(); + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException var152) { + var152.printStackTrace(); + } + } + + DbPool.freeAll(); + } + + if (!isHave) { + valuesList = new ArrayList(); + valuesList.add(groupName); + valuesList.add(itemId); + valuesList.add(objectName); + valuesList.add(factory); + valuesList.add(productionRev); + valuesList.add(lineName); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add(bom); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(groupNo); + valuesList.add(workCenter); + valuesList.add(receiveLocation); + valuesList.add(storageLocation); + valuesList.add("I"); + dataList.add(valuesList); + } + } + } + } else { + String processGroup = ""; + InputStream input21 = null; + ResultSet rs2 = null; + + try { + String selectSql1 = String.format(pro.getProperty("ML_TCMPROCESSSELECTSQL2"), itemId, factory); + System.out.println(selectSql1); + DbPool.getConnection(); + rs2 = DbPool.executeSelectSql(selectSql1); + if (rs2 != null) { + while(rs2.next()) { + processGroup = rs2.getString("PLNNR"); + } + } + } catch (Exception var157) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", 1); + var157.printStackTrace(); + } finally { + if (input21 != null) { + try { + input21.close(); + } catch (IOException var151) { + var151.printStackTrace(); + } + } + + if (rs2 != null) { + try { + rs2.close(); + } catch (SQLException var150) { + var150.printStackTrace(); + } + } + + DbPool.freeAll(); + } + + rs = null; + isHave = false; + + try { + selectSql = String.format(pro.getProperty("ML_TCMPRODUCTREVSELECTSQL2"), itemId, factory); + System.out.println(selectSql); + DbPool.getConnection(); + rs = DbPool.executeSelectSql(selectSql); + if (rs != null && rs.next()) { + valuesList = new ArrayList(); + valuesList.add(""); + valuesList.add(itemId); + valuesList.add(objectName); + valuesList.add(factory); + valuesList.add(""); + valuesList.add(""); + valuesList.add(dateStr); + valuesList.add("99991231"); + valuesList.add(bom); + valuesList.add("1"); + valuesList.add(processGroup); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add(""); + valuesList.add("U"); + dataList.add(valuesList); + haveList.add(valuesList); + isHave = true; + } + } catch (Exception var153) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", 1); + var153.printStackTrace(); + } finally { + if (rs != null) { + try { + rs.close(); + } catch (SQLException var149) { + var149.printStackTrace(); + } + } + + DbPool.freeAll(); + } + + if (!isHave) { + List rowList = new ArrayList(); + rowList.add(""); + rowList.add(itemId); + rowList.add(objectName); + rowList.add(factory); + rowList.add(""); + rowList.add(""); + rowList.add(dateStr); + rowList.add("99991231"); + rowList.add(bom); + rowList.add("1"); + rowList.add(processGroup); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add(""); + rowList.add("I"); + dataList.add(rowList); + } + } + } + + if (haveList.size() > 0) { + StringBuilder haveStringBuilder = new StringBuilder(); + + int i; + for(i = 0; i < haveList.size(); ++i) { + haveStringBuilder.append("物料:"); + haveStringBuilder.append((String)((List)haveList.get(i)).get(0)); + haveStringBuilder.append("工厂:"); + haveStringBuilder.append((String)((List)haveList.get(i)).get(1)); + haveStringBuilder.append("组计数器:"); + haveStringBuilder.append((String)((List)haveList.get(i)).get(9)); + haveStringBuilder.append("\n"); + } + haveStringBuilder.append("已传递过生产版本,是否重新传递?"); + JTextArea textArea = new JTextArea(haveStringBuilder.toString()); + textArea.setEditable(false); + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setPreferredSize(new Dimension(400, 300)); + i = JOptionPane.showConfirmDialog((Component)null, scrollPane, "重新传递", 0); + if (i != 0) { + dataList.removeAll(haveList); + } + } + + (new Thread() { + public void run() { + if (!isProcess) { + new SendProductRevDialog(session, dataList, excelMap); + } else { + MethodUtil.SendErpProductRev(dataList, session); + } + + } + }).start(); + } else { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", 1); + } + } else { + MessageBox.post(AIFUtility.getActiveDesktop(), "首选项ML_Process&ProductRev配置不正确", "ERROR", 1); + } + } catch (Exception var161) { + var161.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (Exception var148) { + var148.printStackTrace(); + } + } + + } + } + + public static void SendErpProductRev(List> dataTableList, TCSession session) { + try { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + StringBuffer messageString = new StringBuffer(); + + for(int i = 0; i < dataTableList.size(); ++i) { + List list = (List)dataTableList.get(i); + SendSAPProductRevBean sendSAPProductRevBean = new SendSAPProductRevBean(); + sendSAPProductRevBean.setMSGID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setBUSID(UUID.randomUUID().toString().replace("-", "")); + sendSAPProductRevBean.setTLGID("JT0001"); + sendSAPProductRevBean.setTLGNAME("维护生产版本接口"); + sendSAPProductRevBean.setDTSEND(sdf.format(new Date())); + sendSAPProductRevBean.setSENDER("TCM"); + sendSAPProductRevBean.setRECEIVER("SAP"); + sendSAPProductRevBean.setFREEUSE(""); + sendSAPProductRevBean.setMATNR(list.get(1) == null ? "" : ((String)list.get(1)).toString()); + sendSAPProductRevBean.setWERKS(list.get(3) == null ? "" : ((String)list.get(3)).toString()); + sendSAPProductRevBean.setVERID(list.get(4) == null ? "" : ((String)list.get(4)).toString()); + sendSAPProductRevBean.setTEXT1(list.get(5) == null ? "" : ((String)list.get(5)).toString()); + sendSAPProductRevBean.setADATU(list.get(6) == null ? "" : ((String)list.get(6)).toString()); + sendSAPProductRevBean.setBDATU(list.get(7) == null ? "" : ((String)list.get(7)).toString()); + sendSAPProductRevBean.setSTLAL(list.get(8) == null ? "" : ((String)list.get(8)).toString()); + sendSAPProductRevBean.setSTLAN(list.get(9) == null ? "" : ((String)list.get(9)).toString()); + sendSAPProductRevBean.setPLNNR(list.get(10) == null ? "" : ((String)list.get(10)).toString()); + sendSAPProductRevBean.setALNAL(list.get(11) == null ? "" : ((String)list.get(11)).toString()); + sendSAPProductRevBean.setMDV01(list.get(12) == null ? "" : ((String)list.get(12)).toString()); + sendSAPProductRevBean.setALORT(list.get(13) == null ? "" : ((String)list.get(13)).toString()); + sendSAPProductRevBean.setELPRO(list.get(14) == null ? "" : ((String)list.get(14)).toString()); + sendSAPProductRevBean.setKZ(list.get(15) == null ? "" : ((String)list.get(15)).toString()); + InputStream in = ScreenShotTest.class.getResourceAsStream("/toERP.properties"); + Properties p = new Properties(); + p.load(in); + String url = "http://mlapp.meiling.com/plmwebapi/sap/setinfo"; + MLtoERPEntity mLtoERPEntity = new MLtoERPEntity(); + mLtoERPEntity.setInfotype("生产版本"); + mLtoERPEntity.setInfocode(session.getUser().getUserId()); + mLtoERPEntity.setInfoname(p.getProperty("infoname")); + mLtoERPEntity.setInfodesc(""); + List list1 = new ArrayList(); + List list2 = new ArrayList(); + MLtoERPEntity2 field1 = new MLtoERPEntity2(); + field1.setField("MATNR"); + field1.setValue(sendSAPProductRevBean.getMATNR()); + list1.add(field1); + MLtoERPEntity2 field2 = new MLtoERPEntity2(); + field2.setField("WERKS"); + field2.setValue(sendSAPProductRevBean.getWERKS()); + list1.add(field2); + MLtoERPEntity2 field3 = new MLtoERPEntity2(); + field3.setField("VERID"); + field3.setValue(sendSAPProductRevBean.getVERID()); + list1.add(field3); + MLtoERPEntity2 field4 = new MLtoERPEntity2(); + field4.setField("TEXT1"); + field4.setValue(sendSAPProductRevBean.getTEXT1()); + list1.add(field4); + MLtoERPEntity2 field5 = new MLtoERPEntity2(); + field5.setField("ADATU"); + field5.setValue(sendSAPProductRevBean.getADATU()); + list1.add(field5); + MLtoERPEntity2 field6 = new MLtoERPEntity2(); + field6.setField("BDATU"); + field6.setValue(sendSAPProductRevBean.getBDATU()); + list1.add(field6); + MLtoERPEntity2 field7 = new MLtoERPEntity2(); + field7.setField("STLAL"); + field7.setValue(sendSAPProductRevBean.getSTLAL()); + list1.add(field7); + MLtoERPEntity2 field8 = new MLtoERPEntity2(); + field8.setField("STLAN"); + field8.setValue(sendSAPProductRevBean.getSTLAN()); + list1.add(field8); + MLtoERPEntity2 field9 = new MLtoERPEntity2(); + field9.setField("PLNNR"); + field9.setValue(sendSAPProductRevBean.getPLNNR()); + list1.add(field9); + MLtoERPEntity2 field10 = new MLtoERPEntity2(); + field10.setField("ALNAL"); + field10.setValue(sendSAPProductRevBean.getALNAL()); + list1.add(field10); + MLtoERPEntity2 field11 = new MLtoERPEntity2(); + field11.setField("MDV01"); + field11.setValue(sendSAPProductRevBean.getMDV01()); + list1.add(field11); + MLtoERPEntity2 field12 = new MLtoERPEntity2(); + field12.setField("ALORT"); + field12.setValue(sendSAPProductRevBean.getALORT()); + list1.add(field12); + MLtoERPEntity2 field13 = new MLtoERPEntity2(); + field13.setField("ELPRO"); + field13.setValue(sendSAPProductRevBean.getELPRO()); + list1.add(field13); + MLtoERPEntity2 field14 = new MLtoERPEntity2(); + field14.setField("KZ"); + field14.setValue(sendSAPProductRevBean.getKZ()); + list1.add(field14); + mLtoERPEntity.setData(list1); + mLtoERPEntity.setList(list2); + Gson gson = new Gson(); + String json = gson.toJson(mLtoERPEntity); + System.out.println(json); + String doPostResult = WebApiUtil.doPost(url, json); + MLRequestEntity resultEntity = (MLRequestEntity)gson.fromJson(doPostResult, MLRequestEntity.class); + String status = resultEntity.getErrcode(); + String result = resultEntity.getResult(); + JSONObject fromObject = JSONObject.fromObject(result); + if (status.equals("0") || status.equals("1")) { + BufferedInputStream input = null; + + try { + input = new BufferedInputStream(MethodUtil.class.getResourceAsStream("/sql.properties")); + Properties pro = new Properties(); + pro.load(input); + String insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVINSERTSQL"), UUID.randomUUID().toString().replace("-", ""), sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), sendSAPProductRevBean.getTLGID(), sendSAPProductRevBean.getTLGNAME(), sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getSENDER(), sendSAPProductRevBean.getRECEIVER(), sendSAPProductRevBean.getFREEUSE(), sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), sendSAPProductRevBean.getVERID(), sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), sendSAPProductRevBean.getBDATU(), sendSAPProductRevBean.getSTLAL(), sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), status, resultEntity.getErrmsg()); + if (sendSAPProductRevBean.getKZ().equals("U")) { + insertSql = String.format(pro.getProperty("ML_TCMPRODUCTREVUPDATESQL"), sendSAPProductRevBean.getMSGID(), sendSAPProductRevBean.getBUSID(), sendSAPProductRevBean.getDTSEND(), sendSAPProductRevBean.getVERID(), sendSAPProductRevBean.getTEXT1(), sendSAPProductRevBean.getADATU(), sendSAPProductRevBean.getBDATU(), sendSAPProductRevBean.getSTLAN(), sendSAPProductRevBean.getPLNNR(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getMDV01(), sendSAPProductRevBean.getALORT(), sendSAPProductRevBean.getELPRO(), status, resultEntity.getErrmsg(), sendSAPProductRevBean.getSTLAL(), sendSAPProductRevBean.getMATNR(), sendSAPProductRevBean.getWERKS(), sendSAPProductRevBean.getALNAL(), sendSAPProductRevBean.getVERID()); + } + + System.out.println(insertSql); + DbPool.getConnection(); + DbPool.executeUpdateSql(insertSql); + DbPool.connection.commit(); + } catch (Exception var46) { + MessageBox.post("数据错误!请联系系统管理员!", "错误!", 1); + var46.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException var45) { + var45.printStackTrace(); + } + } + + DbPool.freeAll(); + } + } + + if (resultEntity.getErrmsg() != null && !resultEntity.getErrmsg().isEmpty() && status.equals("1")) { + messageString.append("【物料代码】:" + fromObject.getString("MATNR").toString()); + messageString.append("【工厂】:" + fromObject.getString("WERKS").toString()); + messageString.append("【生产版本】:" + fromObject.getString("VERID").toString()); + messageString.append("【发送失败】:" + resultEntity.getErrmsg()); + messageString.append("\n"); + } + + System.out.println(messageString); + } + + MessageBox.post("传递成功!", "成功", 2); + } catch (Exception var48) { + var48.printStackTrace(); + } + + } + + private static XSSFRow getRow(XSSFSheet sheet, int num) throws Exception { + XSSFRow row = sheet.getRow(num); + if (row == null) { + row = sheet.createRow(num); + } + + return row; + } + + private static XSSFCell getCell(XSSFRow row, int col) throws Exception { + XSSFCell cell = row.getCell(col); + if (cell == null) { + cell = row.createCell(col); + } + + return cell; + } + + private static String getValue(XSSFCell cell) { + Object value = null; + CellType type = cell.getCellTypeEnum(); + if (type == CellType.STRING) { + value = cell.getStringCellValue(); + } else if (type == CellType.NUMERIC) { + value = (int)cell.getNumericCellValue(); + } + + return "" + value; + } +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MultiComboBox.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MultiComboBox.java new file mode 100644 index 0000000..478333f --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MultiComboBox.java @@ -0,0 +1,205 @@ +package com.connor.ml.tcm.util; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JTextField; +import javax.swing.UIManager; +import javax.swing.plaf.basic.BasicArrowButton; + +import com.teamcenter.rac.util.PropertyLayout; + +public class MultiComboBox extends JComponent { + + private Object[] values; + + public Object[] defaultValues; + + private List listeners = new ArrayList(); + + public MultiPopup popup; + + public JTextField editor; + + protected JButton arrowButton; + + private String valueSperator; + + private static final String DEFAULT_VALUE_SPERATOR = ","; + + public MultiComboBox(Object[] value, Object[] defaultValue){ + this(value,defaultValue,DEFAULT_VALUE_SPERATOR); + } + + public MultiComboBox(Object[] value, Object[] defaultValue , String valueSperator) { + values = value; + defaultValues = defaultValue; + this.valueSperator = valueSperator; + initComponent(); + } + + private void initComponent() { + //暂时使用该布局,后续自己写个布局 + this.setLayout(new PropertyLayout()); + //this.set + popup =new MultiPopup(values,defaultValues); + popup.addActionListener(new PopupAction()); + editor = new JTextField(); + editor.setBackground(Color.WHITE); + editor.setEditable(false); + editor.setPreferredSize(new Dimension(150,30)); +// editor.setBorder(getBorder()); + editor.addMouseListener(new EditorHandler()); + arrowButton = createArrowButton(); + arrowButton.addMouseListener(new EditorHandler()); + add("1.1.left.top",editor); + //add(arrowButton); + setText() ; + + + } + + public Object[] getSelectedValues() { + return popup.getSelectedValues(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + private class PopupAction implements ActionListener{ + + public void actionPerformed(ActionEvent e) { + + if(e.getActionCommand().equals(MultiPopup.CANCEL_EVENT)){ + + }else if(e.getActionCommand().equals(MultiPopup.COMMIT_EVENT)){ + defaultValues = popup.getSelectedValues(); + setText(); + //把事件继续传递出去 + fireActionPerformed(e); + } + + togglePopup(); + + + } + + } + + private void togglePopup(){ + if(popup.isVisible()){ + popup.setVisible(false); + }else{ + popup.setDefaultValue(defaultValues); + popup.show(this, 0, getHeight()); + } + } + + private void setText() { + StringBuilder builder = new StringBuilder(); + for(Object dv : defaultValues){ + builder.append(dv); + builder.append(valueSperator); + } + + editor.setText(builder.substring(0, builder.length() > 0 ? builder.length() -1 : 0).toString()); + } + + private class EditorHandler implements MouseListener{ + + public void mouseClicked(MouseEvent e) { + togglePopup(); + } + + public void mousePressed(MouseEvent e) { + + } + + public void mouseReleased(MouseEvent e) { + + } + + public void mouseEntered(MouseEvent e) { + + } + + public void mouseExited(MouseEvent e) { + + } + + } + + + public void paintComponent(Graphics g){ + g.setColor(Color.white); + g.fillRect(0,0,getWidth(),getHeight()); + } + + + protected JButton createArrowButton() { + JButton button = new BasicArrowButton(BasicArrowButton.SOUTH, + UIManager.getColor("ComboBox.buttonBackground"), + UIManager.getColor("ComboBox.buttonShadow"), + UIManager.getColor("ComboBox.buttonDarkShadow"), + UIManager.getColor("ComboBox.buttonHighlight")); + button.setName("ComboBox.arrowButton"); + return button; + } + + private class MulitComboboxLayout implements LayoutManager{ + + public void addLayoutComponent(String name, Component comp) { + // TODO Auto-generated method stub + + } + + public void removeLayoutComponent(Component comp) { + // TODO Auto-generated method stub + + } + + public Dimension preferredLayoutSize(Container parent) { + return parent.getPreferredSize(); + } + + public Dimension minimumLayoutSize(Container parent) { + return parent.getMinimumSize(); + } + + public void layoutContainer(Container parent) { + int w=parent.getWidth(); + int h=parent.getHeight(); + Insets insets=parent.getInsets(); + h=h-insets.top-insets.bottom; + + } + + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MultiPopup.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MultiPopup.java new file mode 100644 index 0000000..063a39a --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/MultiPopup.java @@ -0,0 +1,194 @@ +package com.connor.ml.tcm.util; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + + + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + private List checkBoxList = new ArrayList(); + + private JButton commitButton ; + + private JButton cancelButton; + + public static final String COMMIT_EVENT = "commit"; + + public static final String CANCEL_EVENT = "cancel"; + + public MultiPopup(Object[] value , Object[] defaultValue) { + super(); + values = value; + defaultValues = defaultValue; + initComponent(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + private void initComponent() { + + JPanel checkboxPane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + + for(Object v : values){ + if(v == null) + { + continue; + } + JCheckBox temp = new JCheckBox(v.toString() , selected(v)); + checkBoxList.add(temp); + } + + if(checkBoxList.get(0).getText().equals("Selected All")) + checkBoxList.get(0).addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + System.out.println("被选中状态 "+checkBoxList.get(0).isSelected()); + if(checkBoxList.get(0).isSelected())//Select All 被选中 + { + //检查其他的是否被选中乳沟没有就选中他们 + for(int i=1; i< checkBoxList.size();i++) + { + if(!checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(true); + } + } + else + { + for(int i=1; i< checkBoxList.size();i++) + { + if(checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(false); + } + } + } + }); + + + + checkboxPane.setLayout(new GridLayout(checkBoxList.size() , 1 ,3, 3)); + for(JCheckBox box : checkBoxList){ + checkboxPane.add(box); + } + + commitButton = new JButton("ok"); + + commitButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("cancel"); + + cancelButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + cancel(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(checkboxPane , BorderLayout.CENTER); + + this.add(buttonPane , BorderLayout.SOUTH); + + + } + + private boolean selected(Object v) { + for(Object dv : defaultValues){ + if( dv .equals(v) ){ + return true; + } + } + return false; + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + public Object[] getSelectedValues(){ + List selectedValues = new ArrayList(); + + if(checkBoxList.get(0).getText().equals("Selected All")) + { + if(checkBoxList.get(0).isSelected()) + { + for(int i = 1 ; i < checkBoxList.size() ; i++) + { + selectedValues.add(values[i]); + } + } + else + { + for(int i = 1 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + } + }else + for(int i = 0 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + public void setDefaultValue(Object[] defaultValue) { + defaultValues = defaultValue; + + } + + public void commit(){ + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + public void cancel(){ + fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ProgressBar.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ProgressBar.java new file mode 100644 index 0000000..9828326 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ProgressBar.java @@ -0,0 +1,143 @@ +package com.connor.ml.tcm.util; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.event.*; +import javax.swing.*; + +import org.eclipse.swt.graphics.Rectangle; + +public class ProgressBar extends AbstractAIFDialog implements ActionListener { + /** + * 内部类,线程任务 + * + * @author Administrator + * + */ + class TaskThread extends Thread { + + public void run() { + + Dimension d = progressbar.getSize(); + bar.paintAll(bar.getGraphics()); + // Rectangle rect = new Rectangle(0,0, d.width, d.height); + for (int i = 0; i < i + 1; i++) { + // 启动线程 + timer.start(); + int value = progressbar.getValue(); + // 让进度条分为100格,以每秒进5格 + if (value < 100) { + value += 5; + progressbar.setValue(value); + + } else { + // 计时器停止,重新开始加载 + timer.stop(); + progressbar.setValue(0); + bar.paintAll(bar.getGraphics()); + } + progressbar.paintImmediately(0, 0, d.width, d.height); + try { + // 线程停止100毫秒 + sleep(100L); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (bool) { + // 设置进度条的可见或者不可见 + bar.setVisible(false); + bar.dispose(); + return; + } + } + + } + + private ProgressBar bar; + + final ProgressBar this$0; + + // 将线程添加到任务中 + public TaskThread(ProgressBar bar) { + super(); + this$0 = ProgressBar.this; + this.bar = bar; + } + } + + public ProgressBar(String showlable) { + super(true); + bool = false; + showLable = null; + showLable = showlable; + } + + public void setBool(boolean bool) { + this.bool = bool; + } + + /** + * 构造进度条的面板 + * + */ + public void initUI() { + Container container = getContentPane(); + JPanel mainPanel = new JPanel(new PropertyLayout()); + label = new JLabel(showLable, 0); + progressbar = new JProgressBar(); + progressbar.setOrientation(0); + // 进度条从0开始,100结束 + progressbar.setMinimum(0); + progressbar.setMaximum(100); + progressbar.setValue(0); + progressbar.setPreferredSize(new Dimension(200, 15)); + progressbar.setBorderPainted(true); + // 启动计时器 + timer = new Timer(50, this); + timer.setRepeats(false); + // 控件的调整 + mainPanel.add("1.1.center", new JLabel(" ")); + mainPanel.add("2.1.center", label); + mainPanel.add("3.1.center", progressbar); + mainPanel.add("4.1.center", new JLabel(" ")); + container.add(mainPanel); + pack(); + setLocation(500, 200); + // 线程任务启动 + TaskThread thread = new TaskThread(this); + thread.start(); + // 内部类,监听关闭按钮的事件 + addWindowListener(new WindowAdapter() { + + public void windowClosing(WindowEvent e) { + bool = true; + } + + }); + setVisible(true); + } + + public void actionPerformed(ActionEvent actionevent) { + } + + public void setText(String message) { + // System.out.println(message); + label.setText(message); + } + + private JProgressBar progressbar; + + private JLabel label; + + private Timer timer; + + private boolean bool; + + private Registry registry; + + private String showLable; + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ProgressBarThread.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ProgressBarThread.java new file mode 100644 index 0000000..42070c7 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/ProgressBarThread.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.util; + +// Referenced classes of package com.teamcenter.rac.importflex: +// ProgressBar + +public class ProgressBarThread extends Thread { + + public ProgressBarThread(String title, String showLable) { + this.title = title; + bar = new ProgressBar(showLable); + } + + public void run() { + bar.setTitle(title); + // 调用初始化面板 + bar.initUI(); + } + + /* + * 设置进度条可显示和不可显示 + */ + public void setBool(boolean bool) { + bar.setBool(true); + } + + private ProgressBar bar; + + private String title; +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/RealBean.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/RealBean.java new file mode 100644 index 0000000..760ebf7 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/RealBean.java @@ -0,0 +1,40 @@ +package com.connor.ml.tcm.util; + +public class RealBean { + private String hzm; + private String daType; + private String toolType; + private String realname; + public String getHzm() { + return hzm; + } + public void setHzm(String hzm) { + this.hzm = hzm; + } + public String getDaType() { + return daType; + } + public void setDaType(String daType) { + this.daType = daType; + } + public String getToolType() { + return toolType; + } + public void setToolType(String toolType) { + this.toolType = toolType; + } + + public String getRealname() { + return realname; + } + public void setRealname(String realname) { + this.realname = realname; + } + @Override + public String toString() { + return "RealBean [hzm=" + hzm + ", daType=" + daType + ", toolType=" + + toolType + ", realname=" + realname + "]"; + } + + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/SAPConn.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/SAPConn.java new file mode 100644 index 0000000..2f16487 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/SAPConn.java @@ -0,0 +1,97 @@ +package com.connor.ml.tcm.util; + +import java.io.File; +import java.io.FileOutputStream; +import java.util.Properties; + +import org.apache.log4j.Logger; + +import com.sap.conn.jco.JCoDestination; +import com.sap.conn.jco.JCoDestinationManager; +import com.sap.conn.jco.JCoException; +import com.sap.conn.jco.ext.DestinationDataProvider; +import com.teamcenter.rac.util.MessageBox; + +public class SAPConn { + private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL"; + + static { + Properties connectProperties = new Properties(); + + connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, + "10.3.1.223"); + connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00"); + connectProperties + .setProperty(DestinationDataProvider.JCO_CLIENT, "800"); + connectProperties.setProperty(DestinationDataProvider.JCO_USER, + "MLSCP"); + connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, + "12345678"); + connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "zh"); + connectProperties.setProperty( + DestinationDataProvider.JCO_POOL_CAPACITY, "3"); + connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, + "10"); + + createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties); + + //----------------------------------------------------------------------------- + +// connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, +// "10.200.200.49"); +// connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00"); +// connectProperties +// .setProperty(DestinationDataProvider.JCO_CLIENT, "800"); +// connectProperties.setProperty(DestinationDataProvider.JCO_USER, +// "GDAB_PROXY"); +// connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, +// "654321"); +// connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "zh"); +// connectProperties.setProperty( +// DestinationDataProvider.JCO_POOL_CAPACITY, "3"); +// connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, +// "10"); +// +// createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties); + + } + + private static void createDataFile(String name, String suffix, + Properties properties) { + File cfg = new File(name + "." + suffix); + if (cfg.exists()) { + cfg.deleteOnExit(); + } + try { + FileOutputStream fos = new FileOutputStream(cfg, false); + properties.store(fos, "for tests only !"); + fos.close(); + } catch (Exception e) { + log.error("Create Data file fault, error msg: " + e.toString()); + throw new RuntimeException("Unable to create the destination file " + + cfg.getName(), e); + } + } + + /** + * 获取sap连接 + * + * @return SAP连接对象 + */ + public static JCoDestination connect() { + JCoDestination destination = null; + try { + destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED); + if(destination==null){ + MessageBox.post("sap连接不上","错误",MessageBox.ERROR); + } + } catch (JCoException e) { + MessageBox.post("sap连接不上","错误",MessageBox.ERROR); + log.error("Connect SAP fault, error msg: " + e.toString()); + } + return destination; + } + + private static Logger log = Logger.getLogger(SAPConn.class); + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/SoaServerUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/SoaServerUtil.java new file mode 100644 index 0000000..ec091cb --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/SoaServerUtil.java @@ -0,0 +1,283 @@ +package com.connor.ml.tcm.util; + +import java.util.List; + +import net.sf.json.JSONArray; + +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMFactory; +import org.apache.axiom.om.OMNamespace; +import org.apache.axis2.AxisFault; +import org.apache.axis2.addressing.EndpointReference; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; + + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentUserType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +public class SoaServerUtil { + + public static TCPreferenceService preferenceService; + public static String priverUserID; + public static String webServiceURL; + + static { + try { + + if (preferenceService == null) { + preferenceService = ((TCSession) AIFUtility + .getCurrentApplication().getSession()) + .getPreferenceService(); + } + + if (priverUserID == null) { + priverUserID = preferenceService.getString( + TCPreferenceService.TC_preference_site, + "Autocode_PriverUser_ID"); + } + + if (webServiceURL == null) { + webServiceURL = preferenceService.getString( + TCPreferenceService.TC_preference_site, + "Autocode_SendClassServer_URL"); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + + public static void sendToClass(String wsoPUID, String classID, String json) { + try { + + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = webServiceURL;// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + System.out.println("url="+url); + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("SendToClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("SendToClass", omNs); + OMElement value = fac.createOMElement("wsoPuiid", omNs); + value.setText(wsoPUID); + OMElement value1 = fac.createOMElement("classID", omNs); + value1.setText(classID); + OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + value2.setText(json); + + method.addChild(value); + method.addChild(value1); + method.addChild(value2); + + OMElement res = sc.sendReceive(method); + + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public void deleteToClass(String classID) { + try { + + ServiceClient sc = new ServiceClient(); + Options opts = new Options(); + String url = webServiceURL;// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL"; + System.out.println("url="+url); + EndpointReference end = new EndpointReference(url); + opts.setTo(end); + opts.setAction("DeleteClass"); + sc.setOptions(opts); + + OMFactory fac = OMAbstractFactory.getOMFactory(); + OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", ""); + OMElement method = fac.createOMElement("DeleteClass", omNs); + //OMElement value = fac.createOMElement("wsoPuiid", omNs); + //value.setText(wsoPUID); + OMElement value = fac.createOMElement("icoPuid", omNs); + value.setText(classID); + //OMElement value2 = fac.createOMElement("JsonContainer", omNs); + // "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]" + //value2.setText(json); + + method.addChild(value); +// method.addChild(value1); +// method.addChild(value2); + + OMElement res = sc.sendReceive(method); + + res.getFirstElement().getText(); + System.out.println(res.getFirstElement().getText()); + } catch (AxisFault e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + public String objectToJson(List props) { + String str = null; + try { + JSONArray json = JSONArray.fromObject(props);// 将java对象转换为json对象 + str = json.toString();// 将json对象转换为字符串 + System.out.println("JSON =>" + str); + } catch (Exception e) { + e.printStackTrace(); + } + return str; + } + + public void grantReadPrivilege(TCSession tcSession, + TCComponent tccomponent) { + try { + TCAccessControlService accessControlService = tcSession + .getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession + .getTypeComponent("User"); + TCComponentUser user = type.find(priverUserID);// 2135 + + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent) + .getItem(); + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tempItem, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } else { + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void grantWritePrivilege(TCSession tcSession, + TCComponent tccomponent) { + try { + TCAccessControlService accessControlService = tcSession + .getTCAccessControlService(); + TCComponentUserType type = (TCComponentUserType) tcSession + .getTypeComponent("User"); + + TCComponentUser user = type.find(priverUserID);// 2135 + if (user == null) { + return; + } + if (tcSession.getUser().equals(user)) { + return; + } + + String[] as2 = new String[] { "READ", "WRITE", "DELETE" }; + + if (tccomponent instanceof TCComponentItemRevision) { + TCComponentItem tempItem = ((TCComponentItemRevision) tccomponent) + .getItem(); + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tempItem, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } else { + openByPass(tcSession); + try { + accessControlService.grantPrivilege(tccomponent, user, as2); + + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + closeByPass(tcSession); + } + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public static void openByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + userservice.call("Connor_set_bypass", obj); + } + + public static void closeByPass(TCSession session) throws TCException { + TCUserService userservice = session.getUserService(); + Object[] obj = new Object[1]; + obj[0] = "origin"; + userservice.call("ORIGIN_close_bypass", obj); + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/TCLOVUtil.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/TCLOVUtil.java new file mode 100644 index 0000000..a644ff9 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/TCLOVUtil.java @@ -0,0 +1,29 @@ +package com.connor.ml.tcm.util; + +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +public class TCLOVUtil { + + public static TCComponentListOfValues findLOVByName(TCSession tcsession, + String s) { + TCComponentListOfValues tccomponentlistofvalues = null; + try { + TCComponentListOfValuesType tccomponentlistofvaluestype = (TCComponentListOfValuesType) tcsession + .getTypeComponent("ListOfValues"); + TCComponentListOfValues atccomponentlistofvalues[] = tccomponentlistofvaluestype + .find(s); + if (atccomponentlistofvalues != null + && atccomponentlistofvalues.length > 0) + tccomponentlistofvalues = atccomponentlistofvalues[0]; + else + tccomponentlistofvalues = null; + } catch (TCException tcexception) { + tccomponentlistofvalues = null; + } + return tccomponentlistofvalues; + } + +} diff --git a/com.connor.ml.tcm/src/com/connor/ml/tcm/util/TableUtil3.java b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/TableUtil3.java new file mode 100644 index 0000000..57c4758 --- /dev/null +++ b/com.connor.ml.tcm/src/com/connor/ml/tcm/util/TableUtil3.java @@ -0,0 +1,59 @@ +package com.connor.ml.tcm.util; + +import javax.swing.JTable; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; + +public class TableUtil3 { + + private TableUtil3() { + throw new Error("Don't let anyone instantiate this class."); + } + + /*** + * hide specified column + * + * @param table + * @param column + */ + public static void hideTableColumn(JTable table, Object column) { + TableColumnModel columns = table.getColumnModel(); + int temp; + if (column instanceof String) { + temp = columns.getColumnIndex(column); + } else { + temp = (int) column; + } + TableColumn column_id_data = columns.getColumn(temp); + column_id_data.setMaxWidth(0); + column_id_data.setPreferredWidth(0); + column_id_data.setMinWidth(0); + + TableColumn column_id_header = table.getTableHeader().getColumnModel().getColumn(temp); + column_id_header.setMaxWidth(0); + column_id_header.setPreferredWidth(0); + column_id_header.setMinWidth(0); + } + + /*** + * show specified column + * + * @param table + * @param column + * @param width + */ + public static void showTableColumn(JTable table, int column) { + int width = 40; + TableColumnModel columns = table.getColumnModel(); + TableColumn column_id_data = columns.getColumn(column); + + column_id_data.setMaxWidth(width + 100); + column_id_data.setPreferredWidth(width); + column_id_data.setMinWidth(width); + + TableColumn column_id_header = table.getTableHeader().getColumnModel().getColumn(column); + column_id_header.setMaxWidth(width + 100); + column_id_header.setPreferredWidth(width); + column_id_header.setMinWidth(width); + } +} \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessCommand.java b/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessCommand.java new file mode 100644 index 0000000..689dae3 --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessCommand.java @@ -0,0 +1,120 @@ +package com.teamcenter.rac.cme.application; + +import java.awt.Frame; + +import com.teamcenter.rac.aif.AbstractAIFCommand; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.NewMEProcessOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; + +public class CreateMEProcessCommand + extends AbstractAIFCommand +{ + private CreateMEProcessDialog dlg; + private boolean itsAnOperation = false; + + public CreateMEProcessCommand(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) + { + if (validComponents(paramArrayOfInterfaceAIFComponent, paramFrame)) + { + this.dlg = new CreateMEProcessDialog(paramFrame, paramArrayOfInterfaceAIFComponent); + setRunnable(this.dlg); + } + } + + public CreateMEProcessCommand(Frame paramFrame, Boolean paramBoolean, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) + { + if (validComponents(paramArrayOfInterfaceAIFComponent, paramFrame)) + { + this.dlg = new CreateMEProcessDialog(paramFrame, paramBoolean.booleanValue(), paramArrayOfInterfaceAIFComponent); + setRunnable(this.dlg); + } + } + + public CreateMEProcessCommand(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, Boolean paramBoolean) + { + this(paramFrame, paramArrayOfInterfaceAIFComponent, paramBoolean, null); + } + + public CreateMEProcessCommand(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, Boolean paramBoolean, String paramString) + { + if (validComponents(paramArrayOfInterfaceAIFComponent, paramFrame)) + { + this.itsAnOperation = paramBoolean.booleanValue(); + this.dlg = new CreateMEProcessDialog(paramFrame, paramArrayOfInterfaceAIFComponent, this.itsAnOperation, paramString); + setRunnable(this.dlg); + } + } + + public CreateMEProcessCommand(Frame paramFrame, TCComponentItemRevision paramTCComponentItemRevision) + { + this.dlg = new CreateMEProcessDialog(paramFrame, paramTCComponentItemRevision); + setRunnable(this.dlg); + } + + public TCComponent getNewProcess() + { + if (this.dlg != null) { + return this.dlg.getNewProcess(); + } + return null; + } + + public CreateMEProcessCommand(Frame paramFrame, TCSession paramTCSession) + { + this.dlg = new CreateMEProcessDialog(paramFrame, paramTCSession); + setRunnable(this.dlg); + } + + public CreateMEProcessCommand(Frame paramFrame, TCSession paramTCSession, Boolean paramBoolean) + { + this.itsAnOperation = paramBoolean.booleanValue(); + this.dlg = new CreateMEProcessDialog(paramFrame, paramTCSession, this.itsAnOperation); + setRunnable(this.dlg); + } + + public CreateMEProcessCommand(TCSession paramTCSession, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, Boolean paramBoolean) + { + setRunnable(new NewMEProcessRunnable(paramTCSession, paramString1, paramString2, paramString3, paramString4, paramString5, paramTCComponent, paramBoolean.booleanValue(), null)); + } + + private boolean validComponents(InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, Frame paramFrame) + { + Registry localRegistry = Registry.getRegistry(this); + for (int i = 0; (paramArrayOfInterfaceAIFComponent != null) && (i < paramArrayOfInterfaceAIFComponent.length); i++) { + if (paramArrayOfInterfaceAIFComponent[i] == null) + { + MessageBox localMessageBox = new MessageBox(paramFrame, localRegistry.getString("invalidObjects"), localRegistry.getString("newItemError.TITLE"), 4); + localMessageBox.setModal(true); + localMessageBox.setVisible(true); + return false; + } + } + return true; + } + + public CreateMEProcessDialog getDlg() + { + return this.dlg; + } + + private class NewMEProcessRunnable + implements Runnable + { + private NewMEProcessOperation op = null; + + public NewMEProcessRunnable(TCSession paramTCSession, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) + { + this.op = new NewMEProcessOperation(paramTCSession, !CreateMEProcessCommand.this.itsAnOperation, null, paramString1, paramString2, paramString3, paramString4, paramString5, paramTCComponent, paramBoolean, paramArrayOfInterfaceAIFComponent, null, null); + } + + public void run() + { + this.op.executeModeless(); + } + } +} diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessDialog.java b/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessDialog.java new file mode 100644 index 0000000..edda885 --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessDialog.java @@ -0,0 +1,1420 @@ +package com.teamcenter.rac.cme.application; + +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.text.DecimalFormat; +import java.text.MessageFormat; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSpinner; +import javax.swing.JTabbedPane; +import javax.swing.JTextArea; +import javax.swing.JTextField; +import javax.swing.SpinnerNumberModel; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.IWorkbenchPart; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.InterfaceAIFOperationListener; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.SelectionHelper; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.AutoGenerateIdUtil; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.METemplatePanel; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.Messages; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.NewMEProcessOperation; +import com.teamcenter.rac.cme.framework.util.MFGStructureTypeUtil; +import com.teamcenter.rac.cme.framework.util.PasteUtils; +import com.teamcenter.rac.cme.kernel.bvr.TCComponentMfgBvrCompoundOperation; +import com.teamcenter.rac.common.TCTypeRenderer; +import com.teamcenter.rac.common.TCUtilities; +import com.teamcenter.rac.common.cme.IMFGApplication; +import com.teamcenter.rac.common.cme.InterfaceUseTemplateDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentAbstractCCStructure; +import com.teamcenter.rac.kernel.TCComponentAppGroupBOPLine; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.ms.util.SelectionUtil; +import com.teamcenter.rac.util.AdapterUtil; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Painter; +import com.teamcenter.rac.util.PlatformHelper; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.SWTUIUtilities; +import com.teamcenter.rac.util.Separator; +import com.teamcenter.rac.util.VerticalLayout; + +public class CreateMEProcessDialog + extends AbstractAIFDialog + implements InterfaceAIFOperationListener, InterfaceUseTemplateDialog +{ + public static final String PREFERENCE_KEY = "Process.Template"; + private JTextField id; + private JTextField rev; + public JPanel namePanel; + private JTextField name; + private JTextArea descriptionText; + private JCheckBox openOnCreate; + private JButton okButton; + private JButton applyButton; + private JButton cancelButton; + private JButton assignButton; + protected static final short OK_BUTTON_CLICKED = 0; + protected static final short APPLY_BUTTON_CLICKED = 1; + protected short okOrApply = 0; + protected TCSession session = null; + protected InterfaceAIFComponent[] pasteTargets = null; + protected AIFDesktop desktop = null; + protected Frame parent = null; + protected CreateMEProcessOperation newMEProcessOp = null; + private Registry appReg; + protected TCComponentItem meProcessComponent = null; + protected TCComponentItemRevision targetProductItem = null; + private boolean isIDModifiable = true; + private boolean isRevIDModifiable = true; + boolean itsAnOperation = false; + boolean itsAPlan = false; + private String defaultProcessTypeName = "MEProcess"; + protected static final String MEPROCESS_TYPE = "MEProcess"; + protected static final String MEPROCESSOP_TYPE = "MEOP"; + protected static int maxNumberOfItems = 0; + private METemplatePanel useTemplatePanel = null; + private JLabel idLabel; + private String previousTemplateType = ""; + private String meProcessType; + private String templateIDStr; + private String templateUIDStr; + private JTabbedPane customTab; + public JPanel quantityPanel; + private SpinnerNumberModel quantitySpinnerModel; + private JSpinner quantitySpinner; + private JLabel spinnerLable; + private JLabel parentLineLabel; + private InterfaceAIFComponent[] tempTargets = null; + private boolean opSuccessAndNotNewRootFlag = false; + private boolean createAsNewRootFlag = false; + private int numOfObjectsEntered = 0; + + public CreateMEProcessDialog(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) + { + super(paramFrame, false); + this.session = ((TCSession)paramArrayOfInterfaceAIFComponent[0].getSession()); + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.parent = paramFrame; + if ((paramFrame instanceof AIFDesktop)) { + this.desktop = ((AIFDesktop)paramFrame); + } + setCreationType(); + initializeDialog(); + } + + public CreateMEProcessDialog(Frame paramFrame, boolean paramBoolean, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent) + { + super(paramFrame, false); + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.parent = paramFrame; + if (paramArrayOfInterfaceAIFComponent != null) { + this.session = ((TCSession)paramArrayOfInterfaceAIFComponent[0].getSession()); + } + if ((paramFrame instanceof AIFDesktop)) { + this.desktop = ((AIFDesktop)paramFrame); + } + if ((this.pasteTargets != null) && (this.pasteTargets.length == 1) && ((this.pasteTargets[0] instanceof TCComponent))) + { + TCComponentItemRevision localTCComponentItemRevision; + if ((this.pasteTargets[0] instanceof TCComponentBOMLine)) + { + try + { + localTCComponentItemRevision = ((TCComponentBOMLine)this.pasteTargets[0]).getItemRevision(); + this.itsAPlan = (localTCComponentItemRevision instanceof TCComponentMEProcessRevision); + } + catch (TCException localTCException) {} + } + else if ((this.pasteTargets[0] instanceof TCComponentItemRevision)) + { + localTCComponentItemRevision = (TCComponentItemRevision)this.pasteTargets[0]; + this.itsAPlan = (localTCComponentItemRevision instanceof TCComponentMEProcessRevision); + } + else + { + this.itsAPlan = (this.pasteTargets[0] instanceof TCComponentMEProcess); + } + this.itsAnOperation = (!this.itsAPlan); + } + initializeDialog(); + } + + public CreateMEProcessDialog(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, boolean paramBoolean) + { + this(paramFrame, paramArrayOfInterfaceAIFComponent, paramBoolean, null); + } + + public CreateMEProcessDialog(Frame paramFrame, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, boolean paramBoolean, String paramString) + { + super(paramFrame, false); + this.session = ((TCSession)paramArrayOfInterfaceAIFComponent[0].getSession()); + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.parent = paramFrame; + if ((paramFrame instanceof AIFDesktop)) { + this.desktop = ((AIFDesktop)paramFrame); + } + this.itsAnOperation = paramBoolean; + this.itsAPlan = (!this.itsAnOperation); + initializeDialog(); + } + + public CreateMEProcessDialog(Frame paramFrame, TCComponentItemRevision paramTCComponentItemRevision) + { + super(paramFrame, false); + this.session = paramTCComponentItemRevision.getSession(); + this.pasteTargets = null; + this.parent = paramFrame; + if ((paramFrame instanceof AIFDesktop)) { + this.desktop = ((AIFDesktop)paramFrame); + } + this.targetProductItem = paramTCComponentItemRevision; + initializeDialog(); + } + + public CreateMEProcessDialog(Frame paramFrame, TCSession paramTCSession) + { + super(paramFrame, false); + this.session = paramTCSession; + this.parent = paramFrame; + if ((paramFrame instanceof AIFDesktop)) { + this.desktop = ((AIFDesktop)paramFrame); + } + initializeDialog(); + } + + public CreateMEProcessDialog(Frame paramFrame, TCSession paramTCSession, boolean paramBoolean) + { + super(paramFrame, false); + this.session = paramTCSession; + this.parent = paramFrame; + if ((paramFrame instanceof AIFDesktop)) { + this.desktop = ((AIFDesktop)paramFrame); + } + this.itsAnOperation = paramBoolean; + this.itsAPlan = (!this.itsAnOperation); + initializeDialog(); + } + + private void addSelectionListenerToSelectionService() + { + ISelectionService localISelectionService = PlatformHelper.getCurrentWorkbenchWindow().getSelectionService(); + localISelectionService.addSelectionListener(new ISelectionListener() + { + public void selectionChanged(IWorkbenchPart paramAnonymousIWorkbenchPart, ISelection paramAnonymousISelection) + { + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = SelectionHelper.getTargetComponents(paramAnonymousISelection); + if (MFGStructureTypeUtil.isProcess((TCComponent)AdapterUtil.getAdapter(arrayOfInterfaceAIFComponent[0], TCComponent.class))) { + CreateMEProcessDialog.this.openOnCreate.setEnabled(true); + } else { + CreateMEProcessDialog.this.openOnCreate.setEnabled(false); + } + } + }); + } + + private void initializeDialog() + { + this.appReg = Registry.getRegistry(this); + TCPreferenceService localTCPreferenceService = this.session.getPreferenceService(); + Integer localInteger = localTCPreferenceService.getIntegerValue("MaxNumberOfObjectsToCreate"); + if (localInteger != null) { + maxNumberOfItems = localInteger.intValue(); + } else { + maxNumberOfItems = 99; + } + String str1; + if (this.itsAnOperation) { + str1 = "NewMEOP.TITLE"; + } else { + str1 = "NewMEProcess.TITLE"; + } + setTitle(this.appReg.getString(str1)); + String str2 = localTCPreferenceService.getStringValue("FLColumnCatIVFSeparatorPref"); + String str3 = localTCPreferenceService.getStringValue("FLColumnCatObjSeparatorPref"); + JPanel localJPanel1 = new JPanel(new VerticalLayout(5, 2, 2, 2, 2)); + getContentPane().add(localJPanel1); + JPanel localJPanel2 = new JPanel(new ButtonLayout()); + JPanel localJPanel3 = new JPanel(new HorizontalLayout()); + JPanel localJPanel4 = new JPanel(new HorizontalLayout()); + JPanel localJPanel5 = new JPanel(new VerticalLayout()); + JPanel localJPanel6 = new JPanel(new VerticalLayout()); + this.customTab = new JTabbedPane(); + this.customTab.addTab(this.appReg.getString("base.TITLE"), localJPanel6); + JPanel localJPanel7 = new JPanel(new PropertyLayout()); + String str4 = this.itsAPlan ? "MEProcess" : "MEOP"; + JLabel localJLabel1 = new JLabel(this.appReg.getImageIcon("new" + str4 + ".ICON")); + String str5 = this.itsAnOperation ? this.appReg.getString("meOperationId") : this.appReg.getString("meProcessId"); + this.idLabel = new JLabel(str5); + JLabel localJLabel2 = new JLabel(this.appReg.getString("meProcessRevision")); + JLabel localJLabel3 = new JLabel(this.appReg.getString("meProcessName")); + this.id = new JTextField(15) + { + public void paint(Graphics paramAnonymousGraphics) + { + super.paint(paramAnonymousGraphics); + Painter.paintIsRequired(this, paramAnonymousGraphics); + } + }; + this.id.addKeyListener(new KeyAdapter() + { + public void keyReleased(KeyEvent paramAnonymousKeyEvent) + { + CreateMEProcessDialog.this.validateEntries(); + } + + public void keyTyped(KeyEvent paramAnonymousKeyEvent) + { + JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); + String str = localJTextField.getText(); + int i = 128; + if (str.length() >= i) + { + localJTextField.setText(str.substring(0, i - 1)); + Toolkit.getDefaultToolkit().beep(); + } + } + }); + this.id.addFocusListener(new FocusAdapter() + { + public void focusGained(FocusEvent paramAnonymousFocusEvent) + { + CreateMEProcessDialog.this.id.selectAll(); + } + }); + AutoGenerateIdUtil.setToolTip(str4, "item_id", this.id, this.appReg.getString("itemInfo.id.TOOLTIP"), this.session); + this.rev = new JTextField(4) + { + public void paint(Graphics paramAnonymousGraphics) + { + super.paint(paramAnonymousGraphics); + Painter.paintIsRequired(this, paramAnonymousGraphics); + } + }; + this.rev.addKeyListener(new KeyAdapter() + { + public void keyReleased(KeyEvent paramAnonymousKeyEvent) + { + CreateMEProcessDialog.this.validateEntries(); + } + + public void keyTyped(KeyEvent paramAnonymousKeyEvent) + { + JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); + String str = localJTextField.getText(); + int i = 32; + if (str.length() >= i) + { + localJTextField.setText(str.substring(0, i - 1)); + Toolkit.getDefaultToolkit().beep(); + } + } + }); + this.rev.addFocusListener(new FocusAdapter() + { + public void focusGained(FocusEvent paramAnonymousFocusEvent) + { + CreateMEProcessDialog.this.rev.selectAll(); + } + }); + this.name = new JTextField(10) + { + public void paint(Graphics paramAnonymousGraphics) + { + super.paint(paramAnonymousGraphics); + Painter.paintIsRequired(this, paramAnonymousGraphics); + } + }; + this.name.addKeyListener(new KeyAdapter() + { + public void keyReleased(KeyEvent paramAnonymousKeyEvent) + { + CreateMEProcessDialog.this.validateEntries(); + } + + public void keyTyped(KeyEvent paramAnonymousKeyEvent) + { + JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); + String str = localJTextField.getText(); + int i = 128; + if (str.length() >= i) + { + localJTextField.setText(str.substring(0, i - 1)); + Toolkit.getDefaultToolkit().beep(); + } + } + + public void keyPressed(KeyEvent paramAnonymousKeyEvent) + { + int i = paramAnonymousKeyEvent.getKeyCode(); + if ((i == 10) && (CreateMEProcessDialog.this.okButton.isEnabled()) && (CreateMEProcessDialog.this.validateId())) + { + CreateMEProcessDialog.this.okOrApply = 0; + CreateMEProcessDialog.this.startCreateOperation(); + } + } + }); + this.name.addFocusListener(new FocusAdapter() + { + public void focusGained(FocusEvent paramAnonymousFocusEvent) + { + CreateMEProcessDialog.this.name.selectAll(); + } + }); + this.namePanel = new JPanel(new HorizontalLayout()); + if (str4 != null) { + try + { + this.namePanel.removeAll(); + this.namePanel.add("left.bind.left.center", this.name); + this.namePanel.revalidate(); + this.namePanel.repaint(); + } + catch (Exception localException) + { + this.namePanel.removeAll(); + this.namePanel.add("left.bind.left.center", this.name); + } + } else { + this.namePanel.add("left.bind.left.center", this.name); + } + this.assignButton = new JButton(this.appReg.getString("newProcessAssign")); + this.assignButton.setMargin(new Insets(0, 0, 0, 0)); + this.assignButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + String str = CreateMEProcessDialog.this.getMEProcessType(); + if ((str == null) || (str.length() == 0)) { + return; + } + if (CreateMEProcessDialog.this.validateId()) + { + CreateMEProcessDialog.this.getAssignedIds(str); + CreateMEProcessDialog.this.validateEntries(); + CreateMEProcessDialog.this.namePanel.requestFocus(); + } + else + { + CreateMEProcessDialog.this.id.setText(""); + } + } + }); + this.quantityPanel = new JPanel(new HorizontalLayout()); + this.quantitySpinnerModel = new SpinnerNumberModel(1, 1, this.appReg.getInt("MAX_NUMBER_OF_ITEMS", 0), 1); + this.quantitySpinner = new JSpinner(this.quantitySpinnerModel); + JFormattedTextField localJFormattedTextField = ((JSpinner.DefaultEditor)this.quantitySpinner.getEditor()).getTextField(); + localJFormattedTextField.setColumns(3); + this.spinnerLable = new JLabel(this.appReg.getString("itemInfo.quantity")); + this.spinnerLable.setLabelFor(this.quantitySpinner); + this.quantitySpinner.addChangeListener(new ChangeListener() + { + public void stateChanged(ChangeEvent paramAnonymousChangeEvent) + { + CreateMEProcessDialog.this.validateEntries(); + } + }); + addValidator(this.quantitySpinner); + this.quantityPanel.add("left", this.spinnerLable); + this.quantityPanel.add("left.nobind", this.quantitySpinner); + JLabel localJLabel4 = new JLabel(this.appReg.getString("newProcessDescription")); + this.descriptionText = new JTextArea(3, 30); + this.descriptionText.setLineWrap(true); + this.descriptionText.setWrapStyleWord(true); + this.descriptionText.addKeyListener(new KeyAdapter() + { + public void keyTyped(KeyEvent paramAnonymousKeyEvent) + { + JTextArea localJTextArea = (JTextArea)paramAnonymousKeyEvent.getSource(); + String str = localJTextArea.getText(); + int i = 240; + if (str.length() >= i) + { + localJTextArea.setText(str.substring(0, i - 1)); + Toolkit.getDefaultToolkit().beep(); + } + } + }); + JScrollPane localJScrollPane = new JScrollPane(); + localJScrollPane.getViewport().add(this.descriptionText); + String str6 = this.itsAnOperation ? this.appReg.getString("setAsRootOperation") : this.appReg.getString("setAsRootProcess"); + this.openOnCreate = new JCheckBox(str6); + this.openOnCreate.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + CreateMEProcessDialog.this.enableApplyButton(); + CreateMEProcessDialog.this.showHideParentLineLabel(); + } + }); + AbstractAIFUIApplication localAbstractAIFUIApplication = AIFUtility.getCurrentApplication(); + Object localObject; + if (((localAbstractAIFUIApplication instanceof IMFGApplication)) && ((this.pasteTargets == null) || (this.pasteTargets.length == 0))) + { + localObject = (IMFGApplication)localAbstractAIFUIApplication; + TCComponentAbstractCCStructure localTCComponentAbstractCCStructure = ((IMFGApplication)localObject).getSelectedStructure(); + if (localTCComponentAbstractCCStructure != null) + { + this.pasteTargets = new InterfaceAIFComponent[1]; + this.pasteTargets[0] = localTCComponentAbstractCCStructure; + } + } + try + { + localObject = "Operation"; + if ((this.pasteTargets != null) && (this.pasteTargets.length > 0) && ((this.pasteTargets[0] instanceof TCComponentMfgBvrCompoundOperation))) { + localObject = "Mfg0MEStep"; + } + if ((this.pasteTargets == null) || (this.pasteTargets.length == 0) || ((this.itsAnOperation) && (!PasteUtils.isPastableForNewCommands((String)localObject, (TCComponent)this.pasteTargets[0]))) || ((!this.itsAnOperation) && (!PasteUtils.isPastableForNewCommands("Process", (TCComponent)this.pasteTargets[0])))) + { + this.openOnCreate.setSelected(true); + this.openOnCreate.setEnabled(false); + this.createAsNewRootFlag = true; + } + else if ((this.pasteTargets != null) && (this.pasteTargets.length > 0) && ((this.pasteTargets[0] instanceof TCComponentBOMLine))) + { + try + { + if (!((TCComponentBOMLine)this.pasteTargets[0]).isPasteAllowed()) + { + this.openOnCreate.setSelected(true); + this.openOnCreate.setEnabled(false); + this.createAsNewRootFlag = true; + } + } + catch (TCException localTCException2) + { + MessageBox.post(localTCException2); + } + } + this.okButton = new JButton(this.appReg.getString("ok")); + } + catch (TCException localTCException1) + { + MessageBox.post(localTCException1); + } + this.okButton.setMnemonic(this.appReg.getString("ok.MNEMONIC").charAt(0)); + this.okButton.setEnabled(false); + this.okButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + CreateMEProcessDialog.this.okOrApply = 0; + if ((CreateMEProcessDialog.this.validateId()) && (CreateMEProcessDialog.this.numOfObjectsEntered <= CreateMEProcessDialog.maxNumberOfItems)) { + CreateMEProcessDialog.this.startCreateOperation(); + } + } + }); + this.applyButton = new JButton(this.appReg.getString("apply")); + this.applyButton.setMnemonic(this.appReg.getString("apply.MNEMONIC").charAt(0)); + this.applyButton.setEnabled(false); + this.applyButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + CreateMEProcessDialog.this.okOrApply = 1; + if ((CreateMEProcessDialog.this.validateId()) && (CreateMEProcessDialog.this.numOfObjectsEntered <= CreateMEProcessDialog.maxNumberOfItems)) { + CreateMEProcessDialog.this.startCreateOperation(); + } + } + }); + this.cancelButton = new JButton(this.appReg.getString("cancel")); + this.cancelButton.setMnemonic(this.appReg.getString("cancel.MNEMONIC").charAt(0)); + this.cancelButton.addActionListener(new AbstractAIFDialog.IC_DisposeActionListener()); + this.cancelButton.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + CreateMEProcessDialog.this.disposeDialog(); + CreateMEProcessDialog.this.useTemplatePanel.close(); + } + }); + setDefaultCloseOperation(0); + addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent paramAnonymousWindowEvent) + { + CreateMEProcessDialog.this.cancelButton.doClick(); + } + }); + this.useTemplatePanel = getTemplatePanel(str4); + this.cancelButton.addActionListener(this.useTemplatePanel); + this.okButton.addActionListener(this.useTemplatePanel); + this.useTemplatePanel.getTemplateTextField().addKeyListener(new KeyAdapter() + { + public void keyReleased(KeyEvent paramAnonymousKeyEvent) + { + JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); + String str = localJTextField.getText(); + boolean bool = str.length() > 0; + CreateMEProcessDialog.this.assignButton.setEnabled(bool); + } + + public void keyTyped(KeyEvent paramAnonymousKeyEvent) + { + JTextField localJTextField = (JTextField)paramAnonymousKeyEvent.getSource(); + String str = localJTextField.getText(); + int i = 128; + if (str.length() >= i) + { + localJTextField.setText(str.substring(0, i - 1)); + Toolkit.getDefaultToolkit().beep(); + } + } + }); + this.useTemplatePanel.getGetTemplateIDButton().addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + TCComponentBOMLine[] arrayOfTCComponentBOMLine = SelectionUtil.getSelectedBOMLines(); + if (arrayOfTCComponentBOMLine != null) + { + final CreateMEProcessDialog.GetPropertyOperation localGetPropertyOperation = new CreateMEProcessDialog.GetPropertyOperation(CreateMEProcessDialog.this, arrayOfTCComponentBOMLine[0]); + localGetPropertyOperation.addOperationListener(new InterfaceAIFOperationListener() + { + public void startOperation(String paramAnonymous2String) {} + + public void endOperation() + { + final String str = (String)localGetPropertyOperation.getOperationResult(); + SWTUIUtilities.asyncExec(new Runnable() + { + public void run() + { + CreateMEProcessDialog.this.useTemplatePanel.getTemplateTextField().setText(str); + TCComponentItem localTCComponentItem = CreateMEProcessDialog.this.getTemplateComponent(); + if (localTCComponentItem != null) { + CreateMEProcessDialog.this.favoriteSelected(localTCComponentItem); + } + JTextField localJTextField = CreateMEProcessDialog.this.useTemplatePanel.getTemplateTextField(); + String str = localJTextField.getText(); + int i = 128; + if (str.length() >= i) + { + localJTextField.setText(str.substring(0, i - 1)); + Toolkit.getDefaultToolkit().beep(); + } + boolean bool = str.length() > 0; + CreateMEProcessDialog.this.assignButton.setEnabled(bool); + } + }); + } + }); + CreateMEProcessDialog.this.session.queueOperation(localGetPropertyOperation); + } + } + }); + this.useTemplatePanel.getTemplateTextField().addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + TCComponentItem localTCComponentItem = CreateMEProcessDialog.this.getTemplateComponent(); + if (localTCComponentItem != null) { + CreateMEProcessDialog.this.favoriteSelected(localTCComponentItem); + } + } + }); + this.useTemplatePanel.getTemplateTextField().addFocusListener(new FocusAdapter() + { + public void focusGained(FocusEvent paramAnonymousFocusEvent) + { + CreateMEProcessDialog.this.useTemplatePanel.getTemplateTextField().selectAll(); + } + }); + localJPanel2.add(this.okButton); + addApplyButton(localJPanel2); + localJPanel2.add(this.cancelButton); + localJPanel3.add("left", this.idLabel); + localJPanel3.add("left", new JLabel(str2)); + localJPanel3.add("left", localJLabel2); + localJPanel3.add("left", new JLabel(str3)); + localJPanel3.add("left.nobind", localJLabel3); + localJPanel4.add("left.nobind", this.id); + localJPanel4.add("left", new JLabel(str2)); + localJPanel4.add("left.nobind", this.rev); + localJPanel4.add("left", new JLabel(str3)); + localJPanel4.add("left.nobind", this.namePanel); + localJPanel4.add("left.nobind", this.assignButton); + localJPanel7.add("1.1.left.top", localJLabel4); + localJPanel7.add("1.2.center.center.resizable.resizable", localJScrollPane); + localJPanel5.add("top", localJPanel3); + localJPanel5.add("top.bind", localJPanel4); + addQuantityPanel(localJPanel5); + localJPanel6.add("top.bind.resizable.resizable", localJPanel5); + localJPanel6.add("top.bind.resizable.resizable", localJPanel7); + TCComponent localTCComponent = null; + if ((!getOpenOnCreateFlag()) && (this.pasteTargets != null) && (this.pasteTargets.length > 0)) + { + localTCComponent = (TCComponent)AdapterUtil.getAdapter(this.pasteTargets[0], TCComponent.class); + if ((localTCComponent != null) && ((MFGStructureTypeUtil.isProcess(localTCComponent)) || (MFGStructureTypeUtil.isOperation(localTCComponent)))) + { + this.parentLineLabel = new JLabel(MessageFormat.format(Messages.FromTemple_createUnder, new Object[] { localTCComponent.toDisplayString() }), TCTypeRenderer.getIcon(localTCComponent, false), 2); + localJPanel1.add("top.nobind.left", this.parentLineLabel); + } + } + else + { + localJPanel1.add("top.nobind.left", localJLabel1); + } + localJPanel1.add("top.bind", new Separator()); + localJPanel1.add("top.bind", this.useTemplatePanel); + localJPanel1.add("top.bind.resizable.resizable", this.customTab); + addOpenOnCreate(localJPanel1); + localJPanel1.add("bottom.bind.center.top", localJPanel2); + localJPanel1.add("bottom.bind", new Separator()); + setSize(getWidth(), getHeight() + 50); + pack(); + setPersistentDisplay(true); + this.id.requestFocus(); + } + + private void addValidator(JSpinner paramJSpinner) + { + final JFormattedTextField localJFormattedTextField = ((JSpinner.DefaultEditor)this.quantitySpinner.getEditor()).getTextField(); + localJFormattedTextField.addFocusListener(new FocusAdapter() + { + public void focusLost(FocusEvent paramAnonymousFocusEvent) + { + String str1 = localJFormattedTextField.getText(); + int i = 1; + try + { + CreateMEProcessDialog.this.numOfObjectsEntered = Integer.parseInt(str1); + } + catch (NumberFormatException localNumberFormatException) + { + i = 0; + } + if ((CreateMEProcessDialog.this.numOfObjectsEntered > CreateMEProcessDialog.maxNumberOfItems) || (i == 0)) + { + String str2 = MessageFormat.format(com.teamcenter.rac.cme.bvr.create.item.Messages.CreateItem_invalidQuantity_MSG, new Object[] { Integer.valueOf(CreateMEProcessDialog.maxNumberOfItems) }); + MessageBox.post(str2, com.teamcenter.rac.cme.bvr.create.item.Messages.CreateItem_InvalidQuantity_TITLE, 1); + localJFormattedTextField.requestFocusInWindow(); + } + } + }); + } + + protected void addApplyButton(JPanel paramJPanel) + { + paramJPanel.add(this.applyButton); + } + + protected void enableApplyButton() + { + this.applyButton.setEnabled(!this.openOnCreate.isSelected()); + } + + protected void showHideParentLineLabel() + { + if ((this.parentLineLabel != null) && (this.openOnCreate != null)) { + this.parentLineLabel.setVisible(!this.openOnCreate.isSelected()); + } + } + + protected void setCreationType() + { + if ((this.pasteTargets != null) && (this.pasteTargets.length == 1) && ((this.pasteTargets[0] instanceof TCComponent))) + { + this.itsAPlan = (((this.pasteTargets[0] instanceof TCComponentMEProcess)) || ((this.pasteTargets[0] instanceof TCComponentMEProcessRevision))); + this.itsAnOperation = (!this.itsAPlan); + } + } + + protected METemplatePanel getTemplatePanel(String paramString) + { + return new METemplatePanel(this, this.session, this.desktop, "Process.Template", "Process.Template." + paramString, paramString, true); + } + + protected void addOpenOnCreate(JPanel paramJPanel) + { + paramJPanel.add("left", this.openOnCreate); + } + + protected void addQuantityPanel(JPanel paramJPanel) + { + paramJPanel.add("top.bind", this.quantityPanel); + ActionListener local24 = new ActionListener() + { + private int numObjectsToCreate = 1; + + public void actionPerformed(ActionEvent paramAnonymousActionEvent) + { + boolean bool1 = CreateMEProcessDialog.this.openOnCreate.isSelected(); + boolean bool2 = !bool1; + int i = 0; + Object localObject; + if (CreateMEProcessDialog.this.pasteTargets != null) + { + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; + int k = (arrayOfInterfaceAIFComponent = CreateMEProcessDialog.this.pasteTargets).length; + for (int j = 0; j < k; j++) + { + localObject = arrayOfInterfaceAIFComponent[j]; + if ((localObject instanceof TCComponentAppGroupBOPLine)) + { + i = 1; + break; + } + } + if (i != 0) { + bool2 = false; + } + } + CreateMEProcessDialog.this.quantitySpinner.setEnabled(bool2); + CreateMEProcessDialog.this.spinnerLable.setEnabled(bool2); + if (bool2) + { + CreateMEProcessDialog.this.quantitySpinner.setToolTipText(null); + CreateMEProcessDialog.this.spinnerLable.setToolTipText(null); + CreateMEProcessDialog.this.quantitySpinnerModel.setValue(Integer.valueOf(this.numObjectsToCreate)); + } + else + { + this.numObjectsToCreate = CreateMEProcessDialog.this.quantitySpinnerModel.getNumber().intValue(); + CreateMEProcessDialog.this.quantitySpinnerModel.setValue(Integer.valueOf(1)); + if (bool1) + { + localObject = CreateMEProcessDialog.this.appReg.getString(CreateMEProcessDialog.this.itsAnOperation ? "QuantityFieldDisabledForRootOperations" : "QuantityFieldDisabledForRootProcesses"); + CreateMEProcessDialog.this.quantitySpinner.setToolTipText((String)localObject); + CreateMEProcessDialog.this.spinnerLable.setToolTipText((String)localObject); + } + else if (i != 0) + { + localObject = CreateMEProcessDialog.this.appReg.getString("QuantityFieldDisabledForOG"); + CreateMEProcessDialog.this.quantitySpinner.setToolTipText((String)localObject); + CreateMEProcessDialog.this.spinnerLable.setToolTipText((String)localObject); + } + } + } + }; + this.openOnCreate.addActionListener(local24); + local24.actionPerformed(null); + } + + public JComponent getNameField() + { + return this.name; + } + + private String getProcessType(TCComponent paramTCComponent) + { + String str; + if (this.itsAPlan) + { + try + { + str = paramTCComponent.getType(); + if ((this.itsAPlan) && (str.equals("MEProcessRevision"))) { + str = this.defaultProcessTypeName; + } + } + catch (Exception localException1) + { + str = this.defaultProcessTypeName; + } + return str; + } + try + { + str = paramTCComponent.getType(); + if ((this.itsAnOperation) && (str.equals("MEOPRevision"))) { + str = this.defaultProcessTypeName; + } + } + catch (Exception localException2) + { + str = this.defaultProcessTypeName; + } + return str; + } + + private void clearFields() + { + this.id.setText(""); + this.id.setEditable(true); + this.rev.setText(""); + validateEntries(); + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000000"); + String newID = oldItemID + "-000001"; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + int i = 1; + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "-" + df.format(i); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + private void getAssignedIds(String paramString) + { + TCComponentItemType localTCComponentItemType = null; + String str1; + Object localObject; + try + { + localTCComponentItemType = (TCComponentItemType)this.session.getTypeComponent(paramString); + str1 = getMEProcessID(); + if (str1.length() == 0) + { + if(this.templateIDStr.indexOf("-") > 0) + { + + String str2 = getGyRuleID(session, templateIDStr.substring(0, templateIDStr.lastIndexOf("-")));//localTCComponentItemType.getNewID(); + + this.isIDModifiable = false;//localTCComponentItemType.isNewIDModifiable(str2); + this.id.setText(str2); + if (!this.isIDModifiable) { + this.id.setEditable(false); + } + } + else + { + String str2 = localTCComponentItemType.getNewID(); + + this.isIDModifiable = localTCComponentItemType.isNewIDModifiable(str2); + this.id.setText(str2); + if (!this.isIDModifiable) { + this.id.setEditable(false); + } + } + + } + } + catch (TCException localTCException1) + { + localObject = new MessageBox(this.parent, localTCException1); + ((MessageBox)localObject).setModal(true); + ((MessageBox)localObject).setVisible(true); + return; + } + String str3; + try + { + if ((str1.length() > 0) && (this.meProcessComponent == null)) + { + this.meProcessComponent = localTCComponentItemType.find(str1); + if (this.meProcessComponent != null) + { + str3 = this.meProcessComponent.getProperty("object_name"); + localObject = this.meProcessComponent.getProperty("object_desc"); + String str4 = getProcessType(this.meProcessComponent); + this.defaultProcessTypeName = str4; + this.name.setText(str3); + this.descriptionText.setText((String)localObject); + } + } + } + catch (TCException localTCException3) + { + this.meProcessComponent = null; + } + try + { + str3 = localTCComponentItemType.getNewRev(this.meProcessComponent); + this.isRevIDModifiable = localTCComponentItemType.isNewRevModifiable(this.meProcessComponent, str3); + this.rev.setText(str3); + if (!this.isRevIDModifiable) { + this.rev.setEditable(false); + } + } + catch (TCException localTCException2) + { + localObject = new MessageBox(this.parent, localTCException2); + ((MessageBox)localObject).setModal(true); + ((MessageBox)localObject).setVisible(true); + return; + } + if (paramString.equalsIgnoreCase("Mfg0MEPlantBOP")) + { + this.openOnCreate.setSelected(true); + this.openOnCreate.setEnabled(false); + } + } + + protected void startCreateOperation() + { + String str1 = this.useTemplatePanel.getTemplateId(); + TCComponentRevisionRule localTCComponentRevisionRule = this.useTemplatePanel.getTemplateRevisionRule(); + String str2 = this.useTemplatePanel.getTemplateCloningRule(); + TCComponent[] arrayOfTCComponent = getTemplateReferenceStructureTCComponents(); + String str3 = this.useTemplatePanel.getTemplateUID(); + int i = getNumberOfItemsToCreate(); + String str4 = null; + String str5 = null; + String str6 = getMEProcessType(); + String str7 = getMEProcessName(); + if (i == 1) + { + str4 = getMEProcessID(); + str5 = getRevID(); + } + this.tempTargets = this.pasteTargets; + if (getOpenOnCreateFlag()) { + this.tempTargets = null; + } + this.newMEProcessOp = new CreateMEProcessOperation(this.session, this.itsAPlan, this.desktop, str7, str4, str5, getDescription(), str6, getUnitofMeasure(), getOpenOnCreateFlag(), this.tempTargets, this.meProcessComponent, null, this.targetProductItem, "Process.Template." + str2, str1, localTCComponentRevisionRule, i, arrayOfTCComponent, this.useTemplatePanel, str3); + this.newMEProcessOp.addOperationListener(this); + this.session.queueOperation(this.newMEProcessOp); + } + + public void startOperation(String paramString) + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + CreateMEProcessDialog.this.okButton.setVisible(false); + CreateMEProcessDialog.this.applyButton.setVisible(false); + CreateMEProcessDialog.this.cancelButton.setVisible(false); + CreateMEProcessDialog.this.id.setEnabled(false); + CreateMEProcessDialog.this.rev.setEnabled(false); + CreateMEProcessDialog.this.namePanel.setEnabled(false); + CreateMEProcessDialog.this.openOnCreate.setEnabled(false); + CreateMEProcessDialog.this.useTemplatePanel.setCloneComponentsEnabled(false); + CreateMEProcessDialog.this.validate(); + } + }); + } + + public void endOperation() + { + this.newMEProcessOp.removeOperationListener(this); + if (!this.newMEProcessOp.isAbortRequested()) + { + this.okButton.setVisible(true); + this.applyButton.setVisible(true); + this.cancelButton.setVisible(true); + this.id.setEnabled(true); + this.id.setText(""); + this.rev.setEnabled(true); + this.rev.setText(""); + this.namePanel.setEnabled(true); + if ((this.pasteTargets == null) || (this.itsAnOperation)) { + this.openOnCreate.setEnabled(false); + } else if ((this.pasteTargets != null) && (this.pasteTargets.length > 0) && ((this.pasteTargets[0] instanceof TCComponentBOMLine))) { + try + { + if (!((TCComponentBOMLine)this.pasteTargets[0]).isPasteAllowed()) { + this.openOnCreate.setEnabled(false); + } else { + this.openOnCreate.setEnabled(true); + } + } + catch (TCException localTCException) + { + MessageBox.post(localTCException); + } + } else { + this.openOnCreate.setEnabled(true); + } + this.useTemplatePanel.setCloneComponentsEnabled(true); + this.namePanel.requestFocus(); + if ((this.namePanel.getComponent(0) instanceof JTextField)) { + this.name.selectAll(); + } + validate(); + validateEntries(); + if (this.newMEProcessOp.getSuccessFlag()) + { + if (this.okOrApply == 0) + { + disposeDialog(); + this.useTemplatePanel.close(); + } + else if ((this.pasteTargets != null) && (this.pasteTargets.length == 1)) + { + TCComponent localTCComponent = (TCComponent)this.pasteTargets[0]; + if ((localTCComponent instanceof TCComponentBOMLine)) { + clearFields(); + } + } + if (this.tempTargets != null) { + this.opSuccessAndNotNewRootFlag = true; + } + } + } + } + + public TCComponent getNewProcess() + { + return this.newMEProcessOp.getNewProcess(); + } + + public String getMEProcessName() + { + return this.name.getText(); + } + + public String getMEProcessID() + { + return this.id.getText(); + } + + public String getRevID() + { + return this.rev.getText(); + } + + public String getDescription() + { + return this.descriptionText.getText(); + } + + public TCComponent getUnitofMeasure() + { + return null; + } + + public String getMEProcessType() + { + if ((this.meProcessType != null) && (this.templateIDStr.equals(this.useTemplatePanel.getTemplateId())) && (this.templateUIDStr.equals(this.useTemplatePanel.getTemplateUID()))) { + return this.meProcessType; + } + this.templateIDStr = this.useTemplatePanel.getTemplateId(); + this.templateUIDStr = this.useTemplatePanel.getTemplateUID(); + this.meProcessType = null; + TCComponentItem localTCComponentItem = getTemplateComponent(); + if (localTCComponentItem != null) + { + this.meProcessType = localTCComponentItem.getType(); + return this.meProcessType; + } + return null; + } + + public boolean getOpenOnCreateFlag() + { + return this.openOnCreate.isSelected(); + } + + private TCComponentItem getTemplateComponent() + { + String str1 = this.useTemplatePanel.getTemplateTextField().getText(); + if ((str1 != null) && (!str1.equals(""))) { + try + { + TCComponentQueryType localTCComponentQueryType = (TCComponentQueryType)this.session.getTypeComponent("ImanQuery"); + String str2 = this.useTemplatePanel.getTemplateUID(); + TCTextService localTCTextService = this.session.getTextService(); + String str3 = localTCTextService.getTextValue("k_find_component_name"); + TCComponentQuery localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find("Item - simple"); + if (localTCComponentQuery == null) { + localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find(str3); + } + String[] arrayOfString1 = { localTCTextService.getTextValue("ItemID") }; + String[] arrayOfString2 = { str1 }; + TCComponentContextList localTCComponentContextList = localTCComponentQuery.getExecuteResultsList(arrayOfString1, arrayOfString2); + TCComponent[] arrayOfTCComponent = localTCComponentContextList.toTCComponentArray(); + if ((arrayOfTCComponent != null) && (arrayOfTCComponent.length > 1) && (!str2.equalsIgnoreCase(""))) { + for (int i = 0; i < arrayOfTCComponent.length; i++) { + if ((str2.equalsIgnoreCase(arrayOfTCComponent[i].getUid())) && (i != 0)) + { + TCComponent localTCComponent = arrayOfTCComponent[0]; + arrayOfTCComponent[0] = arrayOfTCComponent[i]; + arrayOfTCComponent[i] = localTCComponent; + } + } + } + if ((arrayOfTCComponent == null) || (arrayOfTCComponent.length == 0) || (arrayOfTCComponent[0] == null) || (arrayOfTCComponent[0] instanceof TCComponentMEProcess == this.itsAnOperation) || (arrayOfTCComponent[0] instanceof TCComponentMEOP != this.itsAnOperation)) + { + MessageBox.post(this, this.appReg.getString("NoMatchingObject.MSG"), this.appReg.getString("NoMatchingObject.TITLE"), 1); + return null; + } + if ((!this.itsAnOperation) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEProcess"))) + { + MessageBox.post(this.appReg.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), this.appReg.getString("failToCreate"), 4); + return null; + } + if ((this.itsAnOperation) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEOP"))) + { + MessageBox.post(this.appReg.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), this.appReg.getString("failToCreate"), 4); + return null; + } + return (TCComponentItem)arrayOfTCComponent[0]; + } + catch (Exception localException) {} + } + return null; + } + + public void favoriteSelected(TCComponent paramTCComponent) + { + String str1 = paramTCComponent.getType(); + if ((AutoGenerateIdUtil.isAutoGenerateNeededForType(str1)) && ((this.previousTemplateType == null) || (!this.previousTemplateType.equals(str1)))) + { + setTextIdField(""); + setTextRevField(""); + this.previousTemplateType = str1; + } + if (((this.id.getText() == null) || (this.id.getText().length() == 0)) && ((this.rev.getText() == null) || (this.rev.getText().length() == 0))) { + try { + this.templateIDStr = paramTCComponent.getStringProperty("item_id"); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + getAssignedIds(paramTCComponent.getType()); + } + String str2; + try + { + str2 = paramTCComponent.getStringProperty("object_name"); + this.name.setText(str2); + } + catch (TCException localTCException1) {} + try + { + str2 = paramTCComponent.getStringProperty("object_desc"); + this.descriptionText.setText(str2); + } + catch (TCException localTCException2) {} + validateEntries(); + } + + public void validateEntries() + { + autoIdRev(); + this.previousTemplateType = getMEProcessType(); + int i = this.id.getText().length(); + int j = getMEProcessName().trim().length(); + int k = this.rev.getText().length(); + int m = this.useTemplatePanel.getTemplateId() != null ? this.useTemplatePanel.getTemplateId().length() : 0; + int n = getNumberOfItemsToCreate(); + if (n == 1) + { + setEnabledIdField(true); + if (this.isIDModifiable) { + this.id.setEditable(true); + } + setEnabledRevField(true); + if (this.isRevIDModifiable) { + this.rev.setEditable(true); + } + } + else + { + setEnabledIdField(false); + setEnabledRevField(false); + setTextIdField(""); + setTextRevField(""); + } + if (((i > 0) && (k > 0)) || (n > 1) || (m == 0)) { + this.assignButton.setEnabled(false); + } else { + this.assignButton.setEnabled(true); + } + if (((i > 0) && (k > 0)) || ((n > 1) && (j > 0) && (m > 0))) + { + this.okButton.setEnabled(true); + enableApplyButton(); + return; + } + this.okButton.setEnabled(false); + this.applyButton.setEnabled(false); + } + + public void run() + { + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + CreateMEProcessDialog.this.setVisible(true); + } + }); + } + + private void autoIdRev() + { + String str = getMEProcessType(); + if (str != null) { + if ((str.equalsIgnoreCase("Mfg0MEPlantBOP")) && ((this.openOnCreate.isEnabled()) || (!this.openOnCreate.isSelected()))) + { + this.openOnCreate.setSelected(true); + this.openOnCreate.setEnabled(false); + } + else if ((!str.equalsIgnoreCase("Mfg0MEPlantBOP")) && (!this.openOnCreate.isEnabled()) && (!this.createAsNewRootFlag)) + { + this.openOnCreate.setSelected(false); + this.openOnCreate.setEnabled(true); + } + } + if ((!getMEProcessID().equals("")) && (!getRevID().equals(""))) { + return; + } + if (AutoGenerateIdUtil.isAutoGenerateNeededForType(str)) { + getAssignedIds(str); + } + } + + private boolean validateId() + { + Object localObject1 = null; + if (getMEProcessID().length() > 0) + { + TCComponentItemType localTCComponentItemType = null; + Object localObject2; + try + { + localObject2 = getMEProcessType(); + if ((localObject2 == null) || (((String)localObject2).length() == 0)) { + return false; + } + TCComponentType localTCComponentType = this.session.getTypeComponent(getMEProcessType()); + if (localTCComponentType != null) { + if ((localTCComponentType instanceof TCComponentItemType)) + { + localTCComponentItemType = (TCComponentItemType)localTCComponentType; + localObject1 = localTCComponentItemType.find(getMEProcessID()); + } + else if ((localTCComponentType instanceof TCComponentItemRevisionType)) + { + TCComponentItemRevisionType localTCComponentItemRevisionType = (TCComponentItemRevisionType)localTCComponentType; + localObject1 = localTCComponentItemRevisionType.findRevision(getMEProcessID(), getRevID()); + } + } + } + catch (TCException localTCException2) + { + return true; + } + if (localObject1 != null) + { + localObject2 = Registry.getRegistry(this); + MessageBox.post(((Registry)localObject2).getString("sameAsOldId"), ((Registry)localObject2).getString("error.TITLE"), 4); + return false; + } + if (localTCComponentItemType != null) { + try + { + localTCComponentItemType.validateId(getMEProcessID(), getRevID(), getMEProcessType()); + } + catch (TCException localTCException1) + { + MessageBox.post(this.parent, localTCException1); + return false; + } + } + } + return true; + } + + public int getNumberOfItemsToCreate() + { + return this.quantitySpinnerModel.getNumber().intValue(); + } + + public void setEnabledIdField(boolean paramBoolean) + { + this.id.setEnabled(paramBoolean); + } + + public void setTextIdField(String paramString) + { + this.id.setText(paramString); + } + + public void setEnabledRevField(boolean paramBoolean) + { + this.rev.setEnabled(paramBoolean); + } + + public void setTextRevField(String paramString) + { + this.rev.setText(paramString); + } + + public TCComponent[] getTemplateReferenceStructureTCComponents() + { + return this.useTemplatePanel.getTemplateReferenceStructureTCComponents(); + } + + public boolean isOpSuccessAndNotNewRootFlag() + { + return this.opSuccessAndNotNewRootFlag; + } + + private class GetPropertyOperation + extends AbstractAIFOperation + { + private TCComponentBOMLine bomline; + + public GetPropertyOperation(CreateMEProcessDialog createMEProcessDialog, TCComponentBOMLine paramTCComponentBOMLine) + { + this.bomline = paramTCComponentBOMLine; + } + + public void executeOperation() + throws Exception + { + storeOperationResult(this.bomline.getProperty("bl_item_item_id")); + } + } +} diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessOperation.java b/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessOperation.java new file mode 100644 index 0000000..5d463ea --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/cme/application/CreateMEProcessOperation.java @@ -0,0 +1,766 @@ +package com.teamcenter.rac.cme.application; + +import java.text.DecimalFormat; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.swt.widgets.Display; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.aifrcp.event.ClientEventDispatcher; +import com.teamcenter.rac.cme.bvr.connect.Activator; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.METemplatePanel; +import com.teamcenter.rac.cme.bvr.create.fromtemplate.Messages; +import com.teamcenter.rac.cme.connect.ConnectUtil; +import com.teamcenter.rac.cme.connect.MFGConnectData; +import com.teamcenter.rac.cme.connect.MfgConnectOperation; +import com.teamcenter.rac.cme.license.services.ICMELicenseService; +import com.teamcenter.rac.commands.newitem.IdUtils; +import com.teamcenter.rac.common.TCUtilities; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentBOMWindow; +import com.teamcenter.rac.kernel.TCComponentBOMWindowType; +import com.teamcenter.rac.kernel.TCComponentBOPWindow; +import com.teamcenter.rac.kernel.TCComponentBOPWindowType; +import com.teamcenter.rac.kernel.TCComponentContextList; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentMEActivity; +import com.teamcenter.rac.kernel.TCComponentMEOP; +import com.teamcenter.rac.kernel.TCComponentMEOPRevision; +import com.teamcenter.rac.kernel.TCComponentMEOPType; +import com.teamcenter.rac.kernel.TCComponentMEProcess; +import com.teamcenter.rac.kernel.TCComponentMEProcessRevision; +import com.teamcenter.rac.kernel.TCComponentMEProcessType; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentRevisionRule; +import com.teamcenter.rac.kernel.TCComponentRevisionRuleType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTextService; +import com.teamcenter.rac.ms.util.ApplicationPerspectiveUtil; +import com.teamcenter.rac.psebase.AbstractBOMLineViewerApplication; +import com.teamcenter.rac.services.IOpenService; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.log.TcLogger; +import com.teamcenter.services.internal.rac.structuremanagement.StructureService; +import com.teamcenter.services.internal.rac.structuremanagement._2008_06.Structure; + +public class CreateMEProcessOperation + extends AbstractAIFOperation +{ + private static final String COMPONENT_LICENSE_ID = "PROCESS_AUTH"; + protected String meprocessName; + protected String meprocessId; + protected String revId; + protected String description; + protected String meprocessType; + protected TCComponent unitOfMeasure; + protected boolean openOnCreateFlag = true; + protected TCComponentItem oldMEProcess; + protected TCComponentItemRevision revToSaveAs; + protected InterfaceAIFComponent[] pasteTargets; + protected TCComponent newMEProcess; + protected TCComponentItemRevision targetProduct; + protected AIFDesktop desktop; + protected String templatePreferenceKey; + protected String templateId; + private String templateUID; + protected TCComponentRevisionRule templateRevRule; + private boolean successFlag = true; + private AbstractAIFUIApplication theApp; + private boolean itsAPlan; + private int itemsQuantity = 1; + private METemplatePanel templatePanel; + private static TcLogger logger = TcLogger.getLogger(CreateMEProcessOperation.class); + protected TCComponent[] refStructs; + protected List dataToPaste; + protected TCSession session; + + public CreateMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, TCComponent[] paramArrayOfTCComponent) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + } + + public CreateMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, int paramInt, TCComponent[] paramArrayOfTCComponent) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + this.itemsQuantity = paramInt; + } + + public CreateMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, int paramInt, TCComponent[] paramArrayOfTCComponent, METemplatePanel paramMETemplatePanel) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + this.itemsQuantity = paramInt; + this.templatePanel = paramMETemplatePanel; + } + + public CreateMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentMEProcess paramTCComponentMEProcess, TCComponentItemRevision paramTCComponentItemRevision) + { + this.session = paramTCSession; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentMEProcess; + this.targetProduct = paramTCComponentItemRevision; + this.itsAPlan = paramBoolean1; + this.templateId = null; + if (paramAIFDesktop != null) { + this.theApp = paramAIFDesktop.getCurrentApplication(); + } + } + + public CreateMEProcessOperation(TCSession paramTCSession, boolean paramBoolean1, AIFDesktop paramAIFDesktop, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, TCComponent paramTCComponent, boolean paramBoolean2, InterfaceAIFComponent[] paramArrayOfInterfaceAIFComponent, TCComponentItem paramTCComponentItem, TCComponentItemRevision paramTCComponentItemRevision1, TCComponentItemRevision paramTCComponentItemRevision2, String paramString6, String paramString7, TCComponentRevisionRule paramTCComponentRevisionRule, int paramInt, TCComponent[] paramArrayOfTCComponent, METemplatePanel paramMETemplatePanel, String paramString8) + { + this.session = paramTCSession; + this.itsAPlan = paramBoolean1; + this.desktop = paramAIFDesktop; + this.meprocessName = paramString1; + this.meprocessId = paramString2; + this.revId = paramString3; + this.description = paramString4; + this.meprocessType = paramString5; + this.unitOfMeasure = paramTCComponent; + this.openOnCreateFlag = paramBoolean2; + this.pasteTargets = paramArrayOfInterfaceAIFComponent; + this.oldMEProcess = paramTCComponentItem; + this.revToSaveAs = paramTCComponentItemRevision1; + this.targetProduct = paramTCComponentItemRevision2; + this.templatePreferenceKey = paramString6; + this.templateId = paramString7; + this.templateRevRule = paramTCComponentRevisionRule; + this.refStructs = paramArrayOfTCComponent; + this.theApp = paramAIFDesktop.getCurrentApplication(); + this.itemsQuantity = paramInt; + this.templatePanel = paramMETemplatePanel; + this.templateUID = paramString8; + } + + public TCSession getSession() + { + return (TCSession)super.getSession(); + } + + public boolean getSuccessFlag() + { + return this.successFlag; + } + + public TCComponent getNewProcess() + { + return this.newMEProcess; + } + + public void executeOperation() + throws Exception + { + ICMELicenseService localICMELicenseService = Activator.getDefault().getCMELicenseService(); + String str = ApplicationPerspectiveUtil.getCurrentApplicationId(); + boolean bool = false; + if (localICMELicenseService != null) + { + bool = localICMELicenseService.checkAndConsumeComponentLicense("PROCESS_AUTH", str); + if (bool) { + executeOpInternal(); + } + } + } + + private void executeOpInternal() + throws Exception + { + Registry localRegistry = Registry.getRegistry(this); + if (this.itemsQuantity > 1) + { + IdUtils localIdUtils = new IdUtils(getSession()); + for (int i = 0; i < this.itemsQuantity; i++) + { + IdUtils.IdsData localIdsData = localIdUtils.generateIds(this.meprocessType); + String str1 = localIdsData.Id; + String str2 = localIdsData.Rev; + executeOperationInternal(localRegistry, this.meprocessName, str1, str2); + } + } + else + { + executeOperationInternal(localRegistry, this.meprocessName, this.meprocessId, this.revId); + } + if (this.newMEProcess != null) { + pasteNewComponent(localRegistry); + + //更改子对象的ID +// TCComponentMEProcess componentMEProcess = (TCComponentMEProcess) this.newMEProcess; +// TCComponentBOMWindowType bomWindowType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); +// TCComponentBOMWindow bomWindow = bomWindowType.create(null); +// TCComponentBOMLine topline = bomWindow.setWindowTopLine(componentMEProcess, componentMEProcess.getLatestItemRevision(), null, null); +// setMEOPId(topline); + } + } + + public void setMEOPId(TCComponentBOMLine topBomLine) throws Exception + { + AIFComponentContext[] childrens = topBomLine.getChildren(); + for (AIFComponentContext children : childrens) { + TCComponentBOMLine bomLine = ((TCComponentBOMLine) children.getComponent()); + + TCComponentItem item = bomLine.getItem(); + + //更新对象ID + String objectType = item.getProperty("object_type"); + System.out.println("objectType======================="+objectType); + String itemId = ""; + switch (objectType) { + case "ML8_SpecOp": + case "专项工序": + String ml8_SpecOpPeriod = item.getStringProperty("ml8_SpecOpPeriod"); + String ml8_SpecOpCode = item.getStringProperty("ml8_SpecOpCode"); + String ml8_SpecOpNumber = item.getStringProperty("ml8_SpecOpNumber"); + + itemId = getGyRuleID(getSession(), String.format("%s-%s-%s", ml8_SpecOpPeriod,ml8_SpecOpCode,ml8_SpecOpNumber)); + + break; + case "ML8_StdOperation": + case "标准工序": + + String stdOpType = item.getStringProperty("ml8_StdOpType"); + String stdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String productType = item.getStringProperty("ml8_ProductType"); + String materialType = item.getStringProperty("ml8_MaterialType"); + String stdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(getSession(), String.format("%s-%s%s%s-%s", stdOpType,stdOpPeriod,productType,materialType,stdOpNumber)); + + break; + + case "ML8_DifOperation": + case "差异化工序": + + String ml8_StdOpType = item.getStringProperty("ml8_StdOpType"); + String ml8_StdOpPeriod = item.getStringProperty("ml8_StdOpPeriod"); + String ml8_ProductType = item.getStringProperty("ml8_ProductType"); + String ml8_MaterialType = item.getStringProperty("ml8_MaterialType"); + String ml8_StdOpNumber = item.getStringProperty("ml8_StdOpNumber"); + + itemId = getGyRuleID(getSession(), String.format("%s-%s%s%s-%s", ml8_StdOpType,ml8_StdOpPeriod,ml8_ProductType,ml8_MaterialType,ml8_StdOpNumber)); + + break; + default: + break; + } + if(!itemId.isEmpty()) + { + item.lock(); + item.setProperty("item_id", itemId); + item.save(); + item.unlock(); + item.refresh(); + //return; + } + setMEOPId(bomLine); + } + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getGyRuleID(TCSession session, String oldItemID) { + DecimalFormat df = new DecimalFormat("000000"); + String newID = oldItemID + "-000001"; + // String idTemp = + TCComponentItemType tccomponentitemtype; + try { + tccomponentitemtype = (TCComponentItemType) (session + .getTypeComponent("Item")); + + tccomponentitemtype.getNewID(); + int i = 1; + while (tccomponentitemtype.find(newID) != null) { + i++; + newID = oldItemID + "-" + df.format(i); + } + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + /** + * 工艺生成新的ID + * + * @param oldItemID + * @return + */ + public static String getStdOpNumber( String itemID,int num) { + DecimalFormat df = new DecimalFormat("000"); + String newID = "010"; + // String idTemp = + try { + int i = 10; + while (itemID.compareTo(newID) != 0) { + i = i+1; + newID = df.format(i); + } + newID = df.format(i+num); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return newID; + } + + private void executeOperationInternal(Registry paramRegistry, String paramString1, String paramString2, String paramString3) + throws Exception + { + if (this.templateId == null) { + createNotFromTemplate(paramRegistry, paramString1, paramString2, paramString3); + } else { + createFromTemplate(paramRegistry, paramString1, paramString2, paramString3); + } + if (isAbortRequested()) + { + getSession().setStatus(paramRegistry.getString("abort")); + } + else if (this.newMEProcess != null) + { + final Object localObject; + if ((this.pasteTargets != null) && (this.pasteTargets[0] != null) && (this.revToSaveAs != null) && ((this.pasteTargets[0] instanceof TCComponentBOMLine))) + { + localObject = (TCComponentBOMLine)this.pasteTargets[0]; + TCComponentItemRevision localTCComponentItemRevision = (TCComponentItemRevision)this.newMEProcess; + TCProperty localTCProperty = ((TCComponentBOMLine)localObject).getTCProperty("bl_is_precise"); + if (localTCProperty.getLogicalValue()) { + ((TCComponentBOMLine)localObject).replace(((TCComponentBOMLine)localObject).getItem(), localTCComponentItemRevision, ((TCComponentBOMLine)localObject).getReferenceProperty("bl_bomview")); + } + TCComponentBOMWindow localTCComponentBOMWindow = ((TCComponentBOMLine)localObject).window(); + localTCComponentBOMWindow.newIrfWhereConfigured(localTCComponentItemRevision); + localTCComponentBOMWindow.fireChangeEvent(); + } + if (this.openOnCreateFlag) + { + IOpenService localObject1 = AIFUtility.getCurrentOpenService(); + Display.getDefault().asyncExec(new Runnable() + { + public void run() + { + localObject1.open(CreateMEProcessOperation.this.newMEProcess); + } + }); + } + else + { + getSession().setReadyStatus(); + } + } + } + + private void createNotFromTemplate(Registry paramRegistry, String paramString1, String paramString2, String paramString3) + throws Exception + { + getSession().setStatus(paramRegistry.getString("creatingNewMEProcess") + " " + paramString1 + " ..."); + try + { + Object localObject1; + if (this.itsAPlan) + { + localObject1 = null; + localObject1 = (TCComponentMEProcessType)getSession().getTypeComponent(this.meprocessType); + if (this.revToSaveAs != null) + { + this.newMEProcess = this.revToSaveAs.saveAs(paramString3, paramString1, this.description, false, null); + } + else if (this.oldMEProcess == null) + { + this.newMEProcess = ((TCComponentMEProcessType)localObject1).createProcess(paramString2, paramString3, this.meprocessType, paramString1, this.description); + if (this.targetProduct != null) { + this.newMEProcess.setRelated("IMAN_METarget", new TCComponent[] { this.targetProduct }); + } + } + } + else + { + localObject1 = null; + localObject1 = (TCComponentMEOPType)getSession().getTypeComponent(this.meprocessType); + if (this.revToSaveAs != null) + { + this.newMEProcess = this.revToSaveAs.saveAs(paramString3, paramString1, this.description, false, null); + } + else if (this.oldMEProcess == null) + { + this.newMEProcess = ((TCComponentMEOPType)localObject1).createProcessOperation(paramString2, paramString3, this.meprocessType, paramString1, this.description); + if (this.targetProduct != null) { + this.newMEProcess.setRelated("IMAN_METarget", new TCComponent[] { this.targetProduct }); + } + Object localObject2 = (TCComponentMEOP)this.newMEProcess; + Object localObject3 = (TCComponentMEOPRevision)((TCComponentMEOP)localObject2).getLatestItemRevision(); + TCComponentMEActivity localTCComponentMEActivity = (TCComponentMEActivity)((TCComponentMEOPRevision)localObject3).getRelatedComponent("root_activity"); + localTCComponentMEActivity.unlock(); + ((TCComponentMEOPRevision)localObject3).unlock(); + ((TCComponentMEOP)localObject2).unlock(); + } + else + { + this.newMEProcess = this.oldMEProcess.revise(paramString3, paramString1, this.description); + } + } + } + catch (TCException localTCException) + { + Object localObject3; + Object localObject2 = MessageFormat.format(paramRegistry.getString("failToCreate"), new Object[] { paramString1, localTCException.toString() }); + if (this.desktop != null) + { + localObject3 = new MessageBox(this.desktop, (String)localObject2, null, paramRegistry.getString("error.TITLE"), 1, true); + ((MessageBox)localObject3).setVisible(true); + } + else + { + logger.error(localTCException.getLocalizedMessage(), localTCException); + } + this.successFlag = false; + throw localTCException; + } + if ((!(this.newMEProcess instanceof TCComponentMEProcessRevision)) && (!(this.newMEProcess instanceof TCComponentMEOPRevision))) { + addCompToPasteData(); + } + } + + private void createFromTemplate(Registry paramRegistry, String paramString1, String paramString2, String paramString3) + throws Exception + { + getSession().setStatus(paramRegistry.getString("cloningTemplate") + " " + this.templateId + " ..."); + TCComponentBOPWindow localTCComponentBOPWindow = null; + try + { + TCComponentItem localTCComponentItem = getTemplateItem(paramRegistry); + if (localTCComponentItem != null) + { + TCComponentBOMLine localTCComponentBOMLine = this.templatePanel.getTopBomLineFromTemplate(); + TCComponentBOMWindow[] arrayOfTCComponentBOMWindow = new TCComponentBOMWindow[2]; + if (this.refStructs != null) { + for (int i = 0; i < this.refStructs.length; i++) { + arrayOfTCComponentBOMWindow[i] = ((TCComponentBOMWindow)this.refStructs[i]); + } + } + TCComponent localTCComponent = null; + if ((this.theApp instanceof AbstractBOMLineViewerApplication)) + { + Object localObject1 = (AbstractBOMLineViewerApplication)this.theApp; + if (((AbstractBOMLineViewerApplication)localObject1).getEffectivityChangeControl() != null) { + localTCComponent = ((AbstractBOMLineViewerApplication)localObject1).getEffectivityChangeControl().getICRev(); + } + } + if (arrayOfTCComponentBOMWindow != null) + { + Object localObject1 = (TCComponentBOPWindowType)getSession().getTypeComponent("BOPWindow"); + localTCComponentBOPWindow = ((TCComponentBOPWindowType)localObject1).createBOPWindow(this.templateRevRule); + for (int j = 0; j < arrayOfTCComponentBOMWindow.length; j++) { + if (arrayOfTCComponentBOMWindow[j] != null) { + localTCComponentBOPWindow.addReferenceWindow(arrayOfTCComponentBOMWindow[j], "Temp"); + } + } + if (localTCComponent != null) { + localTCComponentBOPWindow.setIncrementalChangeRev(localTCComponent); + } + } + Object localObject1 = localTCComponentBOMLine.getItemRevision(); + if (localObject1 == null) + { + MessageBox.post(this.theApp.getDesktop(), Messages.FromTemplate_noConfiguredTopLineMsg, Messages.FromTemplate_noConfiguredTopLineTitle, 4); + this.successFlag = false; + return; + } + boolean bool1 = this.templatePanel.getCarryOverCheckboxValue(); + localTCComponentBOMLine.window().showSuppressedOccs(this.templatePanel.getCloneSuppressedLineCheckBoxValue()); + localTCComponentBOMLine.window().setRevisionRule(this.templatePanel.getTemplateRevisionRule()); + localTCComponentBOMLine.window().setRevisionRule(this.templatePanel.getTemplateRevisionRule()); + if (this.templatePanel.isEffectivityGroupUsed()) { + localTCComponentBOMLine.window().setEffGrpRevs(this.templatePanel.getEffGrpRevisions()); + } + if (this.templatePanel.isMiscFieldsChanged()) { + localTCComponentBOMLine.window().showUnconfiguredOccs(false); + } + StructureService localStructureService = StructureService.getService(getSession()); + Structure.CopyRecursivelyResponse localCopyRecursivelyResponse = localStructureService.copyRecursively + ((TCComponent)localObject1, this.templatePreferenceKey, localTCComponentBOMLine.window(), localTCComponentBOPWindow, + paramString1, this.description, paramString2, paramString3, bool1); + boolean bool2 = SoaUtil.handlePartialErrors(localCopyRecursivelyResponse.serviceData, AIFUtility.getActiveDesktop()); + if (bool2) + { + if (localCopyRecursivelyResponse.serviceData.sizeOfCreatedObjects() != 0) + { + TCComponentItemRevision localTCComponentItemRevision = (TCComponentItemRevision)localCopyRecursivelyResponse.serviceData.getCreatedObject(0); + if (localTCComponentItemRevision != null) { + this.newMEProcess = localTCComponentItemRevision.getItem(); + } + } + addCompToPasteData(); + } + } + } + catch (Exception localException) + { + MessageBox.post(localException); + getSession().setReadyStatus(); + this.successFlag = false; + throw localException; + } + finally + { + if (localTCComponentBOPWindow != null) + { + localTCComponentBOPWindow.closeBOPWindow(); + localTCComponentBOPWindow = null; + } + } + if (localTCComponentBOPWindow != null) + { + localTCComponentBOPWindow.closeBOPWindow(); + localTCComponentBOPWindow = null; + } + } + + private TCComponentItem getTemplateItem(Registry paramRegistry) + { + TCComponentItem localTCComponentItem = null; + try + { + TCComponentQueryType localTCComponentQueryType = (TCComponentQueryType)getSession().getTypeComponent("ImanQuery"); + TCTextService localTCTextService = getSession().getTextService(); + String str = localTCTextService.getTextValue("k_find_component_name"); + TCComponentQuery localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find("Item - simple"); + if (localTCComponentQuery == null) { + localTCComponentQuery = (TCComponentQuery)localTCComponentQueryType.find(str); + } + String[] arrayOfString1 = { localTCTextService.getTextValue("ItemID") }; + String[] arrayOfString2 = { this.templateId }; + TCComponentContextList localTCComponentContextList = localTCComponentQuery.getExecuteResultsList(arrayOfString1, arrayOfString2); + TCComponent[] arrayOfTCComponent = localTCComponentContextList.toTCComponentArray(); + if ((arrayOfTCComponent.length > 1) && (!this.templateUID.equalsIgnoreCase(""))) { + arrayOfTCComponent = selectItemUsingItemUID(arrayOfTCComponent); + } + if ((arrayOfTCComponent != null) && (arrayOfTCComponent.length > 0) && (arrayOfTCComponent[0] != null) && ((arrayOfTCComponent[0] instanceof TCComponentItem))) + { + if ((this.itsAPlan) && (!(arrayOfTCComponent[0] instanceof TCComponentMEProcess))) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.notAProcess"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + else if ((!this.itsAPlan) && (!(arrayOfTCComponent[0] instanceof TCComponentMEOP))) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.notAnOp"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + else if ((this.itsAPlan) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEProcess"))) + { + MessageBox.post(paramRegistry.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), paramRegistry.getString("failToCreateTitle"), 4); + this.successFlag = false; + } + else if ((!this.itsAPlan) && (!TCUtilities.isAllowedToCreate(arrayOfTCComponent[0], "MEOP"))) + { + MessageBox.post(paramRegistry.getString("newMEProductTemplates.roleProhibitCreate") + " " + arrayOfTCComponent[0].getSubType(), paramRegistry.getString("failToCreateTitle"), 4); + this.successFlag = false; + } + } + else + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.badId") + " " + this.templateId, paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + if (this.templateRevRule == null) { + try + { + TCComponentRevisionRuleType localTCComponentRevisionRuleType = (TCComponentRevisionRuleType)getSession().getTypeComponent("RevisionRule"); + this.templateRevRule = localTCComponentRevisionRuleType.getDefaultRule(); + } + catch (TCException localTCException) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.noRevRule"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + } + if (this.templateRevRule == null) + { + MessageBox.post(paramRegistry.getString("newMEProcessTemplates.noRevRule"), paramRegistry.getString("newMEProcessTemplates.newFailedTitle"), 1); + this.successFlag = false; + } + if (this.successFlag) { + localTCComponentItem = (TCComponentItem)arrayOfTCComponent[0]; + } + } + catch (Exception localException) + { + MessageBox.post(localException); + this.successFlag = false; + } + return localTCComponentItem; + } + + private void addCompToPasteData() + { + Object localObject; + if (this.dataToPaste == null) + { + this.dataToPaste = new ArrayList(); + if (this.pasteTargets != null) + { + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent; + int j = (arrayOfInterfaceAIFComponent = this.pasteTargets).length; + for (int i = 0; i < j; i++) + { + localObject = arrayOfInterfaceAIFComponent[i]; + MFGConnectData localMFGConnectData = new MFGConnectData((InterfaceAIFComponent)localObject, true); + localMFGConnectData.add(this.newMEProcess, null); + this.dataToPaste.add(localMFGConnectData); + } + } + else + { + localObject = new MFGConnectData(null, true); + ((MFGConnectData)localObject).add(this.newMEProcess, null); + this.dataToPaste.add((MFGConnectData)localObject); + } + } + else + { + Iterator localIterator = this.dataToPaste.iterator(); + while (localIterator.hasNext()) + { + localObject = (MFGConnectData)localIterator.next(); + ((MFGConnectData)localObject).add(this.newMEProcess, null); + } + } + } + + protected void pasteNewComponent(Registry paramRegistry) + throws Exception + { + Object localObject1; + Object localObject3; + Object localObject2; + if (((MFGConnectData)this.dataToPaste.get(0)).getTarget() == null) + { + localObject1 = new ArrayList(); + localObject3 = this.dataToPaste.iterator(); + while (((Iterator)localObject3).hasNext()) + { + localObject2 = (MFGConnectData)((Iterator)localObject3).next(); + AIFComponentContext[] arrayOfAIFComponentContext1 = ((MFGConnectData)localObject2).getContextsArray(); + AIFComponentContext[] arrayOfAIFComponentContext2; + int k = (arrayOfAIFComponentContext2 = arrayOfAIFComponentContext1).length; + for (int j = 0; j < k; j++) + { + AIFComponentContext localAIFComponentContext = arrayOfAIFComponentContext2[j]; + ((List)localObject1).add((TCComponent)localAIFComponentContext.getComponent()); + } + } + ConnectUtil.pasteToTargetAccordingToPreference(getSession(), (TCComponent[])((List)localObject1).toArray(new TCComponent[((List)localObject1).size()])); + } + else + { + localObject1 = new MfgConnectOperation(this.dataToPaste); + ((MfgConnectOperation)localObject1).runEx(); + if (((MfgConnectOperation)localObject1).isOperationDone()) + { + localObject2 = (TCComponent[])((MfgConnectOperation)localObject1).getOperationResult(); + if ((localObject2 != null) && (((TCComponent[])localObject2).length > 0) && ((((TCComponent[])localObject2)[0] instanceof TCComponentBOMLine))) + { + localObject3 = new ArrayList(); + for (int i = 0; i < ((TCComponent[])localObject2).length; i++) { + ((List)localObject3).add((TCComponentBOMLine)((TCComponent[])localObject2)[i]); + } + ClientEventDispatcher.fireEventLater(this, "com/teamcenter/rac/cme/ItemCreated", new Object[] { "bomLine", ((TCComponent[])localObject2)[0], "newComponent", localObject3, "recursive", "true", "categoryId", ApplicationPerspectiveUtil.getCurrentApplicationId() }); + } + } + } + } + + private TCComponent[] selectItemUsingItemUID(TCComponent[] paramArrayOfTCComponent) + { + for (int i = 0; i < paramArrayOfTCComponent.length; i++) { + if ((this.templateUID.equalsIgnoreCase(paramArrayOfTCComponent[i].getUid())) && (i != 0)) + { + TCComponent localTCComponent = paramArrayOfTCComponent[0]; + paramArrayOfTCComponent[0] = paramArrayOfTCComponent[i]; + paramArrayOfTCComponent[i] = localTCComponent; + } + } + return paramArrayOfTCComponent; + } +} diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/CreateItemDialog.java b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/CreateItemDialog.java new file mode 100644 index 0000000..6979d9a --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/CreateItemDialog.java @@ -0,0 +1,492 @@ +package com.teamcenter.rac.commands.newitem; + +import java.awt.Dimension; +import java.awt.Frame; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.util.Set; + +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.InterfaceAIFOperationListener; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.common.DialogForBOMLine; +import com.teamcenter.rac.common.propertyrenderer.PropertyPanelRenderer; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentIdContext; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.Separator; +import com.teamcenter.rac.util.VerticalLayout; +import com.teamcenter.rac.util.log.TcLogger; + +@Deprecated +public class CreateItemDialog + extends AbstractAIFDialog + implements InterfaceAIFOperationListener, PropertyChangeListener +{ + private static TcLogger logger = TcLogger.getLogger(CreateItemDialog.class); + private String m_pasteRelation; + private boolean m_pasteRevisionFlag = false; + public static final String TYPES_LOADER = "TYPES_LOADER"; + public static final String ADDITIONAL_PROPERTIES_PAGE = "ADDITIONAL_PROPERTIES_PAGE"; + public static final String WIZARD_PANEL_CLASS_KEY = "WIZARD_PANEL"; + public static final String OPERATION_CLASS_KEY = "OPERATION"; + private final TCSession m_session; + public InterfaceAIFComponent[] pasteTargets; + public JPanel parentPanel; + public JLabel dialogIcon; + public AbstractNewItemPanel dialogPanel; + private NewItemCommand m_cmd; + public NewItemOperation operation; + public DialogForBOMLine viDialog; + public String objectType = "Item"; + public boolean showUOM; + public boolean showQuantity; + protected Boolean closeOnFinish; + private boolean m_enableAutoExposureForCreate = false; + public String defaultSelectionObjectType; + + public CreateItemDialog(NewItemCommand paramNewItemCommand) + { + this(paramNewItemCommand, Boolean.FALSE); + System.out.println("111"); + } + + public CreateItemDialog(NewItemCommand paramNewItemCommand, Boolean paramBoolean) + { + this(paramNewItemCommand.parentFrame, paramNewItemCommand.session, true); + this.m_cmd = paramNewItemCommand; + try + { + this.pasteTargets = paramNewItemCommand.getTargets(); + } + catch (Exception localException) + { + logger.debug(localException.getLocalizedMessage(), localException); + MessageBox.post(localException); + } + this.closeOnFinish = paramBoolean; + this.objectType = paramNewItemCommand.objectType; + this.showUOM = paramNewItemCommand.showUOM; + this.showQuantity = paramNewItemCommand.showQuantity; + this.defaultSelectionObjectType = paramNewItemCommand.defaultSelectionObjectType; + setPasteRelation(paramNewItemCommand.getPasteRelation()); + setRevisionFlag(paramNewItemCommand.getRevisionFlag()); + initUI(); + } + + public CreateItemDialog(Frame paramFrame, boolean paramBoolean) + { + this(paramFrame, (TCSession)AIFUtility.getCurrentApplication().getSession(), paramBoolean); + System.out.println("222"); + } + + protected CreateItemDialog(Frame paramFrame, TCSession paramTCSession, boolean paramBoolean) + { + super(paramFrame, paramBoolean); + this.m_session = paramTCSession; + System.out.println("333"); + } + + public CreateItemDialog(DialogForBOMLine paramDialogForBOMLine) + { + this(paramDialogForBOMLine.getFrame(), (TCSession)paramDialogForBOMLine.getApplication().getSession(), true); + this.viDialog = paramDialogForBOMLine; + this.showUOM = true; + TCComponentUser localTCComponentUser = getSession().getUser(); + TCComponentFolder localTCComponentFolder = null; + try + { + localTCComponentFolder = ((TCComponentUser)localTCComponentUser).getNewStuffFolder(); + InterfaceAIFComponent[] arrayOfInterfaceAIFComponent = { localTCComponentFolder }; + this.pasteTargets = arrayOfInterfaceAIFComponent; + } + catch (TCException localTCException) + { + MessageBox.post(localTCException); + } + this.closeOnFinish = Boolean.TRUE; + initUI(); + } + + public void initUI() + { + System.out.println("444"); + setPersistentDisplay(true); + setOptimalDisplay(true); + String str = getDialogTitle(isVariantItemCreation()); + if (isVariantItemCreation()) { + try + { + str = str + " " + this.viDialog.getBOMLine().getItemRevision().toString(); + } + catch (TCException localTCException) + { + MessageBox.post(localTCException, true); + } + } + setTitle(str); + this.dialogIcon = new JLabel(" "); + this.parentPanel = new JPanel(new VerticalLayout(5, 2, 2, 2, 2)); + getContentPane().add(this.parentPanel); + this.dialogPanel = createDialogPanel(getParent(), getSession(), this); + this.parentPanel.add("top.nobind.left.top", this.dialogIcon); + this.parentPanel.add("top.bind", new Separator()); + if (this.dialogPanel != null) + { + this.dialogPanel.setCloseOnFinish(this.closeOnFinish); + this.parentPanel.add("unbound.bind", this.dialogPanel); + CreateItemInfoPanel localItemInfoPanel = new CreateItemInfoPanel(getSession(), this.dialogPanel); + localItemInfoPanel.buildBaseItemInfoPanel(); + Dimension localDimension1 = localItemInfoPanel.itemInfoPanel.getPreferredSize(); + double d1 = this.dialogPanel.splitPane.getDividerLocation(); + double d2 = localDimension1.getWidth() / (1.0D - d1) + 60.0D; + Dimension localDimension2 = this.parentPanel.getPreferredSize(); + if (d2 < localDimension2.width) { + d2 = localDimension2.width; + } + this.parentPanel.setPreferredSize(new Dimension((int)d2, 350)); + } + pack(); + centerToScreen(1.0D, 0.5D, 0.0D, 0.5D); + } + + public Frame getParent() + { + AIFDesktop localAIFDesktop = AIFDesktop.getActiveDesktop(); + Frame localFrame = (Frame)super.getParent(); + if (localAIFDesktop.getFrame() == localFrame) { + return localAIFDesktop; + } + return localFrame; + } + + public TCSession getSession() + { + return this.m_session; + } + + public NewItemCommand getCommand() + { + return this.m_cmd; + } + + protected AbstractNewItemPanel createDialogPanel(Frame paramFrame, TCSession paramTCSession, CreateItemDialog paramNewItemDialog) + { + Registry localRegistry = getRegistry(); + AbstractNewItemPanel localAbstractNewItemPanel = (AbstractNewItemPanel)localRegistry.newInstanceFor(getRegistrationKeyForWizardPanel(), new Object[] { paramFrame, paramTCSession, paramNewItemDialog }); + return localAbstractNewItemPanel; + } + + protected Registry getRegistry() + { + return Registry.getRegistry(this); + } + + protected String getDialogTitle(boolean paramBoolean) + { + String str1 = getClass().getName(); + str1 = str1 + (paramBoolean ? ".vi." : "."); + str1 = str1 + "TITLE"; + String str2 = getRegistry().getString(str1, null); + if (str2 == null) + { + String str3 = paramBoolean ? "dialog.vi.TITLE" : "dialog.TITLE"; + str2 = getRegistry().getString(str3, ""); + } + return str2; + } + + protected Icon getDialogIcon() + { + Icon localIcon = null; + if (this.dialogIcon != null) { + localIcon = this.dialogIcon.getIcon(); + } + return localIcon; + } + + public String getRegistrationKeyForWizardPanel() + { + Registry localRegistry = getRegistry(); + String str1 = getClass().getName() + "." + "WIZARD_PANEL"; + String str2 = localRegistry.getString(str1, null); + if ((str2 == null) || (str2.length() <= 0)) { + str1 = "newItemDialogPanel"; + } + logger.debug("Registration Key for main panel : " + str1); + return str1; + } + + public String getRegistrationKeyForOperation() + { + Registry localRegistry = getRegistry(); + String str1 = getClass().getName() + "." + "OPERATION"; + String str2 = localRegistry.getString(str1, null); + if ((str2 == null) || (str2.length() <= 0)) { + str1 = "newItemOperation"; + } + logger.debug("Registration Key for operation : " + str1); + return str1; + } + + public void startCommandOperation() + { + this.operation = ((NewItemOperation)getRegistry().newInstanceFor(getRegistrationKeyForOperation(), new Object[] { this })); + this.operation.addOperationListener(this); + this.operation.addPropertyChangeListener(this); + //IOperationService localIOperationService = (IOperationService)OSGIUtil.getService(Activator.getDefault(), IOperationService.class); + AbstractAIFApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + session.queueOperation(this.operation); + //localIOperationService.queueOperation(this.operation); + } + + public void run() + { + setVisible(true); + } + + public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent) {} + + public void startOperation(String paramString) + { + this.dialogPanel.startOperation(paramString); + } + + public void endOperation() + { + this.dialogPanel.endOperation(); + } + + public boolean isVariantItemCreation() + { + return this.viDialog != null; + } + + public boolean toCreateAlternateId() + { + return this.dialogPanel.toCreateAlternateId(); + } + + public String getItemId() + { + return this.dialogPanel.getItemId(); + } + + public String getItemRev() + { + return this.dialogPanel.getItemRev(); + } + + public String getItemName() + { + return this.dialogPanel.getItemName(); + } + + public String getItemDescription() + { + return this.dialogPanel.getItemDescription(); + } + + public Object getUOMComp() + { + return this.dialogPanel.getUOMComp(); + } + + public boolean getIsDescChanged() + { + return this.dialogPanel.getIsDescChanged(); + } + + public boolean getIsUOMChanged() + { + return this.dialogPanel.getIsUOMChanged(); + } + + public TCComponentProject[] getSelectedProjects() + { + return this.dialogPanel.getSelectedProjects(); + } + + public boolean getOpenOnCreateFlag() + { + return this.dialogPanel.getOpenOnCreateFlag(); + } + + public boolean getCheckOutOnCreateFlag() + { + return this.dialogPanel.getCheckOutFlag(); + } + + public void setCheckOutOnCreateFlag(boolean paramBoolean) + { + this.dialogPanel.setCheckOutOnCreateFlag(paramBoolean); + } + + public boolean getClassifyFlag() + { + return this.dialogPanel.getClassifyFlag(); + } + + public String getClassifyType() + { + return this.dialogPanel.getClassifyType(); + } + + public boolean getIdDisplayFlag() + { + return this.dialogPanel.getIdDisplayFlag(); + } + + public boolean getRevDisplayFlag() + { + return this.dialogPanel.getRevDisplayFlag(); + } + + public String getItemType() + { + return this.dialogPanel.getItemType(); + } + + public boolean isConfigurationItem() + { + return this.dialogPanel.isConfigurationItem(); + } + + public AbstractRendering getItemMasterFormStyleSheetPanel() + { + return this.dialogPanel.getItemMasterFormStyleSheetPanel(); + } + + public AbstractRendering getItemRevMasterFormStyleSheetPanel() + { + return this.dialogPanel.getItemRevMasterFormStyleSheetPanel(); + } + + public TCComponentIdContext getContext() + { + return this.dialogPanel.getContext(); + } + + public String getIdType() + { + return this.dialogPanel.getIdType(); + } + + public String getAlternateId() + { + return this.dialogPanel.getAlternateId(); + } + + public String getAlternateRev() + { + return this.dialogPanel.getAlternateRev(); + } + + public String getAlternateName() + { + return this.dialogPanel.getAlternateName(); + } + + public InterfaceAIFComponent[] getTargets() + throws Exception + { + if ((this.m_cmd != null) && ((this.pasteTargets == null) || (this.pasteTargets.length == 0))) { + this.pasteTargets = this.m_cmd.getTargets(); + } + return this.pasteTargets; + } + + public String getAlternateDescription() + { + return this.dialogPanel.getAlternateDescription(); + } + + public PropertyPanelRenderer getAdditionalIdInfoPropertyPanel() + { + return this.dialogPanel.getAdditionalIdInfoPropertyPanel(); + } + + public PropertyPanelRenderer getAdditionalRevInfoPropertyPanel() + { + return this.dialogPanel.getAdditionalRevInfoPropertyPanel(); + } + + public void setDialogPanel(AbstractNewItemPanel paramAbstractNewItemPanel) + { + this.dialogPanel = paramAbstractNewItemPanel; + } + + public AbstractNewItemPanel getDialogPanel() + { + return this.dialogPanel; + } + + public void setOperation(NewItemOperation paramNewItemOperation) + { + this.operation = paramNewItemOperation; + } + + public NewItemOperation getOperation() + { + return this.operation; + } + + public boolean isAutoExposureForCreateEnabled() + { + return this.m_enableAutoExposureForCreate; + } + + public void enableAutoExposureForCreate(boolean paramBoolean) + { + this.m_enableAutoExposureForCreate = paramBoolean; + } + + public int getQuantity() + { + return this.dialogPanel.getQuantity(); + } + + public void setPasteRelation(String paramString) + { + this.m_pasteRelation = paramString; + } + + public String getPasteRelation() + { + return this.m_pasteRelation; + } + + public void setRevisionFlag(boolean paramBoolean) + { + this.m_pasteRevisionFlag = paramBoolean; + } + + public boolean getRevisionFlag() + { + return this.m_pasteRevisionFlag; + } + + public boolean checkLocMasterValue() + { + return false; + } + + public Set listWarningProps() + { + return null; + } +} diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/CreateItemInfoPanel.java b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/CreateItemInfoPanel.java new file mode 100644 index 0000000..774b9cc --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/CreateItemInfoPanel.java @@ -0,0 +1,1807 @@ +package com.teamcenter.rac.commands.newitem; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Frame; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSpinner; +import javax.swing.SpinnerNumberModel; +import javax.swing.border.TitledBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import com.teamcenter.rac.commands.newitem.AbstractNewItemPanel; +import com.teamcenter.rac.commands.newitem.NamingRule; +import com.teamcenter.rac.commands.newitem.NamingRulesHelper; +import com.teamcenter.rac.commands.revise.ReviseArchitecturePanel; +import com.teamcenter.rac.commands.revise.RevisePanel; +import com.teamcenter.rac.commands.revise.RevisionNamingRuleHelper; +import com.teamcenter.rac.common.PropertyConstantHelper; +import com.teamcenter.rac.common.TCConstants; +import com.teamcenter.rac.common.create.CreateInstanceInput; +import com.teamcenter.rac.common.create.IBOCreateDefinition; +import com.teamcenter.rac.common.create.ICreateInputProvider; +import com.teamcenter.rac.common.create.ICreateInstanceInput; +import com.teamcenter.rac.common.l10n.L10NTypesPropertiesHelper; +import com.teamcenter.rac.common.lov.view.components.LOVDisplayer; +import com.teamcenter.rac.kernel.BOCreatePropertyDescriptor; +import com.teamcenter.rac.kernel.ItemValidationInfo; +import com.teamcenter.rac.kernel.NameFieldInfo; +import com.teamcenter.rac.kernel.SoaUtil; +import com.teamcenter.rac.kernel.TCComponentItemRevisionType; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentNameFieldType; +import com.teamcenter.rac.kernel.TCComponentNameRule; +import com.teamcenter.rac.kernel.TCComponentType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.FilterDocument; +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.Separator; +import com.teamcenter.rac.util.VerticalLayout; +import com.teamcenter.rac.util.iTextArea; +import com.teamcenter.rac.util.iTextField; +import com.teamcenter.rac.util.combobox.iComboBox; +import com.teamcenter.rac.util.log.Debug; +import com.teamcenter.rac.util.log.TcLogger; +import com.teamcenter.rac.util.wizard.AbstractControlWizardStepPanel; +import com.teamcenter.services.rac.core.DataManagementService; +import com.teamcenter.services.rac.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsProperties; +import com.teamcenter.services.rac.core._2006_03.DataManagement.GenerateItemIdsAndInitialRevisionIdsResponse; +import com.teamcenter.services.rac.core._2006_03.DataManagement.ItemIdsAndInitialRevisionIds; +import com.teamcenter.services.rac.core._2007_01.DataManagement.GetItemCreationRelatedInfoResponse; +import com.teamcenter.services.rac.core._2008_06.DataManagement.GetNextIdsResponse; +import com.teamcenter.services.rac.core._2008_06.DataManagement.GetRevNRAttachResponse; + +public class CreateItemInfoPanel extends AbstractControlWizardStepPanel implements ICreateInputProvider { + public Frame parentFrame; + public TCSession session; + public AbstractNewItemPanel itemPanel; + public JPanel textPanel; + public JPanel itemInfoPanel; + public JPanel namingAndNumberingPanel; + public JPanel itemIdPanel; + public JPanel revisionIdPanel; + public JComboBox itemIdCombobox; + public JComboBox revisionIdCombobox; + public GetItemCreationRelatedInfoResponse response; + public GetNextIdsResponse newidres1; + public JPanel revIdPanel; + public iComboBox revisionvalueCombobox; + public GetRevNRAttachResponse revResponse; + public JPanel namePanel; + public JPanel otherPropertyPanel; + public JPanel nonPropertiesPanel; + public JLabel infoLabel; + public JLabel itemLabel; + public JLabel descLabel; + public JLabel uomLabel; + public iTextField idTextField; + public iTextField revTextField; + public iTextField nameTextField; + public LOVDisplayer nameLOVUI; + public iTextArea descTextArea; + public JScrollPane descScrollPane; + public JButton assignButton; + public LOVDisplayer uomLovComboBox; + public iComboBox uomComboBox; + public JCheckBox classifyCheckBox; + public TCComponentType[] preLoadTypes; + public ItemValidationInfo valObj; + public String classifyPref = "1"; + public String classifyNewPref = ""; + public String allowCopyAsRevisionPref = ""; + public String idRevSeparator = "/"; + public String revNameSeparator = "-"; + public static final String IDREV_SEPARATOR_PREF = "FLColumnCatIVFSeparatorPref"; + public static final String REVNAME_SEPARATOR_PREF = "FLColumnCatObjSeparatorPref"; + public static final String DISPLAY_ITEM_ID_NAME_MAX_COLUMNS_PREF = "TC_UI_DisplayMaxColumnsForItemIDNameFields"; + public static final String ICS_CLASSIFY_NEW = "ICS_classify_new"; + public static final String CLASSIFY_IMMEDIATE_PREFERENCE = "ICS_classify_immediately"; + public static final String CLASSIFY_ON = "1"; + public static final String CLASSIFY_OFF = "0"; + private static String prevObjectNameInitValue = ""; + private static String prevObjectDescInitValue = ""; + private boolean isStringUOM = false; + public boolean showUOM = true; + public boolean showQuantity = false; + private boolean displayMaxColumnsForItemIDNameFields = false; + private TCPreferenceService prefService; + public JPanel quantityPanel; + private SpinnerNumberModel quantitySpinnerModel; + private JSpinner quantitySpinner; + protected Registry packageReg = null; + private List m_inputs = null; + private Map widgetsMap = null; + public static final String PROPERTY_ITEM_ID = "item_id"; + public static final String PROPERTY_ITEM_REVISION_ID = "item_revision_id"; + public static final String PROPERTY_OBJECT_NAME = "object_name"; + public static final String PROPERTY_OBJECT_DESCRIPTION = "object_desc"; + public static final String PROPERTY_UOM = "uom_tag"; + public static final String PROPERTY_OBJECT_TYPE = "object_type"; + protected boolean revDescRequired = false; + public boolean isRevRuleAttached = false; + private boolean itemIdPattSelEnabled = true; + private boolean revIdPattSelEnabled = true; + private boolean IsDescInCreateTempObjChanged = false; + private boolean IsUOMInCreateTempObjChanged = false; + protected String m_previousSelectedItemType; + + public CreateItemInfoPanel(Frame paramFrame, TCSession paramTCSession, AbstractNewItemPanel paramAbstractNewItemPanel) { + this(paramFrame, paramTCSession, paramAbstractNewItemPanel, false); + } + + public CreateItemInfoPanel(TCSession paramTCSession, AbstractNewItemPanel paramAbstractNewItemPanel) { + super(paramAbstractNewItemPanel); + this.session = paramTCSession; + this.itemPanel = paramAbstractNewItemPanel; + getPreferenceSettings(); + this.packageReg = paramAbstractNewItemPanel.getRegistry(); + } + + public CreateItemInfoPanel(Frame paramFrame, TCSession paramTCSession, AbstractNewItemPanel paramAbstractNewItemPanel, + boolean paramBoolean) { + this(paramFrame, paramTCSession, paramAbstractNewItemPanel, paramBoolean, true, false); + } + + public CreateItemInfoPanel(Frame paramFrame, TCSession paramTCSession, AbstractNewItemPanel paramAbstractNewItemPanel, + boolean paramBoolean1, boolean paramBoolean2, boolean paramBoolean3) { + super(paramAbstractNewItemPanel); + this.parentFrame = paramFrame; + this.session = paramTCSession; + this.itemPanel = paramAbstractNewItemPanel; + this.isStringUOM = paramBoolean1; + this.showUOM = paramBoolean2; + this.showQuantity = paramBoolean3; + this.packageReg = paramAbstractNewItemPanel.getRegistry(); + this.widgetsMap = new HashMap(0); + initPanel(); + } + + public void initPanel() { + getPreferenceSettings(); + setLayout(new VerticalLayout(5, 2, 2, 2, 2)); + this.infoLabel = new JLabel(getPageTitle(), getPageIcon(), 2); + this.infoLabel.setForeground(Color.BLUE); + buildBaseItemInfoPanel(); + this.otherPropertyPanel = buildStaticPropertiesPanel(); + this.nonPropertiesPanel = buildNonPropertiesPanel(); + add("top.bind.left.top", this.infoLabel); + add("top.bind", new Separator()); + add("top.bind.left.top", this.namingAndNumberingPanel); + add("top.bind.left.top", this.itemInfoPanel); + add("top.bind.left.top", this.otherPropertyPanel); + add("bottom.nobind.right.top", this.nonPropertiesPanel); + if (this.itemPanel.getDialog().isAutoExposureForCreateEnabled()) { + applyMetaModelSettings(this.itemPanel.getCreateDefinition()); + } + setOptions(); + setFocus(); + } + + public void buildBaseItemInfoPanel() { + String str1 = this.packageReg.getString("itemId") + " " + this.idRevSeparator + " " + + this.packageReg.getString("rev") + " " + this.revNameSeparator + " " + + this.packageReg.getString("name"); + this.itemLabel = new JLabel(str1); + String str2 = TCSession.getServerEncodingName(this.session); + FilterDocument localFilterDocument = new FilterDocument(TCConstants.getDefaultMaxNameSize(this.session), str2); + this.idTextField = new iTextField(localFilterDocument, "", this.displayMaxColumnsForItemIDNameFields ? 32 : 15, + TCConstants.getDefaultMaxNameSize(this.session), true, null); + localFilterDocument = new FilterDocument(32, str2); + this.revTextField = new iTextField(localFilterDocument, "", 5, 32, true, null); + localFilterDocument = new FilterDocument(TCConstants.getDefaultMaxNameSize(this.session), str2); + this.nameTextField = new iTextField(localFilterDocument, "", + this.displayMaxColumnsForItemIDNameFields ? 32 : 10, TCConstants.getDefaultMaxNameSize(this.session), + true, null); + this.nameTextField.setEnabled(false); + this.namePanel = new JPanel(new HorizontalLayout()); + this.namePanel.add("unbound.bind.left.center", this.nameTextField); + this.revIdPanel = new JPanel(new HorizontalLayout()); + this.revIdPanel.add("left.bind.left.center", this.revTextField); + if (this.showQuantity) { + TCPreferenceService localObject1 = this.session.getPreferenceService(); + int i = ((TCPreferenceService) localObject1).getInt(0, "MaxNumberOfObjectsToCreate", 99); + this.quantityPanel = new JPanel(new HorizontalLayout()); + this.quantitySpinnerModel = new SpinnerNumberModel(1, 1, i, 1); + this.quantitySpinner = new JSpinner(this.quantitySpinnerModel); + this.quantitySpinner.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent paramAnonymousChangeEvent) { + CreateItemInfoPanel.this.validateEntries(); + } + }); + this.quantitySpinner.setEnabled(isQuantityEnabled()); + JFormattedTextField localObject2 = ((JSpinner.DefaultEditor) this.quantitySpinner.getEditor()) + .getTextField(); + ((JFormattedTextField) localObject2).setColumns(3); + JLabel localJLabel = new JLabel(this.packageReg.getString("quantity")); + localJLabel.setLabelFor(this.quantitySpinner); + this.quantityPanel.add("left", localJLabel); + this.quantityPanel.add("left.nobind", this.quantitySpinner); + addValidator(this.quantitySpinner); + } + this.assignButton = new JButton(this.packageReg.getString("assign")); + this.assignButton.setMargin(new Insets(0, 0, 0, 0)); + this.assignButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) { + CreateItemInfoPanel.this.updateLastUsedPref(); + CreateItemInfoPanel.this.getAssignedIds(); + } + }); + this.textPanel = new JPanel(new HorizontalLayout()); + this.textPanel.add("left.nobind", this.idTextField); + this.textPanel.add("left", new JLabel(this.idRevSeparator)); + this.textPanel.add("left.nobind", this.revIdPanel); + this.textPanel.add("left", new JLabel(this.revNameSeparator)); + this.textPanel.add("unbound.bind", this.namePanel); + this.textPanel.add("right.nobind", this.assignButton); + this.itemIdCombobox = new JComboBox(); + this.itemIdCombobox.setSelectedIndex(-1); + this.itemIdCombobox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) { + CreateItemInfoPanel.this.updateLastUsedPref(); + } + }); + this.itemIdPanel = new JPanel(new HorizontalLayout()); + this.itemIdPanel.add("left", new JLabel(this.packageReg.getString("itemId"))); + this.itemIdPanel.add("left", this.itemIdCombobox); + this.revisionIdCombobox = new JComboBox(); + this.revisionIdCombobox.setSelectedIndex(-1); + this.revisionIdCombobox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) { + CreateItemInfoPanel.this.updateLastUsedPref(); + } + }); + this.revisionIdPanel = new JPanel(new HorizontalLayout()); + this.revisionIdPanel.add("left", new JLabel(this.packageReg.getString("rev"))); + this.revisionIdPanel.add("left", this.revisionIdCombobox); + this.namingAndNumberingPanel = new JPanel(new HorizontalLayout()); + this.namingAndNumberingPanel.setBorder( + new TitledBorder(BorderFactory.createEtchedBorder(), this.packageReg.getString("namingpattern"))); + this.namingAndNumberingPanel.add("left", this.itemIdPanel); + this.namingAndNumberingPanel.add("left", this.revisionIdPanel); + this.itemInfoPanel = new JPanel(new VerticalLayout()); + this.itemInfoPanel.setBorder( + new TitledBorder(BorderFactory.createEtchedBorder(), this.packageReg.getString("itemInformation"))); + this.itemInfoPanel.add("top", this.itemLabel); + this.itemInfoPanel.add("top.bind", this.textPanel); + if (this.showQuantity) { + this.itemInfoPanel.add("top.bind", this.quantityPanel); + } + if (this.widgetsMap == null) { + this.widgetsMap = new HashMap(0); + } + Object localObject1 = new NameValueFieldContainer("item_id", this.textPanel, null, this.idTextField); + this.widgetsMap.put("item_id", (NameValueFieldContainer) localObject1); + NameValueFieldContainer localNameValueFieldContainer = new NameValueFieldContainer("item_revision_id", + this.textPanel, null, this.revTextField); + this.widgetsMap.put("item_revision_id", localNameValueFieldContainer); + Object localObject2 = new NameValueFieldContainer("object_name", this.namePanel, null, this.nameTextField); + this.widgetsMap.put("object_name", (NameValueFieldContainer) localObject2); + } + + protected void updateLastUsedPref() { + try { + if (this.namingAndNumberingPanel.isVisible()) { + String str1 = (String) this.itemIdCombobox.getSelectedItem(); + String str2 = (String) this.revisionIdCombobox.getSelectedItem(); + boolean bool1 = false; + boolean bool2 = false; + String[] arrayOfString1 = { "item_id", "item_revision_id" }; + String[] arrayOfString2 = { this.itemPanel.selectedItemType, this.itemPanel.selectedItemType }; + NamingRule[] arrayOfNamingRule = NamingRulesHelper.getInstance().getNamingRules(this.session, + arrayOfString2, arrayOfString1); + String str3 = arrayOfNamingRule[0].getCondition(); + String str4 = arrayOfNamingRule[1].getCondition(); + if (str3 == null) { + str3 = ""; + } + if (str4 == null) { + str4 = ""; + } + bool1 = arrayOfNamingRule[0].patternPresent(str1); + bool2 = arrayOfNamingRule[1].patternPresent(str2); + if (bool1) { + str1 = (String) this.itemIdCombobox.getSelectedItem(); + } else { + str1 = ""; + } + if (bool2) { + str2 = (String) this.revisionIdCombobox.getSelectedItem(); + } else { + str2 = ""; + } + StringBuilder localStringBuilder1 = new StringBuilder(); + localStringBuilder1.append(str3); + localStringBuilder1.append(":"); + localStringBuilder1.append(this.itemPanel.selectedItemType); + localStringBuilder1.append(":"); + localStringBuilder1.append("item_id"); + localStringBuilder1.append(":"); + localStringBuilder1.append(str1); + String str5 = localStringBuilder1.toString(); + StringBuilder localStringBuilder2 = new StringBuilder(); + localStringBuilder2.append(str4); + localStringBuilder2.append(":"); + localStringBuilder2.append(this.itemPanel.selectedItemType); + localStringBuilder2.append(":"); + localStringBuilder2.append("item_revision_id"); + localStringBuilder2.append(":"); + localStringBuilder2.append(str2); + String str6 = localStringBuilder2.toString(); + String[] arrayOfString3 = null; + if ((str2.equals("")) && (!str1.equals(""))) { + arrayOfString3 = new String[1]; + arrayOfString3[0] = str5; + } else if ((!str2.equals("")) && (str1.equals(""))) { + arrayOfString3 = new String[1]; + arrayOfString3[0] = str6; + } else if ((!str2.equals("")) && (!str1.equals(""))) { + arrayOfString3 = new String[2]; + arrayOfString3[0] = str5; + arrayOfString3[1] = str6; + } + if (arrayOfString3 != null) { + this.prefService = this.session.getPreferenceService(); + String[] arrayOfString4 = this.prefService.getStringArray(1, "TC_LAST_USED_PATTERNS"); + ArrayList localArrayList = new ArrayList(); + int i = 0; + int j = 0; + int k = 0; + int m = 0; + for (int n = 0; n < arrayOfString4.length; n++) { + String str7 = arrayOfString4[n]; + if (!str7.equals("")) { + StringTokenizer localStringTokenizer = new StringTokenizer(str7, ":"); + localStringTokenizer.nextToken(); + String str8 = localStringTokenizer.nextToken(); + String str9 = localStringTokenizer.nextToken(); + if (this.itemPanel.selectedItemType.equals(str8)) { + i++; + if ((str9.equals("item_id")) && (arrayOfString3[0] != null)) { + localArrayList.add(m, arrayOfString3[0]); + j++; + m++; + } + if (str9.equals("item_revision_id")) { + if ((arrayOfString3.length == 1) && (arrayOfString3[0] != null)) { + localArrayList.add(m, arrayOfString3[0]); + k++; + m++; + } + if ((arrayOfString3.length > 1) && (arrayOfString3[1] != null)) { + localArrayList.add(m, arrayOfString3[1]); + m++; + k++; + } + } + } else { + localArrayList.add(m, arrayOfString4[n]); + m++; + } + } + } + int n = 0; + if ((arrayOfString4.length == 1) && (arrayOfString4[0].equals(""))) { + n = 0; + } else { + n = arrayOfString4.length; + } + int i1 = 0; + int i2 = 0; + for (int i3 = 0; i3 < arrayOfString3.length; i3++) { + if ((i < 1) && (j < 1) && (k < 1)) { + localArrayList.add(n, arrayOfString3[i3]); + n++; + } + if ((j > 0) && (k < 1) && (!str2.equals("")) && (i1 == 0)) { + localArrayList.add(n, arrayOfString3[1]); + i1++; + } + if ((k > 0) && (j < 1) && (!str1.equals("")) && (i2 == 0)) { + localArrayList.add(n, arrayOfString3[0]); + i2++; + } + } + String[] arrayOfString5 = (String[]) localArrayList.toArray(new String[localArrayList.size()]); + this.prefService.setStringArray(1, "TC_LAST_USED_PATTERNS", arrayOfString5); + } + } + } catch (TCException localTCException) { + TcLogger.getLogger(CreateItemInfoPanel.class).error(localTCException.getLocalizedMessage(), localTCException); + } + } + + protected void addValidator(JSpinner paramJSpinner) { + } + + public JPanel buildStaticPropertiesPanel() { + String str = TCSession.getServerEncodingName(this.session); + this.descLabel = new JLabel(this.packageReg.getString("description")); + FilterDocument localFilterDocument = new FilterDocument(240, str); + this.descTextArea = new iTextArea(localFilterDocument, "", 3, 30, 240, false, null); + this.descTextArea.setLineWrap(true); + this.descTextArea.setWrapStyleWord(true); + this.descScrollPane = new JScrollPane(this.descTextArea); + if (this.showUOM) { + this.uomLabel = new JLabel(this.packageReg.getString("unitOfMeasure")); + this.isStringUOM = (this.itemPanel.dialog.isAutoExposureForCreateEnabled() ? false : this.isStringUOM); + if (!this.isStringUOM) { + String[] localObject = new String[] { "ListOfValues", "NameField" }; + try { + this.preLoadTypes = this.session.getTypeService().getTypeComponents((String[]) localObject); + } catch (TCException localTCException) { + this.preLoadTypes = null; + } + this.uomLovComboBox = createUomLovField(); + } else { + this.uomComboBox = new iComboBox(); + } + } + Object localObject = new JPanel(new PropertyLayout()); + ((JPanel) localObject).add("1.1.left.top", this.descLabel); + ((JPanel) localObject).add("1.2.center.center.resizable.resizable", this.descScrollPane); + if (this.showUOM) { + ((JPanel) localObject).add("2.1.right.top", this.uomLabel); + if (this.isStringUOM) { + ((JPanel) localObject).add("2.2", this.uomComboBox); + } else if (this.uomLovComboBox != null) { + ((JPanel) localObject).add("2.2", this.uomLovComboBox); + } + } + NameValueFieldContainer localNameValueFieldContainer1 = new NameValueFieldContainer("object_desc", + (JPanel) localObject, this.descLabel, this.descTextArea, this.descScrollPane); + this.widgetsMap.put("object_desc", localNameValueFieldContainer1); + NameValueFieldContainer localNameValueFieldContainer2 = new NameValueFieldContainer("uom_tag", + (JPanel) localObject, this.uomLabel, this.uomComboBox != null ? this.uomComboBox : this.uomLovComboBox); + this.widgetsMap.put("uom_tag", localNameValueFieldContainer2); + return (JPanel) localObject; + } + + public JPanel buildNonPropertiesPanel() { + JPanel localJPanel = new JPanel(new HorizontalLayout()); + this.classifyCheckBox = new JCheckBox(this.packageReg.getString("classifyOnCreate")); + this.classifyCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent paramAnonymousActionEvent) { + if (CreateItemInfoPanel.this.classifyCheckBox.isSelected()) { + CreateItemInfoPanel.this.itemPanel.classifyWillRun(); + } + } + }); + localJPanel.add("right.bind", this.classifyCheckBox); + return localJPanel; + } + + public void getPreferenceSettings() { + TCPreferenceService localTCPreferenceService = this.session.getPreferenceService(); + int[] arrayOfInt = { 0, 0, 4, 4, 4 }; + String[] arrayOfString1 = { "FLColumnCatIVFSeparatorPref", "FLColumnCatObjSeparatorPref", "ICS_classify_new", + "ICS_classify_immediately", "TC_UI_DisplayMaxColumnsForItemIDNameFields" }; + String[] arrayOfString2 = localTCPreferenceService.getStrings(arrayOfInt, arrayOfString1); + if ((arrayOfString2 != null) && (arrayOfString2.length > 0)) { + this.idRevSeparator = arrayOfString2[0]; + } else { + this.idRevSeparator = localTCPreferenceService.getString(0, "FLColumnCatIVFSeparatorPref"); + } + if ((arrayOfString2 != null) && (arrayOfString2.length > 1)) { + this.revNameSeparator = arrayOfString2[1]; + } else { + this.revNameSeparator = localTCPreferenceService.getString(0, "FLColumnCatObjSeparatorPref"); + } + if ((arrayOfString2 != null) && (arrayOfString2.length > 2)) { + this.classifyNewPref = arrayOfString2[2]; + } else { + this.classifyNewPref = localTCPreferenceService.getString(4, "ICS_classify_new"); + } + if ((arrayOfString2 != null) && (arrayOfString2.length > 3)) { + this.classifyPref = arrayOfString2[3]; + } else { + this.classifyPref = localTCPreferenceService.getString(4, "ICS_classify_immediately"); + } + this.displayMaxColumnsForItemIDNameFields = localTCPreferenceService.isTrue(4, + "TC_UI_DisplayMaxColumnsForItemIDNameFields"); + this.allowCopyAsRevisionPref = localTCPreferenceService.getString(3, "Allow_Copy_As_Revision"); + if (Debug.isOn("NewItem")) { + System.out.println("ItemInfoPanel::getPreferenceSettings() - classifyNewPref=" + this.classifyNewPref + + " classifyPref=" + this.classifyPref); + System.out.println("ItemInfoPanel::getPreferenceSettings() - displayMaxColumnsForItemIDNameFields=" + + this.displayMaxColumnsForItemIDNameFields); + System.out.println( + "ItemInfoPanel::getPreferenceSettings() - allowCopyAsRevisionPref=" + this.allowCopyAsRevisionPref); + } + } + + public void setOptions() { + setClassifyOptions(); + } + + protected void setClassifyOptions() { + TCComponentType localTCComponentType = getTypeComponent(); + if ((localTCComponentType != null) && (localTCComponentType.isImmediatelyClassifiable())) { + this.classifyCheckBox.setVisible(true); + if (this.classifyPref.equals("0")) { + this.classifyCheckBox.setSelected(false); + } else if (this.itemPanel.isNewRoot()) { + this.classifyCheckBox.setSelected(false); + this.classifyCheckBox.setEnabled(false); + } else { + this.classifyCheckBox.setSelected(true); + } + } else { + this.classifyCheckBox.setVisible(false); + this.classifyCheckBox.setSelected(false); + } + } + + public void getAssignedIds() { + TCComponentItemType localTCComponentItemType = null; + boolean bool1 = true; + boolean bool2 = true; + try { + localTCComponentItemType = (TCComponentItemType) this.session + .getTypeComponent(this.itemPanel.selectedItemType); + DataManagementService localDataManagementService = DataManagementService.getService(this.session); + RevisionNamingRuleHelper.getInstance().loadRevNamingRuleDetails(this.session, + this.itemPanel.selectedItemType, null); + int[] arrayOfInt = RevisionNamingRuleHelper.getInstance().getRevisionNamingRuleFormats(); + int i = arrayOfInt[0]; + int j = arrayOfInt[1]; + Object localObject1; + if (getItemID().length() == 0) { + GenerateItemIdsAndInitialRevisionIdsProperties[] arrayOfGenerateItemIdsAndInitialRevisionIdsProperties = new GenerateItemIdsAndInitialRevisionIdsProperties[1]; + arrayOfGenerateItemIdsAndInitialRevisionIdsProperties[0] = new GenerateItemIdsAndInitialRevisionIdsProperties(); + arrayOfGenerateItemIdsAndInitialRevisionIdsProperties[0].item = null; + arrayOfGenerateItemIdsAndInitialRevisionIdsProperties[0].itemType = this.itemPanel.selectedItemType; + arrayOfGenerateItemIdsAndInitialRevisionIdsProperties[0].count = 1; + localObject1 = localDataManagementService + .generateItemIdsAndInitialRevisionIds(arrayOfGenerateItemIdsAndInitialRevisionIdsProperties); + if (((GenerateItemIdsAndInitialRevisionIdsResponse) localObject1).serviceData + .sizeOfPartialErrors() > 0) { + this.idTextField.setText(""); + this.idTextField.requestFocusInWindow(); + Object localObject2 = SoaUtil.checkPartialErrorsNoThrow( + ((GenerateItemIdsAndInitialRevisionIdsResponse) localObject1).serviceData); + MessageBox.post(this.parentFrame, (Throwable) localObject2); + return; + } + Object localObject2 = null; + String str = null; + Map localMap = ((GenerateItemIdsAndInitialRevisionIdsResponse) localObject1).outputItemIdsAndInitialRevisionIds; + Iterator localIterator = localMap.entrySet().iterator(); + if (localIterator.hasNext()) { + Map.Entry localEntry = (Map.Entry) localIterator.next(); + ItemIdsAndInitialRevisionIds[] arrayOfItemIdsAndInitialRevisionIds = (ItemIdsAndInitialRevisionIds[]) localEntry + .getValue(); + ItemIdsAndInitialRevisionIds localItemIdsAndInitialRevisionIds = arrayOfItemIdsAndInitialRevisionIds[0]; + localObject2 = localItemIdsAndInitialRevisionIds.newItemId; + if (i != 0) { + if (j == 0) { + assignRevIdWithRevisionRule(); + } + } else { + str = localItemIdsAndInitialRevisionIds.newRevId; + this.revTextField.setText(str); + } + bool1 = localItemIdsAndInitialRevisionIds.isItemModify; + bool2 = localItemIdsAndInitialRevisionIds.isRevModify; + } + this.idTextField.setText((String) localObject2); + if (!bool1) { + this.idTextField.setEditable(false); + this.itemIdCombobox.setEnabled(false); + } + if (!bool2) { + this.revTextField.setEditable(false); + this.revisionIdCombobox.setEnabled(false); + } + this.nameTextField.requestFocusInWindow(); + return; + } + boolean bool3 = true; + bool3 = validateId(); + if (!bool3) { + this.idTextField.setText(""); + this.idTextField.requestFocusInWindow(); + return; + } + if (i != 0) { + if (j == 0) { + assignRevIdWithRevisionRule(); + } + } else { + localObject1 = localTCComponentItemType.getNewRev(null); + bool2 = localTCComponentItemType.isNewRevModifiable(null, (String) localObject1); + this.revTextField.setText((String) localObject1); + } + if (!bool2) { + this.revTextField.setEditable(false); + } + this.nameTextField.requestFocusInWindow(); + } catch (TCException localTCException) { + if (Debug.isOn("NewItem")) { + localTCException.printStackTrace(); + } + MessageBox.post(this.parentFrame, localTCException); + } + } + + public void autoAssign() { + } + + public boolean validateId() { + if (Debug.isOn("NewItem")) { + System.out.println("ItemInfoPanel::validateId()"); + } + boolean bool = true; + if (getQuantity() != 1) { + return true; + } + if (getItemID().length() == 0) { + return false; + } + TCComponentItemType localTCComponentItemType = null; + try { + localTCComponentItemType = (TCComponentItemType) this.session + .getTypeComponent(this.itemPanel.selectedItemType); + this.valObj = localTCComponentItemType.validateId(getItemID(), getItemRev(), + this.itemPanel.selectedItemType); + if (this.valObj.getModificationStatus() == 4) { + this.idTextField.setText(this.valObj.getModifiedItemId()); + if (getItemRev() != null) { + this.revTextField.setText(this.valObj.getModifiedItemRevId()); + } + } else if (this.valObj.getModificationStatus() == 5) { + MessageBox.post(this.parentFrame, this.packageReg.getString("sameAsOldId"), + this.packageReg.getString("error.TITLE"), 4); + bool = false; + } else if (this.valObj.getModificationStatus() == 2) { + MessageBox.post(this.parentFrame, this.packageReg.getString("invalidID.MESSAGE"), + this.packageReg.getString("error.TITLE"), 4); + bool = false; + } else if (this.valObj.getModificationStatus() == 3) { + int i = ConfirmationDialog.post(this.parentFrame, this.packageReg.getString("modifiedID.TITLE"), + getItemID() + "/" + getItemRev() + " " + this.packageReg.getString("modifiedID.MESSAGE") + " " + + this.valObj.getModifiedItemId() + "/" + this.valObj.getModifiedItemRevId() + "?", + false); + if (i == 2) { + this.idTextField.setText(this.valObj.getModifiedItemId()); + if (getItemRev() != null) { + this.revTextField.setText(this.valObj.getModifiedItemRevId()); + } + } else if (i != 1) { + TCException localTCException2 = new TCException( + this.packageReg.getString("cancelModifiedID.MESSAGE")); + MessageBox.post(this.parentFrame, localTCException2); + bool = false; + } + } + } catch (TCException localTCException1) { + MessageBox.post(this.parentFrame, localTCException1); + bool = false; + } + return bool; + } + + public void addNotify() { + super.addNotify(); + setButtons(); + } + + public void setButtons() { + this.controlWizardPanel.getBackButton().setEnabled(true); + this.controlWizardPanel.getHomeButton().setEnabled(true); + } + + public boolean isPerformable() { + int i = getItemID().trim().length(); + int j = getItemRev().trim().length(); + int k = getQuantity(); + int m = 1; + int n = 1; + int i1 = 1; + if ((this.uomLovComboBox != null) && (this.uomLovComboBox.isVisible()) && (this.uomLovComboBox.isMandatory()) + && (getUOMComp() == null)) { + m = 0; + } + if ((this.uomComboBox != null) && (this.uomComboBox.isVisible()) && (this.uomComboBox.isMandatory()) + && (getUOMComp() == null)) { + m = 0; + } + if ((this.descTextArea.isRequired()) && (this.descTextArea.isVisible()) + && (getItemDescription().trim().length() <= 0)) { + n = 0; + } + Object localObject; + if ((this.namePanel != null) && (this.namePanel.getComponentCount() > 0)) { + if ((this.namePanel.getComponent(0) instanceof LOVDisplayer)) { + localObject = (LOVDisplayer) this.namePanel.getComponent(0); + if ((((LOVDisplayer) localObject).isVisible()) && (((LOVDisplayer) localObject).isMandatory()) + && (getItemName().trim().length() <= 0)) { + i1 = 0; + } + } else { + localObject = (iTextField) this.namePanel.getComponent(0); + if ((localObject != null) && (((iTextField) localObject).isRequired()) + && (((iTextField) localObject).isVisible()) && (getItemName().trim().length() <= 0)) { + i1 = 0; + } + } + } else { + i1 = 0; + } + if (this.itemPanel.selectedItemType != null) { + if (((i > 0) && (j > 0)) || (k > 1)) { + this.assignButton.setEnabled(false); + } else if (((i > 0) && (this.isRevRuleAttached)) || (k > 1)) { + this.assignButton.setEnabled(false); + } else if (this.namingAndNumberingPanel.isVisible()) { + if ((this.itemIdCombobox != null) && (this.revisionIdCombobox != null)) { + localObject = (String) this.itemIdCombobox.getSelectedItem(); + String str = (String) this.revisionIdCombobox.getSelectedItem(); + if (localObject == null) { + localObject = ""; + } + if (str == null) { + str = ""; + } + if ((this.itemIdCombobox.isEnabled()) && (!((String) localObject).equals("")) + && (!this.revisionIdCombobox.isEnabled())) { + this.assignButton.setEnabled(true); + } else if ((this.itemIdCombobox.isEnabled()) && (((String) localObject).equals("")) + && (!this.revisionIdCombobox.isEnabled())) { + this.assignButton.setEnabled(false); + } else if ((!this.itemIdCombobox.isEnabled()) && (!this.revisionIdCombobox.isEnabled())) { + this.assignButton.setEnabled(true); + } else if ((!this.itemIdCombobox.isEnabled()) && (this.revisionIdCombobox.isEnabled())) { + if (!str.equals("")) { + this.assignButton.setEnabled(true); + } else if (str.equals("")) { + this.assignButton.setEnabled(false); + } + } else if ((this.itemIdCombobox.isEnabled()) && (this.revisionIdCombobox.isEnabled())) { + if ((!str.equals("")) && (!((String) localObject).equals(""))) { + this.assignButton.setEnabled(true); + } else if ((str.equals("")) || (((String) localObject).equals(""))) { + this.assignButton.setEnabled(false); + } + } + } + } else { + this.assignButton.setEnabled(true); + } + } else { + this.assignButton.setEnabled(false); + } + if (((i > 0) && (j > 0)) || ((k > 1) && (i1 != 0) && (m != 0) && (n != 0))) { + if (this.controlWizardPanel.step == this.itemPanel.getItemInfoStep()) { + this.controlWizardPanel.getNextButton().setEnabled(true); + } + return true; + } + if (this.controlWizardPanel.step == this.itemPanel.getItemInfoStep()) { + this.controlWizardPanel.getNextButton().setEnabled(false); + } + return false; + } + + protected TCComponentType getTypeComponent() { + TCComponentItemType localTCComponentItemType = null; + try { + localTCComponentItemType = (TCComponentItemType) this.session + .getTypeComponent(this.itemPanel.selectedItemType); + return localTCComponentItemType; + } catch (TCException localTCException) { + } + return null; + } + + public void itemTypeSelected() { + if (Debug.isOn("NewItem")) { + System.out.println("ItemInfoPanel::itemTypeSelected()"); + } + if ((this.itemPanel.selectedItemType == null) + || (this.itemPanel.selectedItemType.equals(this.m_previousSelectedItemType))) { + return; + } + if ((this.showUOM) && (!this.isStringUOM) && (this.uomLovComboBox != null)) { + this.uomLovComboBox.clearSelection(); + } + String str1 = this.itemPanel.selectedItemType; + Object localObject3; + Object localObject4; + Object localObject5; + Object localObject6; + if (this.itemLabel != null) { + String localObject1 = L10NTypesPropertiesHelper.getItemLabelString(str1, false, this.session); + if (localObject1 != null) { + this.itemLabel.setText((String) localObject1); + this.itemLabel.repaint(); + if ((this.itemIdPanel != null) && (this.revisionIdPanel != null)) { + StringTokenizer localObject2 = new StringTokenizer((String) localObject1, "/"); + if (((StringTokenizer) localObject2).hasMoreTokens()) { + localObject3 = null; + localObject3 = ((StringTokenizer) localObject2).nextToken(); + if (localObject3 != null) { + ((JLabel) this.itemIdPanel.getComponent(0)).setText((String) localObject3); + ((JLabel) this.itemIdPanel.getComponent(0)).repaint(); + } + if (((StringTokenizer) localObject2).hasMoreTokens()) { + localObject4 = ((StringTokenizer) localObject2).nextToken("/"); + localObject5 = new StringTokenizer((String) localObject4, "-"); + if (((StringTokenizer) localObject5).hasMoreTokens()) { + localObject6 = ((StringTokenizer) localObject5).nextToken(); + if (localObject6 != null) { + ((JLabel) this.revisionIdPanel.getComponent(0)).setText((String) localObject6); + ((JLabel) this.revisionIdPanel.getComponent(0)).repaint(); + } + } + } + } + } + } + } + if ((this.showUOM) && (!this.isStringUOM) && (this.uomLovComboBox == null)) { + this.uomLovComboBox = createUomLovField(); + if (this.uomLovComboBox != null) { + this.otherPropertyPanel.add("2.2", this.uomLovComboBox); + this.otherPropertyPanel.revalidate(); + this.otherPropertyPanel.repaint(); + NameValueFieldContainer localObject1 = (NameValueFieldContainer) this.widgetsMap.get("uom_tag"); + ((NameValueFieldContainer) localObject1).resetValueField(this.uomLovComboBox); + } + } + if (this.itemPanel.getDialog().isAutoExposureForCreateEnabled()) { + resetQuantity(); + applyMetaModelSettings(this.itemPanel.getCreateDefinition()); + loadPatterns(); + setToolTip(); + return; + } + try { + TCComponentItemType localObject1 = (TCComponentItemType) this.session + .getTypeComponent(this.itemPanel.selectedItemType); + String localObject2 = null; + if (this.itemPanel.response != null) { + localObject2 = this.itemPanel.response.revTypeName; + } else { + localObject2 = ((TCComponentItemType) localObject1) + .getRevisionTypeName(this.itemPanel.selectedItemType); + } + localObject3 = (TCComponentItemRevisionType) this.session.getTypeComponent((String) localObject2); + localObject4 = null; + if ((localObject5 = getTypeComponent()) != null) { + localObject4 = ((TCComponentType) localObject5).getPropertyDescriptor("object_name"); + } + localObject6 = ((TCComponentItemType) localObject1).getPropertyDescriptor("uom_tag"); + TCPropertyDescriptor localTCPropertyDescriptor1 = ((TCComponentItemType) localObject1) + .getPropertyDescriptor("object_desc"); + TCPropertyDescriptor localTCPropertyDescriptor2 = ((TCComponentItemRevisionType) localObject3) + .getPropertyDescriptor("object_desc"); + if (localTCPropertyDescriptor2.isRequired()) { + this.revDescRequired = true; + } + String str2; + if ((!(this.itemPanel instanceof RevisePanel)) && (!(this.itemPanel instanceof ReviseArchitecturePanel)) + && (((TCComponentItemType) localObject1).hasNoFirstRev())) { + str2 = L10NTypesPropertiesHelper.getItemLabelString(str1, true, this.session); + if (str2 == null) { + str2 = this.packageReg.getString("itemId") + " " + this.idRevSeparator + " " + + this.packageReg.getString("name"); + } + this.itemLabel.setText(str2); + this.itemLabel.repaint(); + this.textPanel.removeAll(); + this.textPanel.add("left.nobind", this.idTextField); + this.textPanel.add("left", new JLabel(this.idRevSeparator)); + this.textPanel.add("left.nobind", this.revIdPanel); + this.textPanel.add("unbound.bind", this.namePanel); + this.textPanel.add("right.nobind", this.assignButton); + } else { + str2 = L10NTypesPropertiesHelper.getItemLabelString(str1, false, this.session); + if (str2 == null) { + str2 = this.packageReg.getString("itemId") + " " + this.idRevSeparator + " " + + this.packageReg.getString("rev") + " " + this.revNameSeparator + " " + + this.packageReg.getString("name"); + } + this.itemLabel.setText(str2); + this.itemLabel.repaint(); + this.textPanel.removeAll(); + this.textPanel.add("left.nobind", this.idTextField); + this.textPanel.add("left", new JLabel(this.idRevSeparator)); + this.textPanel.add("left.nobind", this.revIdPanel); + this.textPanel.add("left", new JLabel(this.revNameSeparator)); + this.textPanel.add("unbound.bind", this.namePanel); + this.textPanel.add("right.nobind", this.assignButton); + } + if (((TCPropertyDescriptor) localObject6).isRequired()) { + if (this.uomLovComboBox != null) { + this.uomLovComboBox.setMandatory(true); + } else if (this.uomComboBox != null) { + this.uomComboBox.setMandatory(true); + } + } else if (this.uomLovComboBox != null) { + this.uomLovComboBox.setMandatory(false); + } else if (this.uomComboBox != null) { + this.uomComboBox.setMandatory(false); + } + if ((localTCPropertyDescriptor1.isRequired()) || (localTCPropertyDescriptor2.isRequired())) { + this.descTextArea.setRequired(true); + } else { + this.descTextArea.setRequired(false); + } + if ((localObject4 != null) && (((TCPropertyDescriptor) localObject4).hasLOVAttached())) { + this.nameLOVUI = new LOVDisplayer((TCPropertyDescriptor) localObject4); + this.nameLOVUI.setMandatory(true); + this.namePanel.removeAll(); + this.namePanel.add("unbound.bind.left.center", this.nameLOVUI); + } else { + this.namePanel.removeAll(); + this.namePanel.add("unbound.bind.left.center", this.nameTextField); + } + this.namePanel.revalidate(); + this.namePanel.repaint(); + } catch (TCException localTCException) { + this.namePanel.removeAll(); + this.namePanel.add("unbound.bind.left.center", this.nameTextField); + } + String[] localObject1 = null; + if (this.itemPanel.response != null) { + localObject1 = this.itemPanel.response.initValuePropertyRules; + } else { + String[] localObject2 = new String[2]; + localObject2[0] = "object_name"; + localObject2[1] = "object_desc"; + localObject1 = PropertyConstantHelper.getInitialValueOnProperties(this.session, + this.itemPanel.selectedItemType, (String[]) localObject2); + } + if (((getItemName().equals("")) || (getItemName().equals(prevObjectNameInitValue))) && (localObject1.length > 0) + && (localObject1[0] != null)) { + JComponent localObject2 = getNameField(); + if ((localObject2 instanceof iTextField)) { + this.nameTextField.setText(localObject1[0]); + } else { + this.nameLOVUI.setDefaultValue(localObject1[0]); + } + prevObjectNameInitValue = localObject1[0]; + } + if (((getItemDescription().equals("")) || (getItemDescription().equals(prevObjectDescInitValue))) + && (localObject1.length > 1) && (localObject1[1] != null)) { + this.descTextArea.setText(localObject1[1]); + prevObjectDescInitValue = localObject1[1]; + } + String[] localObject2 = null; + if (this.itemPanel.response != null) { + localObject2 = this.itemPanel.response.complexValuePropertyRules; + } else { + + String[] localObject7 = new String[1]; + localObject7[0] = "object_desc"; + localObject2 = PropertyConstantHelper.getComplexPropertyValues(this.session, + this.itemPanel.selectedItemType, (String[]) localObject7); + } + this.descTextArea.setEnabled(true); + if ((localObject2 != null) && (localObject2.length >= 1) && (localObject2[0] != null) + && (localObject2[0].length() != 0)) { + this.descTextArea.setEnabled(false); + this.descTextArea.setText(""); + } + setToolTip(); + if (this.isStringUOM) { + loadUOM(); + } + loadPatterns(); + this.m_previousSelectedItemType = str1; + } + + private void setToolTip() { + try { + Object localObject1; + Object localObject2; + if ((this.itemPanel.response != null) && (this.itemPanel.response.patternMap != null)) { + localObject1 = this.itemPanel.response.patternMap; + if (((Map) localObject1).size() > 0) { + localObject2 = null; + if (((Map) localObject1).containsKey("object_name")) { + localObject2 = this.packageReg.getString("name.TOOLTIP"); + setToolTip(((Map) localObject1).get("object_name"), getNameField(), (String) localObject2); + } + if (((Map) localObject1).containsKey("item_id")) { + localObject2 = this.packageReg.getString("id.TOOLTIP"); + setToolTip(((Map) localObject1).get("item_id"), this.idTextField, (String) localObject2); + } + if (((Map) localObject1).containsKey("item_revision_id")) { + localObject2 = this.packageReg.getString("rev.TOOLTIP"); + setToolTip(((Map) localObject1).get("item_revision_id"), getrevIdField(), + (String) localObject2); + } + } else { + localObject2 = getNameField(); + if (localObject2 != null) { + ((JComponent) localObject2).setToolTipText(null); + } + this.idTextField.setToolTipText(null); + this.revTextField.setToolTipText(null); + } + } else { + if ((this.preLoadTypes != null) && (this.preLoadTypes.length > 1)) { + localObject1 = (TCComponentNameFieldType) this.preLoadTypes[1]; + } else { + localObject1 = (TCComponentNameFieldType) this.session.getTypeComponent("NameField"); + } + localObject2 = this.packageReg.getString("name.TOOLTIP"); + setToolTip((TCComponentNameFieldType) localObject1, "object_name", getNameField(), + (String) localObject2); + localObject2 = this.packageReg.getString("id.TOOLTIP"); + setToolTip((TCComponentNameFieldType) localObject1, "item_id", this.idTextField, (String) localObject2); + localObject2 = this.packageReg.getString("rev.TOOLTIP"); + setToolTip((TCComponentNameFieldType) localObject1, "item_revision_id", getrevIdField(), + (String) localObject2); + } + } catch (Exception localException) { + if (Debug.isOn("NewItem")) { + localException.printStackTrace(); + } + } + } + + public void resetQuantity() { + if (this.quantitySpinner != null) { + this.quantitySpinner.setValue(((SpinnerNumberModel) this.quantitySpinner.getModel()).getMinimum()); + this.quantitySpinner.setEnabled(isQuantityEnabled()); + } + } + + protected void loadUOM() { + if ((this.itemPanel.response != null) && (this.uomComboBox != null)) { + String[] arrayOfString1 = this.itemPanel.response.uoms; + this.uomComboBox.removeAllItems(); + String[] arrayOfString2; + int j = (arrayOfString2 = arrayOfString1).length; + for (int i = 0; i < j; i++) { + String str = arrayOfString2[i]; + this.uomComboBox.addItem(str); + } + } + } + + public void setToolTip(TCComponentNameFieldType paramTCComponentNameFieldType, String paramString1, + JComponent paramJComponent, String paramString2) { + try { + NameFieldInfo localNameFieldInfo = paramTCComponentNameFieldType + .askAttachedRule(this.itemPanel.selectedItemType, paramString1); + if (localNameFieldInfo == null) { + paramJComponent.setToolTipText(null); + } else { + TCComponentNameRule localTCComponentNameRule = localNameFieldInfo.getAttachedNameRule(); + String[] arrayOfString1 = localTCComponentNameRule.getPatterns(); + if ((arrayOfString1 != null) && (arrayOfString1.length > 0)) { + StringBuilder localStringBuilder = new StringBuilder(); + localStringBuilder.append(""); + localStringBuilder.append(paramString2); + localStringBuilder.append("
    "); + String[] arrayOfString2; + int j = (arrayOfString2 = arrayOfString1).length; + for (int i = 0; i < j; i++) { + String str = arrayOfString2[i]; + localStringBuilder.append("
  • "); + localStringBuilder.append(str); + localStringBuilder.append("
  • "); + } + localStringBuilder.append("
"); + paramJComponent.setToolTipText(localStringBuilder.toString()); + } else { + paramJComponent.setToolTipText(null); + } + } + } catch (TCException localTCException) { + if (Debug.isOn("NewItem")) { + localTCException.printStackTrace(); + } + } + } + + public void setToolTip(Object paramObject, JComponent paramJComponent, String paramString) { + if (paramJComponent == null) { + return; + } + String[] arrayOfString1 = (String[]) paramObject; + if ((arrayOfString1 != null) && (arrayOfString1.length > 0)) { + StringBuilder localStringBuilder = new StringBuilder(); + localStringBuilder.append(""); + localStringBuilder.append(paramString); + localStringBuilder.append("
    "); + String[] arrayOfString2; + int j = (arrayOfString2 = arrayOfString1).length; + for (int i = 0; i < j; i++) { + String str = arrayOfString2[i]; + localStringBuilder.append("
  • "); + localStringBuilder.append(str); + localStringBuilder.append("
  • "); + } + localStringBuilder.append("
"); + String str = localStringBuilder.toString(); + paramJComponent.setToolTipText(str); + } else if (paramJComponent != null) { + paramJComponent.setToolTipText(null); + } + } + + public void setClassifyOnCreatePreference() { + try { + TCPreferenceService localTCPreferenceService = this.session.getPreferenceService(); + if ((getClassifyFlag()) && (this.classifyPref.equals("0"))) { + localTCPreferenceService.setString(0, "ICS_classify_immediately", "1"); + } else if ((!getClassifyFlag()) && (this.classifyPref.equals("1"))) { + localTCPreferenceService.setString(0, "ICS_classify_immediately", "0"); + } + } catch (TCException localTCException) { + localTCException.printStackTrace(); + MessageBox.post(this.parentFrame, localTCException); + } + } + + public boolean isRequired() { + return true; + } + + public void setPanelDisplay(boolean paramBoolean) { + } + + public String getControlName() { + String str1 = getClass().getName() + "." + "NAME"; + String str2 = this.packageReg.getString(str1, null); + if ((str2 == null) || (str2.length() <= 0)) { + str2 = this.packageReg.getString("itemInfoStep.NAME"); + } + return str2; + } + + public String getToolTip() { + String str1 = getClass().getName() + "." + "TIP"; + String str2 = this.packageReg.getString(str1, null); + if ((str2 == null) || (str2.length() <= 0)) { + str2 = this.packageReg.getString("itemInfoStep.TOOLTIP"); + } + return str2; + } + + public String getPageTitle() { + String str1 = getClass().getName() + "." + "TITLE"; + String str2 = this.packageReg.getString(str1, null); + if ((str2 == null) || (str2.length() <= 0)) { + str2 = this.packageReg.getString("itemInfo.LABEL"); + } + return str2; + } + + public Icon getPageIcon() { + String str = getClass().getName() + "." + "ICON"; + ImageIcon localImageIcon = this.packageReg.getImageIcon(str, null); + if (localImageIcon == null) { + localImageIcon = this.packageReg.getImageIcon("info.ICON"); + } + return localImageIcon; + } + + public JComponent getNameField() { + if ((this.namePanel != null) && (this.namePanel.getComponentCount() > 0) + && ((this.namePanel.getComponent(0) instanceof LOVDisplayer))) { + return this.nameLOVUI; + } + return this.nameTextField; + } + + public JComponent getrevIdField() { + if (((this.revIdPanel.getComponent(0) instanceof iComboBox)) && (this.revisionvalueCombobox != null)) { + return this.revisionvalueCombobox; + } + return this.revTextField; + } + + public JComponent getDescField() { + return this.descTextArea; + } + + public JComponent getUOMField() { + if (this.uomLovComboBox != null) { + return this.uomLovComboBox; + } + if (this.uomComboBox != null) { + return this.uomComboBox; + } + return null; + } + + protected LOVDisplayer createUomLovField() { + LOVDisplayer localLOVDisplayer = null; + TCComponentType localTCComponentType; + if ((localTCComponentType = getTypeComponent()) != null) { + try { + TCPropertyDescriptor localTCPropertyDescriptor = localTCComponentType.getPropertyDescriptor("uom_tag"); + localLOVDisplayer = new LOVDisplayer(localTCPropertyDescriptor); + } catch (TCException localTCException) { + TcLogger.getLogger(CreateItemInfoPanel.class).error(localTCException.getLocalizedMessage(), localTCException); + } + } + return localLOVDisplayer; + } + + public String getItemID() { + return this.idTextField.getText(); + } + + public String getItemRev() { + if (((this.revIdPanel.getComponent(0) instanceof iComboBox)) && (this.revisionvalueCombobox != null)) { + return this.revisionvalueCombobox.getSelectedItem().toString(); + } + return this.revTextField.getText(); + } + + public String getItemName() { + if ((this.namePanel != null) && (this.namePanel.getComponentCount() > 0) + && ((this.namePanel.getComponent(0) instanceof LOVDisplayer))) { + return this.nameLOVUI.getSelectedDisplayValue(); + } + return this.nameTextField.getText(); + } + + public String getItemInternalName() { + if ((this.namePanel != null) && (this.namePanel.getComponentCount() > 0) + && ((this.namePanel.getComponent(0) instanceof LOVDisplayer))) { + return (String) this.nameLOVUI.getSelectedValue(); + } + return this.nameTextField.getText(); + } + + public String getItemDescription() { + return this.descTextArea.getText(); + } + + public Object getUOMComp() { + Object localObject = null; + if (this.uomLovComboBox != null) { + localObject = this.uomLovComboBox.getSelectedValue(); + } else if (this.uomComboBox != null) { + localObject = this.uomComboBox.getSelectedItem(); + } + if ((localObject != null) && (localObject.toString().equals(""))) { + localObject = null; + } + return localObject; + } + + public boolean getClassifyFlag() { + return this.classifyCheckBox.isSelected(); + } + + public String getClassifyType() { + return this.classifyNewPref; + } + + public void setClassifyFlag(boolean paramBoolean) { + this.classifyCheckBox.setSelected(paramBoolean); + } + + public boolean allowCopyAsRevision() { + return this.allowCopyAsRevisionPref.equalsIgnoreCase("true"); + } + + public List getCreateInputs() { + ArrayList localArrayList = null; + IBOCreateDefinition localIBOCreateDefinition1 = ((AbstractNewItemPanel) this.controlWizardPanel) + .getCreateDefinition(); + if (localIBOCreateDefinition1 != null) { + localArrayList = new ArrayList(2); + CreateInstanceInput localCreateInstanceInput1 = new CreateInstanceInput(localIBOCreateDefinition1); + localCreateInstanceInput1.add("item_id", getItemID()); + localCreateInstanceInput1.add("object_name", getItemInternalName()); + localCreateInstanceInput1.add("object_desc", getItemDescription()); + localCreateInstanceInput1.add("uom_tag", getUOMComp()); + localArrayList.add(localCreateInstanceInput1); + List localList = localIBOCreateDefinition1.getSecondaryCreateDefinition("revision"); + if ((localList != null) && (localList.size() > 0)) { + IBOCreateDefinition localIBOCreateDefinition2 = (IBOCreateDefinition) localList.get(0); + if (localIBOCreateDefinition2 != null) { + CreateInstanceInput localCreateInstanceInput2 = new CreateInstanceInput(localIBOCreateDefinition2); + localCreateInstanceInput2.add("item_revision_id", getItemRev()); + localArrayList.add(localCreateInstanceInput2); + } + } + } + return localArrayList; + } + + protected void setFocus() { + this.idTextField.requestFocusInWindow(); + } + + public void assignRevIdWithRevisionRule() { + try { + String str1 = null; + String[] arrayOfString = RevisionNamingRuleHelper.getInstance().getAvailableNextRevOtions(); + String str2 = arrayOfString[0]; + StringTokenizer localStringTokenizer = new StringTokenizer(str2, ","); + str1 = localStringTokenizer.nextToken(); + this.revisionIdCombobox.setEnabled(false); + this.revTextField.setText(str1); + this.nameTextField.requestFocusInWindow(); + } catch (Exception localException) { + if (Debug.isOn("NewItem")) { + localException.printStackTrace(); + } + MessageBox.post(this.parentFrame, localException); + } + } + + public void loadPatterns() { + String[] arrayOfString1 = { "item_id", "item_revision_id" }; + String[] arrayOfString2 = { this.itemPanel.selectedItemType, this.itemPanel.selectedItemType }; + String str1 = this.itemPanel.selectedItemType; + NamingRule[] arrayOfNamingRule = NamingRulesHelper.getInstance().getNamingRules(this.session, arrayOfString2, + arrayOfString1); + String[] arrayOfString3 = arrayOfNamingRule[0].getPatterns(); + String[] arrayOfString4 = arrayOfNamingRule[1].getPatterns(); + String str2 = arrayOfNamingRule[0].getPreferredPattern(); + String str3 = arrayOfNamingRule[1].getPreferredPattern(); + int i = 0; + int j = 0; + if (arrayOfString3 != null) { + i = arrayOfString3.length; + } + if (arrayOfString4 != null) { + j = arrayOfString4.length; + } + int k = 0; + int m = 0; + String[] arrayOfString5; + int i2; + int i1; + String str4; + if (i > 0) { + this.itemIdCombobox.removeAllItems(); + i2 = (arrayOfString5 = arrayOfString3).length; + for (i1 = 0; i1 < i2; i1++) { + str4 = arrayOfString5[i1]; + this.itemIdCombobox.addItem(str4); + } + } + if (j > 0) { + this.revisionIdCombobox.removeAllItems(); + i2 = (arrayOfString5 = arrayOfString4).length; + for (i1 = 0; i1 < i2; i1++) { + str4 = arrayOfString5[i1]; + this.revisionIdCombobox.addItem(str4); + } + } + if ((j > 1) || (i > 1)) { + this.namingAndNumberingPanel.setVisible(true); + } else if ((j < 2) && (i < 2)) { + this.namingAndNumberingPanel.setVisible(false); + } + if ((j > 1) && (i < 2)) { + this.itemIdCombobox.setSelectedItem(""); + this.itemIdCombobox.setEditable(true); + this.itemIdCombobox.setEnabled(false); + this.revisionIdCombobox.setEnabled(true); + } + if ((i > 1) && (j < 2)) { + this.revisionIdCombobox.setSelectedItem(""); + this.itemIdCombobox.setEnabled(true); + this.revisionIdCombobox.setEditable(true); + this.revisionIdCombobox.setEnabled(false); + } + if ((i > 1) && (j > 1)) { + this.itemIdCombobox.setEnabled(true); + this.revisionIdCombobox.setEnabled(true); + this.revisionIdCombobox.setEditable(false); + this.itemIdCombobox.setEditable(false); + } + int n; + if (!this.itemIdCombobox.isEnabled()) { + this.itemIdCombobox.setSelectedItem(""); + this.itemIdPattSelEnabled = false; + } else { + this.itemIdPattSelEnabled = true; + for (n = 0; n < i; n++) { + if (str2.equals(arrayOfString3[n])) { + k = 1; + } + } + if (k == 0) { + str2 = ""; + } + if (k != 0) { + this.itemIdCombobox.setEditable(false); + this.itemIdCombobox.setSelectedItem(str2); + } + if (str2.equals("")) { + this.itemIdCombobox.setSelectedIndex(-1); + this.itemIdCombobox.setEditable(false); + this.itemIdCombobox.setSelectedItem(str2); + } + } + if (!this.revisionIdCombobox.isEnabled()) { + this.revisionIdCombobox.setSelectedItem(""); + this.revIdPattSelEnabled = false; + } else { + this.revIdPattSelEnabled = true; + for (n = 0; n < j; n++) { + if (str3.equals(arrayOfString4[n])) { + m = 1; + } + } + if (m == 0) { + str3 = ""; + } + if (m != 0) { + this.revisionIdCombobox.setEditable(false); + this.revisionIdCombobox.setSelectedItem(str3); + } + if (str3.equals("")) { + this.revisionIdCombobox.setSelectedIndex(-1); + this.revisionIdCombobox.setEditable(false); + this.revisionIdCombobox.setSelectedItem(str3); + } + } + if (str1 != null) { + RevisionNamingRuleHelper.getInstance().loadRevNamingRuleDetails(this.session, str1, null); + if (RevisionNamingRuleHelper.getInstance().getRevisionNamingRuleFormats()[0] != 0) { + this.revisionIdCombobox.setEnabled(false); + this.revIdPattSelEnabled = false; + } + } + RevisionNamingRuleHelper.getInstance().loadComboWithAvailableInitAndSecRevOptions(this, this.session); + boolean bool1 = isItemIdPanelIntact(); + boolean bool2 = isRevisionIdPanelIntact(); + if (i == 0) { + if (bool1) { + this.namingAndNumberingPanel.remove(this.itemIdPanel); + } + } else if (!bool1) { + Component localComponent = null; + if (bool2) { + localComponent = this.namingAndNumberingPanel.getComponent(0); + this.namingAndNumberingPanel.remove(localComponent); + } + this.namingAndNumberingPanel.add("left", this.itemIdPanel); + ((JComboBox) this.itemIdPanel.getComponent(1)).setEnabled(true); + if ((bool2) && (localComponent != null)) { + this.namingAndNumberingPanel.add("left", localComponent); + } + } + if (j == 0) { + if (bool2) { + this.namingAndNumberingPanel.remove(this.revisionIdPanel); + } + } else if (!bool2) { + this.namingAndNumberingPanel.add("left", this.revisionIdPanel); + ((JComboBox) this.revisionIdPanel.getComponent(1)).setEnabled(true); + } + } + + protected boolean isItemIdPanelIntact() { + Component[] arrayOfComponent = this.namingAndNumberingPanel.getComponents(); + for (int i = 0; i < arrayOfComponent.length; i++) { + if (arrayOfComponent[i] == this.itemIdPanel) { + return true; + } + } + return false; + } + + protected boolean isRevisionIdPanelIntact() { + Component[] arrayOfComponent = this.namingAndNumberingPanel.getComponents(); + for (int i = 0; i < arrayOfComponent.length; i++) { + if (arrayOfComponent[i] == this.revisionIdPanel) { + return true; + } + } + return false; + } + + protected void applyMetaModelSettings(IBOCreateDefinition paramIBOCreateDefinition) { + if (paramIBOCreateDefinition != null) { + List localList1 = paramIBOCreateDefinition.getCreatePropertyDescriptors(); + if ((localList1 != null) && (localList1.size() > 0)) { + BOCreatePropertyDescriptor localBOCreatePropertyDescriptor1 = getCreatePropertyDescriptor("item_id", + localList1); + applyMetaModelDefinitionToField("item_id", localBOCreatePropertyDescriptor1); + BOCreatePropertyDescriptor localBOCreatePropertyDescriptor2 = getCreatePropertyDescriptor("object_name", + localList1); + applyMetaModelDefinitionToField("object_name", localBOCreatePropertyDescriptor2); + BOCreatePropertyDescriptor localBOCreatePropertyDescriptor3 = getCreatePropertyDescriptor("object_desc", + localList1); + applyMetaModelDefinitionToField("object_desc", localBOCreatePropertyDescriptor3); + BOCreatePropertyDescriptor localBOCreatePropertyDescriptor4 = getCreatePropertyDescriptor("uom_tag", + localList1); + applyMetaModelDefinitionToField("uom_tag", localBOCreatePropertyDescriptor4); + List localList2 = paramIBOCreateDefinition.getSecondaryCreateDefinition("revision"); + if ((localList2 != null) && (localList2.size() > 0)) { + IBOCreateDefinition localIBOCreateDefinition = (IBOCreateDefinition) localList2.get(0); + if (localIBOCreateDefinition != null) { + BOCreatePropertyDescriptor localBOCreatePropertyDescriptor5 = getCreatePropertyDescriptor( + "item_revision_id", localIBOCreateDefinition.getCreatePropertyDescriptors()); + applyMetaModelDefinitionToField("item_revision_id", localBOCreatePropertyDescriptor5); + } + } + } + } + } + + private BOCreatePropertyDescriptor getCreatePropertyDescriptor(String paramString, + List paramList) { + Object localObject = null; + if ((paramList != null) && (paramList.size() > 0)) { + Iterator localIterator = paramList.iterator(); + while (localIterator.hasNext()) { + BOCreatePropertyDescriptor localBOCreatePropertyDescriptor = (BOCreatePropertyDescriptor) localIterator + .next(); + if (localBOCreatePropertyDescriptor.getPropertyDescriptor().getName().equals(paramString)) { + localObject = localBOCreatePropertyDescriptor; + break; + } + } + } + return (BOCreatePropertyDescriptor) localObject; + } + + private void applyMetaModelDefinitionToField(String paramString, + BOCreatePropertyDescriptor paramBOCreatePropertyDescriptor) { + NameValueFieldContainer localNameValueFieldContainer = (NameValueFieldContainer) this.widgetsMap + .get(paramString); + if (localNameValueFieldContainer != null) { + if (paramBOCreatePropertyDescriptor == null) { + localNameValueFieldContainer.setVisible(false); + } else { + localNameValueFieldContainer.setVisible(true); + if (paramString.equals("uom_tag")) { + applyMetaModelDefinitionToLOVField(paramBOCreatePropertyDescriptor, localNameValueFieldContainer); + } else if (paramString.equals("object_name")) { + applyMetaModelDefinitionToNameField(paramBOCreatePropertyDescriptor, localNameValueFieldContainer); + } else { + applyMetaModelDefinitionToStringProps(paramBOCreatePropertyDescriptor, + localNameValueFieldContainer); + } + } + } + } + + private void applyMetaModelDefinitionToStringProps(BOCreatePropertyDescriptor paramBOCreatePropertyDescriptor, + NameValueFieldContainer paramNameValueFieldContainer) { + boolean bool = paramBOCreatePropertyDescriptor.getPropertyDescriptor().isRequired(); + String str1 = paramBOCreatePropertyDescriptor.getDefaultValue(); + JComponent localJComponent = paramNameValueFieldContainer.getValueField(); + if ((localJComponent instanceof iTextField)) { + ((iTextField) localJComponent).setRequired(bool); + ((iTextField) localJComponent).setText(str1); + } else if ((localJComponent instanceof iTextArea)) { + ((iTextArea) localJComponent).setRequired(bool); + ((iTextArea) localJComponent).setText(str1); + } + String str2 = this.packageReg.getString("namingPatternPrefix.TOOLTIP", null); + str2 = MessageFormat.format(str2, + new Object[] { paramBOCreatePropertyDescriptor.getPropertyDescriptor().getDisplayName() }); + setToolTip(paramBOCreatePropertyDescriptor.getNamingPatterns(), paramNameValueFieldContainer.getValueField(), + str2); + } + + private void applyMetaModelDefinitionToNameField(BOCreatePropertyDescriptor paramBOCreatePropertyDescriptor, + NameValueFieldContainer paramNameValueFieldContainer) { + JPanel localJPanel = paramNameValueFieldContainer.getParentContainer(); + localJPanel.removeAll(); + if (paramBOCreatePropertyDescriptor.getPropertyDescriptor().hasLOVAttached()) { + this.nameLOVUI = new LOVDisplayer(paramBOCreatePropertyDescriptor.getPropertyDescriptor()); + this.nameLOVUI.setMandatory(true); + localJPanel.add("unbound.bind.left.center", this.nameLOVUI); + paramNameValueFieldContainer.resetValueField(this.nameLOVUI); + } else { + localJPanel.add("unbound.bind.left.center", this.nameTextField); + paramNameValueFieldContainer.resetValueField(this.nameTextField); + } + this.widgetsMap.put(paramBOCreatePropertyDescriptor.getPropertyDescriptor().getName(), + paramNameValueFieldContainer); + localJPanel.validate(); + localJPanel.repaint(); + if (paramBOCreatePropertyDescriptor.getPropertyDescriptor().hasLOVAttached()) { + applyMetaModelDefinitionToLOVField(paramBOCreatePropertyDescriptor, paramNameValueFieldContainer); + } else { + applyMetaModelDefinitionToStringProps(paramBOCreatePropertyDescriptor, paramNameValueFieldContainer); + } + } + + private void applyMetaModelDefinitionToLOVField(BOCreatePropertyDescriptor paramBOCreatePropertyDescriptor, + NameValueFieldContainer paramNameValueFieldContainer) { + boolean bool = paramBOCreatePropertyDescriptor.getPropertyDescriptor().isRequired(); + String str1 = paramBOCreatePropertyDescriptor.getDefaultValue(); + JComponent localJComponent = paramNameValueFieldContainer.getValueField(); + if ((localJComponent instanceof LOVDisplayer)) { + ((LOVDisplayer) localJComponent).setMandatory(bool); + ((LOVDisplayer) localJComponent).setDefaultValue(str1); + ((LOVDisplayer) localJComponent).setPropertyData(null, + paramBOCreatePropertyDescriptor.getPropertyDescriptor()); + } else if ((localJComponent instanceof iComboBox)) { + ((iComboBox) localJComponent).setMandatory(bool); + ((iComboBox) localJComponent).setSelectedItem(str1); + } + String str2 = this.packageReg.getString("namingPatternPrefix.TOOLTIP", null); + MessageFormat.format(str2, + new Object[] { paramBOCreatePropertyDescriptor.getPropertyDescriptor().getDisplayName() }); + setToolTip(paramBOCreatePropertyDescriptor.getNamingPatterns(), paramNameValueFieldContainer.getValueField(), + str2); + } + + public int getQuantity() { + if (this.quantitySpinner != null) { + return ((Integer) this.quantitySpinner.getValue()).intValue(); + } + return 1; + } + + public void validateEntries() { + int i = getQuantity(); + if (i > 1) { + this.assignButton.setEnabled(false); + setEnabledIdField(false); + setEnabledRevField(false); + setTextIdField(""); + setTextRevField(""); + } else { + this.assignButton.setEnabled(true); + setEnabledIdField(true); + this.idTextField.setEditable(true); + setEnabledRevField(true); + this.revTextField.setEditable(true); + } + } + + public String getMEName() { + if ((this.namePanel != null) && (this.namePanel.getComponentCount() > 0) + && ((this.namePanel.getComponent(0) instanceof LOVDisplayer))) { + String str = this.nameLOVUI.getSelectedDisplayValue(); + if (str == null) { + return ""; + } + return str; + } + return this.nameTextField.getText(); + } + + public void setEnabledIdField(boolean paramBoolean) { + this.idTextField.setEnabled(paramBoolean); + } + + public void setTextIdField(String paramString) { + this.idTextField.setText(paramString); + } + + public void setEnabledRevField(boolean paramBoolean) { + this.revTextField.setEnabled(paramBoolean); + } + + public void setTextRevField(String paramString) { + this.revTextField.setText(paramString); + } + + public boolean isQuantityEnabled() { + return !((AbstractNewItemPanel) this.controlWizardPanel).isNewRoot(); + } + + public boolean isItemIdPattComboEnabled() { + return this.itemIdPattSelEnabled; + } + + public boolean isRevIdPattComboEnabled() { + return this.revIdPattSelEnabled; + } + + public void disableQuantitySpinner() { + if (this.quantitySpinner != null) { + this.quantitySpinner.setEnabled(false); + } + } + + public void enableQuantitySpinner() { + if (this.quantitySpinner != null) { + this.quantitySpinner.setEnabled(true); + } + } + + public void setStoredCreateInputs(List paramList) { + this.m_inputs = paramList; + } + + public List getStoredCreateInputs() { + return this.m_inputs; + } + + public boolean getIsDescChanged() { + return this.IsDescInCreateTempObjChanged; + } + + public void setIsDescChanged(boolean paramBoolean) { + this.IsDescInCreateTempObjChanged = paramBoolean; + } + + public boolean getIsUOMChanged() { + return this.IsUOMInCreateTempObjChanged; + } + + public void setIsUOMChanged(boolean paramBoolean) { + this.IsUOMInCreateTempObjChanged = paramBoolean; + } + + private static class NameValueFieldContainer { + private JPanel m_parentContainer; + private JLabel m_label; + private JComponent m_valueField; + private JComponent m_valueFieldSupportingContainer; + + public NameValueFieldContainer(String paramString, JPanel paramJPanel, JLabel paramJLabel, + JComponent paramJComponent) { + this(paramString, paramJPanel, paramJLabel, paramJComponent, null); + } + + public NameValueFieldContainer(String paramString, JPanel paramJPanel, JLabel paramJLabel, + JComponent paramJComponent1, JComponent paramJComponent2) { + this.m_parentContainer = paramJPanel; + this.m_label = paramJLabel; + this.m_valueField = paramJComponent1; + this.m_valueFieldSupportingContainer = paramJComponent2; + } + + public JPanel getParentContainer() { + return this.m_parentContainer; + } + + public JComponent getValueField() { + return this.m_valueField; + } + + public void resetValueField(JComponent paramJComponent) { + this.m_valueField = paramJComponent; + } + + public void setVisible(boolean paramBoolean) { + if (this.m_label != null) { + this.m_label.setVisible(paramBoolean); + } + if (this.m_valueField != null) { + this.m_valueField.setVisible(paramBoolean); + if (this.m_valueFieldSupportingContainer != null) { + this.m_valueFieldSupportingContainer.setVisible(paramBoolean); + } + } + if (this.m_parentContainer != null) { + this.m_parentContainer.validate(); + this.m_parentContainer.repaint(); + } + } + } +} diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/newitem_user.properties b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/newitem_user.properties new file mode 100644 index 0000000..dbdd540 --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/newitem/newitem_user.properties @@ -0,0 +1,3 @@ +#delete +#-------------------------------------------------- +newItemDialog=com.teamcenter.rac.commands.newitem.CreateItemDialog \ No newline at end of file diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/commands/paste/PasteOperation.java b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/paste/PasteOperation.java new file mode 100644 index 0000000..e172113 --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/commands/paste/PasteOperation.java @@ -0,0 +1,513 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package com.teamcenter.rac.commands.paste; + +import com.teamcenter.rac.aif.AIFClipboard; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AIFPortal; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.commands.newproxylink.NewProxyLinkCommand; +import com.teamcenter.rac.commands.newproxylink.NewProxyLinkOperation; +import com.teamcenter.rac.commands.open.OpenCommand; +import com.teamcenter.rac.common.Activator; +import com.teamcenter.rac.common.IMultiTarget; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentTcFile; +import com.teamcenter.rac.kernel.TCComponentTempProxyLink; +import com.teamcenter.rac.kernel.TCComponentTraceLink; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCComponentWorkContext; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCPreferenceService; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.ConfirmationDialog; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.OSGIUtil; +import com.teamcenter.rac.util.Registry; +import com.teamcenter.rac.util.log.Debug; +import com.teamcenter.rac.util.log.TcLogger; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Vector; + +public class PasteOperation extends AbstractAIFOperation implements IMultiTarget { + private AIFComponentContext[] contextArray; + private InterfaceAIFComponent[] childrenComps; + private TCComponent parentComp; + private String contextString; + protected Object operationResultNew; + protected boolean statusUse; + private String cookieName; + private boolean openAfterPasteFlag; + public static final int relationNotFoundErrorCode = 38015; + private static final TcLogger logger = TcLogger.getLogger(PasteOperation.class); + + public PasteOperation(AbstractAIFUIApplication var1, TCComponent var2, InterfaceAIFComponent var3, String var4) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + AIFComponentContext var5 = new AIFComponentContext(var2, var3, var4); + this.contextArray = new AIFComponentContext[]{var5}; + } + + public PasteOperation(AbstractAIFUIApplication var1, TCComponent var2, InterfaceAIFComponent[] var3, String var4) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.parentComp = var2; + this.childrenComps = var3; + this.contextString = var4; + } + + public PasteOperation(AbstractAIFUIApplication var1, TCComponent var2, InterfaceAIFComponent[] var3, String var4, boolean var5) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.parentComp = var2; + this.childrenComps = var3; + this.contextString = var4; + this.openAfterPasteFlag = var5; + } + + public PasteOperation(TCComponent var1, InterfaceAIFComponent[] var2, String var3) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.parentComp = var1; + this.childrenComps = var2; + this.contextString = var3; + } + + public PasteOperation(AbstractAIFUIApplication var1, AIFComponentContext var2) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.contextArray = new AIFComponentContext[]{var2}; + } + + public PasteOperation(AIFComponentContext var1) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.contextArray = new AIFComponentContext[]{var1}; + } + + public PasteOperation(AIFComponentContext var1, boolean var2) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.contextArray = new AIFComponentContext[]{var1}; + this.openAfterPasteFlag = var2; + } + + public PasteOperation(AbstractAIFUIApplication var1, AIFComponentContext[] var2) { + this(var2); + } + + public PasteOperation(AIFComponentContext[] var1) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.contextArray = var1; + } + + public PasteOperation(TCComponent var1, InterfaceAIFComponent[] var2, String var3, Object var4, boolean var5) { + this(var1, var2, var3, var4, var5, false); + } + + public PasteOperation(TCComponent var1, InterfaceAIFComponent[] var2, String var3, Object var4, boolean var5, boolean var6) { + this.statusUse = false; + this.cookieName = "PasteConfirm"; + this.openAfterPasteFlag = false; + this.parentComp = var1; + this.childrenComps = var2; + this.contextString = var3; + this.operationResultNew = var4; + this.statusUse = var5; + this.openAfterPasteFlag = var6; + } + + /** + * 自动指派=>新建(子)对象=>(父对象所在的)项目中 + * @throws TCException + */ + public void automaticAssignment(TCComponent parentComponent,TCComponent childComponent) throws TCException { + System.out.println("触发自动指派方法~·~·~"); + if (parentComponent == null) { + System.out.println("未获取到父件对象!"); + return; + } + if (childComponent == null) { + System.out.println("未获取到新建对象!"); + return; + } + + //避免和“创建时间表获取项目编号”冲突,过滤时间表类型(因为选中项目创建时间表时,会自动指派对应项目,且此时的父件类型为Newstuff。为了避免冲突,当创建时间表时,不再触发当前自动掷牌方法) + String childTypeString0 = childComponent.getStringProperty("object_type"); + if (childTypeString0.equals("Schedule")) { + System.out.println("当前新建对象是时间表,不需要自动指派项目!"); + return; + } + + + final String OBJECT_TYPE = "ML_AutoAssignProject_ObjectType"; + TCSession session = (TCSession) this.getSession(); + final TCComponentProjectType tccomponentprojecttype = (TCComponentProjectType) session.getTypeComponent("TC_Project"); + + int matchTab = 0; + String parentTypeString = parentComponent.getStringProperty("object_type"); + System.out.println("父件类型="+parentTypeString); + //判断当前新建对象的类型是否符合首选项配置 + TCPreferenceService preferenceService = session.getPreferenceService(); + String[] createObjectTypes = preferenceService.getStringValues(OBJECT_TYPE); + if (createObjectTypes.length > 0) { + System.out.println("获取首选项配置成功!"); + if (parentTypeString.equals("文件夹") || parentTypeString.equals("Folder")) { + //获取当前新建对象的类型 + String childTypeString = childComponent.getStringProperty("object_type"); + System.out.println("当前新建对象的类型="+childTypeString); + //将新建对象的类型与首选项中配置的类型比较 + for (int i = 0; i < createObjectTypes.length; i++) { + if (childTypeString.equals(createObjectTypes[i])) { + System.out.println("当前新建对象"+childComponent.getProperty("object_name")+"的类型"+childTypeString+"和首选项配置匹配!"); + matchTab ++; + //获取父对象所在的项目-projectComponents + TCComponent[] projectComponents = parentComponent.getReferenceListProperty("project_list"); + if (projectComponents.length <= 0) { + System.out.println("获取父件指派项目失败!"); + return; + }else { + for (int j = 0; j < projectComponents.length; j++) { + String projectTypeString = projectComponents[j].getStringProperty("object_type"); + String projectNameString = projectComponents[j].getStringProperty("object_name"); +// if (projectTypeString != null && "tc_project".equals(projectTypeString)) { + if (projectComponents[j] instanceof TCComponentProject) { + TCComponentProject assignProject = (TCComponentProject)projectComponents[j]; + try { + //开始遍历项目,将新建对象逐个指派到这些项目中 + tccomponentprojecttype.assignToProject(assignProject, childComponent); + } catch (Exception e) { + e.printStackTrace(); + if (parentComponent instanceof TCComponentFolder) { + TCComponentFolder fatherFolder = (TCComponentFolder)parentComponent; + String fatherFolderName = fatherFolder.getStringProperty("object_name"); + System.out.println("指派项目异常,将创建的异常对象仍然放入当前文件夹:"+fatherFolderName+"下!"); + MessageBox.post(AIFDesktop.getActiveDesktop(), + "对象指派时出现异常:\n" + e + "\n异常对象存放在当前文件夹下! \n 创建的数据未成功指派项目,请联系项目经理获取项目特权后,再将创建的文档指派到项目下", "", + MessageBox.INFORMATION); +// fatherFolder.add("contents", childComponent); + } + + } + }else { + System.out.println("当前指派项目【"+projectNameString+"】的类型为【"+projectTypeString+"】,非tc_project类型,不指派!"); + } + } + } + break; + } + } + if (matchTab == 0) { + System.out.println("当前创建对象类型不匹配任一首选项配置类型,不指派任何项目"); + } + }else { + System.out.println("当前父件非文件夹对象,不指派任何项目!"); + } + }else { + System.out.println("获取首选项["+OBJECT_TYPE+"]失败!无法完成自动指派操作"); + } + } + + public void executeOperation() throws TCException { + System.out.println("触发paste操作~~~"); + System.out.println("contextString = "+contextString); + TCSession var1 = (TCSession)this.getSession(); + Registry var2 = Registry.getRegistry(this); + if (this.parentComp != null && this.childrenComps != null) { + try { + this.executeByChunk(); + if (this.contextString.equals("CMImplements")) { + ((TCComponent)this.childrenComps[0]).fireChildCountChange("CMImplementedBy"); + } + } catch (TCException var16) { + throw var16; + } + + if (this.openAfterPasteFlag) { + try { + OpenCommand var18 = (OpenCommand)var2.newInstanceForEx("openCommand", new Object[]{AIFUtility.getActiveDesktop(), this.childrenComps}); + var18.executeModeless(); + } catch (Exception var14) { + logger.error(var14.getLocalizedMessage(), var14); + } + } + + } else { + TCComponent var3 = null; + TCComponent var4 = null; + ArrayList var5 = new ArrayList(); + boolean var6 = false; + + try { + ArrayList var7 = new ArrayList(); + + for(int var8 = 0; var8 < this.contextArray.length; ++var8) { + var4 = (TCComponent)this.contextArray[var8].getParentComponent(); + if (this.contextArray[var8].getComponent() instanceof TCComponentTempProxyLink) { + TCComponentTempProxyLink var9 = (TCComponentTempProxyLink)this.contextArray[var8].getComponent(); + this.setStatus(MessageFormat.format(var2.getString("pastingInto"), var9.toString(), var4.toString())); + NewProxyLinkCommand var10 = new NewProxyLinkCommand(var9.getSession(), AIFDesktop.getActiveDesktop(), var9.getAppId(), new String[]{var9.getObjId()}, new InterfaceAIFComponent[]{var4}, Boolean.FALSE); + var10.executeModal(); + NewProxyLinkOperation var11 = var10.getOperation(); + if (var11 != null) { + TCComponent[] var12 = var11.getNewObjectLinks(); + if (var12 != null && var12.length > 0) { + var3 = var12[0]; + String var13 = var4.getPreferredPasteRelation(var3); + this.contextArray[var8] = new AIFComponentContext(var4, var3, var13); + } else { + this.contextArray[var8] = null; + } + } else { + this.contextArray[var8] = null; + } + } else { + var3 = (TCComponent)this.contextArray[var8].getComponent(); + this.setStatus(MessageFormat.format(var2.getString("pastingInto"), var3.toString(), var4.toString())); + this.contextArray[var8] = this.processPaste(this.contextArray[var8], var7); + var5.add(var3); + if (!var6 && var3 instanceof TCComponentWorkContext) { + var6 = true; + } + } + + + //根据情况自动指派项目 + automaticAssignment(var4,var3); +// System.out.println("怀疑的新建对象名称:"+var3.getStringProperty("object_name")+"。对象类型:"+var3.getStringProperty("object_type")); +// System.out.println("怀疑的父件对象名称:"+var4.getStringProperty("object_name")+"。对象类型:"+var4.getStringProperty("object_type")); + } + + this.pasteInChunk(var7); + } catch (Exception var17) { + if (Debug.isOn("action,copy,cut,paste")) { + Debug.printStackTrace(var17); + } + + throw new TCException(var17); + } + + if (var6) { + this.clearWorkContextProperty(var1); + } + + if (this.openAfterPasteFlag && !var5.isEmpty()) { + InterfaceAIFComponent[] var19 = (InterfaceAIFComponent[])var5.toArray(new InterfaceAIFComponent[var5.size()]); + + try { + OpenCommand var20 = (OpenCommand)var2.newInstanceForEx("openCommand", new Object[]{AIFUtility.getActiveDesktop(), var19}); + var20.executeModeless(); + } catch (Exception var15) { + logger.error(var15.getLocalizedMessage(), var15); + } + } + + } + } + + protected AIFComponentContext processPaste(AIFComponentContext var1, List var2) throws TCException { + TCComponent var3 = (TCComponent)var1.getParentComponent(); + return var3.pasteOperation(var1); + } + + protected void pasteInChunk(List var1) throws TCException { + } + + private void executeByChunk() throws TCException { + if (this.parentComp != null && this.childrenComps != null) { + TCSession var1 = this.parentComp.getSession(); + Registry var2 = Registry.getRegistry(this); + AIFComponentContext[] var3 = new AIFComponentContext[this.childrenComps.length]; + boolean var4 = false; + + try { + StringBuilder var5 = new StringBuilder(); + + int var13; + for(var13 = 0; var13 < this.childrenComps.length; ++var13) { + var5.append(var13 == 0 ? "" : ", "); + var5.append(this.childrenComps[var13]); + } + + this.setStatus(MessageFormat.format(var2.getString("pastingInto"), var5.toString(), this.parentComp.toString())); + + for(var13 = 0; var13 < this.childrenComps.length; ++var13) { + var3[var13] = new AIFComponentContext(this.parentComp, this.childrenComps[var13], this.contextString); + if (!var4 && this.childrenComps[var13] instanceof TCComponentWorkContext) { + var4 = true; + } + } + + boolean var14 = this.isConfirmPasteEnabled(); + boolean var15 = false; + if (var14) { + var15 = this.isExplicitPasteOperation(); + } + + if (var15) { + int var17 = ConfirmationDialog.post(AIFDesktop.getActiveDesktop(), var2.getString("pasteConfirmTitle"), var2.getString("pasteConfirmText"), false, this.cookieName); + if (var17 == 2) { + if (this.parentComp instanceof TCComponentTraceLink && ((TCComponent)this.childrenComps[0]).isTypeOf("Fnd0CustomNoteRevision")) { + this.pasteToNoteProperty(); + } else { + this.storeOperationResult(this.parentComp.pasteOperation(var3)); + } + } + } else if (this.parentComp instanceof TCComponentTraceLink && ((TCComponent)this.childrenComps[0]).isTypeOf("Fnd0CustomNoteRevision")) { + this.pasteToNoteProperty(); + } else if (this.parentComp instanceof TCComponentDataset && this.contextString.equals("ref_list")) { + TCComponentDataset var16 = (TCComponentDataset)this.parentComp; + + for(int var18 = 0; var18 < this.childrenComps.length; ++var18) { + TCComponent var19 = (TCComponent)this.childrenComps[var18]; + if (var19 instanceof TCComponentTcFile) { + TCComponentTcFile var11 = (TCComponentTcFile)var19; + var16.addNamedReference(var19, var11.getRefDatasetNamedReferences()); + } else if (var19 instanceof TCComponentForm) { + TCComponentForm var20 = (TCComponentForm)var19; + var16.addNamedReference(var19, var20.getRefDatasetNamedReferences()); + } + + this.parentComp.refresh(); + } + } else { + this.storeOperationResult(this.parentComp.pasteOperation(var3)); + } + } catch (TCException var12) { + int[] var6 = var12.getErrorCodes(); + String var7 = this.contextString; + if (var6[0] != 38015) { + throw var12; + } + + if (var7 == null || var7.isEmpty()) { + var7 = this.parentComp.getDefaultPasteRelation(); + } + + String var8 = this.parentComp.getType(); + Object[] var9 = new Object[]{var8, var7}; + String var10 = MessageFormat.format(var2.getString("formattedAttachmentPanelPasteError"), var9); + MessageBox.post(var10.trim(), var2.getString("warning.TITLE"), 4); + } + + if (var4) { + this.clearWorkContextProperty(var1); + } + + } + } + + private void clearWorkContextProperty(AbstractAIFSession var1) { + if (var1 != null && var1 instanceof TCSession) { + TCSession var2 = (TCSession)var1; + TCComponentUser var3 = var2.getUser(); + if (var3 != null) { + var3.clearCache("work_contexts"); + } + } + + } + + private boolean isConfirmPasteEnabled() { + TCPreferenceService var1 = (TCPreferenceService)OSGIUtil.getService(Activator.getDefault(), TCPreferenceService.class); + Boolean var2 = var1.getLogicalValue("TC_confirm_paste_operation"); + return var2 != null && var2; + } + + private boolean isExplicitPasteOperation() { + Vector var1 = null; + boolean var2 = false; + AIFClipboard var3 = AIFPortal.getClipboard(); + Transferable var4 = var3.getContents(this); + + try { + if (var4 != null) { + var1 = (Vector)var4.getTransferData(new DataFlavor(Vector.class, "AIF Vector")); + } + } catch (Exception var8) { + logger.error(var8.getLocalizedMessage(), var8); + var1 = null; + } + + if (var1 != null) { + var2 = true; + + for(int var5 = 0; var5 < this.childrenComps.length; ++var5) { + int var6 = 0; + + for(int var7 = 0; var7 < var1.size() && !((TCComponent)var1.get(var7)).equals(this.childrenComps[var5]); ++var7) { + ++var6; + } + + if (var6 == var1.size()) { + var2 = false; + break; + } + } + + var1.clear(); + var1 = null; + } + + return var2; + } + + private void pasteToNoteProperty() throws TCException { + TCProperty var1 = this.parentComp.getTCProperty("fnd0CustomNotes"); + if (var1 != null) { + TCComponent[] var2 = var1.getReferenceValueArray(); + ArrayList var3 = new ArrayList(); + + int var4; + for(var4 = 0; var4 < var2.length; ++var4) { + var3.add(var2[var4]); + } + + for(var4 = 0; var4 < this.childrenComps.length; ++var4) { + var3.add((TCComponent)this.childrenComps[var4]); + } + + TCComponent[] var5 = new TCComponent[var3.size()]; + var5 = (TCComponent[])var3.toArray(new TCComponent[var3.size()]); + var1.setReferenceValueArray(var5); + } + + } + + public AIFComponentContext[] getTargetContexts() { + return this.contextArray; + } + + public Map getPartialFailedTargets() { + return Collections.EMPTY_MAP; + } +} diff --git a/com.connor.ml.tcm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/com.connor.ml.tcm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..ff2ba23 --- /dev/null +++ b/com.connor.ml.tcm/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties @@ -0,0 +1,4 @@ +#Item\ Master.FORMJAVARENDERING=com.connor.study.form.MyFormStylesheet +#lp2projectcombo.DEFINITION=com.connor.lp.sheet.Lp2PropertyComboBean +#label.DEFINITION=com.teamcenter.rac.stylesheet.PropertyLabel +loadsheet.DEFINITION=com.connor.ml.tcm.AssignProductName.AssignPropertyTextField \ No newline at end of file diff --git a/com.connor.ml.tcm/src/plm.properties b/com.connor.ml.tcm/src/plm.properties new file mode 100644 index 0000000..d6a7cfe --- /dev/null +++ b/com.connor.ml.tcm/src/plm.properties @@ -0,0 +1,7 @@ +EXCEL3.SQL=SELECT DISTINCT p1.puid, p3.pcreation_date, CASE WHEN p4.pitem_revision_id = 'A' AND p7.pname IN ('ML8_SXFB', 'ML8_JGFB') THEN p4.puid ELSE p4.puid END AS puid FROM PITEM p1 INNER JOIN PWORKSPACEOBJECT p2 ON p1.puid = p2.puid AND p2.pobject_type = 'ML8_Part' AND ( SELECT count(puid) FROM PPSOCCURRENCE WHERE rchild_itemu = p2.puid ) = 0 INNER JOIN PPOM_APPLICATION_OBJECT p3 ON p1.puid = p3.puid AND p3.pcreation_date < ( SELECT CONVERT( varchar(70), dateadd(MONTH, -2, CAST(GETDATE() AS datetime)), 21 )) INNER JOIN PITEMREVISION p4 ON p1.puid = p4.ritems_tagu AND p4.pitem_revision_id =( SELECT max(pitem_revision_id) AS item_revision_id FROM PITEMREVISION WHERE ritems_tagu = p1.puid GROUP BY ritems_tagu ) INNER JOIN PML8_PART p5 ON p1.puid = p5.puid AND p5.pml8_Status IN (?, ?, ?) INNER JOIN PRELEASE_STATUS_LIST p6 ON p4.puid = p6.puid INNER JOIN PRELEASESTATUS p7 ON p6.pvalu_0 = p7.puid +EXCEL4.SQL=SELECT DISTINCT ritems_tagu FROM ( SELECT T7.pname, isnull(T9.pml8_Status, '') pml8_Status, T1.ritems_tagu, T4.puid, CASE WHEN T7.pname IN('ML8_Replaced', 'ML8_Freeze') AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others')THEN 'ok' WHEN (pml8_Status = ? OR T7.pname = 'ML8_Replaced') AND T8.pobject_type = 'ML8_Part' THEN 'ok' ELSE 'no' END OTHERS FROM AAA T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.ritems_tagu INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid INNER JOIN PRELEASE_STATUS_LIST T6 ON T5.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid INNER JOIN PWORKSPACEOBJECT T8 ON T5.ritems_tagu = T8.puid AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others', 'ML8_Part') LEFT JOIN PML8_PART T9 ON T5.ritems_tagu = T9.puid) TTT1 WHERE OTHERS = 'ok' AND ritems_tagu NOT IN( SELECT DISTINCT ritems_tagu FROM ( SELECT T7.pname, isnull(T9.pml8_Status, '') pml8_Status, T1.ritems_tagu, T4.puid, CASE WHEN T7.pname IN('ML8_Replaced', 'ML8_Freeze') AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others')THEN 'ok' WHEN (pml8_Status = ? OR T7.pname = 'ML8_Replaced') AND T8.pobject_type = 'ML8_Part' THEN 'ok' ELSE 'no' END OTHERS FROM AAA T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.ritems_tagu INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid INNER JOIN PRELEASE_STATUS_LIST T6 ON T5.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid INNER JOIN PWORKSPACEOBJECT T8 ON T5.ritems_tagu = T8.puid AND T8.pobject_type IN('ML8_Refrigerator', 'ML8_Washing', 'ML8_Cold', 'ML8_Others', 'ML8_Part') LEFT JOIN PML8_PART T9 ON T5.ritems_tagu = T9.puid) sss WHERE OTHERS = 'no') GROUP BY ritems_tagu +EXCEL5.SQL=WITH TEMP AS( SELECT T5.ritems_tagu AS parent_uid FROM ( SELECT * FROM PITEM WHERE puid = ? ) T1 INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = T1.puid INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid UNION ALL SELECT T5.ritems_tagu AS parent_uid FROM TEMP A INNER JOIN PPSOCCURRENCE T2 ON T2.rchild_itemu = A.parent_uid INNER JOIN POM_BACKPOINTER T3 ON T3.from_uid = T2.puid AND T3.to_class = '934' INNER JOIN PSTRUCTURE_REVISIONS T4 ON T4.pvalu_0 = T3.to_uid INNER JOIN PITEMREVISION T5 ON T4.puid = T5.puid) SELECT DISTINCT * FROM TEMP +#截图比例原理:由宽度来产生对应比例的高度 +#截图比例:x/y (HEIGHT=WIDTH*y/x) +IMAGE.WIDTH=7 +IMAGE.HEIGHT=5 \ No newline at end of file diff --git a/com.connor.ml.tcm/src/sql.properties b/com.connor.ml.tcm/src/sql.properties new file mode 100644 index 0000000..9c521ac --- /dev/null +++ b/com.connor.ml.tcm/src/sql.properties @@ -0,0 +1,2 @@ +ML_WEBSERVICE_LOGINSERTSQL=INSERT INTO ML_WEBSERVICE_LOG (NAME,JSON,CREATE_DATE,TYPE) VALUES(\'%s\',\'%s\',\'%s\',\'%s\') +ML_TCMSENDSAPBOMINSERTSQL=INSERT INTO ML_TCMSENDSAPBOM VALUES (\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\',\'%s\') \ No newline at end of file diff --git a/com.connor.ml.tcm/src/sqlconn.properties b/com.connor.ml.tcm/src/sqlconn.properties new file mode 100644 index 0000000..956ac8d --- /dev/null +++ b/com.connor.ml.tcm/src/sqlconn.properties @@ -0,0 +1,9 @@ +#DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +#Connection=jdbc:sqlserver://10.18.1.100:1433; DatabaseName=TC +#User=infodba +#Password=Plm_8023 + +DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +Connection=jdbc:sqlserver://10.18.1.100:1433; DatabaseName=TC +User=infodba +Password=Plm_8023 \ No newline at end of file diff --git a/com.connor.ml.tcm/src/toERP.properties b/com.connor.ml.tcm/src/toERP.properties new file mode 100644 index 0000000..0911e10 --- /dev/null +++ b/com.connor.ml.tcm/src/toERP.properties @@ -0,0 +1,6 @@ +#url=http://mlapp.meiling.com/plmwebapi/sap/setinfo +#涓枃闇瑕佺敤unicode +#娴嬭瘯绯荤粺 +#infoname=\u6d4b\u8bd5\u7cfb\u7edf +#姝e紡绯荤粺 +infoname=\u6b63\u5f0f\u7cfb\u7edf \ No newline at end of file diff --git a/com.connor.ml.tcm/缇庤彵TCM鍔熻兘 .xlsx b/com.connor.ml.tcm/缇庤彵TCM鍔熻兘 .xlsx new file mode 100644 index 0000000..1cb0ee2 Binary files /dev/null and b/com.connor.ml.tcm/缇庤彵TCM鍔熻兘 .xlsx differ