commit 5e54e672977b453c33730c48cce64caa29879c0a Author: xiongcz Date: Mon Jun 9 10:56:49 2025 +0800 chore: 添加项目配置和资源文件 - 新增 .idea目录下的项目配置文件,包括 .gitignore、iml 文件、vcs.xml 等 - 添加 bin 目录下的资源文件,如属性文件、SQL 文件等 - 新增多语言支持文件 k_locale.properties 和 k_locale_zh_CN.properties - 添加 stylesheet 配置文件和 PLM 相关属性文件 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..3fb61d2 --- /dev/null +++ b/.classpath @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..157f1d9 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# ĬϺԵļ +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/cn.net.connor.ml.plm.iml b/.idea/cn.net.connor.ml.plm.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/cn.net.connor.ml.plm.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..10340b3 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d7b5d73 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..52caf6f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..8fe689b --- /dev/null +++ b/.project @@ -0,0 +1,28 @@ + + + cn.net.connor.ml.plm + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..0fed281 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding//src/plm.properties=GBK diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9f6ece8 --- /dev/null +++ b/.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/META-INF/MANIFEST.MF b/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e25bf75 --- /dev/null +++ b/META-INF/MANIFEST.MF @@ -0,0 +1,844 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Plm +Bundle-SymbolicName: cn.net.connor.ml.plm;singleton:=true +Bundle-Version: 1.0.0.0 +Bundle-Activator: cn.net.connor.ml.plm.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + com.teamcenter.rac.pca.kernel, + com.teamcenter.rac.util, + com.teamcenter.rac.aifrcp, + TcSoaCoreRac, + TcSoaClient, + com.teamcenter.rac.common, + com.teamcenter.rac.ui, + org.eclipse.osgi.services;bundle-version="3.7.100", + org.eclipse.osgi.util;bundle-version="3.5.100", + com.teamcenter.rac.commonclient;bundle-version="13000.1.0", + com.teamcenter.rac.tcapps, + com.teamcenter.rac.classification.icm;bundle-version="13000.1.0", + com.teamcenter.rac.kernel, + com.teamcenter.rac.aps0apscore.kernel +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Automatic-Module-Name: cn.net.connor.ml.plm +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: lib/fastjson-1.2.78.jar, + lib/httpclient-4.5.10.jar, + lib/httpcore-4.4.12.jar, + lib/httpmime-4.5.10.jar, + lib/jaxb-api-2.2.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/jcommon-1.0.23.jar, + lib/jfreechart-1.0.19.jar, + lib/yujianbo-java-tools-8.2.1.jar, + lib/sqljdbc4.jar, + lib/easyexcel-2.1.4.jar, + lib/slf4j-api-1.7.26.jar, + lib/poi-examples-3.17.jar, + lib/poi-excelant-3.17.jar, + lib/poi-ooxml-3.17.jar, + lib/poi-ooxml-schemas-3.17.jar, + lib/poi-scratchpad-3.17.jar, + lib/poi-3.17.jar, + ., + lib/cglib-3.1.jar, + lib/com.ibm.icu-4.4.2.jar, + lib/commons-collections4-4.1.jar, + lib/commons-math3-3.6.1.jar, + lib/ehcache-3.7.1.jar, + lib/FastInfoset-1.2.15.jar, + lib/fastjson-1.2.76.jar, + lib/istack-commons-runtime-3.0.7.jar, + lib/javax.activation-api-1.2.0.jar, + lib/jaxb-runtime-2.3.1.jar, + lib/stax-ex-1.8.jar, + lib/txw2-2.3.1.jar, + lib/xmlbeans-2.6.0.jar +Export-Package: ., + cn.net.connor.ml.plm, + cn.net.connor.ml.plm.AssignProductName, + cn.net.connor.ml.plm.CreateTimeSheet, + cn.net.connor.ml.plm.WBSExport, + cn.net.connor.ml.plm.beans, + cn.net.connor.ml.plm.createProject, + cn.net.connor.ml.plm.exportExcel, + cn.net.connor.ml.plm.getFolder, + cn.net.connor.ml.plm.getSpecifications, + cn.net.connor.ml.plm.implementRate, + cn.net.connor.ml.plm.melingKnowledgeBase, + cn.net.connor.ml.plm.melingSectrum, + cn.net.connor.ml.plm.modelImport, + cn.net.connor.ml.plm.planningPanel, + cn.net.connor.ml.plm.projectSchedule, + cn.net.connor.ml.plm.saveAs, + cn.net.connor.ml.plm.updateDesignName, + cn.net.connor.ml.plm.updateDesignProperty, + cn.net.connor.ml.plm.updateDocState, + cn.net.connor.ml.plm.updateUser, + cn.net.connor.ml.plm.util, + 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.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.keypoint, + 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.sun.istack, + com.sun.istack.localization, + com.sun.istack.logging, + 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.yujianbo.charts, + com.yujianbo.config, + com.yujianbo.json, + com.yujianbo.main, + com.yujianbo.sql.hibernate.interfaces, + com.yujianbo.sql.hibernate.service, + com.yujianbo.sql.sql.bean, + com.yujianbo.sql.sql.service, + com.yujianbo.sql.sql.statements, + com.yujianbo.swing, + com.yujianbo.system.date, + com.yujianbo.system.excel, + com.yujianbo.system.file, + com.yujianbo.system.image, + com.yujianbo.system.lunar, + com.yujianbo.system.math, + com.yujianbo.system.net, + com.yujianbo.system.pdf, + com.yujianbo.system.qrcode, + com.yujianbo.system.string, + com.yujianbo.system.video, + com.yujianbo.web.servlet.editor.filter, + com.yujianbo.web.servlet.editor.service, + com.yujianbo.web.servlet.editor.servlet, + com.yujianbo.web.servlet.filter, + com.yujianbo.web.servlet.upload.pojo, + com.yujianbo.web.servlet.upload.service, + com.yujianbo.web.servlet.upload.servlet, + com.yujianbo.web.struts2.action.upload, + com.yujianbo.web.struts2.pojo, + javax.activation, + javax.xml.bind, + javax.xml.bind.annotation, + javax.xml.bind.annotation.adapters, + javax.xml.bind.attachment, + javax.xml.bind.helpers, + javax.xml.bind.util, + 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, + 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.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.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.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.etsi.uri.x01903.v13, + org.etsi.uri.x01903.v13.impl, + org.jfree, + org.jfree.base, + org.jfree.base.config, + org.jfree.base.log, + org.jfree.base.modules, + org.jfree.chart, + org.jfree.chart.annotations, + org.jfree.chart.axis, + org.jfree.chart.block, + org.jfree.chart.demo, + org.jfree.chart.editor, + org.jfree.chart.encoders, + org.jfree.chart.entity, + org.jfree.chart.event, + org.jfree.chart.imagemap, + org.jfree.chart.labels, + org.jfree.chart.needle, + org.jfree.chart.panel, + org.jfree.chart.plot, + org.jfree.chart.plot.dial, + org.jfree.chart.renderer, + org.jfree.chart.renderer.category, + org.jfree.chart.renderer.xy, + org.jfree.chart.resources, + org.jfree.chart.servlet, + org.jfree.chart.title, + org.jfree.chart.urls, + org.jfree.chart.util, + org.jfree.data, + org.jfree.data.category, + org.jfree.data.contour, + org.jfree.data.function, + org.jfree.data.gantt, + org.jfree.data.general, + org.jfree.data.io, + org.jfree.data.jdbc, + org.jfree.data.resources, + org.jfree.data.statistics, + org.jfree.data.time, + org.jfree.data.time.ohlc, + org.jfree.data.xml, + org.jfree.data.xy, + org.jfree.date, + org.jfree.io, + org.jfree.layout, + org.jfree.resources, + org.jfree.text, + org.jfree.threads, + org.jfree.ui, + org.jfree.ui.about, + org.jfree.ui.about.resources, + org.jfree.ui.action, + org.jfree.ui.tabbedui, + org.jfree.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.w3.x2000.x09.xmldsig, + org.w3.x2000.x09.xmldsig.impl, + schemaorg_apache_xmlbeans.system.s8C3F193EE11A2F798ACF65489B9E6078, + schemaorg_apache_xmlbeans.system.sF1327CCA741569E70F9CA8C9AF9B44B2 +Import-Package: com.teamcenter.rac.schedule.commands.newschedule, + com.teamcenter.rac.schedule.plugin, + com.teamcenter.rac.schedule.project.sharedUtils, + com.teamcenter.rac.schedule.wizardpages, + com.teamcenter.rac.ui.commands.handlers, + org.apache.poi.xssf.usermodel, + org.dom4j, + org.dom4j.io diff --git a/bin/cn/net/connor/ml/plm/Activator.class b/bin/cn/net/connor/ml/plm/Activator.class new file mode 100644 index 0000000..ff0d211 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/Activator.class differ diff --git a/bin/cn/net/connor/ml/plm/AssignProductName/AssignPropertyTextField.class b/bin/cn/net/connor/ml/plm/AssignProductName/AssignPropertyTextField.class new file mode 100644 index 0000000..0eed54d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/AssignProductName/AssignPropertyTextField.class differ diff --git a/bin/cn/net/connor/ml/plm/CreateTimeSheet/CreateScheduleHandler.class b/bin/cn/net/connor/ml/plm/CreateTimeSheet/CreateScheduleHandler.class new file mode 100644 index 0000000..3650df6 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/CreateTimeSheet/CreateScheduleHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/KAction.class b/bin/cn/net/connor/ml/plm/KAction.class new file mode 100644 index 0000000..23397b9 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/KAction.class differ diff --git a/bin/cn/net/connor/ml/plm/KCommand.class b/bin/cn/net/connor/ml/plm/KCommand.class new file mode 100644 index 0000000..3085ada Binary files /dev/null and b/bin/cn/net/connor/ml/plm/KCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/KHandler.class b/bin/cn/net/connor/ml/plm/KHandler.class new file mode 100644 index 0000000..9b88790 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/KHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/KLocale.class b/bin/cn/net/connor/ml/plm/KLocale.class new file mode 100644 index 0000000..4bd0bea Binary files /dev/null and b/bin/cn/net/connor/ml/plm/KLocale.class differ diff --git a/bin/cn/net/connor/ml/plm/KOperation.class b/bin/cn/net/connor/ml/plm/KOperation.class new file mode 100644 index 0000000..72d80ea Binary files /dev/null and b/bin/cn/net/connor/ml/plm/KOperation.class differ diff --git a/bin/cn/net/connor/ml/plm/KOperation2.class b/bin/cn/net/connor/ml/plm/KOperation2.class new file mode 100644 index 0000000..3221d93 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/KOperation2.class differ diff --git a/bin/cn/net/connor/ml/plm/KUtil.class b/bin/cn/net/connor/ml/plm/KUtil.class new file mode 100644 index 0000000..3f0839a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/KUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/WBSExport/WBSExportCommand.class b/bin/cn/net/connor/ml/plm/WBSExport/WBSExportCommand.class new file mode 100644 index 0000000..174036a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/WBSExport/WBSExportCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/WBSExport/WBSExportOperation.class b/bin/cn/net/connor/ml/plm/WBSExport/WBSExportOperation.class new file mode 100644 index 0000000..2adb9f5 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/WBSExport/WBSExportOperation.class differ diff --git a/bin/cn/net/connor/ml/plm/aaaaa.class b/bin/cn/net/connor/ml/plm/aaaaa.class new file mode 100644 index 0000000..35f7248 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/aaaaa.class differ diff --git a/bin/cn/net/connor/ml/plm/beans/ImportBean.class b/bin/cn/net/connor/ml/plm/beans/ImportBean.class new file mode 100644 index 0000000..676c1f1 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/beans/ImportBean.class differ diff --git a/bin/cn/net/connor/ml/plm/beans/LOVBean.class b/bin/cn/net/connor/ml/plm/beans/LOVBean.class new file mode 100644 index 0000000..4da7154 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/beans/LOVBean.class differ diff --git a/bin/cn/net/connor/ml/plm/beans/ObjectFactory.class b/bin/cn/net/connor/ml/plm/beans/ObjectFactory.class new file mode 100644 index 0000000..5b6d6e0 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/beans/ObjectFactory.class differ diff --git a/bin/cn/net/connor/ml/plm/beans/Property.class b/bin/cn/net/connor/ml/plm/beans/Property.class new file mode 100644 index 0000000..e47e767 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/beans/Property.class differ diff --git a/bin/cn/net/connor/ml/plm/beans/Search.class b/bin/cn/net/connor/ml/plm/beans/Search.class new file mode 100644 index 0000000..5fd589e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/beans/Search.class differ diff --git a/bin/cn/net/connor/ml/plm/beans/Searchs.class b/bin/cn/net/connor/ml/plm/beans/Searchs.class new file mode 100644 index 0000000..3809e92 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/beans/Searchs.class differ diff --git a/bin/cn/net/connor/ml/plm/beans/TMomUserBean.class b/bin/cn/net/connor/ml/plm/beans/TMomUserBean.class new file mode 100644 index 0000000..03aa5fb Binary files /dev/null and b/bin/cn/net/connor/ml/plm/beans/TMomUserBean.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/RemoveBOM2Handler$1.class b/bin/cn/net/connor/ml/plm/bom/RemoveBOM2Handler$1.class new file mode 100644 index 0000000..fcd2c22 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/RemoveBOM2Handler$1.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/RemoveBOM2Handler.class b/bin/cn/net/connor/ml/plm/bom/RemoveBOM2Handler.class new file mode 100644 index 0000000..48b855c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/RemoveBOM2Handler.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/RemoveBOMHandler.class b/bin/cn/net/connor/ml/plm/bom/RemoveBOMHandler.class new file mode 100644 index 0000000..6129e55 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/RemoveBOMHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog$1.class b/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog$1.class new file mode 100644 index 0000000..ca8d9bb Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog$2.class b/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog$2.class new file mode 100644 index 0000000..9332f9b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog.class b/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog.class new file mode 100644 index 0000000..50807b6 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/UpdateDescDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateDescHandler.class b/bin/cn/net/connor/ml/plm/bom/UpdateDescHandler.class new file mode 100644 index 0000000..98e75cf Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/UpdateDescHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateDescHandler.java.bak b/bin/cn/net/connor/ml/plm/bom/UpdateDescHandler.java.bak new file mode 100644 index 0000000..7b8b5b7 --- /dev/null +++ b/bin/cn/net/connor/ml/plm/bom/UpdateDescHandler.java.bak @@ -0,0 +1,77 @@ +package cn.net.connor.ml.plm.bom; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateDescHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null || !(target instanceof TCComponentItemRevision)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ汾"); + return null; + } + TCComponentUser user = session.getUser(); + try { + TCComponent group = user.getRelatedComponent("login_group"); + + String group_name = group.getProperty("object_string"); + System.out.println("group_name=" + group_name); + if (group_name.contains("dba")) { + new Thread(new UpdateDescDialog(app, target, session)).start(); + return null; + } + + TCComponent[] tasks = target.getRelatedComponents("fnd0StartedWorkflowTasks"); + if (tasks == null || tasks.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ûҵ̶"); + return null; + } + String task_name = KUtil.getPrefVal(session, "Meling_task_name2"); + + 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) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ϿΪգ"); + return null; + } + user_name = users[0].getRelatedComponent("fnd0Performer").getProperty("user_id"); + } + } + if (!flag) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ڵƲƥ䣡"); + return null; + } + + String userName = user.getProperty("user_id"); + if (!userName.equals(user_name)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "Ͽ뵱ǰ¼ûƥ䣡"); + return null; + } + + new Thread(new UpdateDescDialog(app, target, session)).start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateDescOperation.class b/bin/cn/net/connor/ml/plm/bom/UpdateDescOperation.class new file mode 100644 index 0000000..c037512 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/UpdateDescOperation.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateQuantityDialog.class b/bin/cn/net/connor/ml/plm/bom/UpdateQuantityDialog.class new file mode 100644 index 0000000..7042fa5 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/UpdateQuantityDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/bom/UpdateQuantityHandler.class b/bin/cn/net/connor/ml/plm/bom/UpdateQuantityHandler.class new file mode 100644 index 0000000..4ffc511 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/bom/UpdateQuantityHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/createProject/CreateProjectCommand.class b/bin/cn/net/connor/ml/plm/createProject/CreateProjectCommand.class new file mode 100644 index 0000000..f71f361 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/createProject/CreateProjectCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ConditionMapper.class b/bin/cn/net/connor/ml/plm/exportExcel/ConditionMapper.class new file mode 100644 index 0000000..a6770f5 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ConditionMapper.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel1Command.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel1Command.class new file mode 100644 index 0000000..b4899a9 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel1Command.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel1Dialog.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel1Dialog.class new file mode 100644 index 0000000..218791a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel1Dialog.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel2Command.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel2Command.class new file mode 100644 index 0000000..da4d3ab Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel2Command.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel2Operation.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel2Operation.class new file mode 100644 index 0000000..999bf3f Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel2Operation.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel3Command.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel3Command.class new file mode 100644 index 0000000..b6cd6b9 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel3Command.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel3Operation.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel3Operation.class new file mode 100644 index 0000000..5fae7b5 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel3Operation.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel4Command.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel4Command.class new file mode 100644 index 0000000..a68bf42 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel4Command.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel4Operation.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel4Operation.class new file mode 100644 index 0000000..fdee701 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcel4Operation.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelCommand6.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelCommand6.class new file mode 100644 index 0000000..897e0db Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelCommand6.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$1.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$1.class new file mode 100644 index 0000000..513bf5b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$1.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$2.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$2.class new file mode 100644 index 0000000..7f32d77 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$2.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$3.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$3.class new file mode 100644 index 0000000..8106d9c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6$3.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6.class new file mode 100644 index 0000000..b646b42 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son$1.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son$1.class new file mode 100644 index 0000000..13ab3ad Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son$1.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son$2.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son$2.class new file mode 100644 index 0000000..1a43c3d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son$2.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son.class new file mode 100644 index 0000000..33f1fc4 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelUtil.class b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelUtil.class new file mode 100644 index 0000000..95b4e14 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/ExportExcelUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/TCUtil.class b/bin/cn/net/connor/ml/plm/exportExcel/TCUtil.class new file mode 100644 index 0000000..b91e621 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/TCUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportHandler.class b/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportHandler.class new file mode 100644 index 0000000..70fd39e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.class b/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.class new file mode 100644 index 0000000..370898c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.class differ diff --git a/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java.bak20230927 b/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java.bak20230927 new file mode 100644 index 0000000..932e14f --- /dev/null +++ b/bin/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java.bak20230927 @@ -0,0 +1,269 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Properties; + +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.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +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 cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.getSpecifications.SqlUtil; + +public class UsedbyProductReportOperation extends AbstractAIFOperation { + + private TCSession session; + private TCComponentItemRevision target; + private TCComponentDataset model; + private XSSFRow sourceRow; + private ArrayList ulist; + + public UsedbyProductReportOperation(TCSession session, TCComponentItemRevision target, TCComponentDataset model) { + this.session = session; + this.target = target; + this.model = model; + } + + @Override + public void executeOperation() throws Exception { + AIFDesktop desktop = AIFUtility.getActiveDesktop(); + FileInputStream input = null; + FileOutputStream output = null; + try { + KUtil.setByPass(true); + if (!getParents(target)) { + return; + } + Date now = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + File directory = TCUtil.saveExcelChooser(target.getProperty("item_id")+"_"+"ʹڻ嵥" + sdf.format(now),target.getStringProperty("item_id")); + if (directory == null) + return; + if (directory.exists()) + directory.delete(); + String path = directory.getPath(); + + TCComponentTcFile[] files = model.getTcFiles(); + File file = files[0].getFile(System.getProperty("java.io.tmpdir")); + input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + + int i = 2; + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow row; + XSSFCell cell; + sourceRow = getRow(sheet, i); + for (TCComponent c : ulist) { + row = getRow(sheet, i); + cell = getCell(row, 0); + cell.setCellValue(i - 1);// + cell = getCell(row, 1); + cell.setCellValue(c.getProperty("item_id"));// ϴ + cell = getCell(row, 2); + cell.setCellValue(c.getProperty("object_name"));// Ʒ + cell = getCell(row, 3); + cell.setCellValue(c.getProperty("object_desc"));// + cell = getCell(row, 4); + cell.setCellValue(c.getProperty("ml8_SalesMode").equals("ڶ") ? "" : "");// Ƿڶ + cell = getCell(row, 5); + cell.setCellValue(c.getProperty("item_revision_id"));// 汾 +// TCComponent[] relateds1 = c.getRelatedComponents("release_status_list"); +// if (relateds1.length > 0 && relateds1[0].getProperty("object_name").equals("ȡ")) { +// cell.setCellValue("");// Ƿȡ +// } else { +// cell.setCellValue("");// Ƿȡ +// } + TCComponent[] relateds2 = c.getRelatedComponents("ML8_ProjectRelation"); + if (relateds2.length > 0) { + cell = getCell(row, 7); + cell.setCellValue(relateds2[0].getProperty("ml8_ProductCode"));// Ʒ + cell = getCell(row, 8); + cell.setCellValue(relateds2[0].getProperty("ml8_ProductType"));// Ʒͺ + } else { + cell = getCell(row, 7); + cell.setCellValue("");// Ʒ + cell = getCell(row, 8); + cell.setCellValue("");// Ʒͺ + } + cell = getCell(row, 9); + cell.setCellValue(c.getProperty("ml8_NativeProducts"));// ԭƷ + cell = getCell(row, 10); + cell.setCellValue(c.getProperty("ml8_ProductCode"));// ʷƷ + cell = getCell(row, 11); + cell.setCellValue(c.getProperty("ml8_ProductType"));// ʷƷͺ + cell = getCell(row, 12); + cell.setCellValue(c.getProperty("release_status_list"));// Ʒ״̬ + + cell = getCell(row, 6); + cell.setCellFormula(cell.getCellFormula()); + i++; + } + + output = new FileOutputStream(file.getPath()); + wb.write(output); + wb.close(); + input.close(); + output.close(); +// System.out.println("file:"+file.getPath()); + String newPath = System.getProperty("java.io.tmpdir") + path.substring(path.lastIndexOf("\\")); + File reFile = new File(newPath); + file.renameTo(reFile); +// System.out.println("new directory:"+reFile.getPath()); + reFile.renameTo(directory); + + MessageBox.post(desktop, "", "INFO", MessageBox.INFORMATION); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(desktop, "" + e.getMessage(), "ERROR", MessageBox.ERROR); + } finally { + KUtil.setByPass(false); + if (input != null) + input.close(); + if (output != null) + output.close(); + } + } + + 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); + if (row.getRowNum() > 2) + cell.setCellStyle(getCell(sourceRow, col).getCellStyle()); + return cell; + } +// private List list=new ArrayList(); + +// private void getUsedParents(TCComponent[] whereUsed,Map map,String uid) throws TCException { +// for(TCComponent component:whereUsed) { +// if(component instanceof TCComponentItemRevision) { +// TCComponentItemRevision revision=(TCComponentItemRevision) component; +// String status = revision.getProperty("release_status_list"); +// map.put(revision, uid); +// if(status!=null && !status.equals("ML8_Replaced")&&!status.equals("ȡ")) { +// System.out.println("revision"+revision.getStringProperty("object_string")); +// TCComponent[] whereUsed2 = revision.whereUsed((short) 0); +// +// for(TCComponent component2:whereUsed2) { +// if(component2 instanceof TCComponentItemRevision) { +// map.put((TCComponentItemRevision) component2, uid); +// TCComponent[] whereUsed3 = component2.whereUsed((short) 0); +// getUsedParents(whereUsed3,map,uid); +// } +// } +// } +// } +// } +// } + + private boolean getParents(TCComponentItemRevision target) throws Exception { + String uid = target.getItem().getUid(); + +// TCComponent[] whereUsed = target.whereUsed((short) 0); +// Map map=new HashedMap (); +// +// getUsedParents(whereUsed,map,uid); + + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return false; + } + InputStream in = UsedbyProductReportOperation.class.getResourceAsStream("/plm.properties"); + Properties p = new Properties(); + p.load(in); + String sql = p.getProperty("EXCEL5.SQL"); + ResultSet rs = SqlUtil.read(sql, new String[] { uid }); + ulist = new ArrayList(); + while (rs.next()) { + String id = rs.getString(2); + try { + TCComponentItemRevision topRev = (TCComponentItemRevision) session.stringToComponent(id); + System.out.println("ҵ汾"+topRev); + System.out.println("ҵ汾"); + String item_id = topRev.getProperty("item_id"); + System.out.println("id="+item_id); + TCComponent[] releaselist = topRev.getReferenceListProperty("release_status_list"); + if (item_id.startsWith("ML") && !item_id.contains("-")) { + if(releaselist==null||releaselist.length==0) { + ulist.add(topRev); + System.out.println(topRev+"ûз״̬excel"); + } +// else { +// boolean is_Replaced = false; +// for(TCComponent comp2:releaselist) { +// System.out.println(topRev+"ķ״̬Ϊ"+comp2.getStringProperty("object_name")); +// if(comp2.getStringProperty("object_name").equals("ML8_Replaced")) { +// is_Replaced = true; +// break; +// } +// } +// if(!is_Replaced) { +// System.out.println(topRev+"״̬DZȡexcel"); +// ulist.add(topRev); +// } +// } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + String sql2 = p.getProperty("EXCEL6.SQL"); + ResultSet rs2 = SqlUtil.read(sql2, new String[] { uid }); +// ulist = new ArrayList(); + while (rs2.next()) { + String id = rs2.getString(2); + try { + TCComponentItemRevision topRev = (TCComponentItemRevision) session.stringToComponent(id); + System.out.println("ҵ汾"+topRev); + String item_id = topRev.getProperty("item_id"); + System.out.println("id="+item_id); + if (item_id.startsWith("ML") && !item_id.contains("-")) { + ulist.add(topRev); + System.out.println(topRev+"excel"); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + + + + SqlUtil.free(); + if (ulist.size() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿѯΪգ", "", MessageBox.INFORMATION); + return false; + } + return true; + } +} diff --git a/bin/cn/net/connor/ml/plm/getFolder/GetFolderCommand.class b/bin/cn/net/connor/ml/plm/getFolder/GetFolderCommand.class new file mode 100644 index 0000000..151cdfc Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getFolder/GetFolderCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog$1.class b/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog$1.class new file mode 100644 index 0000000..1009364 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog$2.class b/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog$2.class new file mode 100644 index 0000000..944a17a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog.class b/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog.class new file mode 100644 index 0000000..0952cfc Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getFolder/GetFolderDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.class b/bin/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.class new file mode 100644 index 0000000..31463a2 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java.bak20250116 b/bin/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java.bak20250116 new file mode 100644 index 0000000..62cb7fd --- /dev/null +++ b/bin/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java.bak20250116 @@ -0,0 +1,101 @@ +package cn.net.connor.ml.plm.getPropertyByDesign; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; + +public class GetPropertyByDesignHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡϰ汾"); + return null; + } + String type = target.getType(); + if (!"ML8_RefrigeratorRevision|ML8_PartRevision|ML8_ColdRevision|ML8_WashingRevision|ML8_OthersRevision".contains(type)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡϰ汾"); + return null; + } + TCSession session = (TCSession) app.getSession(); + String[] props = session.getPreferenceService().getStringValues("Meling_Design_To_Part"); + if (props == null || props.length < 1) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ[Meling_Design_To_Part]"); + return null; + } + try { + TCComponentItemRevision related = (TCComponentItemRevision) target.getRelatedComponent("TC_Is_Represented_By"); + if (related == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ṩΪգ"); + return null; + } + TCComponentItemRevision rev = related.getItem().getLatestItemRevision(); + if (rev.getRelatedComponents("release_status_list").length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "µư汾ûз"); + return null; + } + + for (String prop : props) { + String[] d2p = prop.split("="); + if (d2p == null || d2p.length != 2) { + System.out.println("ѡ[Meling_Design_To_Part]\n" + prop); +// KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ[Meling_Design_To_Part]\n" + prop); + continue; + } + System.out.println("2023/1/10УĿ״̬"); + TCComponent[] release_status_list = target.getReferenceListProperty("release_status_list"); + TCComponent[] fnd0StartedWorkflowTasks = target.getReferenceListProperty("fnd0StartedWorkflowTasks"); + + if(release_status_list!=null&&release_status_list.length>0) { + throw new Exception(target+"ѷ"); + }else if(fnd0StartedWorkflowTasks!=null&&fnd0StartedWorkflowTasks.length>0) { + throw new Exception(target+""); + }else { + KUtil.setByPass(true); + try { + target.setProperty(d2p[1], rev.getProperty(d2p[0])); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.info(AIFDesktop.getActiveDesktop(), "ͬԳ\n" + e.getMessage()); + return null; + } + KUtil.info(AIFDesktop.getActiveDesktop(), "ͬɹ"); + return null; + } + /** + * existFile:ǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public boolean checkAccessPrivilige(TCSession session, TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } +} diff --git a/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsCommand.class b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsCommand.class new file mode 100644 index 0000000..d2d71dd Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog$1.class b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog$1.class new file mode 100644 index 0000000..a369ff7 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.class b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.class new file mode 100644 index 0000000..d438a9e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java.bak b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java.bak new file mode 100644 index 0000000..4a2ed90 --- /dev/null +++ b/bin/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java.bak @@ -0,0 +1,188 @@ +package cn.net.connor.ml.plm.getSpecifications; + +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.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; + +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; + +public class GetSpecificationsDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + private TCComponent target; + private JButton query; + private JTextField field; + private DefaultListModel model; + private TCSession session; + + public GetSpecificationsDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + if (!init()) { + return; + } + initUI(); + addListeners(); + showDialog(); + } + + private boolean init() { + target = (TCComponent) app.getTargetComponent(); + if (target != null && target.getType().equals("ML8_PartRevision")) { + return true; + } else { + KUtil.info(GetSpecificationsDialog.this, "ѡ㲿汾"); + return false; + } + } + + private void addListeners() { + this.query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { +// String prop = target.getProperty("ml8_Specifications"); + String parm = field.getText().trim(); + if (parm.equals("")) { + KUtil.info(GetSpecificationsDialog.this, "ѯΪգ"); + return; + } +// Connection conn = SqlUtil.getSqlserverConnection(); + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + disposeDialog(); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return; + } + // SELECT pml8_Specifications FROM PML8_PARTREVISION where pml8_Specifications + // like '%' ORDER BY pml8_Specifications DESC; + parm = parm + "%"; +// int i1 = parm.indexOf("."); + int i2 = parm.indexOf("("); + if (i2 < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯʽ", "", MessageBox.INFORMATION); + return; + } + String left = parm.split("\\(")[0]; + int i1 = left.lastIndexOf("."); + if (i1 < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯʽ", "", MessageBox.INFORMATION); + return; + } + parm = parm.substring(0, i1 + 1) + "%" + parm.substring(i2); + ResultSet rs = SqlUtil.read( + "SELECT pml8_Specifications FROM PML8_PARTREVISION where pml8_Specifications like ? ORDER BY pml8_Specifications DESC;", + new String[] { parm }); + model.removeAllElements(); + Integer bigNumber = 0; + String bigStr = ""; + while (rs.next()) { + String str = rs.getString(1); +// int i11 = str.indexOf(".("); + int i22 = str.indexOf("("); + String leftleft = str.split("\\(")[0]; + int i11 = leftleft.lastIndexOf("."); + + if ((i11 + 1) == i22) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯ쳣ݣ[" + str + "]", "", MessageBox.INFORMATION); + continue; + } + + Integer temp = Integer.valueOf(str.substring(i11 + 1, i22)); + bigNumber = bigNumber > temp ? bigNumber : temp; + bigStr = str.substring(0, i11 + 1) + (bigNumber + 1) + str.substring(i22); + model.addElement(str); + } + bigNumber++; + System.out.println("bigStr=" + bigStr); + SqlUtil.free(); + if (model.getSize() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯΪգ", "", MessageBox.INFORMATION); + return; + } + setModel(bigStr); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ִг쳣\n" + e1, "", MessageBox.INFORMATION); + } + } + }); + } + + protected void setModel(String str) throws TCException { +// int i1 = str.indexOf("."); +// int i2 = str.indexOf("("); +// +// int big = Integer.valueOf(str.substring(i1 + 1, i2)) + 1; +// str = str.substring(0, i1 + 1) + big + str.substring(i2); +// System.out.println(str); + int yesOrNo = JOptionPane.showConfirmDialog(null, "Ƿ[" + str + "]Թͺϣ", "", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + target.setProperty("ml8_Specifications", str); + } else { + // 1 + } + } + + private void initUI() { + this.setMinimumSize(new Dimension(200, 100)); + this.setLayout(new BorderLayout(20, 5)); + this.add(BorderLayout.NORTH, initQueryPanel()); + this.add(BorderLayout.CENTER, initListPanel()); + } + + private Component initListPanel() { + model = new DefaultListModel(); + JList list = new JList(model); + JScrollPane pane = new JScrollPane(list); + return pane; + } + + private Component initQueryPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + + JLabel label = new JLabel("ͺţ"); + try { + field = new JTextField(target.getProperty("ml8_Specifications")); + } catch (TCException e) { + e.printStackTrace(); + } + field.setPreferredSize(new Dimension(100, 25)); + query = new JButton("ѯ"); + panel.add(label); + panel.add(field); + panel.add(query); + return panel; + } +} diff --git a/bin/cn/net/connor/ml/plm/getSpecifications/SqlUtil.class b/bin/cn/net/connor/ml/plm/getSpecifications/SqlUtil.class new file mode 100644 index 0000000..25b1bc4 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/getSpecifications/SqlUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/getSpecifications/getSpecifications.properties b/bin/cn/net/connor/ml/plm/getSpecifications/getSpecifications.properties new file mode 100644 index 0000000..7120aee --- /dev/null +++ b/bin/cn/net/connor/ml/plm/getSpecifications/getSpecifications.properties @@ -0,0 +1,24 @@ +SQL.URL=jdbc:sqlserver://10.128.10.50:1433;DatabaseName=Basedb_2012 +SQL.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver +SQL.USER=PLMUser +SQL.PASSWORD=PLMUser + +SQL.TCDATA.URL=jdbc:oracle:thin:@192.168.0.103:1521:TC +SQL.TCDATA.DRIVER=oracle.jdbc.driver.OracleDriver +SQL.TCDATA.USER=infodba +SQL.TCDATA.PASSWORD=infodba + +SQL.TEMPLATE_TREE=select t.PmpcCode, t.PmpcCompanyCode, t.PmpcName, t.PmpcUpperCode, t.PmpcItem, t.PmpcPrhCode, t.PmpcEnd from CcemVW_Pmpc t; +SQL.TEMPLATE=select t.PrhName,t.PrdLine,t.PrdNo,t.PrdFeatureCode,t.FeatureName,t.PrdCanInput,t.PrdRightSign from CcemVW_Prd t where t.prhcode = ? order by t.PrdNo +SQL.LOV=select t.PrddNo,t.PrddFeatureCode,t.PrddValue from CcemVW_Prdd t where t.PrddDisabled=0 and t.PrddCode = ? and PrddLine = ? order by t.PrddNo + +DATARELEASE.CHECKPROP=s8WSOType +DATARELEASE.RELEASESTATUS=S81Delivered +DATARELEASE.OTHER=����Ʒ�� +DATARELEASE.ROLE=�Ŀ�רԱ +DATARECEIVE.GROUP=���ݽ����� + +SQL.SQLSERVER.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver +SQL.SQLSERVER.URL=jdbc:sqlserver://192.168.220.129:1433;DatabaseName=TC13 +SQL.SQLSERVER.USER=infodba +SQL.SQLSERVER.PASSWORD=infodba \ No newline at end of file diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$1.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$1.class new file mode 100644 index 0000000..0a19922 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$2.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$2.class new file mode 100644 index 0000000..816cccf Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$3.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$3.class new file mode 100644 index 0000000..59a46fe Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$4.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$4.class new file mode 100644 index 0000000..91211a0 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$4.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$5.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$5.class new file mode 100644 index 0000000..d73f5df Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$5.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$6.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$6.class new file mode 100644 index 0000000..88747b5 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$6.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$7.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$7.class new file mode 100644 index 0000000..18aafba Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$7.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$8.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$8.class new file mode 100644 index 0000000..3dd352b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog$8.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog.class new file mode 100644 index 0000000..b76f690 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler$1.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler$1.class new file mode 100644 index 0000000..20c952f Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler$1.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler.class b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler.class new file mode 100644 index 0000000..f7635c2 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/CommonUtil.class b/bin/cn/net/connor/ml/plm/gotoQMS/CommonUtil.class new file mode 100644 index 0000000..3da6983 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/CommonUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/DbPool.class b/bin/cn/net/connor/ml/plm/gotoQMS/DbPool.class new file mode 100644 index 0000000..45605fd Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/DbPool.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/GotoQMSHandler.class b/bin/cn/net/connor/ml/plm/gotoQMS/GotoQMSHandler.class new file mode 100644 index 0000000..69302da Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/GotoQMSHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/HttpUtil.class b/bin/cn/net/connor/ml/plm/gotoQMS/HttpUtil.class new file mode 100644 index 0000000..3a472ff Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/HttpUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil$1.class b/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil$1.class new file mode 100644 index 0000000..159802a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil$1.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil$2.class b/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil$2.class new file mode 100644 index 0000000..eafd36e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil$2.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil.class b/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil.class new file mode 100644 index 0000000..3d1e71d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/gotoQMS/TCUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/gotoQMS/sql.properties b/bin/cn/net/connor/ml/plm/gotoQMS/sql.properties new file mode 100644 index 0000000..8c21d90 --- /dev/null +++ b/bin/cn/net/connor/ml/plm/gotoQMS/sql.properties @@ -0,0 +1,2 @@ +ML_WEBSERVICE_LOGINSERTSQL=INSERT INTO ML_WEBSERVICE_LOG 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/bin/cn/net/connor/ml/plm/gotoQMS/sqlconn.properties b/bin/cn/net/connor/ml/plm/gotoQMS/sqlconn.properties new file mode 100644 index 0000000..a9f980b --- /dev/null +++ b/bin/cn/net/connor/ml/plm/gotoQMS/sqlconn.properties @@ -0,0 +1,4 @@ +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/bin/cn/net/connor/ml/plm/implementRate/ImplementRateCommand.class b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateCommand.class new file mode 100644 index 0000000..e914825 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$1.class b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$1.class new file mode 100644 index 0000000..a843bf0 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$2.class b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$2.class new file mode 100644 index 0000000..b81d46b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$3.class b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$3.class new file mode 100644 index 0000000..a4688ab Binary files /dev/null and b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog.class b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog.class new file mode 100644 index 0000000..05b397b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialogController.class b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialogController.class new file mode 100644 index 0000000..8bae13c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/implementRate/ImplementRateDialogController.class differ diff --git a/bin/cn/net/connor/ml/plm/k_locale.properties b/bin/cn/net/connor/ml/plm/k_locale.properties new file mode 100644 index 0000000..ac8931f --- /dev/null +++ b/bin/cn/net/connor/ml/plm/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/bin/cn/net/connor/ml/plm/k_locale_zh_CN.properties b/bin/cn/net/connor/ml/plm/k_locale_zh_CN.properties new file mode 100644 index 0000000..902d489 --- /dev/null +++ b/bin/cn/net/connor/ml/plm/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/bin/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseCommand.class b/bin/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseCommand.class new file mode 100644 index 0000000..80dcada Binary files /dev/null and b/bin/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseOperation.class b/bin/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseOperation.class new file mode 100644 index 0000000..4bbb00e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseOperation.class differ diff --git a/bin/cn/net/connor/ml/plm/melingSectrum/MelingSectrumCommand.class b/bin/cn/net/connor/ml/plm/melingSectrum/MelingSectrumCommand.class new file mode 100644 index 0000000..011c3bb Binary files /dev/null and b/bin/cn/net/connor/ml/plm/melingSectrum/MelingSectrumCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/melingSectrum/MelingSectrumOperation.class b/bin/cn/net/connor/ml/plm/melingSectrum/MelingSectrumOperation.class new file mode 100644 index 0000000..f21d336 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/melingSectrum/MelingSectrumOperation.class differ diff --git a/bin/cn/net/connor/ml/plm/modelImport/ModelImportCommand.class b/bin/cn/net/connor/ml/plm/modelImport/ModelImportCommand.class new file mode 100644 index 0000000..9d89b3f Binary files /dev/null and b/bin/cn/net/connor/ml/plm/modelImport/ModelImportCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/modelImport/ModelImportOperation.class b/bin/cn/net/connor/ml/plm/modelImport/ModelImportOperation.class new file mode 100644 index 0000000..073700e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/modelImport/ModelImportOperation.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog$1.class b/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog$1.class new file mode 100644 index 0000000..daf619b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog$2.class b/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog$2.class new file mode 100644 index 0000000..8d8fb93 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog.class b/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog.class new file mode 100644 index 0000000..da5701d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/AddUserDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/Constant.class b/bin/cn/net/connor/ml/plm/planningPanel/Constant.class new file mode 100644 index 0000000..4489f33 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/Constant.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/MultiColumnTableRowSorter.class b/bin/cn/net/connor/ml/plm/planningPanel/MultiColumnTableRowSorter.class new file mode 100644 index 0000000..831b366 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/MultiColumnTableRowSorter.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/MutilColumnTableCellHeaderRenderer.class b/bin/cn/net/connor/ml/plm/planningPanel/MutilColumnTableCellHeaderRenderer.class new file mode 100644 index 0000000..07f914e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/MutilColumnTableCellHeaderRenderer.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelCommand.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelCommand.class new file mode 100644 index 0000000..c46b28d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$1.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$1.class new file mode 100644 index 0000000..d75024b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$2.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$2.class new file mode 100644 index 0000000..92e666b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$3.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$3.class new file mode 100644 index 0000000..3b92849 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$4.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$4.class new file mode 100644 index 0000000..5e01caa Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$4.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$5.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$5.class new file mode 100644 index 0000000..14d0b52 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$5.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$6.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$6.class new file mode 100644 index 0000000..9c470b8 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$6.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$7.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$7.class new file mode 100644 index 0000000..542b63d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$7.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$8.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$8.class new file mode 100644 index 0000000..28e2994 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$8.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$9.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$9.class new file mode 100644 index 0000000..e5d672b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog$9.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog.class new file mode 100644 index 0000000..11c7ec5 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialogController.class b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialogController.class new file mode 100644 index 0000000..3e56bcb Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialogController.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$1.class b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$1.class new file mode 100644 index 0000000..b603c84 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$2.class b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$2.class new file mode 100644 index 0000000..15cf42e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$3.class b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$3.class new file mode 100644 index 0000000..7c900cf Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$4.class b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$4.class new file mode 100644 index 0000000..c9322b7 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog$4.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog.class b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog.class new file mode 100644 index 0000000..c2d7cc7 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar$1.class b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar$1.class new file mode 100644 index 0000000..4af8971 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar$1.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar$TaskThread.class b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar$TaskThread.class new file mode 100644 index 0000000..c8131dd Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar$TaskThread.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar.class b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar.class new file mode 100644 index 0000000..d41d6b6 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBar.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/ProgressBarThread.class b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBarThread.class new file mode 100644 index 0000000..81ff035 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/ProgressBarThread.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/SorterColumnGroupUtil.class b/bin/cn/net/connor/ml/plm/planningPanel/SorterColumnGroupUtil.class new file mode 100644 index 0000000..e161977 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/SorterColumnGroupUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/Constant.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/Constant.class new file mode 100644 index 0000000..b225c76 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/Constant.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/SorterColumnGroupUtil.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/SorterColumnGroupUtil.class new file mode 100644 index 0000000..3f943f2 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/SorterColumnGroupUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/SorterUtil.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/SorterUtil.class new file mode 100644 index 0000000..a7aee2e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/SorterUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableHeaderButton.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableHeaderButton.class new file mode 100644 index 0000000..714281f Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableHeaderButton.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$1.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$1.class new file mode 100644 index 0000000..db06e31 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$1.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$2.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$2.class new file mode 100644 index 0000000..9c3feb9 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$2.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$3.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$3.class new file mode 100644 index 0000000..f2ce2b0 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table$3.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table.class new file mode 100644 index 0000000..c2a6ad1 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3TableMode.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3TableMode.class new file mode 100644 index 0000000..2edc6c8 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3TableMode.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test$1.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test$1.class new file mode 100644 index 0000000..adfafb7 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test$1.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test.class new file mode 100644 index 0000000..77cfb46 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrderSorter.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrderSorter.class new file mode 100644 index 0000000..28dfe7a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrderSorter.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable/User.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/User.class new file mode 100644 index 0000000..22a0ef9 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable/User.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/MultiColumnTableRowSorter.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/MultiColumnTableRowSorter.class new file mode 100644 index 0000000..1064050 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/MultiColumnTableRowSorter.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/MutilColumnTableCellHeaderRenderer.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/MutilColumnTableCellHeaderRenderer.class new file mode 100644 index 0000000..cb6f76a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/MutilColumnTableCellHeaderRenderer.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$1.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$1.class new file mode 100644 index 0000000..77c25d1 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$1.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$2.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$2.class new file mode 100644 index 0000000..3c3c91e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$2.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$3.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$3.class new file mode 100644 index 0000000..c288b4a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$3.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$4.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$4.class new file mode 100644 index 0000000..a5705a3 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo$4.class differ diff --git a/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo.class b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo.class new file mode 100644 index 0000000..b7dee61 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$1.class b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$1.class new file mode 100644 index 0000000..5c82b65 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$2.class b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$2.class new file mode 100644 index 0000000..11f154d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$3.class b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$3.class new file mode 100644 index 0000000..d557881 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog.class b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog.class new file mode 100644 index 0000000..beb66cf Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleCommand.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleCommand.class new file mode 100644 index 0000000..1a4b9fe Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$1.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$1.class new file mode 100644 index 0000000..f75cd40 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$2.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$2.class new file mode 100644 index 0000000..ebdfb73 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$3.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$3.class new file mode 100644 index 0000000..11ff91f Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$4.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$4.class new file mode 100644 index 0000000..e48fe02 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$4.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$5.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$5.class new file mode 100644 index 0000000..7d5719c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog$5.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog.class new file mode 100644 index 0000000..6e50028 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController$1.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController$1.class new file mode 100644 index 0000000..9bb1949 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController$1.class differ diff --git a/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController.class b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController.class new file mode 100644 index 0000000..18eff1b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController.class differ diff --git a/bin/cn/net/connor/ml/plm/refreshRev/RefreshRevAction.class b/bin/cn/net/connor/ml/plm/refreshRev/RefreshRevAction.class new file mode 100644 index 0000000..3fdf48b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/refreshRev/RefreshRevAction.class differ diff --git a/bin/cn/net/connor/ml/plm/refreshRev/RefreshRevHandler.class b/bin/cn/net/connor/ml/plm/refreshRev/RefreshRevHandler.class new file mode 100644 index 0000000..29af5dd Binary files /dev/null and b/bin/cn/net/connor/ml/plm/refreshRev/RefreshRevHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/G4MDialog$MyG4MContext.class b/bin/cn/net/connor/ml/plm/saveAs/G4MDialog$MyG4MContext.class new file mode 100644 index 0000000..69e6664 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/G4MDialog$MyG4MContext.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/G4MDialog$MyG4MPanel.class b/bin/cn/net/connor/ml/plm/saveAs/G4MDialog$MyG4MPanel.class new file mode 100644 index 0000000..183c71c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/G4MDialog$MyG4MPanel.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/G4MDialog.class b/bin/cn/net/connor/ml/plm/saveAs/G4MDialog.class new file mode 100644 index 0000000..2b4f9b8 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/G4MDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/SaveAsCommand.class b/bin/cn/net/connor/ml/plm/saveAs/SaveAsCommand.class new file mode 100644 index 0000000..abc804b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/SaveAsCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$1.class b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$1.class new file mode 100644 index 0000000..f69e3a8 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$2.class b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$2.class new file mode 100644 index 0000000..be858c9 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$3.class b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$3.class new file mode 100644 index 0000000..5cf3161 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$4.class b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$4.class new file mode 100644 index 0000000..1cceb25 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog$4.class differ diff --git a/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog.class b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog.class new file mode 100644 index 0000000..b8c33a7 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/saveAs/SaveAsDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/tcm/TCM01Command.class b/bin/cn/net/connor/ml/plm/tcm/TCM01Command.class new file mode 100644 index 0000000..fb55f9c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/tcm/TCM01Command.class differ diff --git a/bin/cn/net/connor/ml/plm/tcm/TCM01Operation.class b/bin/cn/net/connor/ml/plm/tcm/TCM01Operation.class new file mode 100644 index 0000000..79877da Binary files /dev/null and b/bin/cn/net/connor/ml/plm/tcm/TCM01Operation.class differ diff --git a/bin/cn/net/connor/ml/plm/test/BigDecimalUtils.class b/bin/cn/net/connor/ml/plm/test/BigDecimalUtils.class new file mode 100644 index 0000000..e373f73 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/BigDecimalUtils.class differ diff --git a/bin/cn/net/connor/ml/plm/test/CheckHandler.class b/bin/cn/net/connor/ml/plm/test/CheckHandler.class new file mode 100644 index 0000000..8a86d87 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/CheckHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ScreenShotTest$1.class b/bin/cn/net/connor/ml/plm/test/ScreenShotTest$1.class new file mode 100644 index 0000000..7d9532d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ScreenShotTest$1.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ScreenShotTest.class b/bin/cn/net/connor/ml/plm/test/ScreenShotTest.class new file mode 100644 index 0000000..7298615 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ScreenShotTest.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ScreenShotWindow$1.class b/bin/cn/net/connor/ml/plm/test/ScreenShotWindow$1.class new file mode 100644 index 0000000..0e15a58 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ScreenShotWindow$1.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ScreenShotWindow$2.class b/bin/cn/net/connor/ml/plm/test/ScreenShotWindow$2.class new file mode 100644 index 0000000..a9682d0 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ScreenShotWindow$2.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ScreenShotWindow.class b/bin/cn/net/connor/ml/plm/test/ScreenShotWindow.class new file mode 100644 index 0000000..d8b4f05 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ScreenShotWindow.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ToolsWindow$1.class b/bin/cn/net/connor/ml/plm/test/ToolsWindow$1.class new file mode 100644 index 0000000..8616108 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ToolsWindow$1.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ToolsWindow$2.class b/bin/cn/net/connor/ml/plm/test/ToolsWindow$2.class new file mode 100644 index 0000000..a84f38f Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ToolsWindow$2.class differ diff --git a/bin/cn/net/connor/ml/plm/test/ToolsWindow.class b/bin/cn/net/connor/ml/plm/test/ToolsWindow.class new file mode 100644 index 0000000..1ba6816 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/test/ToolsWindow.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog$MyG4MContext.class b/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog$MyG4MContext.class new file mode 100644 index 0000000..3aa03fe Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog$MyG4MContext.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog$MyG4MPanel.class b/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog$MyG4MPanel.class new file mode 100644 index 0000000..3c93f71 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog$MyG4MPanel.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog.class b/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog.class new file mode 100644 index 0000000..715b6cd Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDesignName/G4MDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDesignName/UpdateDesignNameCommand.class b/bin/cn/net/connor/ml/plm/updateDesignName/UpdateDesignNameCommand.class new file mode 100644 index 0000000..540b264 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDesignName/UpdateDesignNameCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDesignProperty/UpdateDesignPropertyHandler.class b/bin/cn/net/connor/ml/plm/updateDesignProperty/UpdateDesignPropertyHandler.class new file mode 100644 index 0000000..f269676 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDesignProperty/UpdateDesignPropertyHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateCommand.class b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateCommand.class new file mode 100644 index 0000000..3a7cfb0 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateCommand.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog$1.class b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog$1.class new file mode 100644 index 0000000..b65fb4b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog$2.class b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog$2.class new file mode 100644 index 0000000..03ba066 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog.class b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog.class new file mode 100644 index 0000000..d8349cb Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$1.class b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$1.class new file mode 100644 index 0000000..6e676d6 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$1.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$2.class b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$2.class new file mode 100644 index 0000000..cf471d2 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$2.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$3.class b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$3.class new file mode 100644 index 0000000..1635797 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$3.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$4.class b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$4.class new file mode 100644 index 0000000..a9f60c2 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$4.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$5.class b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$5.class new file mode 100644 index 0000000..a11becb Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog$5.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog.class b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog.class new file mode 100644 index 0000000..175638d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/ShowSearchDialog.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/UpdateUserHandler.class b/bin/cn/net/connor/ml/plm/updateUser/UpdateUserHandler.class new file mode 100644 index 0000000..784816d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/UpdateUserHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/UserList.class b/bin/cn/net/connor/ml/plm/updateUser/UserList.class new file mode 100644 index 0000000..24faf3c Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/UserList.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/test6$1.class b/bin/cn/net/connor/ml/plm/updateUser/test6$1.class new file mode 100644 index 0000000..fd29669 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/test6$1.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/test6$2.class b/bin/cn/net/connor/ml/plm/updateUser/test6$2.class new file mode 100644 index 0000000..6b45d96 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/test6$2.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/test6$3.class b/bin/cn/net/connor/ml/plm/updateUser/test6$3.class new file mode 100644 index 0000000..6fecc2e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/test6$3.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/test6$4.class b/bin/cn/net/connor/ml/plm/updateUser/test6$4.class new file mode 100644 index 0000000..37ad61d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/test6$4.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/test6$5.class b/bin/cn/net/connor/ml/plm/updateUser/test6$5.class new file mode 100644 index 0000000..cd8ddd8 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/test6$5.class differ diff --git a/bin/cn/net/connor/ml/plm/updateUser/test6.class b/bin/cn/net/connor/ml/plm/updateUser/test6.class new file mode 100644 index 0000000..652c28d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/updateUser/test6.class differ diff --git a/bin/cn/net/connor/ml/plm/util/AutoCompleter.class b/bin/cn/net/connor/ml/plm/util/AutoCompleter.class new file mode 100644 index 0000000..6a2f23b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/AutoCompleter.class differ diff --git a/bin/cn/net/connor/ml/plm/util/BigDecimalUtils.class b/bin/cn/net/connor/ml/plm/util/BigDecimalUtils.class new file mode 100644 index 0000000..0525d32 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/BigDecimalUtils.class differ diff --git a/bin/cn/net/connor/ml/plm/util/FileUtil.class b/bin/cn/net/connor/ml/plm/util/FileUtil.class new file mode 100644 index 0000000..faac1fe Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/FileUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/util/JAutoCompleteComboBox.class b/bin/cn/net/connor/ml/plm/util/JAutoCompleteComboBox.class new file mode 100644 index 0000000..34be8d4 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/JAutoCompleteComboBox.class differ diff --git a/bin/cn/net/connor/ml/plm/util/JProTextField.class b/bin/cn/net/connor/ml/plm/util/JProTextField.class new file mode 100644 index 0000000..a844b38 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/JProTextField.class differ diff --git a/bin/cn/net/connor/ml/plm/util/JaxbUtil.class b/bin/cn/net/connor/ml/plm/util/JaxbUtil.class new file mode 100644 index 0000000..bc8c909 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/JaxbUtil.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiComboBox$EditorHandler.class b/bin/cn/net/connor/ml/plm/util/MultiComboBox$EditorHandler.class new file mode 100644 index 0000000..2cfd955 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiComboBox$EditorHandler.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiComboBox$MulitComboboxLayout.class b/bin/cn/net/connor/ml/plm/util/MultiComboBox$MulitComboboxLayout.class new file mode 100644 index 0000000..1f17a4d Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiComboBox$MulitComboboxLayout.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiComboBox$PopupAction.class b/bin/cn/net/connor/ml/plm/util/MultiComboBox$PopupAction.class new file mode 100644 index 0000000..eace8c0 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiComboBox$PopupAction.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiComboBox.class b/bin/cn/net/connor/ml/plm/util/MultiComboBox.class new file mode 100644 index 0000000..18ae12b Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiComboBox.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiPopup$1.class b/bin/cn/net/connor/ml/plm/util/MultiPopup$1.class new file mode 100644 index 0000000..ef3d69e Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiPopup$1.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiPopup$2.class b/bin/cn/net/connor/ml/plm/util/MultiPopup$2.class new file mode 100644 index 0000000..3240dfb Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiPopup$2.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiPopup$3.class b/bin/cn/net/connor/ml/plm/util/MultiPopup$3.class new file mode 100644 index 0000000..697d2db Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiPopup$3.class differ diff --git a/bin/cn/net/connor/ml/plm/util/MultiPopup.class b/bin/cn/net/connor/ml/plm/util/MultiPopup.class new file mode 100644 index 0000000..cf947ac Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/MultiPopup.class differ diff --git a/bin/cn/net/connor/ml/plm/util/ProgressBar$1.class b/bin/cn/net/connor/ml/plm/util/ProgressBar$1.class new file mode 100644 index 0000000..c3a98b1 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/ProgressBar$1.class differ diff --git a/bin/cn/net/connor/ml/plm/util/ProgressBar$2.class b/bin/cn/net/connor/ml/plm/util/ProgressBar$2.class new file mode 100644 index 0000000..6010501 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/ProgressBar$2.class differ diff --git a/bin/cn/net/connor/ml/plm/util/ProgressBar.class b/bin/cn/net/connor/ml/plm/util/ProgressBar.class new file mode 100644 index 0000000..c0c1b5a Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/ProgressBar.class differ diff --git a/bin/cn/net/connor/ml/plm/util/TCGroupDialogTree.class b/bin/cn/net/connor/ml/plm/util/TCGroupDialogTree.class new file mode 100644 index 0000000..f15eb45 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/TCGroupDialogTree.class differ diff --git a/bin/cn/net/connor/ml/plm/util/TableUtil3.class b/bin/cn/net/connor/ml/plm/util/TableUtil3.class new file mode 100644 index 0000000..1b2f950 Binary files /dev/null and b/bin/cn/net/connor/ml/plm/util/TableUtil3.class differ diff --git a/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/bin/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..bfc2b8e --- /dev/null +++ b/bin/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=cn.net.connor.ml.plm.AssignProductName.AssignPropertyTextField \ No newline at end of file diff --git a/bin/plm.properties b/bin/plm.properties new file mode 100644 index 0000000..c999966 --- /dev/null +++ b/bin/plm.properties @@ -0,0 +1,10 @@ +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 +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 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 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, T5.puid AS rev_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, T5.puid AS rev_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 +EXCEL5.SQL= WITH TEMP AS(SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 and (not exists(select * from PRELEASE_STATUS_LIST where puid =T5.puid) or exists (select * from PRELEASE_STATUS_LIST where puid=T5.puid and pvalu_0 in(select puid from PRELEASESTATUS where pname not like 'ML8_Replaced' )))UNION ALL SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 and (not exists(select * from PRELEASE_STATUS_LIST where puid =T5.puid) or exists (select * from PRELEASE_STATUS_LIST where puid=T5.puid and pvalu_0 in(select puid from PRELEASESTATUS where pname not like 'ML8_Replaced' )))) SELECT DISTINCT * FROM TEMP +EXCEL6.SQL=WITH TEMP AS( SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 INNER JOIN PRELEASE_STATUS_LIST T6 ON T4.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid AND T7.pname not like 'ML8_Replaced' UNION ALL SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 INNER JOIN PRELEASE_STATUS_LIST T6 ON T4.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid AND T7.pname not like 'ML8_Replaced') SELECT DISTINCT * FROM TEMP +#ͼԭɿӦĸ߶ +#ͼx/y (HEIGHT=WIDTH*y/x) +IMAGE.WIDTH=1 +IMAGE.HEIGHT=1 \ No newline at end of file diff --git a/bin/sql.properties b/bin/sql.properties new file mode 100644 index 0000000..8c21d90 --- /dev/null +++ b/bin/sql.properties @@ -0,0 +1,2 @@ +ML_WEBSERVICE_LOGINSERTSQL=INSERT INTO ML_WEBSERVICE_LOG 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/bin/sqlconn.properties b/bin/sqlconn.properties new file mode 100644 index 0000000..f3204cf --- /dev/null +++ b/bin/sqlconn.properties @@ -0,0 +1,4 @@ +DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +Connection=jdbc:sqlserver://10.18.1.106:1433; DatabaseName=TC +User=infodba +Password=Plm_8023 diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..17221a8 --- /dev/null +++ b/build.properties @@ -0,0 +1,42 @@ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + icons/,\ + lib/fastjson-1.2.78.jar,\ + lib/httpclient-4.5.10.jar,\ + lib/httpcore-4.4.12.jar,\ + lib/httpmime-4.5.10.jar,\ + lib/jaxb-api-2.2.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/jcommon-1.0.23.jar,\ + lib/jfreechart-1.0.19.jar,\ + lib/yujianbo-java-tools-8.2.1.jar,\ + .,\ + lib/sqljdbc4.jar,\ + lib/easyexcel-2.1.4.jar,\ + lib/slf4j-api-1.7.26.jar,\ + lib/poi-examples-3.17.jar,\ + lib/poi-excelant-3.17.jar,\ + lib/poi-ooxml-3.17.jar,\ + lib/poi-ooxml-schemas-3.17.jar,\ + lib/poi-scratchpad-3.17.jar,\ + lib/poi-3.17.jar,\ + lib/cglib-3.1.jar,\ + lib/com.ibm.icu-4.4.2.jar,\ + lib/commons-collections4-4.1.jar,\ + lib/commons-math3-3.6.1.jar,\ + lib/ehcache-3.7.1.jar,\ + lib/FastInfoset-1.2.15.jar,\ + lib/fastjson-1.2.76.jar,\ + lib/istack-commons-runtime-3.0.7.jar,\ + lib/javax.activation-api-1.2.0.jar,\ + lib/jaxb-runtime-2.3.1.jar,\ + lib/stax-ex-1.8.jar,\ + lib/txw2-2.3.1.jar,\ + lib/xmlbeans-2.6.0.jar +source.. = src/ diff --git a/icons/group_16.png b/icons/group_16.png new file mode 100644 index 0000000..71a4bfb Binary files /dev/null and b/icons/group_16.png differ diff --git a/icons/person_16.png b/icons/person_16.png new file mode 100644 index 0000000..fa412c8 Binary files /dev/null and b/icons/person_16.png differ diff --git a/icons/role_16.png b/icons/role_16.png new file mode 100644 index 0000000..78c754d Binary files /dev/null and b/icons/role_16.png differ diff --git a/icons/sample.png b/icons/sample.png new file mode 100644 index 0000000..02c4b79 Binary files /dev/null and b/icons/sample.png differ diff --git a/icons/sample@2x.png b/icons/sample@2x.png new file mode 100644 index 0000000..c1224d1 Binary files /dev/null and b/icons/sample@2x.png differ diff --git a/lib/FastInfoset-1.2.15.jar b/lib/FastInfoset-1.2.15.jar new file mode 100644 index 0000000..2671209 Binary files /dev/null and b/lib/FastInfoset-1.2.15.jar differ diff --git a/lib/cglib-3.1.jar b/lib/cglib-3.1.jar new file mode 100644 index 0000000..25a5df1 Binary files /dev/null and b/lib/cglib-3.1.jar differ diff --git a/lib/com.ibm.icu-4.4.2.jar b/lib/com.ibm.icu-4.4.2.jar new file mode 100644 index 0000000..5261d46 Binary files /dev/null and b/lib/com.ibm.icu-4.4.2.jar differ diff --git a/lib/commons-beanutils-1.7.0.jar b/lib/commons-beanutils-1.7.0.jar new file mode 100644 index 0000000..b1b89c9 Binary files /dev/null and b/lib/commons-beanutils-1.7.0.jar differ diff --git a/lib/commons-codec-1.3.jar b/lib/commons-codec-1.3.jar new file mode 100644 index 0000000..957b675 Binary files /dev/null and b/lib/commons-codec-1.3.jar differ diff --git a/lib/commons-collections-3.2.jar b/lib/commons-collections-3.2.jar new file mode 100644 index 0000000..75580be Binary files /dev/null and b/lib/commons-collections-3.2.jar differ diff --git a/lib/commons-collections4-4.1.jar b/lib/commons-collections4-4.1.jar new file mode 100644 index 0000000..43a9413 Binary files /dev/null and b/lib/commons-collections4-4.1.jar differ diff --git a/lib/commons-httpclient-3.1.jar b/lib/commons-httpclient-3.1.jar new file mode 100644 index 0000000..7c59774 Binary files /dev/null and b/lib/commons-httpclient-3.1.jar differ diff --git a/lib/commons-lang-2.4.jar b/lib/commons-lang-2.4.jar new file mode 100644 index 0000000..532939e Binary files /dev/null and b/lib/commons-lang-2.4.jar differ diff --git a/lib/commons-logging-1.1.jar b/lib/commons-logging-1.1.jar new file mode 100644 index 0000000..2ff9bbd Binary files /dev/null and b/lib/commons-logging-1.1.jar differ diff --git a/lib/commons-math3-3.6.1.jar b/lib/commons-math3-3.6.1.jar new file mode 100644 index 0000000..0ff582c Binary files /dev/null and b/lib/commons-math3-3.6.1.jar differ diff --git a/lib/easyexcel-2.1.4.jar b/lib/easyexcel-2.1.4.jar new file mode 100644 index 0000000..b14f5f8 Binary files /dev/null and b/lib/easyexcel-2.1.4.jar differ diff --git a/lib/ehcache-3.7.1.jar b/lib/ehcache-3.7.1.jar new file mode 100644 index 0000000..dd0088d Binary files /dev/null and b/lib/ehcache-3.7.1.jar differ diff --git a/lib/fastjson-1.2.76.jar b/lib/fastjson-1.2.76.jar new file mode 100644 index 0000000..c241c1d Binary files /dev/null and b/lib/fastjson-1.2.76.jar differ diff --git a/lib/fastjson-1.2.78.jar b/lib/fastjson-1.2.78.jar new file mode 100644 index 0000000..bb42302 Binary files /dev/null and b/lib/fastjson-1.2.78.jar differ diff --git a/lib/httpclient-4.5.10.jar b/lib/httpclient-4.5.10.jar new file mode 100644 index 0000000..d0c7821 Binary files /dev/null and b/lib/httpclient-4.5.10.jar differ diff --git a/lib/httpcore-4.4.12.jar b/lib/httpcore-4.4.12.jar new file mode 100644 index 0000000..1838672 Binary files /dev/null and b/lib/httpcore-4.4.12.jar differ diff --git a/lib/httpmime-4.5.10.jar b/lib/httpmime-4.5.10.jar new file mode 100644 index 0000000..0fae6d0 Binary files /dev/null and b/lib/httpmime-4.5.10.jar differ diff --git a/lib/istack-commons-runtime-3.0.7.jar b/lib/istack-commons-runtime-3.0.7.jar new file mode 100644 index 0000000..2fe5b82 Binary files /dev/null and b/lib/istack-commons-runtime-3.0.7.jar differ diff --git a/lib/javax.activation-api-1.2.0.jar b/lib/javax.activation-api-1.2.0.jar new file mode 100644 index 0000000..986c365 Binary files /dev/null and b/lib/javax.activation-api-1.2.0.jar differ diff --git a/lib/jaxb-api-2.2.jar b/lib/jaxb-api-2.2.jar new file mode 100644 index 0000000..68a8250 Binary files /dev/null and b/lib/jaxb-api-2.2.jar differ diff --git a/lib/jaxb-runtime-2.3.1.jar b/lib/jaxb-runtime-2.3.1.jar new file mode 100644 index 0000000..0b9ef67 Binary files /dev/null and b/lib/jaxb-runtime-2.3.1.jar differ diff --git a/lib/jcommon-1.0.23.jar b/lib/jcommon-1.0.23.jar new file mode 100644 index 0000000..4dbb094 Binary files /dev/null and b/lib/jcommon-1.0.23.jar differ diff --git a/lib/jfreechart-1.0.19.jar b/lib/jfreechart-1.0.19.jar new file mode 100644 index 0000000..10f276c Binary files /dev/null and b/lib/jfreechart-1.0.19.jar differ diff --git a/lib/poi-3.17.jar b/lib/poi-3.17.jar new file mode 100644 index 0000000..353ce76 Binary files /dev/null and b/lib/poi-3.17.jar differ diff --git a/lib/poi-examples-3.17.jar b/lib/poi-examples-3.17.jar new file mode 100644 index 0000000..a923b04 Binary files /dev/null and b/lib/poi-examples-3.17.jar differ diff --git a/lib/poi-excelant-3.17.jar b/lib/poi-excelant-3.17.jar new file mode 100644 index 0000000..da9f5ed Binary files /dev/null and b/lib/poi-excelant-3.17.jar differ diff --git a/lib/poi-ooxml-3.17.jar b/lib/poi-ooxml-3.17.jar new file mode 100644 index 0000000..68086e8 Binary files /dev/null and b/lib/poi-ooxml-3.17.jar differ diff --git a/lib/poi-ooxml-schemas-3.17.jar b/lib/poi-ooxml-schemas-3.17.jar new file mode 100644 index 0000000..2e9b3e7 Binary files /dev/null and b/lib/poi-ooxml-schemas-3.17.jar differ diff --git a/lib/poi-scratchpad-3.17.jar b/lib/poi-scratchpad-3.17.jar new file mode 100644 index 0000000..12ba1f1 Binary files /dev/null and b/lib/poi-scratchpad-3.17.jar differ diff --git a/lib/slf4j-api-1.7.26.jar b/lib/slf4j-api-1.7.26.jar new file mode 100644 index 0000000..d2f27ac Binary files /dev/null and b/lib/slf4j-api-1.7.26.jar differ diff --git a/lib/sqljdbc4.jar b/lib/sqljdbc4.jar new file mode 100644 index 0000000..d6b7f6d Binary files /dev/null and b/lib/sqljdbc4.jar differ diff --git a/lib/stax-ex-1.8.jar b/lib/stax-ex-1.8.jar new file mode 100644 index 0000000..5e60637 Binary files /dev/null and b/lib/stax-ex-1.8.jar differ diff --git a/lib/txw2-2.3.1.jar b/lib/txw2-2.3.1.jar new file mode 100644 index 0000000..75ed519 Binary files /dev/null and b/lib/txw2-2.3.1.jar differ diff --git a/lib/xmlbeans-2.6.0.jar b/lib/xmlbeans-2.6.0.jar new file mode 100644 index 0000000..d1b6627 Binary files /dev/null and b/lib/xmlbeans-2.6.0.jar differ diff --git a/lib/yujianbo-java-tools-8.2.1.jar b/lib/yujianbo-java-tools-8.2.1.jar new file mode 100644 index 0000000..9efcb1b Binary files /dev/null and b/lib/yujianbo-java-tools-8.2.1.jar differ diff --git a/plugin.xml b/plugin.xml new file mode 100644 index 0000000..7248954 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,1250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/Activator.java b/src/cn/net/connor/ml/plm/Activator.java new file mode 100644 index 0000000..b8bd89f --- /dev/null +++ b/src/cn/net/connor/ml/plm/Activator.java @@ -0,0 +1,44 @@ +package cn.net.connor.ml.plm; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "cn.net.connor.ml.plm"; //$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/src/cn/net/connor/ml/plm/AssignProductName/AssignPropertyTextField.java b/src/cn/net/connor/ml/plm/AssignProductName/AssignPropertyTextField.java new file mode 100644 index 0000000..e236ea4 --- /dev/null +++ b/src/cn/net/connor/ml/plm/AssignProductName/AssignPropertyTextField.java @@ -0,0 +1,419 @@ +package cn.net.connor.ml.plm.AssignProductName; + +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.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.AbstractRendering; +import com.teamcenter.rac.stylesheet.PropertyTextField; +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.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/src/cn/net/connor/ml/plm/CreateTimeSheet/CreateScheduleHandler.java b/src/cn/net/connor/ml/plm/CreateTimeSheet/CreateScheduleHandler.java new file mode 100644 index 0000000..cc5301e --- /dev/null +++ b/src/cn/net/connor/ml/plm/CreateTimeSheet/CreateScheduleHandler.java @@ -0,0 +1,119 @@ +package cn.net.connor.ml.plm.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); + + return registry.getString("dialog.TITLE"); + } + + + + + +} diff --git a/src/cn/net/connor/ml/plm/KAction.java b/src/cn/net/connor/ml/plm/KAction.java new file mode 100644 index 0000000..4303e4a --- /dev/null +++ b/src/cn/net/connor/ml/plm/KAction.java @@ -0,0 +1,37 @@ +package cn.net.connor.ml.plm; + +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/src/cn/net/connor/ml/plm/KCommand.java b/src/cn/net/connor/ml/plm/KCommand.java new file mode 100644 index 0000000..9d263cf --- /dev/null +++ b/src/cn/net/connor/ml/plm/KCommand.java @@ -0,0 +1,16 @@ +package cn.net.connor.ml.plm; + +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/src/cn/net/connor/ml/plm/KHandler.java b/src/cn/net/connor/ml/plm/KHandler.java new file mode 100644 index 0000000..31e2415 --- /dev/null +++ b/src/cn/net/connor/ml/plm/KHandler.java @@ -0,0 +1,24 @@ +package cn.net.connor.ml.plm; + +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/src/cn/net/connor/ml/plm/KLocale.java b/src/cn/net/connor/ml/plm/KLocale.java new file mode 100644 index 0000000..6a40ace --- /dev/null +++ b/src/cn/net/connor/ml/plm/KLocale.java @@ -0,0 +1,22 @@ +package cn.net.connor.ml.plm; + +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/src/cn/net/connor/ml/plm/KOperation.java b/src/cn/net/connor/ml/plm/KOperation.java new file mode 100644 index 0000000..5d98b43 --- /dev/null +++ b/src/cn/net/connor/ml/plm/KOperation.java @@ -0,0 +1,54 @@ +package cn.net.connor.ml.plm; + +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/src/cn/net/connor/ml/plm/KOperation2.java b/src/cn/net/connor/ml/plm/KOperation2.java new file mode 100644 index 0000000..a7895d6 --- /dev/null +++ b/src/cn/net/connor/ml/plm/KOperation2.java @@ -0,0 +1,55 @@ +package cn.net.connor.ml.plm; + +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(); + }finally { + KUtil.setByPass(false); + } + } +} diff --git a/src/cn/net/connor/ml/plm/KUtil.java b/src/cn/net/connor/ml/plm/KUtil.java new file mode 100644 index 0000000..ee7addf --- /dev/null +++ b/src/cn/net/connor/ml/plm/KUtil.java @@ -0,0 +1,1991 @@ +package cn.net.connor.ml.plm; + +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ԪöŸ Excel5еԪ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 + "\n"); + } + } + // 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/src/cn/net/connor/ml/plm/WBSExport/WBSExportCommand.java b/src/cn/net/connor/ml/plm/WBSExport/WBSExportCommand.java new file mode 100644 index 0000000..4054086 --- /dev/null +++ b/src/cn/net/connor/ml/plm/WBSExport/WBSExportCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.WBSExport; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class WBSExportCommand extends KCommand { + + public WBSExportCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new WBSExportOperation(app, "ĿWBSexcel")); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/WBSExport/WBSExportOperation.java b/src/cn/net/connor/ml/plm/WBSExport/WBSExportOperation.java new file mode 100644 index 0000000..0437404 --- /dev/null +++ b/src/cn/net/connor/ml/plm/WBSExport/WBSExportOperation.java @@ -0,0 +1,198 @@ +package cn.net.connor.ml.plm.WBSExport; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentScheduleTask; +import com.teamcenter.rac.kernel.TCException; + +import cn.net.connor.ml.plm.KOperation; +import cn.net.connor.ml.plm.KUtil; + +public class WBSExportOperation extends KOperation { + public static final String PREF_COLUMNS = "Meling_Export_ScheduleTask"; + public static final String PREF_FORMAT = "Meling_TaskTime_Format"; + private TCComponent target; + private String[] realNames; + private ArrayList list; + private String[] formats; + + public WBSExportOperation(AbstractAIFApplication app, String opName) { + super(app, opName, "ִ..."); + target = (TCComponent) app.getTargetComponent(); + } + + @Override + public boolean init() throws Exception { + if (target != null) { + String type = target.getType(); + System.out.println("type=" + type); + if (type.equals("Schedule")) { + target = target.getRelatedComponent("fnd0SummaryTask"); + } + if (type.equals("ScheduleTask") || type.equals("Schedule")) { + realNames = KUtil.getPrefVals(session, PREF_COLUMNS); + formats = KUtil.getPrefVals(session, PREF_FORMAT); + + if (realNames == null || realNames.length < 1) { + KUtil.info(getCurrentDesktop(), "ѡ<" + PREF_COLUMNS + ">ô"); + return false; + } + return true; + } + } + KUtil.info(getCurrentDesktop(), "ѡʱе"); + return false; + } + + @Override + public void execute() throws Exception { + TCComponentScheduleTask topTask = (TCComponentScheduleTask) target; + File file = getFile(); + if (file == null) { + return; + } + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + + list = new ArrayList(); + findAllTask(topTask); + int rowCount = list.size(); + System.out.println("rowCount=" + rowCount + ", realNames.length=" + realNames.length); + if (rowCount < 2) { + KUtil.info(getCurrentDesktop(), "ʱû"); + return; + } + for (int i = 0; i < rowCount + 1; i++) { + Row row = sheet.createRow(i); + for (int j = 0; j < realNames.length; j++) { + Cell cell = row.createCell(j); + try { + if (i == 0) { + cell.setCellValue(topTask.getTCProperty(realNames[j]).getName()); + } else if (i == 1) { + TCComponent top = target.getRelatedComponent("schedule_tag"); + if (realNames[j].equals("start_date")) { + cell.setCellValue(top.getProperty("start_date")); + } else if (realNames[j].equals("finish_date")) { + cell.setCellValue(top.getProperty("finish_date")); + } else { + cell.setCellValue(list.get(i - 1)[j]); + } + } else { + cell.setCellValue(list.get(i - 1)[j]); + } + } catch (Exception e) { + KUtil.info(getCurrentDesktop(), "[" + realNames[j] + "]ȡ쳣"); + e.printStackTrace(); + return; + } + // ڸʽ + try { + if (i > 0) { + if (formats != null && formats.length > 0) { + for (String format : formats) { + String[] propF = format.split("="); + if (propF.length != 2) { + KUtil.info(getCurrentDesktop(), "ѡ<" + PREF_FORMAT + ">ô"); + return; + } + if (format.contains(realNames[j])) { + SimpleDateFormat sdf = new SimpleDateFormat(propF[1]); + String value = cell.getStringCellValue(); + if (value.equals("")) { + break; + } + Date newDate = sdf.parse(value); + cell.setCellValue(sdf.format(newDate)); + break; + } + } + } + } + } catch (Exception e) { + KUtil.info(getCurrentDesktop(), "[" + realNames[j] + "]ʽ쳣"); + e.printStackTrace(); + return; + } + } + } + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + KUtil.info(getCurrentDesktop(), "ɹ"); + } + + private void findAllTask(TCComponentScheduleTask topTask) throws TCException { + list.add(topTask.getProperties(realNames)); + AIFComponentContext[] childrens = topTask.getChildren(); + if (childrens != null && childrens.length > 0) { + for (AIFComponentContext children : childrens) { + if (!(children.getComponent() instanceof TCComponentScheduleTask)) { + continue; + } + TCComponentScheduleTask task = (TCComponentScheduleTask) children.getComponent(); + findAllTask(task); + } + } + } + + private File getFile() throws TCException { + JFileChooser jf = new JFileChooser(); + String name = target.getProperty("object_string") + new SimpleDateFormat("yyyyMMdd").format(new Date()) + ".xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(getCurrentDesktop(), ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(getCurrentDesktop(), "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(getCurrentDesktop(), "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new XSSFWorkbook(); + workbook.createSheet("sheet1"); + return workbook; + } +} diff --git a/src/cn/net/connor/ml/plm/aaaaa.java b/src/cn/net/connor/ml/plm/aaaaa.java new file mode 100644 index 0000000..19c5422 --- /dev/null +++ b/src/cn/net/connor/ml/plm/aaaaa.java @@ -0,0 +1,62 @@ +package cn.net.connor.ml.plm; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +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 javax.swing.RowSorter; +import javax.swing.SortOrder; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; + +import com.teamcenter.rac.kernel.TCComponent; + +public class aaaaa { + public static void main(String[] args) throws ParseException { + String newID = "1234"; + int lastnum = Integer.parseInt(newID.substring(newID.length() - 1)) + 1; + newID = newID.substring(0, newID.length() - 1) + lastnum; + + System.out.println(newID); + } + + /** + * ĸַ+1 + * + * @param s + * @return + */ + private static String changeLetter(String s) { + // A-Z:65-90 + for (int i = s.length() - 1; i > -1; i--) { + char c = s.charAt(i); + if (c == 90) { + c = 65; + s = s.substring(0, i) + c + s.substring(i + 1); + if (i == 0) { + s = "A" + s; + break; + } else { + char lastc = s.charAt(i - 1); + if (lastc == 90) { + + } else { + lastc++; + s = s.substring(0, i - 1) + lastc + s.substring(i); + break; + } + } + } else { + c++; + s = s.substring(0, i) + c + s.substring(i + 1); + break; + } + } + return s; + } +} diff --git a/src/cn/net/connor/ml/plm/beans/ImportBean.java b/src/cn/net/connor/ml/plm/beans/ImportBean.java new file mode 100644 index 0000000..cecd282 --- /dev/null +++ b/src/cn/net/connor/ml/plm/beans/ImportBean.java @@ -0,0 +1,50 @@ +package cn.net.connor.ml.plm.beans; + +import java.util.ArrayList; + +public class ImportBean { + private String puid; + private ArrayList toList; + private String type; + private ArrayList> list; + + public String getPuid() { + return puid; + } + + public void setPuid(String puid) { + this.puid = puid; + } + + public ArrayList getToList() { + return toList; + } + + public void setToList(ArrayList toList) { + this.toList = toList; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ArrayList> getList() { + return list; + } + + public void setList(ArrayList> list) { + this.list = list; + } + + public ImportBean(String puid, ArrayList toList, String type, ArrayList> list) { + super(); + this.puid = puid; + this.toList = toList; + this.type = type; + this.list = list; + } +} diff --git a/src/cn/net/connor/ml/plm/beans/LOVBean.java b/src/cn/net/connor/ml/plm/beans/LOVBean.java new file mode 100644 index 0000000..ef1d295 --- /dev/null +++ b/src/cn/net/connor/ml/plm/beans/LOVBean.java @@ -0,0 +1,38 @@ +package cn.net.connor.ml.plm.beans; + +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/src/cn/net/connor/ml/plm/beans/ObjectFactory.java b/src/cn/net/connor/ml/plm/beans/ObjectFactory.java new file mode 100644 index 0000000..f18441c --- /dev/null +++ b/src/cn/net/connor/ml/plm/beans/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 cn.net.connor.ml.plm.beans; + +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/src/cn/net/connor/ml/plm/beans/Property.java b/src/cn/net/connor/ml/plm/beans/Property.java new file mode 100644 index 0000000..da8d55a --- /dev/null +++ b/src/cn/net/connor/ml/plm/beans/Property.java @@ -0,0 +1,176 @@ +// +// ļ 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 cn.net.connor.ml.plm.beans; + +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="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 = "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; + } + + /** + * ȡ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/src/cn/net/connor/ml/plm/beans/Search.java b/src/cn/net/connor/ml/plm/beans/Search.java new file mode 100644 index 0000000..7c0d425 --- /dev/null +++ b/src/cn/net/connor/ml/plm/beans/Search.java @@ -0,0 +1,140 @@ +// +// ļ 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 cn.net.connor.ml.plm.beans; + +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="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 = "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 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/src/cn/net/connor/ml/plm/beans/Searchs.java b/src/cn/net/connor/ml/plm/beans/Searchs.java new file mode 100644 index 0000000..ee3da89 --- /dev/null +++ b/src/cn/net/connor/ml/plm/beans/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 cn.net.connor.ml.plm.beans; + +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/src/cn/net/connor/ml/plm/beans/TMomUserBean.java b/src/cn/net/connor/ml/plm/beans/TMomUserBean.java new file mode 100644 index 0000000..19b2032 --- /dev/null +++ b/src/cn/net/connor/ml/plm/beans/TMomUserBean.java @@ -0,0 +1,68 @@ +package cn.net.connor.ml.plm.beans; + +import javax.swing.ImageIcon; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentPerson; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; + +public class TMomUserBean { + private TCComponent User; + private TCComponent Parent; + private ImageIcon ImageIcon; + private String UserName; + + public TCComponent getParent() { + return Parent; + } + + public void setParent(TCComponent Parent) { + this.Parent = Parent; + } + + public TCComponent getUser() { + return User; + } + + public void setUser(TCComponent user) { + User = user; + } + + public TMomUserBean() { + + } + + public TMomUserBean(TCComponent user, TCComponent Parent) { + this.Parent = Parent; + this.User = user; + if (user != null) { + + try { + if (user instanceof TCComponentRole) { + this.ImageIcon = new ImageIcon("icons\\role_16.png"); + + } else if (user instanceof TCComponentPerson) { + this.ImageIcon = new ImageIcon("icons\\persons_16.png"); + + } else if (user instanceof TCComponentGroup) { + this.ImageIcon = new ImageIcon("icons\\group_16.png"); + + } else if (user instanceof TCComponentUser) { + this.ImageIcon = new ImageIcon("icons\\persons_16.png"); + } + this.UserName = user.getStringProperty("object_string"); + } catch (TCException e) { + e.printStackTrace(); + } + } + } + + @Override + public String toString() { + return UserName; + } + +} diff --git a/src/cn/net/connor/ml/plm/bom/RemoveBOM2Handler.java b/src/cn/net/connor/ml/plm/bom/RemoveBOM2Handler.java new file mode 100644 index 0000000..bed3eb3 --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/RemoveBOM2Handler.java @@ -0,0 +1,72 @@ +package cn.net.connor.ml.plm.bom; + +import javax.swing.JOptionPane; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; + +//汾Ҽ˵ƳBOM +public class RemoveBOM2Handler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + // ѡĶ汾Сûκη״̬ + new Thread() { + public void run(){ + try { + int choose = JOptionPane.showOptionDialog(AIFUtility.getActiveDesktop(), "Ƿȷ?", "ʾ", + JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {"",""}, ""); + if(choose != 0) + return; + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCComponent target = (TCComponent) app.getTargetComponent(); + int length1 = target.getRelatedComponents("fnd0StartedWorkflowTasks").length; + int length2 = target.getRelatedComponents("release_status_list").length; + if (length1 != 0 || length2 != 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), ":\nѡĶ汾Сûκη״̬"); + return; + } + String type = target.getType(); + + KUtil.setByPass(true); + if (type.equals("ML8_DesignRevision")) { + TCComponent[] relateds = target.getRelatedComponents("representation_for"); + if (relateds != null) { + for (TCComponent related : relateds) { + TCComponent[] rels = related.getRelatedComponents("TC_Is_Represented_By"); + if (rels != null) { +// related.cutOperation("TC_Is_Represented_By", rels); + related.cutOperation("TC_Is_Represented_By", new TCComponent[] { target }); + } + } + System.out.println("Ѽйϵ[representation_for]µĶ"); + } + } else if (type.equals("ML8_PartRevision") || type.equals("ML8_RefrigeratorRevision") || type.equals("ML8_WashingRevision") + || type.equals("ML8_ColdRevision") || type.equals("ML8_OthersRevision")) { + TCComponent[] relateds = target.getRelatedComponents("TC_Is_Represented_By"); + if (relateds != null) { + target.cutOperation("TC_Is_Represented_By", relateds); + System.out.println("Ѽйϵ[TC_Is_Represented_By]µĶ"); + } + } + target.refresh(); + } catch (TCException e) { + e.printStackTrace(); + MessageBox.post(e.getMessage(),"ʧ",MessageBox.INFORMATION); + }finally { + KUtil.setByPass(false); + } + } + }.start(); + return null; + } +} diff --git a/src/cn/net/connor/ml/plm/bom/RemoveBOMHandler.java b/src/cn/net/connor/ml/plm/bom/RemoveBOMHandler.java new file mode 100644 index 0000000..00157bb --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/RemoveBOMHandler.java @@ -0,0 +1,108 @@ +package cn.net.connor.ml.plm.bom; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; + +public class RemoveBOMHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null || !(target instanceof TCComponentBOMLine)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡBOMУ"); + return null; + } + TCComponentBOMLine bom = (TCComponentBOMLine) target; + try { + String bl_level_starting_0 = bom.getProperty("bl_level_starting_0"); + if(!"1".equals(bl_level_starting_0)) { + MessageBox.post("ѡڶbomУ","",MessageBox.INFORMATION); + return null; + } + String str = bom.getProperty("ML8_MBOM"); + if (str == null || !str.equals("MBOM")) { + KUtil.info(AIFDesktop.getActiveDesktop(), "[ML8_MBOM]"); + return null; + } + KUtil.setByPass(true); + TCComponentBOMLine parent = bom.parent(); + if (parent == null) { + KUtil.setByPass(false); + KUtil.info(AIFDesktop.getActiveDesktop(), "BOMûи"); + return null; + } + + TCComponentBOMLine top = bom.getCachedWindow().getTopBOMLine(); + // жϸڵ + { + TCComponent rev = top.getRelatedComponent("mfg0realRevision"); + // fnd0StartedWorkflowTasks + TCComponent[] tasks = rev.getRelatedComponents("fnd0StartedWorkflowTasks"); + if (tasks == null || tasks.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ڵ鲻ͨ"); + return null; + } + String task_name = KUtil.getPrefVal(session, "Meling_task_name"); + boolean flag = false; + boolean flag2 = 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) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ϿΪգ"); + return null; + } +//202403--NYL-MBOM༭ڵԱ༭Ȩ + for(TCComponent user : users) { + if (user.getRelatedComponent("fnd0Performer").getProperty("user_id")==session.getUser().getProperty("user_id")) + { + flag2=true; + break; + } + } +// user_name = users[0].getRelatedComponent("fnd0Performer").getProperty("user_id"); + } + } + if (!flag) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ڵƲƥ䣡"); + return null; + } + +// String userName = session.getUser().getProperty("user_id"); + if (!flag2) { + KUtil.info(AIFDesktop.getActiveDesktop(), "Ͽ뵱ǰ¼ûƥ䣡"); + return null; + } + } + parent.remove("", bom); + parent.getCachedWindow().save(); + parent.getCachedWindow().refresh(); + KUtil.setByPass(false); + } catch (Exception e) { + KUtil.setByPass(false); + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + return null; + } + +} diff --git a/src/cn/net/connor/ml/plm/bom/UpdateDescDialog.java b/src/cn/net/connor/ml/plm/bom/UpdateDescDialog.java new file mode 100644 index 0000000..45dd354 --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/UpdateDescDialog.java @@ -0,0 +1,101 @@ +package cn.net.connor.ml.plm.bom; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.exportExcel.ExportExcel1Dialog; + +@SuppressWarnings("serial") +public class UpdateDescDialog extends AbstractAIFDialog { + + private TCComponent rev; + private JButton okButton; + private JButton cancelButton; + private JTextField text1; + private JTextField text2; + private AbstractAIFUIApplication app; + private TCSession session; + + public UpdateDescDialog(AbstractAIFUIApplication app, TCComponent rev, TCSession session) { + this.app = app; + this.rev = rev; + this.session = session; + } + + @Override + public void run() { + try { + initUI(); + } catch (TCException e) { + e.printStackTrace(); + } + addListeners(); + showDialog(); + } + + private void addListeners() { + this.okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String wlms = text2.getText().trim(); + UpdateDescOperation operation=new UpdateDescOperation(rev, text1.getText().trim(),wlms,session,UpdateDescDialog.this); + session.queueOperation(operation); +// KUtil.setByPass(true); +// try { +// +// TCComponent[] search = session.search("ML_", new String[] { "" }, new String[] { wlms }); +// if (search.length == 1 && search[0].getUid().equals(rev.getUid())) { +// +// } else if (search.length > 0) { +// KUtil.info(UpdateDescDialog.this, "ظ"); +// return; +// } +// +// } catch (Exception e1) { +// e1.printStackTrace(); +// } +// KUtil.setByPass(false); +// disposeDialog(); + } + }); + this.cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + private void initUI() throws TCException { + this.setMinimumSize(new Dimension(200, 100)); + this.setLayout(new PropertyLayout(10, 5)); + this.add("1.1.left.top", new JLabel("׼")); + text1 = new JTextField(rev.getProperty("ml8_StdDesc")); + text2 = new JTextField(rev.getProperty("object_desc")); + text1.setPreferredSize(new Dimension(100, 25)); + text2.setPreferredSize(new Dimension(100, 25)); + + this.add("1.2.left.top", text1); + this.add("2.1.left.top", new JLabel("")); + this.add("2.2.left.top", text2); + + okButton = new JButton("ȷ"); + cancelButton = new JButton("ȡ"); + this.add("3.1.left.top", okButton); + this.add("3.2.left.top", cancelButton); + + } +} diff --git a/src/cn/net/connor/ml/plm/bom/UpdateDescHandler.java b/src/cn/net/connor/ml/plm/bom/UpdateDescHandler.java new file mode 100644 index 0000000..aaf96ad --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/UpdateDescHandler.java @@ -0,0 +1,89 @@ +package cn.net.connor.ml.plm.bom; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateDescHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null || !(target instanceof TCComponentItemRevision)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ汾"); + return null; + } + TCComponentUser user = session.getUser(); + try { + TCComponent group = user.getRelatedComponent("login_group"); + + String group_name = group.getProperty("object_string"); + System.out.println("group_name=" + group_name); + if (group_name.contains("dba")) { + new Thread(new UpdateDescDialog(app, target, session)).start(); + return null; + } + + TCComponent[] tasks = target.getRelatedComponents("fnd0StartedWorkflowTasks"); + if (tasks == null || tasks.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ûҵ̶"); + return null; + } + String task_name = KUtil.getPrefVal(session, "Meling_task_name2"); + + boolean flag = false; + boolean flag2 = 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) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ϿΪգ"); + return null; + } +//202404--NYL-ǩԱȨ + for(TCComponent user1 : users) { + if (session.getUser().getProperty("user_id").toString() == user1.getRelatedComponent("fnd0Performer") + .getProperty("user_id")) + { + flag2=true; + break; + } + } +// user_name = users[0].getRelatedComponent("fnd0Performer").getProperty("user_id"); + } + } + + if (!flag) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ڵƲƥ䣡"); + return null; + } +// +// String userName = user.getProperty("user_id"); +// if (!userName.equals(user_name)) { + if(!flag2) { + KUtil.info(AIFDesktop.getActiveDesktop(), "Ͽ뵱ǰ¼ûƥ䣡"); + return null; + } + + new Thread(new UpdateDescDialog(app, target, session)).start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/cn/net/connor/ml/plm/bom/UpdateDescHandler.java.bak b/src/cn/net/connor/ml/plm/bom/UpdateDescHandler.java.bak new file mode 100644 index 0000000..7b8b5b7 --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/UpdateDescHandler.java.bak @@ -0,0 +1,77 @@ +package cn.net.connor.ml.plm.bom; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateDescHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null || !(target instanceof TCComponentItemRevision)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ汾"); + return null; + } + TCComponentUser user = session.getUser(); + try { + TCComponent group = user.getRelatedComponent("login_group"); + + String group_name = group.getProperty("object_string"); + System.out.println("group_name=" + group_name); + if (group_name.contains("dba")) { + new Thread(new UpdateDescDialog(app, target, session)).start(); + return null; + } + + TCComponent[] tasks = target.getRelatedComponents("fnd0StartedWorkflowTasks"); + if (tasks == null || tasks.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ûҵ̶"); + return null; + } + String task_name = KUtil.getPrefVal(session, "Meling_task_name2"); + + 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) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ϿΪգ"); + return null; + } + user_name = users[0].getRelatedComponent("fnd0Performer").getProperty("user_id"); + } + } + if (!flag) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ڵƲƥ䣡"); + return null; + } + + String userName = user.getProperty("user_id"); + if (!userName.equals(user_name)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "Ͽ뵱ǰ¼ûƥ䣡"); + return null; + } + + new Thread(new UpdateDescDialog(app, target, session)).start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/cn/net/connor/ml/plm/bom/UpdateDescOperation.java b/src/cn/net/connor/ml/plm/bom/UpdateDescOperation.java new file mode 100644 index 0000000..6511354 --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/UpdateDescOperation.java @@ -0,0 +1,67 @@ +package cn.net.connor.ml.plm.bom; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateDescOperation extends AbstractAIFOperation { + private TCComponent rev; + private String text1; + private String wlms; + private AbstractAIFDialog dialog; + private TCSession session; + @Override + public void executeOperation() throws Exception { + // TODO Auto-generated method stub + KUtil.setByPass(true); + try { + + + TCComponent[] search = session.search("ML_", new String[] { "" }, new String[] { wlms }); + if (search.length == 1 && search[0].getProperty("item_id").equals(rev.getProperty("item_id"))) { + + } + else if (search.length > 0) { +// KUtil.info(dialog, "ظ"); + + for(TCComponent component:search) { + if(component.getProperty("item_id").equals(rev.getProperty("item_id"))) { + continue; + }else if (component.getProperty("item_id").contains("-")) { + + }else { + KUtil.info(dialog, "ظ"); + return; + } + + } + } + + rev.lock(); + rev.setProperty("ml8_StdDesc", text1); + rev.setProperty("object_desc", wlms); + rev.save(); + rev.unlock(); + rev.refresh(); + + } catch (Exception e1) { + e1.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + dialog.disposeDialog(); + + } + + public UpdateDescOperation(TCComponent rev,String text1,String wlms,TCSession session,AbstractAIFDialog dialog) { + this.rev=rev; + this.text1=text1; + this.wlms=wlms; + this.session=session; + this.dialog=dialog; + } + +} diff --git a/src/cn/net/connor/ml/plm/bom/UpdateQuantityDialog.java b/src/cn/net/connor/ml/plm/bom/UpdateQuantityDialog.java new file mode 100644 index 0000000..80be825 --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/UpdateQuantityDialog.java @@ -0,0 +1,56 @@ +package cn.net.connor.ml.plm.bom; + +import java.util.regex.Pattern; + +import javax.swing.JOptionPane; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCException; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateQuantityDialog extends AbstractAIFDialog { + + private TCComponentBOMLine bom; + + public UpdateQuantityDialog(AbstractAIFUIApplication app, TCComponentBOMLine bom) { + this.bom = bom; + } + + @Override + public void run() { + String number = JOptionPane.showInputDialog(this, "", "", JOptionPane.PLAIN_MESSAGE); + if (number != null && !number.equals("")) { +// if (isInteger(number)) { + KUtil.setByPass(true); + try { + bom.setProperty("bl_quantity", number); + bom.getCachedWindow().save(); + bom.getCachedWindow().refresh(); + } catch (TCException e) { + KUtil.setByPass(false); + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } +// } else { +// KUtil.info(AIFDesktop.getActiveDesktop(), "ʽ"); +// return; +// } + } + } + + /*Ƽٶ + * жǷΪ + * @param str ַ + * @return true,򷵻false + */ + public static boolean isInteger(String str) { + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + return pattern.matcher(str).matches(); + } + +} diff --git a/src/cn/net/connor/ml/plm/bom/UpdateQuantityHandler.java b/src/cn/net/connor/ml/plm/bom/UpdateQuantityHandler.java new file mode 100644 index 0000000..fdcaa90 --- /dev/null +++ b/src/cn/net/connor/ml/plm/bom/UpdateQuantityHandler.java @@ -0,0 +1,96 @@ +package cn.net.connor.ml.plm.bom; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentBOMLine; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateQuantityHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); +// TCComponentUser user = session.getUser(); + + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null || !(target instanceof TCComponentBOMLine)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡBOMУ"); + return null; + } + TCComponentBOMLine bom = (TCComponentBOMLine) target; + try { +// TCComponent group = user.getRelatedComponent("login_group"); +// String group_name = group.getProperty("object_string"); +// System.out.println("group_name=" + group_name); +// if (group_name.contains("dba")) { +// new Thread(new UpdateQuantityDialog(app, bom)).start(); +// return null; +// } + String str = bom.getProperty("ML8_MBOM"); + if (str == null || !str.equals("MBOM")) { + KUtil.info(AIFDesktop.getActiveDesktop(), "[ML8_MBOM]"); + return null; + } + + TCComponentBOMLine top = bom.getCachedWindow().getTopBOMLine(); + + TCComponent rev = top.getRelatedComponent("mfg0realRevision"); + // fnd0StartedWorkflowTasks + TCComponent[] tasks = rev.getRelatedComponents("fnd0StartedWorkflowTasks"); + if (tasks == null || tasks.length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ڵ鲻ͨ"); + return null; + } + String task_name = KUtil.getPrefVal(session, "Meling_task_name"); + boolean flag = false; + boolean flag2 = 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) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ϿΪգ"); + return null; + } +//202403--NYL-MBOM༭ڵԱ༭Ȩ + for(TCComponent user1 : users) { + + if (user1.getRelatedComponent("fnd0Performer").getProperty("user_id")==session.getUser().getProperty("user_id")) + { + flag2=true; + break; + } + } +// user_name = users[0].getRelatedComponent("fnd0Performer").getProperty("user_id"); + } + } + if (!flag) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ڵƲƥ䣡"); + return null; + } + +// String userName = user.getProperty("user_id"); + if (!flag2) { + KUtil.info(AIFDesktop.getActiveDesktop(), "Ͽ뵱ǰ¼ûƥ䣡"); + return null; + } + + new Thread(new UpdateQuantityDialog(app, bom)).start(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/src/cn/net/connor/ml/plm/createProject/CreateProjectCommand.java b/src/cn/net/connor/ml/plm/createProject/CreateProjectCommand.java new file mode 100644 index 0000000..977b068 --- /dev/null +++ b/src/cn/net/connor/ml/plm/createProject/CreateProjectCommand.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.createProject; + +import java.awt.Frame; + +import com.teamcenter.rac.commands.project.ProjectCommand; +import com.teamcenter.rac.kernel.TCComponent; + +public class CreateProjectCommand extends ProjectCommand{ + + public CreateProjectCommand(Frame frame, TCComponent[] atccomponent, String s) { + super(frame, atccomponent, s); + } + +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/ConditionMapper.java b/src/cn/net/connor/ml/plm/exportExcel/ConditionMapper.java new file mode 100644 index 0000000..dfad68c --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ConditionMapper.java @@ -0,0 +1,25 @@ +package cn.net.connor.ml.plm.exportExcel; + +public class ConditionMapper { + private String name; + private String field; + private String type; + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getField() { + return field; + } + public void setField(String field) { + this.field = field; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel1Command.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel1Command.java new file mode 100644 index 0000000..b4c2d0a --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel1Command.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.exportExcel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ExportExcel1Command extends KCommand { + + public ExportExcel1Command(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ExportExcel1Dialog(app)); + + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel1Dialog.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel1Dialog.java new file mode 100644 index 0000000..2277d08 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel1Dialog.java @@ -0,0 +1,375 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileOutputStream; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileSystemView; + +import com.alibaba.excel.EasyExcelFactory; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.metadata.Sheet; +import com.alibaba.excel.metadata.Table; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.PropertyDateComponent; + +import cn.net.connor.ml.plm.KUtil; + +@SuppressWarnings("deprecation") +public class ExportExcel1Dialog extends AbstractAIFDialog { + + /** + * + */ + private static final long serialVersionUID = 1L; +// private AbstractAIFApplication app; + private PropertyDateComponent date; + private JButton export; + private TCSession session; +// private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm:ss"); + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd"); +// private SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy hh:mm"); + + public ExportExcel1Dialog(AbstractAIFApplication app) { + super(false); +// this.app = app; + session = (TCSession) app.getSession(); + } + + @Override + public void run() { + initUI(); + addListeners(); + showDialog(); + } + + private void addListeners() { + this.export.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String dateString = date.getDateString(); + if (dateString == null) { + KUtil.info(ExportExcel1Dialog.this, "ѡڣ"); + return; + } + Date temp = date.getDate(); +// Calendar c = Calendar.getInstance(); +// c.setTime(temp); +// c.add(Calendar.DAY_OF_MONTH, 1); + String date = sdf.format(temp); + + System.out.println("date:"+date);// 10 쿪ʼʱ +// System.out.println(sdf.format(c.getTime()));// 11 + try { + String names = KUtil.getPrefVal(session, "Meling_Node_Name"); + if (names == null || names.equals("")) { + KUtil.info(ExportExcel1Dialog.this, "ѡ[Meling_Node_Name]"); + return; + } +// TCComponent[] searchs = session.search("̲ѯ", new String[] { "", "" }, + TCComponent[] searchs = session.search("̲ѯ-zmj", new String[] { "", "", "" }, +// new String[] { sdf.format(temp), sdf.format(c.getTime()) }); + new String[] { date+" 00:00:00", date+" 23:59:59", names }); + if (searchs.length < 1) { + KUtil.info(ExportExcel1Dialog.this, "̲ѯΪգ"); + return; + } + + String[] props = { "release_status_list", "item_id", "item_revision_id", "object_name", "object_desc", "ml8_Units", + "ml8_HazardConstraint", "ml8_ProductCode", "ml8_ProcessingMode", "ml8_Child", "ml8_FigureNum", "ml8_Specifications", + "ml8_ProductType", "ml8_Colour", "ml8_ProjectName" }; + ArrayList> listlist = new ArrayList>(); + +// String[] namess = names.split(";"); + // ڵ + for (TCComponent audit : searchs) { + TCComponent node = audit.getReferenceProperty("parent_task"); + System.out.println("audit:"+audit+"\nnode"+node); + if(node==null) + continue; + String name = node.getProperty("object_name"); + +// boolean flag = false; +// for (String str : namess) { +// if (str.equals(name)) { +// flag = true; +// } +// } +// if (!flag) { +// continue; +// } + + System.out.println("ҵˡ "); + TCComponent search = node.getRelatedComponent("fnd0RootTask"); + TCComponent rootTask = search.getRelatedComponent("root_task"); + String task_state = rootTask.getStringProperty("task_state"); + + System.out.println("task_state"+task_state); + if(task_state.equals("")) { + continue; + } + + ArrayList list = new ArrayList(); +// String flowDate = search.getProperty("creation_date");// ̴ʱ +// String flowDate = search.getProperty("last_mod_date");// ڵ޸ʱ +// String flowDate = node.getProperty("fnd0EndDate");// ڵʱ + String flowDate = audit.getProperty("fnd0LoggedDate");// ־ʱ + String flowName = name;// + String userName = search.getRelatedComponent("owning_user").getProperty("object_string");// ̴ + String userGroup = search.getProperty("owning_group");// ߲ + list.add(flowDate); + list.add(flowName); + list.add(userName); + String user = audit.getProperty("fnd0UserId"); + TCComponent[] searchUser = session.search("__WEB_find_user", new String[] { "û ID" }, new String[] { user }); + System.out.println("fnd0UserId:"+user+">>"+searchUser.length); + if(searchUser!=null && searchUser.length>0) { + user = searchUser[0].getProperty("user_name"); + System.out.println("user:"+user); + } + + TCComponent[] targets = rootTask.getRelatedComponents("root_target_attachments"); + if (targets.length > 0) { + boolean tempFlag = false; + // ƥ͵Ķ + for (TCComponent target : targets) { + if (!(target instanceof TCComponentItemRevision)) { + continue; + } + if (!"ML8_CNoticeRevision;ML8_CFrozenRevision;ML8_CChosenRevision".contains(target.getType())) { + continue; + } + tempFlag = true; + + ArrayList list1 = new ArrayList<>(); + list1.addAll(list); + String[] values = target.getProperties(props); + list1.addAll(Arrays.asList(values)); + list1.add(userGroup);// 17 + list1.add(user); + listlist.add(list1); +// if (target.getType().equals("ML8_CNoticeRevision")) { +// TCComponent[] relateds = target.getRelatedComponents("ML8_GXBGH"); +// for (TCComponent related : relateds) { +// if (!(related instanceof TCComponentItemRevision)) { +// continue; +// } +// ArrayList list2 = new ArrayList<>(); +// list2.addAll(list); +// String[] value = related.getProperties(props); +// list2.addAll(Arrays.asList(value)); +// list2.add(userGroup); +// listlist.add(list2); +// } +// } +// if (target.getType().equals("ML8_CFrozenRevision")) { +// TCComponent[] related1s = target.getRelatedComponents("ML8_GXDJ"); +// for (TCComponent related1 : related1s) { +// if (!(related1 instanceof TCComponentItemRevision)) { +// continue; +// } +// ArrayList list2 = new ArrayList<>(); +// list2.addAll(list); +// String[] value = related1.getProperties(props); +// list2.addAll(Arrays.asList(value)); +// list2.add(userGroup); +// listlist.add(list2); +// } +// TCComponent[] related2s = target.getRelatedComponents("ML8_GXPT"); +// for (TCComponent related2 : related2s) { +// if (!(related2 instanceof TCComponentItemRevision)) { +// continue; +// } +// ArrayList list2 = new ArrayList<>(); +// list2.addAll(list); +// String[] value = related2.getProperties(props); +// list2.addAll(Arrays.asList(value)); +// list2.add(userGroup); +// listlist.add(list2); +// } +// } +// if (target.getType().equals("ML8_CChosenRevision")) { +// TCComponent[] related1s = target.getRelatedComponents("ML8_GXPT"); +// for (TCComponent related1 : related1s) { +// if (!(related1 instanceof TCComponentItemRevision)) { +// continue; +// } +// ArrayList list2 = new ArrayList<>(); +// list2.addAll(list); +// String[] value = related1.getProperties(props); +// list2.addAll(Arrays.asList(value)); +// list2.add(userGroup); +// listlist.add(list2); +// } +// TCComponent[] related2s = target.getRelatedComponents("ML8_GXXY"); +// for (TCComponent related2 : related2s) { +// if (!(related2 instanceof TCComponentItemRevision)) { +// continue; +// } +// ArrayList list2 = new ArrayList<>(); +// list2.addAll(list); +// String[] value = related2.getProperties(props); +// list2.addAll(Arrays.asList(value)); +// list2.add(userGroup); +// listlist.add(list2); +// } +// TCComponent[] related3s = target.getRelatedComponents("ML8_GXYY"); +// for (TCComponent related3 : related3s) { +// if (!(related3 instanceof TCComponentItemRevision)) { +// continue; +// } +// ArrayList list2 = new ArrayList<>(); +// list2.addAll(list); +// String[] value = related3.getProperties(props); +// list2.addAll(Arrays.asList(value)); +// list2.add(userGroup); +// listlist.add(list2); +// } +// } + } + // Ŀж + if (!tempFlag) { + for (TCComponent target : targets) { + if (!(target instanceof TCComponentItemRevision)) { + continue; + } + ArrayList list1 = new ArrayList<>(); + list1.addAll(list); + String[] values = target.getProperties(props); + list1.addAll(Arrays.asList(values)); + list1.add(userGroup);// 17 + list1.add(user); + listlist.add(list1); + } + } + } + } + + outtoExcel(listlist); + disposeDialog(); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + } + + protected void outtoExcel(ArrayList> listlist) { + for (ArrayList arrayList : listlist) { + System.out.println(arrayList); + } + System.out.println("ʼ"); + System.out.println(listlist.size()); + File file = getFile(); + if (file == null) { + return; + } + try { + FileOutputStream fos = new FileOutputStream(file); + ExcelWriter writer = EasyExcelFactory.getWriter(fos); + + Sheet sheet = new Sheet(1, 0); + sheet.setSheetName("ձ"); + Table table = new Table(1); + + List> headList = new ArrayList>(); + String[] head = new String[] { "ʱ", "ҵ", "", "ҵ״̬", "ID", "汾", "", "", "Ĭϵλ", "ΣԼ", "Ʒ", "ӹʽ", "Ӽ", "ͼ", "ͺ", + "Ʒͺ", "ɫ", "Ŀ", "߲", "" }; + for (String string : head) { + ArrayList list = new ArrayList<>(); + list.add(string); + headList.add(list); + } + table.setHead(headList); + writer.write1(listlist, sheet, table); + writer.finish(); + KUtil.info(this, "ɹ!\n" + file); + fos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private File getFile() { + JFileChooser jf = new JFileChooser(); + String name = "ձ.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(null, ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(null, "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(null, "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private void initUI() { + this.setTitle("ѡ"); + this.setLayout(new GridBagLayout()); + GridBagConstraints c = new GridBagConstraints(); + + JLabel label = new JLabel("ѡڣ"); + date = new PropertyDateComponent(); + export = new JButton(""); + + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 0.2;// Ȩ + c.gridx = 0;// + c.gridy = 0;// + this.add(label, c); + + c.fill = GridBagConstraints.HORIZONTAL; + c.weightx = 0.8; + c.gridx = 1; + c.gridy = 0; + this.add(date, c); + + c.fill = GridBagConstraints.HORIZONTAL; + c.gridx = 0; + c.gridy = 1; + c.weightx = 0.0; + c.gridwidth = 2; + this.add(export, c); + + } + +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel2Command.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel2Command.java new file mode 100644 index 0000000..2271ce1 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel2Command.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.exportExcel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ExportExcel2Command extends KCommand { + + public ExportExcel2Command(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + + this.setRunnable(new ExportExcel2Operation(app, "Чݱ")); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel2Operation.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel2Operation.java new file mode 100644 index 0000000..ed280c1 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel2Operation.java @@ -0,0 +1,241 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.io.File; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import 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.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; + +import cn.net.connor.ml.plm.KOperation2; +import cn.net.connor.ml.plm.KUtil; +//Чݱ +public class ExportExcel2Operation extends KOperation2 { + + private LinkedHashMap map; + private ArrayList ids; + private String state;// ״̬ + + public ExportExcel2Operation(AbstractAIFApplication app, String opName) { + super(app, opName); + } + + @Override + public boolean init() throws Exception { + pb.setText("ڳʼ..."); + String testValue = KUtil.getPrefVal((TCSession) app.getSession(), "Meling_Limit_Excel"); + TCComponent[] searchs = session.search("ݱ", new String[] { "ID" }, new String[] { testValue }); + if (searchs.length < 1) { + KUtil.info(getCurrentDesktop(), "̲ѯΪգ"); + return false; + } + // 洢յĶ + map = new LinkedHashMap(); + // 洢ID + ids = new ArrayList<>(); + + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + + int i = 1; + for (TCComponent search : searchs) { + String message = "ѯ" + i + "/" + searchs.length; + pb.setText(message); + TCComponentItemRevision rev = (TCComponentItemRevision) search; + TCComponentBOMLine line = view.setWindowTopLine(rev.getItem(), rev, null, null);// Ѱ汾bomline +//NYL202310ԻȡԭΪml8_MaterialStatusΪml8_Status + state = rev.getProperty("ml8_MaterialStatus"); + state = state == null ? "" : state; + findAllBoms(line, message); + i++; + } + + // + for (String id : ids) { + if (map.get(id) != null) { + map.remove(id); + } + } + + pb.setText("Ҫ" + map.size()); + if (map.size() == 0) { + return false; + } + return true; + } + + // BOM + private void findAllBoms(TCComponentBOMLine line, String message) throws TCException { + AIFComponentContext[] childs = line.getChildren(); + if (childs == null || childs.length == 0) { + System.out.println(line + "ͼΪգ"); + pb.setText(message + ">>" + line + "ͼΪգ"); + return; + } + for (AIFComponentContext child : childs) { + TCComponentBOMLine cLine = (TCComponentBOMLine) child.getComponent(); + String item_id = cLine.getProperty("bl_rev_awp0Item_item_id"); +//NYL202310ֵӶֵFreezePart + //if (state.equals("") || state.equals("FreezePart")) + //ӷֹ״̬ 20250116 + if (state.equals("ObsoletePart") || state.equals("FreezePart")) { + if (!map.containsKey(item_id)) { + map.put(item_id, cLine.getRelatedComponent("mfg0realRevision")); + } + } else { + if (!ids.contains(item_id)) { + ids.add(item_id); + } + } + findAllBoms(cLine, message); + } + } + + @Override + public void execute() throws Exception { + File file = getFile(); + if (file == null) { + return; + } + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + + String[] columnNames = { "", "ͼ", "汾", "״̬", "", "Ŀ", "ɫ", "Ӽ", "ӹʽ", "Ƿۺ󱸼", "", "", "" }; + Row title = sheet.createRow(0); + for (int i = 0; i < columnNames.length; i++) { + Cell cell = title.createCell(i); + cell.setCellValue(columnNames[i]); + } + + int i = 1; + for (String id : map.keySet()) { + pb.setText("ڵ" + i + "/" + map.size() + "..."); + Row row = sheet.createRow(i); + for (int j = 0; j < columnNames.length; j++) { + Cell cell = row.createCell(j); + if (j == 0) {// + cell.setCellValue(id); + } + TCComponentItemRevision rev = (TCComponentItemRevision) map.get(id); + TCComponentItem item = rev.getItem(); + + if (j == 1) {// ͼ + cell.setCellValue(rev.getProperty("ml8_FigureNum")); + } + if (j == 2) {// 汾 + cell.setCellValue(rev.getProperty("item_revision_id")); + } + if (j == 3) {// ״̬ + if (item.getType().equals("ML8_Refrigerator")) { + cell.setCellValue(rev.getProperty("ml8_MaterialStatus")); + } else if (item.getType().equals("ML8_Part") || item.getType().equals("ML8_RawMaterial")) { + cell.setCellValue(item.getProperty("ml8_Status")); + } + } + if (j == 4) {// + cell.setCellValue(rev.getProperty("object_desc")); + } + if (j == 5) {// Ŀ + TCComponent[] form = rev.getRelatedComponents("ML8_ProjectRelation"); + if (form == null || form.length == 0) { + cell.setCellValue(""); + } else { + cell.setCellValue(form[0].getProperty("ml8_ProjectName")); + } + } + if (j == 6) {// ɫ + cell.setCellValue(rev.getProperty("ml8_Colour")); + } + if (j == 7) {// Ӽ + cell.setCellValue(rev.getProperty("ml8_Child")); + } + if (j == 8) {// ӹʽ + cell.setCellValue(rev.getProperty("ml8_ProcessingMode")); + } + if (j == 9) {// Ƿۺ󱸼 + cell.setCellValue(rev.getProperty("ml8_AfterSale")); + } + if (j == 10) {// + cell.setCellValue(rev.getProperty("creation_date")); + } + if (j == 11) {// + cell.setCellValue(rev.getProperty("ml8_BOMFirstTime")); + } + if (j == 12) {// + cell.setCellValue(rev.getProperty("ml8_Proposer")); + } + } + i++; + } + + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + KUtil.info(getCurrentDesktop(), "ɹ"); + } + + private File getFile() throws TCException { + JFileChooser jf = new JFileChooser(); + String name = "Чݱ.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(getCurrentDesktop(), ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(getCurrentDesktop(), "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(getCurrentDesktop(), "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new XSSFWorkbook(); + workbook.createSheet("sheet1"); + return workbook; + } +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel3Command.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel3Command.java new file mode 100644 index 0000000..dace077 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel3Command.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.exportExcel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ExportExcel3Command extends KCommand { + + public ExportExcel3Command(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + + this.setRunnable(new ExportExcel3Operation(app, "ϱ")); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel3Operation.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel3Operation.java new file mode 100644 index 0000000..b75f81f --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel3Operation.java @@ -0,0 +1,223 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.io.File; + +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Properties; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KOperation2; +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.getSpecifications.SqlUtil; + +//ϱ +public class ExportExcel3Operation extends KOperation2 { + + private ArrayList plist; + private ArrayList dlist; + + public ExportExcel3Operation(AbstractAIFApplication app, String opName) { + super(app, opName); + } + + @Override + public boolean init() throws Exception { + pb.setText("ڳʼ..."); + + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return false; + } + +// System.out.println(Thread.currentThread().getContextClassLoader().getResource("plm.properties").getFile()); + InputStream in = ExportExcel3Operation.class.getResourceAsStream("/plm.properties"); + Properties p = new Properties(); + p.load(in); + + String sql = p.getProperty("EXCEL3.SQL"); +//NYL״ֵ̬仯ĸΪӢIJӲ컯״̬-202310 + ResultSet rs = SqlUtil.read(sql, new String[] { "PreferencePart", "CommonPart", "RestrictPart", "DiscrepantPart" }); + plist = new ArrayList(); + dlist = new ArrayList(); + while (rs.next()) { +// String ipuid = rs.getString(1); + String date = rs.getString(2); + String puid = rs.getString(3); + dlist.add(date); + plist.add(puid); + } + pb.setText("ѯĽ" + plist.size()); + SqlUtil.free(); + return true; + } + + @Override + public void execute() throws Exception { + File file = getFile(); + if (file == null) { + return; + } + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + + String[] columnNames = { "ϴ", "A汾", "A汾ʱ", "°汾", "", "ʱ", "", "״̬", "ͺ", "", "Ŀ", "", "", "ע2" }; + Row title = sheet.createRow(0); + for (int i = 0; i < columnNames.length; i++) { + Cell cell = title.createCell(i); + cell.setCellValue(columnNames[i]); + } + String group = session.getGroup().getProperty("object_string"); + int k = 0; + for (int i = 0; i < plist.size(); i++) { + pb.setText("ڴ" + (i + 1) + "/" + plist.size()); + String puid = plist.get(i); + TCComponentItemRevision rev = null; + try { + rev = (TCComponentItemRevision) session.stringToComponent(puid); + } catch (TCException e1) { + e1.printStackTrace(); + } + if (rev == null) { + continue; + } + if(rev.getProperty("item_id").indexOf("-")>-1) { + continue; + } + Row row = sheet.createRow(k + 1); + k++; + for (int j = 0; j < columnNames.length; j++) { + Cell cell = row.createCell(j); + if (j == 0) {// ϴ + cell.setCellValue(rev.getProperty("item_id")); + } + if (j == 1) {// A汾 ml8_Proposer + cell.setCellValue(rev.getProperty("ml8_Proposer")); + } + if (j == 2) {// A汾ʱ + cell.setCellValue(dlist.get(i)); + } + TCComponentItem item = rev.getItem(); + TCComponentItemRevision latest = null; + try { + latest = item == null ? null : item.getLatestItemRevision(); + } catch (TCException e) { + e.printStackTrace(); + } + if (j == 3) {// °汾 + cell.setCellValue(latest == null ? "" : latest.getProperty("item_revision_id")); + } + if (j == 4) {// + TCComponent[] states = rev.getRelatedComponents("release_status_list"); + if (states != null && states.length > 0) { + String name = states[0].getProperty("object_name"); + cell.setCellValue(name); + } + } + // creation_date + if (j == 5) {// ʱ + cell.setCellValue(latest == null ? "" : latest.getProperty("creation_date")); + } + if (j == 6) {// + cell.setCellValue(rev.getProperty("object_name")); + } + if (j == 7) {// ״̬ ml8_Status + cell.setCellValue(rev.getProperty("ml8_Status")); + } + if (j == 8) {// ͺml8_Specifications + cell.setCellValue(rev.getProperty("ml8_Specifications")); + } + if (j == 9) {// + cell.setCellValue(rev.getProperty("object_desc")); + } + if (j == 10) {// Ŀ + TCComponent[] relations = rev.getRelatedComponents("ML8_ProjectRelation"); + if (relations != null && relations.length > 0) { + String name = relations[0].getProperty("object_name"); + cell.setCellValue(name); + } + } + if (j == 11) {// + cell.setCellValue(latest == null ? "" : latest.getProperty("ml8_Proposer")); + } + if (j == 12) {// + cell.setCellValue(group); + } + if (j == 13) {// ע2 + cell.setCellValue(rev.getProperty("ml8_Remark2")); + } + } + } + + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + KUtil.info(getCurrentDesktop(), "ɹ"); + } + + private File getFile() throws TCException { + JFileChooser jf = new JFileChooser(); + String name = "ϱ.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(getCurrentDesktop(), ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(getCurrentDesktop(), "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(getCurrentDesktop(), "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new SXSSFWorkbook(100); + workbook.createSheet("sheet1"); + return workbook; + } +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel4Command.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel4Command.java new file mode 100644 index 0000000..d1bb0d5 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel4Command.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.exportExcel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ExportExcel4Command extends KCommand { + + public ExportExcel4Command(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + + this.setRunnable(new ExportExcel4Operation(app, "ݱ")); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcel4Operation.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel4Operation.java new file mode 100644 index 0000000..65d376c --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcel4Operation.java @@ -0,0 +1,209 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Properties; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KOperation2; +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.getSpecifications.SqlUtil; + +//ݱ +public class ExportExcel4Operation extends KOperation2 { + +// private ArrayList ids; +// private String state;// ״̬ + private ArrayList rlist; + + public ExportExcel4Operation(AbstractAIFApplication app, String opName) { + super(app, opName); + } + + @Override + public boolean init() throws Exception { + pb.setText("ڳʼ..."); + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return false; + } + InputStream in = ExportExcel3Operation.class.getResourceAsStream("/plm.properties"); + Properties p = new Properties(); + p.load(in); + + String sql = p.getProperty("EXCEL4.SQL"); + //ResultSet rs = SqlUtil.read(sql, new String[] { "FreezePart", "FreezePart" }); + ResultSet rs = SqlUtil.read(sql, new String[] { "FreezePart", "ObsoletePart","FreezePart", "ObsoletePart" });//Ҫӷֹ״̬ 20250116 + rlist = new ArrayList(); + while (rs.next()) { + String uid = rs.getString(1);// uid + try { + TCComponent item = session.stringToComponent(uid); + if (item instanceof TCComponentItem) { + rlist.add(((TCComponentItem) item).getLatestItemRevision()); + } + } catch (TCException e) { +// e.printStackTrace(); + } + } + if (rlist.size() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿѯΪգ", "", MessageBox.INFORMATION); + return false; + } + pb.setText("ѯĽ" + rlist.size()); + SqlUtil.free(); + return true; + } + + @Override + public void execute() throws Exception { + File file = getFile(); + if (file == null) { + return; + } + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + + String[] columnNames = { "", "ͼ", "汾", "״̬", "", "Ŀ", "ɫ", "Ӽ", "ӹʽ", "Ƿۺ󱸼", "", "", "" }; + Row title = sheet.createRow(0); + for (int i = 0; i < columnNames.length; i++) { + Cell cell = title.createCell(i); + cell.setCellValue(columnNames[i]); + } + + int i = 1; + for (TCComponentItemRevision rev : rlist) { + if(rev.getProperty("item_id").indexOf("-")>-1) { + continue; + } + pb.setText("ڵ" + i + "/" + rlist.size() + "..."); + Row row = sheet.createRow(i); + for (int j = 0; j < columnNames.length; j++) { + Cell cell = row.createCell(j); + if (j == 0) {// + cell.setCellValue(rev.getProperty("item_id")); + } + TCComponentItem item = rev.getItem(); + + if (j == 1) {// ͼ + cell.setCellValue(rev.getProperty("ml8_FigureNum")); + } + if (j == 2) {// 汾 + cell.setCellValue(rev.getProperty("item_revision_id")); + } + if (j == 3) {// ״̬ + if (item.getType().equals("ML8_Refrigerator")) { + cell.setCellValue(rev.getProperty("ml8_MaterialStatus")); + } else if (item.getType().equals("ML8_Part") || item.getType().equals("ML8_RawMaterial")) { + cell.setCellValue(item.getProperty("ml8_Status")); + } + } + if (j == 4) {// + cell.setCellValue(rev.getProperty("object_desc")); + } + if (j == 5) {// Ŀ + TCComponent[] form = rev.getRelatedComponents("ML8_ProjectRelation"); + if (form == null || form.length == 0) { + cell.setCellValue(""); + } else { + cell.setCellValue(form[0].getProperty("ml8_ProjectName")); + } + } + if (j == 6) {// ɫ + cell.setCellValue(rev.getProperty("ml8_Colour")); + } + if (j == 7) {// Ӽ + cell.setCellValue(rev.getProperty("ml8_Child")); + } + if (j == 8) {// ӹʽ + cell.setCellValue(rev.getProperty("ml8_ProcessingMode")); + } + if (j == 9) {// Ƿۺ󱸼 + cell.setCellValue(rev.getProperty("ml8_AfterSale")); + } + if (j == 10) {// + cell.setCellValue(rev.getProperty("creation_date")); + } + if (j == 11) {// + cell.setCellValue(rev.getProperty("ml8_BOMFirstTime")); + } + if (j == 12) {// + cell.setCellValue(rev.getProperty("ml8_Proposer")); + } + } + i++; + } + + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + KUtil.info(getCurrentDesktop(), "ɹ"); + } + + private File getFile() throws TCException { + JFileChooser jf = new JFileChooser(); + String name = "ݱ.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(getCurrentDesktop(), ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(getCurrentDesktop(), "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(getCurrentDesktop(), "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new XSSFWorkbook(); + workbook.createSheet("sheet1"); + return workbook; + } +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcelCommand6.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelCommand6.java new file mode 100644 index 0000000..8755042 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelCommand6.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.exportExcel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ExportExcelCommand6 extends KCommand { + + public ExportExcelCommand6(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ExportExcelDialog6(app)); + + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6.java new file mode 100644 index 0000000..a5c1706 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6.java @@ -0,0 +1,368 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; + +import com.alibaba.excel.EasyExcelFactory; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.metadata.Sheet; +import com.alibaba.excel.metadata.Table; +import com.sun.xml.bind.v2.util.QNameMap.Entry; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.PropertyDateComponent; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.yujianbo.main.main; + +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.gotoQMS.DbPool; + +@SuppressWarnings("deprecation") +public class ExportExcelDialog6 extends AbstractAIFDialog { + + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private PropertyDateComponent date; + private JButton export; + private TCSession session; + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd"); + private String[] values; + private String path=""; + private String[] condition; + + public ExportExcelDialog6(AbstractAIFApplication app) { + super(false); + this.app = app; + session = (TCSession) app.getSession(); + values = session.getPreferenceService().getStringValues("CONNOR_FIELD"); + condition = session.getPreferenceService().getStringValues("CONNOR_CONDITION"); + } + + @Override + public void run() { + if(values == null) { + System.out.println("ѡ CONNOR_FIELD"); + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "ѡ CONNOR_FIELD", "", 1); + return; + } + if(condition == null) { + System.out.println("ѡ CONNOR_FIELD"); + MessageBox.post(AIFDesktop.getActiveDesktop().getShell(), + "ѡ CONNOR_CONDITION", "", 1); + return; + } + initUI(); + showDialog(); + } + + private void initUI() { + this.setTitle("ѡ"); + this.setLayout(new PropertyLayout()); + + //ӵпʼ + int line = 5; + HashMap stringValueMap = new HashMap(); + HashMap> dateValueMap = new HashMap>(); + ArrayList conditionList = getCondition(condition); + for (int i = 0; i < conditionList.size(); i++) { + ConditionMapper con = conditionList.get(i); + System.out.println(i+"-"+con.getField()+"-"+con.getName()+"-"+con.getType()); + //Stringֶ + if(con.getType().equals("string")) { + JLabel labelName = new JLabel(con.getName()+""); + JTextField name = new JTextField(50); + this.add(line+".1.center.top",labelName); + this.add(line+".2.center.top",name); + stringValueMap.put(con.getField(), name); + line++; + }else if(con.getType().equals("date")){ + JLabel labelDate1 = new JLabel(con.getName()+"ʼڣ"); + DateButton dateButton1 = new DateButton(sdf); + JLabel labelDate2 = new JLabel(con.getName()+"ڣ"); + DateButton dateButton2 = new DateButton(sdf); + this.add(line+".1.center.top",labelDate1); + this.add(line+".2.center.top",dateButton1); + this.add(line+".3.center.top",labelDate2); + this.add(line+".4.center.top",dateButton2); + ArrayList dateList = new ArrayList(); + dateList.add(dateButton1); + dateList.add(dateButton2); + dateValueMap.put(con.getField(), dateList); + line++; + } + + } +// JLabel labelName = new JLabel(" дӿƣ"); +// JTextField name = new JTextField(50); +// +// JLabel labelType = new JLabel(" дӿͣ"); +// JTextField type = new JTextField(50); +// +// JLabel labelItemId = new JLabel("дitem"); +// JTextField itemId = new JTextField(50); +// +// JLabel labelDate1 = new JLabel("ѡʼڣ"); +// DateButton dateButton1 = new DateButton(sdf); +// JLabel labelDate2 = new JLabel("ѡڣ"); +// DateButton dateButton2 = new DateButton(sdf); +// if(dateButton1.getDate().getTime() > dateButton2.getDate().getTime()) { +// MessageBox.post("Ҫʼ", "ʾ", MessageBox.INFORMATION); +// return; +// } + export = new JButton("ѯ"); + export.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + //׼sql + String conditionSql = ""; + for (java.util.Map.Entry map : stringValueMap.entrySet()) { + String tempSql = getSql(map.getValue().getText(),map.getKey()); + conditionSql += tempSql; + } + for (java.util.Map.Entry> map : dateValueMap.entrySet()) { + String tempSql = getDate(map.getValue().get(0).getDateString(), map.getValue().get(1).getDateString(), map.getKey()); + conditionSql += tempSql; + } + String field = values[0]; + String sql = "SELECT "+ field + " FROM ML_WEBSERVICE_LOG WHERE 1=1 " + conditionSql; + ResultSet res; + try { + DbPool.getConnection(); + System.out.println(sql); + res = DbPool.executeSelectSql(sql); + //׼table + int count = 0;//ܹ + while(res.next()) { + count++; + } + System.out.println("-----------------------count="+count); + String[] strField = getStrings(field); + String data[][] = new String[count][strField.length]; + int index = 0;//б + res = DbPool.executeSelectSql(sql); + while(res.next()) { + for (int i = 0; i < strField.length; i++) { + data[index][i] = res.getString(strField[i]); + } + index++; + } + new Thread(new ExportExcelDialog6Son(app,strField,data)).start(); + } catch (Exception e2) { + // TODO: handle exception + }finally { + DbPool.freeAll(); + } + + } + }); + + //־ + JLabel weekReport = new JLabel(" 鿴һĽӿ־"); + Button choosePathButton = new Button("ѡ񱣴·"); + JTextField pathText = new JTextField(40); + choosePathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JFileChooser jFileChooser = new JFileChooser(); + //ֻѡļ + jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int showOpenDialog = jFileChooser.showOpenDialog(null); + if(showOpenDialog == JFileChooser.APPROVE_OPTION) { + File selectedFile = jFileChooser.getSelectedFile(); + path = selectedFile.getAbsolutePath(); + pathText.setText(path); + System.out.println(path); + } + + } + }); + JButton excel = new JButton("һĽӿڱEXCEL"); + excel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent var1) { + // TODO Auto-generated method stub + String field = values[0]; + String sql = "SELECT * FROM ML_WEBSERVICE_LOG where ITEMID IN (select ITEMID from (select ITEMID,count(*) cnt from ML_WEBSERVICE_LOG where ITEMID is not NULL and ITEMID!='' and DateDiff(dd,CREATE_DATE,getdate())<=7 GROUP BY ITEMID,NAME ) a where a.cnt % 2 = 1\r\n" + + ")"; + ResultSet res; + try { + DbPool.getConnection(); + System.out.println(sql); + res = DbPool.executeSelectSql(sql); + //׼table + int count = 0;//ܹ + while(res.next()) { + count++; + } + System.out.println("-----------------------count="+count); + String[] strField = getStrings(field); + String data[][] = new String[count][strField.length]; + int index = 0;//б + res = DbPool.executeSelectSql(sql); + while(res.next()) { + for (int i = 0; i < strField.length; i++) { + data[index][i] = res.getString(strField[i]); + } + index++; + } + String title = "һĽӿ־"; + HSSFWorkbook myexcel = ExportExcelUtil.getHSSFWorkbook(title, strField, data); + String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); + String fileName = "һĽӿ־"+date+".xls"; + if(path.equals("") || path.isEmpty()) { + MessageBox.post("ѡļ·", "ʾ", MessageBox.INFORMATION); + return; + } + System.out.println(path+"\\"+fileName); + File file = new File(path+"\\"+fileName); + FileOutputStream out = null; + try { + out = new FileOutputStream(file); + } catch (FileNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if (file.exists()) { + boolean deleteFlag = file.delete(); + } + try { + boolean newFileFlag = file.createNewFile(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + myexcel.write(out); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("ɹ", "ʾ", MessageBox.INFORMATION); + disposeDialog(); + } catch (Exception e2) { + // TODO: handle exception + }finally { + DbPool.freeAll(); + } + + + + } + }); + + this.add("1.1.center.top",weekReport); + this.add("2.1.center.top",choosePathButton); + this.add("2.2.center.top",pathText); + this.add("3.1.center.top",excel); + this.add("4.1.center.top",new JLabel(" ")); +// this.add("1.1.center.top",labelName); +// this.add("1.2.center.top",name); +// this.add("2.1.center.top",labelType); +// this.add("2.2.center.top",type); +// this.add("3.1.center.top",labelItemId); +// this.add("3.2.center.top",itemId); +// this.add("4.1.center.top",labelDate1); +// this.add("4.2.center.top",dateButton1); +// this.add("4.3.center.top",labelDate2); +// this.add("4.4.center.top",dateButton2); + this.add(line+".1.center.top",export); + + + this.pack(); + this.setSize(new Dimension(600,400)); + this.centerToScreen(); + this.showDialog(); + } + + protected String getDate(String dateString, String dateString2,String filed) { + String sql = "AND "; + if(dateString.isEmpty() && !dateString2.isEmpty()) { + sql = sql + filed +" < '"+dateString2+"'"; + }else if(!dateString.isEmpty() && dateString2.isEmpty()){ + sql = sql + filed +" > '"+dateString+"'"; + }else if(dateString.isEmpty() && dateString2.isEmpty()) { + sql = ""; + }else { + sql = sql + filed +" > '"+dateString+"'"+" AND "+filed+" < '"+dateString2+"'"; + } + return sql; + } + + protected String getSql(String text,String field) { + // TODO Auto-generated method stub + if(text.isEmpty() || text.equals("")) { + return ""; + }else { + String sql = "AND"; + String[] values = getStrings(text); + for (int i = 0; i < values.length; i++) { + sql = sql+" "+field+"='"+values[i]+"' or"; + } + //ȥһor + String finalSql = sql.substring(0,sql.length()-2); + return finalSql; + } + + } + + private String[] getStrings(String str) { + String[] values = str.split(","); + return values; + } + + public ArrayList getCondition(String[] condition) { + ArrayList list = new ArrayList(); + for (int i = 0; i < condition.length; i++) { + ConditionMapper conditionMapper = new ConditionMapper(); + String[] values = condition[i].split("-"); + if(values.length > 0 && values != null){ + conditionMapper.setName(values[0]); + conditionMapper.setField(values[1]); + conditionMapper.setType(values[2]); + } + list.add(conditionMapper); + } + return list; + } +} + +//sqlӵipַҪ +//־50ij7 diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son.java new file mode 100644 index 0000000..88c4347 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelDialog6Son.java @@ -0,0 +1,153 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.awt.Button; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import javax.swing.JButton; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; + +import com.alibaba.excel.EasyExcelFactory; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.metadata.Sheet; +import com.alibaba.excel.metadata.Table; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.PropertyDateComponent; +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.ml.plm.KUtil; + +@SuppressWarnings("deprecation") +public class ExportExcelDialog6Son extends AbstractAIFDialog { + + + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private TCSession session; + private String data[][]; + private String[] columnNames; + private String path=""; + public ExportExcelDialog6Son(AbstractAIFApplication app,String[] columnNames,String data[][]) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + this.data = data; + this.columnNames = columnNames; + } + + @Override + public void run() { + initUI(); + showDialog(); + } + + + private void initUI() { + this.setTitle("ѯ"); + this.setLayout(new PropertyLayout()); + JTable table = new JTable(data, columnNames); + JScrollPane tablePane = new JScrollPane(table); + //table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + //ѡļ· + Button choosePathButton = new Button("ѡ񱣴·"); + JTextField pathText = new JTextField(40); + choosePathButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + // TODO Auto-generated method stub + JFileChooser jFileChooser = new JFileChooser(); + //ֻѡļ + jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + int showOpenDialog = jFileChooser.showOpenDialog(null); + if(showOpenDialog == JFileChooser.APPROVE_OPTION) { + File selectedFile = jFileChooser.getSelectedFile(); + path = selectedFile.getAbsolutePath(); + //ֵʾҳ + pathText.setText(path); + System.out.println(path); + } + + } + }); + + + JButton excel = new JButton("־EXCEL"); + excel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent var1) { + // TODO Auto-generated method stub + String title = "־"; + HSSFWorkbook myexcel = ExportExcelUtil.getHSSFWorkbook(title, columnNames, data); + String date = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()); + String fileName = "־"+date+".xls"; + if(path.equals("") || path.isEmpty()) { + MessageBox.post("ѡļ·", "ʾ", MessageBox.INFORMATION); + return; + } + System.out.println(path+"\\"+fileName); + File file = new File(path+"\\"+fileName); + FileOutputStream out = null; + try { + out = new FileOutputStream(file); + } catch (FileNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + if (file.exists()) { + boolean deleteFlag = file.delete(); + } + try { + boolean newFileFlag = file.createNewFile(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + try { + myexcel.write(out); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + MessageBox.post("ɹ", "ʾ", MessageBox.INFORMATION); + disposeDialog(); + } + }); + + this.add("1.1.center.top",tablePane); + this.add("2.1.center.top",choosePathButton); + this.add("3.1.center.top",pathText); + this.add("4.1.center.top",excel); + this.pack(); + this.setSize(new Dimension(600,400)); + this.centerToScreen(); + this.showDialog(); + + } + +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/ExportExcelUtil.java b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelUtil.java new file mode 100644 index 0000000..42ee25e --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/ExportExcelUtil.java @@ -0,0 +1,79 @@ +package cn.net.connor.ml.plm.exportExcel; + +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddress; + +public class ExportExcelUtil { + /** + * + * @param title + * @param headers ͷ + * @param values Ԫ + * @return + */ + public static HSSFWorkbook getHSSFWorkbook(String title, String headers[], String [][] values){ + + //һHSSFWorkbookӦһExcelļ + HSSFWorkbook hssfWorkbook = new HSSFWorkbook(); + + //workbookһsheet,ӦExcelļеsheet + HSSFSheet hssfSheet = hssfWorkbook.createSheet(title); + + //ϲ + hssfSheet.addMergedRegion(new CellRangeAddress(0,(short)0,0,(short)headers.length - 1)); + + //ñʽ + HSSFCellStyle style = hssfWorkbook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); //þʽ + style.setVerticalAlignment(VerticalAlignment.CENTER); + //ñ + Font titleFont = hssfWorkbook.createFont(); + titleFont.setFontHeightInPoints((short) 14); + style.setFont(titleFont); + + //ֵͷʽ ñͷ + HSSFCellStyle hssfCellStyle = hssfWorkbook.createCellStyle(); + hssfCellStyle.setAlignment(HorizontalAlignment.CENTER); //þʽ + hssfCellStyle.setBorderBottom(BorderStyle.THIN); + hssfCellStyle.setBorderLeft(BorderStyle.THIN); + hssfCellStyle.setBorderRight(BorderStyle.THIN); + hssfCellStyle.setBorderTop(BorderStyle.THIN); + + //ñʽ + //Ԫ񣬲ֵͷ ñͷ + HSSFCellStyle style1 = hssfWorkbook.createCellStyle(); + style1.setBorderBottom(BorderStyle.THIN); + style1.setBorderLeft(BorderStyle.THIN); + style1.setBorderRight(BorderStyle.THIN); + style1.setBorderTop(BorderStyle.THIN); + + // + HSSFRow hssfRow = hssfSheet.createRow(0); + HSSFCell cell = hssfRow.createCell(0); + cell.setCellValue(title); + cell.setCellStyle(style); + + + + //ͷ + HSSFRow row1 = hssfSheet.createRow(1); + for (int i = 0; i < headers.length; i++) { + HSSFCell hssfCell = row1.createCell(i); + hssfCell.setCellValue(headers[i]); + hssfCell.setCellStyle(hssfCellStyle); + } + + // + for (int i = 0; i screenWidth) { + abstractAIFDialog.setSize(new Dimension((int) Math.floor(screenWidth - 20), (int) Math.floor(dialogSize.getHeight()))); + abstractAIFDialog.setLocation(10, (int) Math.floor(abstractAIFDialog.getLocation().getY())); + } + if (screenHeight < MINHEIGHT && dialogSize.getHeight() > screenHeight) { + abstractAIFDialog.setSize(new Dimension((int) Math.floor(dialogSize.getWidth()), (int) Math.floor(screenHeight - 20))); + abstractAIFDialog.setLocation((int) Math.floor(abstractAIFDialog.getLocation().getX()), 10); + } + /* + * if((screenWidth + * MINWIDTH||dialogSize.getHeight()>MINHEIGHT)) { abstractAIFDialog.setSize(new + * Dimension((int)Math.floor(screenWidth-20),(int)Math.floor(screenHeight-20))); + * abstractAIFDialog.setLocation(10, 10); } + */ + } + + public static TCComponentBOMWindow getWindow(TCSession session) throws Exception{ + TCComponentBOMWindow window = null; + TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + window = bomWinType.create(null); + return window; + } + + public static TCComponentBOMLine getBOMLine(TCSession session,TCComponentBOMWindow window, TCComponentItemRevision revision) + throws Exception { + window.lock(); + TCComponentBOMLine bomLine = window.setWindowTopLine(null, revision, null, null); + window.save(); + window.unlock(); + return bomLine; + } + public static TCComponentPseudoFolder getPseudoFolder(TCComponent parent, String relation) throws Exception { + TCComponentPseudoFolder pseudoFolder = null; + AIFComponentContext[] comps = parent.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if (comp instanceof TCComponentPseudoFolder) { + if (comp.isTypeOf("PseudoFolder")) { +// System.out.println("PseudoFolder type:" + comp.getDefaultPasteRelation()); + if (comp.getDefaultPasteRelation().equalsIgnoreCase(relation)) { + pseudoFolder = (TCComponentPseudoFolder) comp; + break; + } + } + } + } + } + return pseudoFolder; + } + public static TCComponentForm getItemRevisionMasterForm(TCComponentItemRevision revision) throws Exception { + if (revision != null) { + AIFComponentContext[] contexts = revision.getChildren("IMAN_master_form_rev"); + if (contexts != null && contexts.length > 0) { + InterfaceAIFComponent component = contexts[0].getComponent(); + if (component instanceof TCComponentForm) { + return (TCComponentForm) component; + } + } + } + return null; + } + + public static LinkedHashMap getlovValues(TCSession session, String lovName) throws TCException { + LinkedHashMap lovVal = new LinkedHashMap(); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lovs = lovType.find(lovName); + if (lovs != null && lovs.length > 0) { + TCComponentListOfValues lov = lovs[0]; + ListOfValuesInfo lovInfo = lov.getListOfValues(); + String[] code = lovInfo.getStringListOfValues(); + String[] name = lovInfo.getLOVDisplayValues(); + if (code != null && name != null) { + for (int i = 0; i < code.length; i++) { + // System.out.printf("code[%d]=%s name[%d]=%s \n", i, code[i], i, name[i]); + lovVal.put(code[i], name[i]); + } + } + return lovVal; + } + return null; + } + + public static String getTableValue(JTable table, int row, int col){ + Object val = table.getValueAt(row, col); + if(val==null) + return ""; + else + return val.toString(); + } + public static TCComponent[] query(TCSession session, String queryName, String[] aKey, String[] aVal) throws Exception { + TCComponentQueryType imanQueryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery imancomponentquery = (TCComponentQuery) imanQueryType.find(queryName); + if (imancomponentquery == null) { + throw new Exception("δҵѯ " + queryName + "!"); + } + aKey = session.getTextService().getTextValues(aKey); +// for (int i = 0; i < aKey.length; i++) { +// System.out.println(aKey[i] + "===============" + aVal[i]); +// } + TCComponentContextList componentContextList = imancomponentquery.getExecuteResultsList(aKey, aVal); + return componentContextList.toTCComponentArray(); + } + public static TCComponent[] query(TCSession session, String queryName, Vector Keys, Vector Vals) throws Exception { + TCComponentQueryType imanQueryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery imancomponentquery = (TCComponentQuery) imanQueryType.find(queryName); + if (imancomponentquery == null) { + System.out.println("δҵѯ" + queryName); + throw new Exception("Query:"+queryName+" cannot find"); + } + TCQueryClause[] qc = imancomponentquery.describe(); +// Map clauseMap = new HashMap<>(); + for(TCQueryClause c : qc) { + String key = c.getUserEntryNameDisplay(); + String value = c.getDefaultValue(); +// System.out.println(key + "==>" + c.getAttributeName()); + if(!value.trim().isEmpty() && !Keys.contains(key)) { + if(key.isEmpty()) + Keys.add(c.getAttributeName()); + else + Keys.add(key); + Vals.add(value); + } + } + int size = Keys.size(); + String[] keyA = new String[size]; + String[] valueA = new String[size]; + for(int i=0; i 0) { + Integer maxId = 0; + for (TCComponent comp : comps) { + String pid = comp.getProperty("item_id"); + System.out.println("pid:" + pid); + String pidSuffix = pid.substring(pid.length() - 3); + if (Integer.parseInt(pidSuffix) > maxId) { + maxId = Integer.parseInt(pidSuffix); + } + } + return String.format("%03d", maxId + 1); + } + return "001"; + } + + public static File saveExcelChooser() { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Excel", saveType)); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + System.out.println("saveExcelChooser1:" + path); + } + return dir; + } + + public static File saveExcelChooser(String defaultFile,String item_id) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + chooser.setSelectedFile(new File(defaultFile)); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Excel", saveType)); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + String substring = path.substring(path.lastIndexOf("\\")+1); + //substring=item_id+substring; + path=dir.getParent()+File.separator+substring.replace("\\", "_"); + System.out.println(path); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + if(dir.exists()) + dir.delete(); +// System.out.println("saveExcelChooser1:" + dir.getPath()); + } + return dir; + } + + public static File saveExcelChooser(String defaultFile) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + chooser.setSelectedFile(new File(defaultFile)); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Excel", saveType)); + int returnVal = chooser.showSaveDialog(new Frame()); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + if(dir.exists()) + dir.delete(); +// System.out.println("saveExcelChooser1:" + dir.getPath()); + } + return dir; + } + public static File saveExcelChooserAsk(String defaultFile) { + File dir = null; + JFileChooser chooser = new JFileChooser(); + chooser.setAcceptAllFileFilterUsed(false); +// File currentDir = FileSystemView.getFileSystemView().getDefaultDirectory(); + File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory(); + chooser.setCurrentDirectory(desktopDir); + chooser.setSelectedFile(new File(defaultFile)); + String saveType[] = { "xlsx" }; + chooser.setFileFilter(new FileNameExtensionFilter("Excel", saveType)); + int returnVal = chooser.showSaveDialog(null); + if (returnVal == JFileChooser.APPROVE_OPTION) { + dir = chooser.getSelectedFile(); + String path = dir.getPath(); + if(!path.toLowerCase().endsWith(".xlsx")) { + path += ".xlsx"; + dir = new File(path); + } + if(dir.exists()) { + int choose = JOptionPane.showOptionDialog(chooser, "ļѴڣǷ滻?", "ʾ", + JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {"",""}, ""); + if(choose==0) + dir.delete(); + else + dir = saveExcelChooserAsk(dir.getPath()); + } +// System.out.println("saveExcelChooser1:" + dir.getPath()); + } +// new Thread() { +// public void run() { +// +// } +// }; + return dir; + } + + public static boolean contains(String[] array, String str) { + for(String s : array) { +// System.out.println("contains:"+s+"="+str); + if(s.equals(str)) + return true; + } + return false; + } + + public static Map executeToMap(InputStream in){ + System.out.println("Read properties file"); + try { + BufferedReader reader = new BufferedReader(new InputStreamReader(in, "utf-8")); + String line = null; + Map resultMap = new LinkedHashMap<>(16); + if (reader.ready()) { + while (null != (line = reader.readLine())) { + if (line.length() <= 0 || line.contains("#") || !line.contains("=")) { + continue; + } + resultMap.put(line.substring(0, line.indexOf("=")), line.substring(line.indexOf("=") + 1)); + } + } + in.close(); + reader.close(); + return resultMap; + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post("Find properties file failed", "ERROR", MessageBox.ERROR); + } + return null; + } + + public static TCComponentDataset createExcelDataset(TCSession session, File file, String datasetName) throws Exception { + String refType = null, objType = null, fileName = null; + fileName = file.getName().toLowerCase(); + if (fileName.endsWith("xls")) { + refType = "excel"; + objType = "MSExcel"; + } else if (fileName.endsWith("xlsx")) { + refType = "excel"; + objType = "MSExcelX"; + } + TCComponentDatasetType compType = (TCComponentDatasetType) session.getTypeService().getTypeComponent("Dataset"); + TCComponentDataset dataset = compType.create(datasetName, "description", objType); + dataset.setFiles(new String[] { file.getAbsolutePath() }, new String[] { refType }); + return dataset; + } + + public static Vector getChildren(TCComponent parent, String relation, String name) throws Exception { + Vector result = new Vector<>(); + AIFComponentContext[] children; + if(relation==null || relation.isEmpty()) + children = parent.getChildren(); + else + children = parent.getChildren(relation); + for(AIFComponentContext c : children) { + TCComponent comp = (TCComponent) c.getComponent(); + if(comp.getProperty("object_name").equals(name)) + result.add(comp); + } + return result; + } + 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/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportHandler.java b/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportHandler.java new file mode 100644 index 0000000..72b9463 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportHandler.java @@ -0,0 +1,56 @@ +package cn.net.connor.ml.plm.exportExcel; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.IHandler; + +import com.teamcenter.rac.aif.AIFDesktop; +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.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +//ļнṹ +public class UsedbyProductReportHandler extends AbstractHandler implements IHandler{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("UsedbyProductReportHandler"); + AIFDesktop desktop = AIFUtility.getActiveDesktop(); + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent target = app.getTargetComponent(); + if(target==null) { + MessageBox.post(desktop, "ѡԭϰ汾е", "ERROR", MessageBox.ERROR); + return null; + } + String type = target.getType(); + if(!type.equals("ML8_PartRevision") && !type.equals("ML8_RawMaterialRevision")) { + MessageBox.post(desktop, "ѡԭϰ汾е", "ERROR", MessageBox.ERROR); + return null; + } + String option = session.getPreferenceService().getStringValue("ML8_UsedbyProductReport"); + if(option==null || option.isEmpty()) { + MessageBox.post(desktop, "ѡML8_UsedbyProductReportòȷ", "ERROR", MessageBox.ERROR); + return null; + } + TCComponent model = session.stringToComponent(option);//AGFAAIXI5kSPsC + if(model==null || !model.isTypeOf("MSExcelX")) { + MessageBox.post(desktop, "ѡML8_UsedbyProductReportģUIDòȷ", "ERROR", MessageBox.ERROR); + return null; + } + UsedbyProductReportOperation operation = new UsedbyProductReportOperation(session, (TCComponentItemRevision)target, (TCComponentDataset)model); + session.queueOperation(operation); +// MessageBox.post(desktop, "ݽ", "ʾ", MessageBox.INFORMATION); + }catch(Exception e) { + e.printStackTrace(); + MessageBox.post(desktop, ""+e.getMessage(), "ERROR", MessageBox.ERROR); + } + return null; + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java b/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java new file mode 100644 index 0000000..92cb0e7 --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java @@ -0,0 +1,279 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Properties; + +import javax.swing.JOptionPane; + +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.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +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 cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.getSpecifications.SqlUtil; + +public class UsedbyProductReportOperation extends AbstractAIFOperation { + + private TCSession session; + private TCComponentItemRevision target; + private TCComponentDataset model; + private XSSFRow sourceRow; + private ArrayList ulist; + + public UsedbyProductReportOperation(TCSession session, TCComponentItemRevision target, TCComponentDataset model) { + this.session = session; + this.target = target; + this.model = model; + } + + @Override + public void executeOperation() throws Exception { + AIFDesktop desktop = AIFUtility.getActiveDesktop(); + FileInputStream input = null; + FileOutputStream output = null; + try { + KUtil.setByPass(true); + if (!getParents(target)) { + return; + } + Date now = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + File directory = TCUtil.saveExcelChooser(target.getProperty("item_id")+"_"+"ʹڻ嵥" + sdf.format(now),target.getStringProperty("item_id")); + if (directory == null) + return; + if (directory.exists()) + directory.delete(); + String path = directory.getPath(); + + TCComponentTcFile[] files = model.getTcFiles(); + File file = files[0].getFile(System.getProperty("java.io.tmpdir")); + input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + + int i = 2; + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow row; + XSSFCell cell; + sourceRow = getRow(sheet, i); + for (TCComponent c : ulist) { + row = getRow(sheet, i); + cell = getCell(row, 0); + cell.setCellValue(i - 1);// + cell = getCell(row, 1); + cell.setCellValue(c.getProperty("item_id"));// ϴ + cell = getCell(row, 2); + cell.setCellValue(c.getProperty("object_name"));// Ʒ + cell = getCell(row, 3); + cell.setCellValue(c.getProperty("object_desc"));// + cell = getCell(row, 4); + cell.setCellValue(c.getProperty("ml8_SalesMode").equals("ڶ") ? "" : "");// Ƿڶ + cell = getCell(row, 5); + cell.setCellValue(c.getProperty("item_revision_id"));// 汾 +// TCComponent[] relateds1 = c.getRelatedComponents("release_status_list"); +// if (relateds1.length > 0 && relateds1[0].getProperty("object_name").equals("ȡ")) { +// cell.setCellValue("");// Ƿȡ +// } else { +// cell.setCellValue("");// Ƿȡ +// } + TCComponent[] relateds2 = c.getRelatedComponents("ML8_ProjectRelation"); + if (relateds2.length > 0) { + cell = getCell(row, 7); + cell.setCellValue(relateds2[0].getProperty("ml8_ProductCode"));// Ʒ + cell = getCell(row, 8); + cell.setCellValue(relateds2[0].getProperty("ml8_ProductType"));// Ʒͺ + } else { + cell = getCell(row, 7); + cell.setCellValue("");// Ʒ + cell = getCell(row, 8); + cell.setCellValue("");// Ʒͺ + } + cell = getCell(row, 9); + cell.setCellValue(c.getProperty("ml8_NativeProducts"));// ԭƷ + cell = getCell(row, 10); + cell.setCellValue(c.getProperty("ml8_ProductCode"));// ʷƷ + cell = getCell(row, 11); + cell.setCellValue(c.getProperty("ml8_ProductType"));// ʷƷͺ + cell = getCell(row, 12); + cell.setCellValue(c.getProperty("release_status_list"));// Ʒ״̬ + + cell = getCell(row, 6); + cell.setCellFormula(cell.getCellFormula()); + i++; + } + + output = new FileOutputStream(file.getPath()); + wb.write(output); + wb.close(); + input.close(); + output.close(); +// System.out.println("file:"+file.getPath()); + KUtil.setByPass(false); + String newPath = System.getProperty("java.io.tmpdir") + path.substring(path.lastIndexOf("\\")); + File reFile = new File(newPath); + file.renameTo(reFile); +// System.out.println("new directory:"+reFile.getPath()); + reFile.renameTo(directory); + +// MessageBox.post(desktop, "", "INFO", MessageBox.INFORMATION); + //Զ򿪡NYL--20230906 + int choose = JOptionPane.showOptionDialog(desktop, "ѵ"+directory.getPath()+"Ƿ?", "ʾ", + JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {"",""}, ""); + if(choose==0) { + Runtime runtime = Runtime.getRuntime(); + runtime.exec("cmd /c start exit &&\"" + directory + "\" "); + } + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(desktop, "" + e.getMessage(), "ERROR", MessageBox.ERROR); + } finally { + KUtil.setByPass(false); + if (input != null) + input.close(); + if (output != null) + output.close(); + } + } + + 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); + if (row.getRowNum() > 2) + cell.setCellStyle(getCell(sourceRow, col).getCellStyle()); + return cell; + } +// private List list=new ArrayList(); + +// private void getUsedParents(TCComponent[] whereUsed,Map map,String uid) throws TCException { +// for(TCComponent component:whereUsed) { +// if(component instanceof TCComponentItemRevision) { +// TCComponentItemRevision revision=(TCComponentItemRevision) component; +// String status = revision.getProperty("release_status_list"); +// map.put(revision, uid); +// if(status!=null && !status.equals("ML8_Replaced")&&!status.equals("ȡ")) { +// System.out.println("revision"+revision.getStringProperty("object_string")); +// TCComponent[] whereUsed2 = revision.whereUsed((short) 0); +// +// for(TCComponent component2:whereUsed2) { +// if(component2 instanceof TCComponentItemRevision) { +// map.put((TCComponentItemRevision) component2, uid); +// TCComponent[] whereUsed3 = component2.whereUsed((short) 0); +// getUsedParents(whereUsed3,map,uid); +// } +// } +// } +// } +// } +// } + + private boolean getParents(TCComponentItemRevision target) throws Exception { + String uid = target.getItem().getUid(); + +// TCComponent[] whereUsed = target.whereUsed((short) 0); +// Map map=new HashedMap (); +// +// getUsedParents(whereUsed,map,uid); + + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return false; + } + InputStream in = UsedbyProductReportOperation.class.getResourceAsStream("/plm.properties"); + Properties p = new Properties(); + p.load(in); + String sql = p.getProperty("EXCEL5.SQL"); + ResultSet rs = SqlUtil.read(sql, new String[] { uid }); + ulist = new ArrayList(); + while (rs.next()) { + String id = rs.getString(2); + try { + TCComponentItemRevision topRev = (TCComponentItemRevision) session.stringToComponent(id); + System.out.println("ҵ汾"+topRev); + System.out.println("ҵ汾"); + String item_id = topRev.getProperty("item_id"); + System.out.println("id="+item_id); + TCComponent[] releaselist = topRev.getReferenceListProperty("release_status_list"); + if (item_id.startsWith("ML") && !item_id.contains("-")) { + if(releaselist==null||releaselist.length==0) { + ulist.add(topRev); + System.out.println(topRev+"ûз״̬excel"); + } +// else { +// boolean is_Replaced = false; +// for(TCComponent comp2:releaselist) { +// System.out.println(topRev+"ķ״̬Ϊ"+comp2.getStringProperty("object_name")); +// if(comp2.getStringProperty("object_name").equals("ML8_Replaced")) { +// is_Replaced = true; +// break; +// } +// } +// if(!is_Replaced) { +// System.out.println(topRev+"״̬DZȡexcel"); +// ulist.add(topRev); +// } +// } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + String sql2 = p.getProperty("EXCEL6.SQL"); + ResultSet rs2 = SqlUtil.read(sql2, new String[] { uid }); +// ulist = new ArrayList(); + while (rs2.next()) { + String id = rs2.getString(2); + try { + TCComponentItemRevision topRev = (TCComponentItemRevision) session.stringToComponent(id); + System.out.println("ҵ汾"+topRev); + String item_id = topRev.getProperty("item_id"); + System.out.println("id="+item_id); + if (item_id.startsWith("ML") && !item_id.contains("-")) { + ulist.add(topRev); + System.out.println(topRev+"excel"); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + + + + SqlUtil.free(); + if (ulist.size() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿѯΪգ", "", MessageBox.INFORMATION); + return false; + } + return true; + } +} diff --git a/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java.bak20230927 b/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java.bak20230927 new file mode 100644 index 0000000..932e14f --- /dev/null +++ b/src/cn/net/connor/ml/plm/exportExcel/UsedbyProductReportOperation.java.bak20230927 @@ -0,0 +1,269 @@ +package cn.net.connor.ml.plm.exportExcel; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.sql.Connection; +import java.sql.ResultSet; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.Properties; + +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.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFOperation; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +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 cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.getSpecifications.SqlUtil; + +public class UsedbyProductReportOperation extends AbstractAIFOperation { + + private TCSession session; + private TCComponentItemRevision target; + private TCComponentDataset model; + private XSSFRow sourceRow; + private ArrayList ulist; + + public UsedbyProductReportOperation(TCSession session, TCComponentItemRevision target, TCComponentDataset model) { + this.session = session; + this.target = target; + this.model = model; + } + + @Override + public void executeOperation() throws Exception { + AIFDesktop desktop = AIFUtility.getActiveDesktop(); + FileInputStream input = null; + FileOutputStream output = null; + try { + KUtil.setByPass(true); + if (!getParents(target)) { + return; + } + Date now = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + File directory = TCUtil.saveExcelChooser(target.getProperty("item_id")+"_"+"ʹڻ嵥" + sdf.format(now),target.getStringProperty("item_id")); + if (directory == null) + return; + if (directory.exists()) + directory.delete(); + String path = directory.getPath(); + + TCComponentTcFile[] files = model.getTcFiles(); + File file = files[0].getFile(System.getProperty("java.io.tmpdir")); + input = new FileInputStream(file); + XSSFWorkbook wb = new XSSFWorkbook(input); + + int i = 2; + XSSFSheet sheet = wb.getSheetAt(0); + XSSFRow row; + XSSFCell cell; + sourceRow = getRow(sheet, i); + for (TCComponent c : ulist) { + row = getRow(sheet, i); + cell = getCell(row, 0); + cell.setCellValue(i - 1);// + cell = getCell(row, 1); + cell.setCellValue(c.getProperty("item_id"));// ϴ + cell = getCell(row, 2); + cell.setCellValue(c.getProperty("object_name"));// Ʒ + cell = getCell(row, 3); + cell.setCellValue(c.getProperty("object_desc"));// + cell = getCell(row, 4); + cell.setCellValue(c.getProperty("ml8_SalesMode").equals("ڶ") ? "" : "");// Ƿڶ + cell = getCell(row, 5); + cell.setCellValue(c.getProperty("item_revision_id"));// 汾 +// TCComponent[] relateds1 = c.getRelatedComponents("release_status_list"); +// if (relateds1.length > 0 && relateds1[0].getProperty("object_name").equals("ȡ")) { +// cell.setCellValue("");// Ƿȡ +// } else { +// cell.setCellValue("");// Ƿȡ +// } + TCComponent[] relateds2 = c.getRelatedComponents("ML8_ProjectRelation"); + if (relateds2.length > 0) { + cell = getCell(row, 7); + cell.setCellValue(relateds2[0].getProperty("ml8_ProductCode"));// Ʒ + cell = getCell(row, 8); + cell.setCellValue(relateds2[0].getProperty("ml8_ProductType"));// Ʒͺ + } else { + cell = getCell(row, 7); + cell.setCellValue("");// Ʒ + cell = getCell(row, 8); + cell.setCellValue("");// Ʒͺ + } + cell = getCell(row, 9); + cell.setCellValue(c.getProperty("ml8_NativeProducts"));// ԭƷ + cell = getCell(row, 10); + cell.setCellValue(c.getProperty("ml8_ProductCode"));// ʷƷ + cell = getCell(row, 11); + cell.setCellValue(c.getProperty("ml8_ProductType"));// ʷƷͺ + cell = getCell(row, 12); + cell.setCellValue(c.getProperty("release_status_list"));// Ʒ״̬ + + cell = getCell(row, 6); + cell.setCellFormula(cell.getCellFormula()); + i++; + } + + output = new FileOutputStream(file.getPath()); + wb.write(output); + wb.close(); + input.close(); + output.close(); +// System.out.println("file:"+file.getPath()); + String newPath = System.getProperty("java.io.tmpdir") + path.substring(path.lastIndexOf("\\")); + File reFile = new File(newPath); + file.renameTo(reFile); +// System.out.println("new directory:"+reFile.getPath()); + reFile.renameTo(directory); + + MessageBox.post(desktop, "", "INFO", MessageBox.INFORMATION); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(desktop, "" + e.getMessage(), "ERROR", MessageBox.ERROR); + } finally { + KUtil.setByPass(false); + if (input != null) + input.close(); + if (output != null) + output.close(); + } + } + + 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); + if (row.getRowNum() > 2) + cell.setCellStyle(getCell(sourceRow, col).getCellStyle()); + return cell; + } +// private List list=new ArrayList(); + +// private void getUsedParents(TCComponent[] whereUsed,Map map,String uid) throws TCException { +// for(TCComponent component:whereUsed) { +// if(component instanceof TCComponentItemRevision) { +// TCComponentItemRevision revision=(TCComponentItemRevision) component; +// String status = revision.getProperty("release_status_list"); +// map.put(revision, uid); +// if(status!=null && !status.equals("ML8_Replaced")&&!status.equals("ȡ")) { +// System.out.println("revision"+revision.getStringProperty("object_string")); +// TCComponent[] whereUsed2 = revision.whereUsed((short) 0); +// +// for(TCComponent component2:whereUsed2) { +// if(component2 instanceof TCComponentItemRevision) { +// map.put((TCComponentItemRevision) component2, uid); +// TCComponent[] whereUsed3 = component2.whereUsed((short) 0); +// getUsedParents(whereUsed3,map,uid); +// } +// } +// } +// } +// } +// } + + private boolean getParents(TCComponentItemRevision target) throws Exception { + String uid = target.getItem().getUid(); + +// TCComponent[] whereUsed = target.whereUsed((short) 0); +// Map map=new HashedMap (); +// +// getUsedParents(whereUsed,map,uid); + + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return false; + } + InputStream in = UsedbyProductReportOperation.class.getResourceAsStream("/plm.properties"); + Properties p = new Properties(); + p.load(in); + String sql = p.getProperty("EXCEL5.SQL"); + ResultSet rs = SqlUtil.read(sql, new String[] { uid }); + ulist = new ArrayList(); + while (rs.next()) { + String id = rs.getString(2); + try { + TCComponentItemRevision topRev = (TCComponentItemRevision) session.stringToComponent(id); + System.out.println("ҵ汾"+topRev); + System.out.println("ҵ汾"); + String item_id = topRev.getProperty("item_id"); + System.out.println("id="+item_id); + TCComponent[] releaselist = topRev.getReferenceListProperty("release_status_list"); + if (item_id.startsWith("ML") && !item_id.contains("-")) { + if(releaselist==null||releaselist.length==0) { + ulist.add(topRev); + System.out.println(topRev+"ûз״̬excel"); + } +// else { +// boolean is_Replaced = false; +// for(TCComponent comp2:releaselist) { +// System.out.println(topRev+"ķ״̬Ϊ"+comp2.getStringProperty("object_name")); +// if(comp2.getStringProperty("object_name").equals("ML8_Replaced")) { +// is_Replaced = true; +// break; +// } +// } +// if(!is_Replaced) { +// System.out.println(topRev+"״̬DZȡexcel"); +// ulist.add(topRev); +// } +// } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + String sql2 = p.getProperty("EXCEL6.SQL"); + ResultSet rs2 = SqlUtil.read(sql2, new String[] { uid }); +// ulist = new ArrayList(); + while (rs2.next()) { + String id = rs2.getString(2); + try { + TCComponentItemRevision topRev = (TCComponentItemRevision) session.stringToComponent(id); + System.out.println("ҵ汾"+topRev); + String item_id = topRev.getProperty("item_id"); + System.out.println("id="+item_id); + if (item_id.startsWith("ML") && !item_id.contains("-")) { + ulist.add(topRev); + System.out.println(topRev+"excel"); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + + + + SqlUtil.free(); + if (ulist.size() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿѯΪգ", "", MessageBox.INFORMATION); + return false; + } + return true; + } +} diff --git a/src/cn/net/connor/ml/plm/getFolder/GetFolderCommand.java b/src/cn/net/connor/ml/plm/getFolder/GetFolderCommand.java new file mode 100644 index 0000000..8b827ab --- /dev/null +++ b/src/cn/net/connor/ml/plm/getFolder/GetFolderCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.getFolder; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class GetFolderCommand extends KCommand { + + public GetFolderCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new GetFolderDialog(app)); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/getFolder/GetFolderDialog.java b/src/cn/net/connor/ml/plm/getFolder/GetFolderDialog.java new file mode 100644 index 0000000..c069072 --- /dev/null +++ b/src/cn/net/connor/ml/plm/getFolder/GetFolderDialog.java @@ -0,0 +1,150 @@ +package cn.net.connor.ml.plm.getFolder; + +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 javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class GetFolderDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + private TCComponent target; + private TCSession session; + private TCComponent folder; + private JButton ok; + private JButton cannel; + private JTree tree; + + public GetFolderDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + try { + if (!init()) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + addListeners(); + showDialog(); + } + + private boolean init() throws Exception { + target = (TCComponent) app.getTargetComponent(); + if (target != null && target.getType().equals("ML8_CChosenRevision")) { + String puid = KUtil.getPrefVal(session, "Meling_Folder_Puid"); + if (puid == null || puid.equals("")) { + KUtil.info(GetFolderDialog.this, "ѡ[Meling_Folder_Puid]"); + return false; + } + folder = session.stringToComponent(puid); + if (folder == null) { + KUtil.info(GetFolderDialog.this, "ѡֵ쳣"); + return false; + } + return true; + } else { + KUtil.info(GetFolderDialog.this, "ѡѡ汾"); + return false; + } + } + + private void addListeners() { + this.ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int count = tree.getSelectionCount(); + if (count != 1) { + KUtil.info(GetFolderDialog.this, "뵥ѡļ"); + return; + } + // ȡѡнڵ + DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + if (node.getChildCount() != 0) { + KUtil.info(GetFolderDialog.this, "ѡײļУ"); + return; + } + TCComponent selFolder = (TCComponent) node.getUserObject(); + try { + target.add("ML8_CChosenFolder", selFolder); + disposeDialog(); + } catch (TCException e1) { + e1.printStackTrace(); + } + } + }); + this.cannel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + private void initUI() { + this.setTitle("ѡѡļ"); + this.setPreferredSize(new Dimension(300, 500)); + this.setLayout(new BorderLayout(10, 10)); + this.add(BorderLayout.CENTER, initTreePanel()); + this.add(BorderLayout.SOUTH, initButtonPanel()); + } + + private Component initButtonPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); + ok = new JButton("ȷ"); + cannel = new JButton("ȡ"); + panel.add(ok); + panel.add(cannel); + return panel; + } + + private Component initTreePanel() { + DefaultMutableTreeNode top = new DefaultMutableTreeNode(folder); + try { + initTree(top, folder); + } catch (TCException e) { + KUtil.info(GetFolderDialog.this, "ʼļ쳣\n" + e); + e.printStackTrace(); + } + tree = new JTree(top); + JScrollPane jsp = new JScrollPane(tree); + return jsp; + } + + private void initTree(DefaultMutableTreeNode top, TCComponent folder2) throws TCException { + TCComponent[] childs = folder2.getRelatedComponents("contents"); + if (childs != null && childs.length > 0) { + for (TCComponent child : childs) { + if (child instanceof TCComponentFolder) { + DefaultMutableTreeNode node = new DefaultMutableTreeNode(child); + top.add(node); + initTree(node, child); + } + } + } + } + +} diff --git a/src/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java b/src/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java new file mode 100644 index 0000000..4b6547e --- /dev/null +++ b/src/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java @@ -0,0 +1,170 @@ +package cn.net.connor.ml.plm.getPropertyByDesign; +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + + +import cn.net.connor.ml.plm.KUtil; + +public class GetPropertyByDesignHandler extends AbstractHandler { + + @SuppressWarnings("finally") + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + + + try { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCComponent target = (TCComponent) app.getTargetComponent(); + TCSession session = (TCSession) app.getSession(); + TCComponentUser user = session.getUser(); + if (target == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡϰ汾"); + return null; + } + if(!checkAccessPrivilige(session,user,target,"WRITE")) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡĶ޸ԡдȨ"); + return null; + } + String type = target.getType(); + if (!"ML8_RefrigeratorRevision|ML8_PartRevision|ML8_ColdRevision|ML8_WashingRevision|ML8_OthersRevision".contains(type)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡϰ汾"); + return null; + } + System.out.println("2023/1/10УĿ״̬"); + if(target.getReferenceListProperty("release_status_list").length>0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "з״̬ĵͬԣ"); + return null; + } + if(target.getReferenceListProperty("fnd0StartedWorkflowTasks").length>0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "Уĵͬԣ"); + return null; + } + + TCComponentItemRevision related = (TCComponentItemRevision) target.getRelatedComponents("TC_Is_Represented_By")[0]; + + if (related == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ṩΪգ"); + return null; + } + TCComponentItemRevision rev = related.getItem().getLatestItemRevision(); + //A汾ҹĵ״̬ͬ + if (target.getProperty("item_revision_id") .equals("A") && rev.getRelatedComponents("release_status_list").length==0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ĵ°汾δĵͬ"); + return null; + } + //A汾ҹĵTCM״̬ͬ + if (target.getProperty("item_revision_id") .equals("A") && !(rev.getRelatedComponents("release_status_list")[0].getProperty("name").equalsIgnoreCase("TCM Released") || rev.getRelatedComponents("release_status_list")[0].getProperty("name").equals("TCM ѷ"))) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ĵ°汾״̬󣬲ͬĵ״̬"); + return null; + } + //ĵA汾δͬ + if (rev.getProperty("item_revision_id").equalsIgnoreCase("A") && rev.getRelatedComponents("release_status_list").length==0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ĵA汾δͬȷĵͬ"); + return null; + } + //ĵA汾״̬TCMͬ + if (rev.getProperty("item_revision_id").equalsIgnoreCase("A") && !(rev.getRelatedComponents("release_status_list")[0].getProperty("name").equalsIgnoreCase("TCM Released") || rev.getRelatedComponents("release_status_list")[0].getProperty("name").equals("TCM ѷ"))) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ĵA汾״̬󣬲ͬȷĵͬ"); + return null; + } + + String[] props = session.getPreferenceService().getStringValues("Meling_Design_To_Part"); + if (props == null || props.length < 1) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ[Meling_Design_To_Part]ϵϵͳԱ"); + return null; + } + //ĵ״̬TCM״̬ͬǰϲУҲκη״̬ + if (rev.getRelatedComponents("release_status_list").length>0 && (rev.getRelatedComponents("release_status_list")[0].getProperty("name").equalsIgnoreCase("TCM Released") || rev.getRelatedComponents("release_status_list")[0].getProperty("name").equals("TCM ѷ"))) { + for (String prop : props) { + String[] d2p = prop.split("="); + try { + target.setProperty(d2p[1], rev.getProperty(d2p[0])); + } catch (Exception e) { + e.printStackTrace(); + KUtil.info(AIFDesktop.getActiveDesktop(),":["+d2p[1]+ "]ͬʧܣϵϵͳԱ"); + return null; + }finally { + KUtil.setByPass(false); + } + + } + KUtil.info(AIFDesktop.getActiveDesktop(), "ͬɹ"); + return null; + } + //ϷA汾ҹĵTCM״̬ + System.out.println("2025/01/16УϺ͹ĵǷͬһҾ޷״̬֧ͬ"); + if (!target.getProperty("item_revision_id") .equals("A") ) { + if(!(rev.getRelatedComponents("release_status_list").length==0)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ĵ״̬ȷϣ"); + } + String[] types = {"ML8_CNoticeRevision"}; + String[] relations = {"ML8_GXBGH"}; + AIFComponentContext[] primarysA=((TCComponent) target).whereReferencedByTypeRelation(types,relations); + if(primarysA.length==0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ޱͬ"); + return null; + } + + AIFComponentContext[] primarysB=((TCComponent) rev).whereReferencedByTypeRelation(types,relations); + if(primarysB.length==0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ޱͬͬ"); + return null; + } + if(primarysA[0].getComponent().getUid()==primarysB[0].getComponent().getUid()) { + for (String prop : props) { + String[] d2p = prop.split("="); + try { + target.setProperty(d2p[1], rev.getProperty(d2p[0])); + } catch (Exception e) { + e.printStackTrace(); + KUtil.info(AIFDesktop.getActiveDesktop(),":["+d2p[1]+ "]ͬʧܣϵϵͳԱ"); + return null; + }finally { + KUtil.setByPass(false); + } + + } + KUtil.info(AIFDesktop.getActiveDesktop(), "ͬɹĵδעⱣ֤ĵԲٱٽͬһ߱"); + return null; + } + else { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡϺ͹ĵҪͬһиģͬ"); + return null; + } + } + } + + catch(Exception e){ + e.printStackTrace(); + KUtil.info(AIFDesktop.getActiveDesktop(),"ͬʧܣϵϵͳԱ"); + return null; + } + finally { + return null; + } + } + /** + * existFile:ǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public boolean checkAccessPrivilige(TCSession session, TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } +} diff --git a/src/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java.bak20250116 b/src/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java.bak20250116 new file mode 100644 index 0000000..62cb7fd --- /dev/null +++ b/src/cn/net/connor/ml/plm/getPropertyByDesign/GetPropertyByDesignHandler.java.bak20250116 @@ -0,0 +1,101 @@ +package cn.net.connor.ml.plm.getPropertyByDesign; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.commands.common.NotDefinedException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AbstractAIFSession; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; + +public class GetPropertyByDesignHandler extends AbstractHandler { + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡϰ汾"); + return null; + } + String type = target.getType(); + if (!"ML8_RefrigeratorRevision|ML8_PartRevision|ML8_ColdRevision|ML8_WashingRevision|ML8_OthersRevision".contains(type)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡϰ汾"); + return null; + } + TCSession session = (TCSession) app.getSession(); + String[] props = session.getPreferenceService().getStringValues("Meling_Design_To_Part"); + if (props == null || props.length < 1) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ[Meling_Design_To_Part]"); + return null; + } + try { + TCComponentItemRevision related = (TCComponentItemRevision) target.getRelatedComponent("TC_Is_Represented_By"); + if (related == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ṩΪգ"); + return null; + } + TCComponentItemRevision rev = related.getItem().getLatestItemRevision(); + if (rev.getRelatedComponents("release_status_list").length == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "µư汾ûз"); + return null; + } + + for (String prop : props) { + String[] d2p = prop.split("="); + if (d2p == null || d2p.length != 2) { + System.out.println("ѡ[Meling_Design_To_Part]\n" + prop); +// KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ[Meling_Design_To_Part]\n" + prop); + continue; + } + System.out.println("2023/1/10УĿ״̬"); + TCComponent[] release_status_list = target.getReferenceListProperty("release_status_list"); + TCComponent[] fnd0StartedWorkflowTasks = target.getReferenceListProperty("fnd0StartedWorkflowTasks"); + + if(release_status_list!=null&&release_status_list.length>0) { + throw new Exception(target+"ѷ"); + }else if(fnd0StartedWorkflowTasks!=null&&fnd0StartedWorkflowTasks.length>0) { + throw new Exception(target+""); + }else { + KUtil.setByPass(true); + try { + target.setProperty(d2p[1], rev.getProperty(d2p[0])); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.info(AIFDesktop.getActiveDesktop(), "ͬԳ\n" + e.getMessage()); + return null; + } + KUtil.info(AIFDesktop.getActiveDesktop(), "ͬɹ"); + return null; + } + /** + * existFile:ǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + public boolean checkAccessPrivilige(TCSession session, TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } +} diff --git a/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsCommand.java b/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsCommand.java new file mode 100644 index 0000000..c55b0d3 --- /dev/null +++ b/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.getSpecifications; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class GetSpecificationsCommand extends KCommand { + + public GetSpecificationsCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new GetSpecificationsDialog(app)); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java b/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java new file mode 100644 index 0000000..f5f731a --- /dev/null +++ b/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java @@ -0,0 +1,213 @@ +package cn.net.connor.ml.plm.getSpecifications; + +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.sql.Connection; +import java.sql.ResultSet; + +import java.util.regex.Pattern; + +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + + +import cn.net.connor.ml.plm.KUtil; + +public class GetSpecificationsDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + private TCComponent target; + private JButton query; + private JTextField field; + private DefaultListModel model; + private TCSession session; + + public GetSpecificationsDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + if (!init()) { + return; + } + initUI(); + addListeners(); + showDialog(); + } + + private boolean init() { + target = (TCComponent) app.getTargetComponent(); + if (target != null && target.getType().equals("ML8_PartRevision")) { + return true; + } else { + KUtil.info(GetSpecificationsDialog.this, "ѡ㲿汾"); + return false; + } + } + //nyl-20240115ǷΪж + public static boolean isInteger(String str) { + Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$"); + return pattern.matcher(str).matches(); + } + private void addListeners() { + this.query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { +// String prop = target.getProperty("ml8_Specifications"); + String parm = field.getText().trim(); + if (parm.equals("")) { + KUtil.info(GetSpecificationsDialog.this, "ѯΪգ"); + return; + } +// Connection conn = SqlUtil.getSqlserverConnection(); + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + disposeDialog(); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return; + } + // SELECT pml8_Specifications FROM PML8_PARTREVISION where pml8_Specifications + // like '%' ORDER BY pml8_Specifications DESC; + //NYL-20240115ĩβȥģ + // parm = parm + "%"; +// int i1 = parm.indexOf("."); + int i2 = parm.lastIndexOf("("); + if (i2 < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯʽ", "", MessageBox.INFORMATION); + return; + } + String left = parm.substring(0, i2 + 1);; + int i1 = left.lastIndexOf("."); + String parm3=left.substring(0, i1 + 1); + if (i1 < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯʽ", "", MessageBox.INFORMATION); + return; + } + parm = parm.substring(0, i1 + 1) + "%" + parm.substring(i2); + ResultSet rs = SqlUtil.read( + "SELECT pml8_Specifications FROM PML8_PARTREVISION where pml8_Specifications like ? ORDER BY pml8_Specifications DESC;", + new String[] { parm }); + Integer bigNumber = 0; + String bigStr = ""; + while (rs.next()) { + String str = rs.getString(1);//ȡǰеһֵ + System.out.println("rs:" + str); + int i22 = str.lastIndexOf("("); + String str2=str.substring(0, i22 + 1); + + int i11 = str2.lastIndexOf("."); + String str3=str2.substring(0, i11 + 1); + if(parm3.length()!=str3.length()) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ˮģѯݲƥ䣺[" + str + "]", "ȷ", MessageBox.INFORMATION); + SqlUtil.free(); + return; + } + + if ((i11 + 1) == i22) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ˮѯ쳣ݣһ𣩣[" + str + "]", "ȷ", MessageBox.INFORMATION); + SqlUtil.free(); + return; + } + if(!isInteger(str.substring(i11 + 1, i22))) + { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ˮѯݴڵ֮Ǵ[" + str + "]", "ȷ", MessageBox.INFORMATION); + SqlUtil.free(); + return; + } + try { + + Integer temp = Integer.valueOf(str.substring(i11 + 1, i22)); + bigNumber = bigNumber > temp ? bigNumber : temp; + }catch(NumberFormatException ee) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯ쳣ݣ[" + str + "]", "", MessageBox.INFORMATION); + continue; + } + bigStr = str.substring(0, i11 + 1) + (bigNumber + 1) + str.substring(i22); + } + bigNumber++; + System.out.println("bigStr=" + bigStr); + SqlUtil.free(); + if (bigStr.equals("")) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯΪգ", "", MessageBox.INFORMATION); + return; + } + setModel(bigStr); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ִг쳣\n" + e1, "", MessageBox.INFORMATION); + } + } + }); + } + + protected void setModel(String str) throws TCException { +// int i1 = str.indexOf("."); +// int i2 = str.indexOf("("); +// +// int big = Integer.valueOf(str.substring(i1 + 1, i2)) + 1; +// str = str.substring(0, i1 + 1) + big + str.substring(i2); +// System.out.println(str); + int yesOrNo = JOptionPane.showConfirmDialog(null, "Ƿ[" + str + "]Թͺϣ", "", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + target.setProperty("ml8_Specifications", str); + } else { + // 1 + } + } + + private void initUI() { + this.setMinimumSize(new Dimension(200, 100)); + this.setLayout(new BorderLayout(20, 5)); + this.add(BorderLayout.NORTH, initQueryPanel()); + this.add(BorderLayout.CENTER, initListPanel()); + } + + private Component initListPanel() { + model = new DefaultListModel(); + JList list = new JList(model); + JScrollPane pane = new JScrollPane(list); + return pane; + } + + private Component initQueryPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + + JLabel label = new JLabel("ͺţ"); + try { + field = new JTextField(target.getProperty("ml8_Specifications")); + } catch (TCException e) { + e.printStackTrace(); + } + field.setPreferredSize(new Dimension(100, 25)); + query = new JButton("ѯ"); + panel.add(label); + panel.add(field); + panel.add(query); + return panel; + } +} diff --git a/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java.bak b/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java.bak new file mode 100644 index 0000000..4a2ed90 --- /dev/null +++ b/src/cn/net/connor/ml/plm/getSpecifications/GetSpecificationsDialog.java.bak @@ -0,0 +1,188 @@ +package cn.net.connor.ml.plm.getSpecifications; + +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.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; + +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; + +public class GetSpecificationsDialog extends AbstractAIFDialog { + + private AbstractAIFApplication app; + private TCComponent target; + private JButton query; + private JTextField field; + private DefaultListModel model; + private TCSession session; + + public GetSpecificationsDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + if (!init()) { + return; + } + initUI(); + addListeners(); + showDialog(); + } + + private boolean init() { + target = (TCComponent) app.getTargetComponent(); + if (target != null && target.getType().equals("ML8_PartRevision")) { + return true; + } else { + KUtil.info(GetSpecificationsDialog.this, "ѡ㲿汾"); + return false; + } + } + + private void addListeners() { + this.query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + try { +// String prop = target.getProperty("ml8_Specifications"); + String parm = field.getText().trim(); + if (parm.equals("")) { + KUtil.info(GetSpecificationsDialog.this, "ѯΪգ"); + return; + } +// Connection conn = SqlUtil.getSqlserverConnection(); + String[] prefVals = null; + prefVals = KUtil.getPrefVals(session, "Meling_SqlServer"); + Connection conn = SqlUtil.getSqlserverConnection(prefVals[0], prefVals[1], prefVals[2], prefVals[3]); + if (conn == null) { + disposeDialog(); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ݿʧ", "", MessageBox.INFORMATION); + return; + } + // SELECT pml8_Specifications FROM PML8_PARTREVISION where pml8_Specifications + // like '%' ORDER BY pml8_Specifications DESC; + parm = parm + "%"; +// int i1 = parm.indexOf("."); + int i2 = parm.indexOf("("); + if (i2 < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯʽ", "", MessageBox.INFORMATION); + return; + } + String left = parm.split("\\(")[0]; + int i1 = left.lastIndexOf("."); + if (i1 < 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯʽ", "", MessageBox.INFORMATION); + return; + } + parm = parm.substring(0, i1 + 1) + "%" + parm.substring(i2); + ResultSet rs = SqlUtil.read( + "SELECT pml8_Specifications FROM PML8_PARTREVISION where pml8_Specifications like ? ORDER BY pml8_Specifications DESC;", + new String[] { parm }); + model.removeAllElements(); + Integer bigNumber = 0; + String bigStr = ""; + while (rs.next()) { + String str = rs.getString(1); +// int i11 = str.indexOf(".("); + int i22 = str.indexOf("("); + String leftleft = str.split("\\(")[0]; + int i11 = leftleft.lastIndexOf("."); + + if ((i11 + 1) == i22) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯ쳣ݣ[" + str + "]", "", MessageBox.INFORMATION); + continue; + } + + Integer temp = Integer.valueOf(str.substring(i11 + 1, i22)); + bigNumber = bigNumber > temp ? bigNumber : temp; + bigStr = str.substring(0, i11 + 1) + (bigNumber + 1) + str.substring(i22); + model.addElement(str); + } + bigNumber++; + System.out.println("bigStr=" + bigStr); + SqlUtil.free(); + if (model.getSize() == 0) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯΪգ", "", MessageBox.INFORMATION); + return; + } + setModel(bigStr); + } catch (Exception e1) { + e1.printStackTrace(); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ִг쳣\n" + e1, "", MessageBox.INFORMATION); + } + } + }); + } + + protected void setModel(String str) throws TCException { +// int i1 = str.indexOf("."); +// int i2 = str.indexOf("("); +// +// int big = Integer.valueOf(str.substring(i1 + 1, i2)) + 1; +// str = str.substring(0, i1 + 1) + big + str.substring(i2); +// System.out.println(str); + int yesOrNo = JOptionPane.showConfirmDialog(null, "Ƿ[" + str + "]Թͺϣ", "", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + target.setProperty("ml8_Specifications", str); + } else { + // 1 + } + } + + private void initUI() { + this.setMinimumSize(new Dimension(200, 100)); + this.setLayout(new BorderLayout(20, 5)); + this.add(BorderLayout.NORTH, initQueryPanel()); + this.add(BorderLayout.CENTER, initListPanel()); + } + + private Component initListPanel() { + model = new DefaultListModel(); + JList list = new JList(model); + JScrollPane pane = new JScrollPane(list); + return pane; + } + + private Component initQueryPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + + JLabel label = new JLabel("ͺţ"); + try { + field = new JTextField(target.getProperty("ml8_Specifications")); + } catch (TCException e) { + e.printStackTrace(); + } + field.setPreferredSize(new Dimension(100, 25)); + query = new JButton("ѯ"); + panel.add(label); + panel.add(field); + panel.add(query); + return panel; + } +} diff --git a/src/cn/net/connor/ml/plm/getSpecifications/SqlUtil.java b/src/cn/net/connor/ml/plm/getSpecifications/SqlUtil.java new file mode 100644 index 0000000..63e54ed --- /dev/null +++ b/src/cn/net/connor/ml/plm/getSpecifications/SqlUtil.java @@ -0,0 +1,554 @@ +package cn.net.connor.ml.plm.getSpecifications; + +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.Date; + +import com.teamcenter.rac.util.Registry; + +public class SqlUtil { + + public static Connection connection = null; + public static PreparedStatement ps = null; + public static ResultSet rs = null; + public static Registry reg = Registry.getRegistry(SqlUtil.class); + public static int ORACLE = 1; + public static int SQLSERVER = 2; + + public static Connection getConnection(int dbType) { + if (dbType == ORACLE) { + return getOracleConnection(); + } else if (dbType == SQLSERVER) { + return getSqlserverConnection(); + } + return null; + } + + public static Date getDate(java.sql.Date date) { + if (date == null) { + return null; + } + return new Date(date.getTime()); + } + + /** + * ݿ + */ + public static Connection getSqlserverConnection() { + String driver = reg.getString("SQL.SQLSERVER.DRIVER"); + String url = reg.getString("SQL.SQLSERVER.URL"); + String user = reg.getString("SQL.SQLSERVER.USER"); + String password = reg.getString("SQL.SQLSERVER.PASSWORD"); + System.out.println("ݿϢ"); + System.out.println("DRIVER: " + driver); + System.out.println("URL: " + url); + System.out.println("USER: " + user); + if (connection != null) { + try { + connection.close(); + } catch (Exception e1) { + e1.printStackTrace(); + } + connection = null; + } + try { + // + Class.forName(driver); + connection = DriverManager.getConnection(url, user, password); + connection.setAutoCommit(false); + } catch (ClassNotFoundException e) { + // ݿ쳣 + System.out.println("δҵݿ"); + e.printStackTrace(); + } catch (SQLException e) { + // ݿʧ쳣 + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return connection; + } + + public static Connection getSqlserverConnection(String driver, String url, String user, String password) { +// String driver = reg.getString("SQL.SQLSERVER.DRIVER"); +// String url = reg.getString("SQL.SQLSERVER.URL"); +// String user = reg.getString("SQL.SQLSERVER.USER"); +// String password = reg.getString("SQL.SQLSERVER.PASSWORD"); + System.out.println("ݿϢ"); + System.out.println("DRIVER: " + driver); + System.out.println("URL: " + url); + System.out.println("USER: " + user); + if (connection != null) { + try { + connection.close(); + } catch (Exception e1) { + e1.printStackTrace(); + } + connection = null; + } + try { + // + Class.forName(driver); + connection = DriverManager.getConnection(url, user, password); + connection.setAutoCommit(false); + } catch (ClassNotFoundException e) { + // ݿ쳣 + System.out.println("δҵݿ"); + e.printStackTrace(); + } catch (SQLException e) { + // ݿʧ쳣 + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return connection; + } + + public static Connection getOracleConnection(String url, String user, String password) { + String driver = "oracle.jdbc.driver.OracleDriver"; + System.out.println("ݿϢ"); + System.out.println("DRIVER: " + driver); + System.out.println("URL: " + url); + System.out.println("USER: " + user); + if (connection != null) { + try { + connection.close(); + } catch (Exception e1) { + e1.printStackTrace(); + } + connection = null; + } + try { + // + Class.forName(driver); + // 1.getConnection()MySQLݿ⣡ + connection = DriverManager.getConnection(url, user, password); + connection.setAutoCommit(false); + } catch (ClassNotFoundException e) { + // ݿ쳣 + System.out.println("δҵݿ"); + e.printStackTrace(); + } catch (SQLException e) { + // ݿʧ쳣 + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return connection; + } + + public static Connection getOracleConnection() { + // String driver = reg.getString("SQL.ORACLE.DRIVER"); + String url = reg.getString("SQL.ORACLE.URL"); + String user = reg.getString("SQL.ORACLE.USER"); + String password = reg.getString("SQL.ORACLE.PASSWORD"); + /*if(prefs!=null&&prefs.length==5) { + url = "jdbc:oracle:thin:@"+prefs[0]+":"+prefs[1]+":"+prefs[2]; + user = prefs[3]; + password = prefs[4]; + }*/ + return getOracleConnection(url, user, password); + } + + /** + * ˽йnew󣬷ֹö + */ + private SqlUtil() { + } + + /** + * ƴSELECT + * + * @param tableName + * @param selectElement + * @param args + * @return + */ + public static String getSelectSql(String tableName, String[] selectElement, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT "); + if (selectElement != null) { + for (String element : selectElement) { + valuesSB.append(element).append(","); + } + valuesSB.delete(valuesSB.length() - 1, valuesSB.length()); + } + valuesSB.append(" FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * ƴSELECT + * + * @param tableName + * @param args + * @return + */ + public static String getSelectSql(String tableName, String... args) { + StringBuffer valuesSB = new StringBuffer("SELECT * FROM "); + valuesSB.append(tableName); + valuesSB.append(" WHERE"); + for (int i = 0; i < args.length; i++) { + valuesSB.append(" "); + valuesSB.append(args[i]); + valuesSB.append("=? "); + valuesSB.append("AND"); + } + + valuesSB.delete(valuesSB.length() - 3, valuesSB.length()); + return valuesSB.toString(); + } + + /** + * ƴӸ + * + * @param tableName + * @param args + * @param args2 + * @return + */ + public static String getUpdataSQL(String tableName, String[] args, String[] args2) { + StringBuffer updateSB = new StringBuffer("UPDATE "); + updateSB.append(tableName); + updateSB.append(" SET "); + // ƴӸ + for (int i = 0; i < args.length; i++) { + if (args[i].toUpperCase().equals("CREATED_DATE") || args[i].toUpperCase().equals("LAST_UPDATE_DATE")) { + updateSB.append(args[i]).append("=to_date(?,'yyyy-MM-dd HH24:mi:ss') ,"); + } else { + updateSB.append(args[i]).append("=? ,"); + } + } + updateSB.delete(updateSB.length() - 2, updateSB.length()); + ; + updateSB.append(" WHERE "); + for (int i = 0; i < args2.length; i++) { + updateSB.append(args2[i]).append("=? AND "); + } + updateSB.delete(updateSB.length() - 4, updateSB.length()); + return updateSB.toString(); + } + + /** + * ƴSQLinsert + * + * @param tableName + * @param args + * @return + */ + public static String getInsertSql(String tableName, String... args) { + StringBuffer insertSql = new StringBuffer("insert into "); + StringBuffer values = new StringBuffer("values("); + + if (tableName != null && args != null && args.length > 0) { + insertSql.append(tableName); + insertSql.append("("); + for (int i = 0; i < args.length; i++) { + insertSql.append(args[i]); + insertSql.append(", "); + if (args[i].toUpperCase().equals("LAST_UPDATE_DATE") || args[i].toUpperCase().equals("CREATED_DATE")) { + values.append("to_date(?,'yyyy-MM-dd HH24:mi:ss'), "); + } else { + values.append("?, "); + } + + } + } else { + return null; + } + insertSql.delete(insertSql.length() - 2, insertSql.length()); + values.delete(values.length() - 2, values.length()); + insertSql.append(") ").append(values).append(")"); + return insertSql.toString(); + } + + /** + * õݿ + * + * @param tableName + * @param args + * + * @param args2 + * + * @return ƴӺĴݿ + */ + public final static String GetCreateTableSQL(String tableName, String[] args, String[] args2) { + + if (args == null || args2 == null || args.length != args2.length) { + System.out.println("THE INPUT PRAGREMS IS ERROR"); + return null; + } + StringBuffer createSQL = new StringBuffer("create table "); + createSQL.append(tableName); + createSQL.append("("); + for (int i = 0; i < args.length; i++) { + createSQL.append(args[i] + " "); + createSQL.append(args2[i] + ", "); + } + createSQL.delete(createSQL.length() - 2, createSQL.length()); + createSQL.append(")"); + return createSQL.toString(); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(String sql) throws SQLException { + return getPs(sql, null); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(Object[] argments, String sql) throws SQLException { + return getPs(sql, argments); + } + + /** + * õStatement + */ + public final static PreparedStatement getPs(String sql, Object[] argments) throws SQLException { + SqlUtil.ps = SqlUtil.connection.prepareStatement(sql); + if (argments != null) { + for (int i = 0; i < argments.length; i++) { + SqlUtil.ps.setObject(i + 1, argments[i]); + } + } + return SqlUtil.ps; + } + + /** + * + */ + public final static int write(String sql) { + return write(sql, null); + } + + /** + * + */ + public final static int write(Object[] argments, String sql) { + return write(sql, argments); + } + + /** + * + */ + public final static int write(String sql, Object[] argments) { + + return update(sql, argments); + } + + /** + * ɾ + */ + public final static int delete(String sql) { + return delete(sql, null); + } + + /** + * ɾ + */ + public final static int delete(Object[] argments, String sql) { + return delete(sql, argments); + } + + /** + * ɾ + */ + public final static int delete(String sql, Object[] argments) { + return update(sql, argments); + } + + /** + * ޸ + */ + public final static int update(String sql) { + return update(sql, null); + } + + /** + * ޸ + */ + public final static int update(String[] argments, String sql) { + return update(sql, argments); + } + + /** + * ޸(ɾնҪô˷˴쳣رճConnectionΪĶ) + */ + public final static int update(String sql, Object[] argments) { + int i = -1; + try { + i = SqlUtil.getPs(argments, sql).executeUpdate(); + SqlUtil.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtil.rs, SqlUtil.ps); + } + return i; + } + + /** + * ѯ + */ + public final static ResultSet read(String sql) throws SQLException { + return read(sql, null); + } + + /** + * ѯ + */ + public final static ResultSet read(Object[] argments, String sql) throws SQLException { + return read(sql, argments); + } + + /** + * ѯ(вѯնҪô˷治쳣׳ɵߴfinallyͷԴ) + * + * @throws SQLException + */ + public final static ResultSet read(String sql, Object[] argments) throws SQLException { + System.out.println("sql=" + sql); + return SqlUtil.rs = SqlUtil.getPs(argments, sql).executeQuery(); + } + + /** + * + */ + public final static boolean createTable(String sql) { + return go(sql, null); + } + + /** + * ɾ + */ + public final static boolean dropTable(String sql) { + return go(sql, null); + } + + /** + * ޸ı + */ + public final static boolean alterTable(String sql) { + return go(sql, null); + } + + /** + * ˷ִDDL(,޸ı,ɾ) + */ + private final static boolean go(String sql, Object[] argments) { + boolean flag = false; + try { + flag = SqlUtil.getPs(sql, argments).execute(); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + free(SqlUtil.rs, SqlUtil.ps); + } + if (flag) { + try { + SqlUtil.connection.commit(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + return flag; + } + + /** + * ͷԴ + */ + public final static void free(ResultSet resultSet) { + free(resultSet, null, null); + } + + /** + * ͷԴ + */ + public final static void free(Statement statement) { + free(null, statement, null); + } + + /** + * ͷԴ + */ + public final static void free(Connection connection) { + free(null, null, connection); + } + + /** + * ͷԴ + */ + public final static void free(ResultSet resultSet, Statement statement) { + free(resultSet, statement, null); + } + + /** + * ͷԴ + */ + public final static void free(Statement statement, Connection connection) { + free(null, statement, connection); + } + + /** + * ͷԴ(Ĭϲ) + */ + public final static void free() { + free(SqlUtil.rs, SqlUtil.ps); + } + + /** + * ͷԴ(ȫͷ) + */ + public final static void freeAll() { + free(SqlUtil.rs, SqlUtil.ps, SqlUtil.connection); + } + + /** + * ͷԴ(ҲҪȫͷ) + */ + public final static void free(ResultSet resultSet, Statement statement, Connection connection) { + try { + if (resultSet != null) { + try { + resultSet.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + try { + if (statement != null) { + try { + statement.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } finally { + if (connection != null) { + try { + connection.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + } + } + } +} diff --git a/src/cn/net/connor/ml/plm/getSpecifications/getSpecifications.properties b/src/cn/net/connor/ml/plm/getSpecifications/getSpecifications.properties new file mode 100644 index 0000000..7120aee --- /dev/null +++ b/src/cn/net/connor/ml/plm/getSpecifications/getSpecifications.properties @@ -0,0 +1,24 @@ +SQL.URL=jdbc:sqlserver://10.128.10.50:1433;DatabaseName=Basedb_2012 +SQL.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver +SQL.USER=PLMUser +SQL.PASSWORD=PLMUser + +SQL.TCDATA.URL=jdbc:oracle:thin:@192.168.0.103:1521:TC +SQL.TCDATA.DRIVER=oracle.jdbc.driver.OracleDriver +SQL.TCDATA.USER=infodba +SQL.TCDATA.PASSWORD=infodba + +SQL.TEMPLATE_TREE=select t.PmpcCode, t.PmpcCompanyCode, t.PmpcName, t.PmpcUpperCode, t.PmpcItem, t.PmpcPrhCode, t.PmpcEnd from CcemVW_Pmpc t; +SQL.TEMPLATE=select t.PrhName,t.PrdLine,t.PrdNo,t.PrdFeatureCode,t.FeatureName,t.PrdCanInput,t.PrdRightSign from CcemVW_Prd t where t.prhcode = ? order by t.PrdNo +SQL.LOV=select t.PrddNo,t.PrddFeatureCode,t.PrddValue from CcemVW_Prdd t where t.PrddDisabled=0 and t.PrddCode = ? and PrddLine = ? order by t.PrddNo + +DATARELEASE.CHECKPROP=s8WSOType +DATARELEASE.RELEASESTATUS=S81Delivered +DATARELEASE.OTHER=����Ʒ�� +DATARELEASE.ROLE=�Ŀ�רԱ +DATARECEIVE.GROUP=���ݽ����� + +SQL.SQLSERVER.DRIVER=com.microsoft.sqlserver.jdbc.SQLServerDriver +SQL.SQLSERVER.URL=jdbc:sqlserver://192.168.220.129:1433;DatabaseName=TC13 +SQL.SQLSERVER.USER=infodba +SQL.SQLSERVER.PASSWORD=infodba \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog.java b/src/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog.java new file mode 100644 index 0000000..e8fd54b --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/AssignProjectDialog.java @@ -0,0 +1,463 @@ +/* +#============================================================================= +# +# opyright (c) 2009 Origin Enterprise Solution LTD. +# +#============================================================================= +# File name: CopyFolderAndAssginToProjectDialog.java +# File description: +#============================================================================= +# Date Name Action Description of Change +# 2017-5-10 Administrator Ini ʼ +#============================================================================= + */ +package cn.net.connor.ml.plm.gotoQMS; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Vector; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.border.TitledBorder; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; + +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCPropertyDescriptor; +import com.teamcenter.rac.kernel.TCSession; + +import com.teamcenter.rac.util.ButtonLayout; + +import com.teamcenter.rac.util.MessageBox; +import com.teamcenter.rac.util.PropertyLayout; +import com.teamcenter.rac.util.VerticalLayout; +import com.teamcenter.services.rac.core.ProjectLevelSecurityService; +import com.teamcenter.services.rac.core._2018_11.ProjectLevelSecurity.UserGroupRoleInfo; +import com.teamcenter.services.rac.core._2018_11.ProjectLevelSecurity.UserProjectsResponse; + + +/** + * @author Administrator + */ +//@SuppressWarnings({"rawtypes","unchecked"}) +public class AssignProjectDialog extends AbstractAIFDialog { + + private static final long serialVersionUID = 1L; + TCSession session; +// AbstractAIFUIApplication app; + +// private JList projectList; +// private JList targetList; + private DefaultListModel projectM; + private DefaultListModel targetM; + private JTextField xmmc; + private JTextField cdbm; + private JTextField xmsyz; + private InterfaceAIFComponent[] targets; + private String lineSeparator = System.lineSeparator();// з + private HashMap map = new HashMap(); + + public AssignProjectDialog(TCSession pSession, InterfaceAIFComponent[] selectTarget) { + super(AIFUtility.getActiveDesktop(), true); // true + try { + this.session = pSession; + this.targets = selectTarget; + init(); + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AIFUtility.getActiveDesktop(), "" + TCUtil.getStackTrace(e), "", MessageBox.ERROR); + } + } + + private void init() throws Exception { + setTitle("ָɸĿ"); + final TCComponentProjectType tccomponentprojecttype = (TCComponentProjectType) session + .getTypeComponent("TC_Project"); +// final JPanel jptopleft = new JPanel(new PropertyLayout(2,2,2,2,2,2)); + this.projectM = new DefaultListModel<>(); + this.targetM = new DefaultListModel<>(); + final JPanel jptopleft = new JPanel(new BorderLayout()); + final JPanel jptopright = new JPanel(new VerticalLayout()); + + final Vector list = new Vector<>();// listPro("*"); + + String user = session.getUser().getUserId(); + String uidUser = session.getUser().getUid(); + + final JList projectList = new JList(projectM); + projectList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + jptopleft.setBorder(BorderFactory.createTitledBorder(null, "ѡĿ", TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N + JScrollPane folderscrollPane = new JScrollPane(); + folderscrollPane.setPreferredSize(new Dimension(410, 500)); + folderscrollPane.getViewport().add(projectList); + jptopleft.add(BorderLayout.CENTER, folderscrollPane); + + final JList targetList = new JList(targetM); + jptopright.setBorder(BorderFactory.createTitledBorder(null, "ѡĿ", TitledBorder.DEFAULT_JUSTIFICATION, + TitledBorder.DEFAULT_POSITION, new Font("", 0, 12))); // NOI18N + + targetList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + JScrollPane proscrollPane = new JScrollPane(targetList); + proscrollPane.setPreferredSize(new Dimension(410, 500)); + + final JButton addbtn = new JButton(">"); + JButton removebtn = new JButton("<"); + addbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + String select = projectList.getSelectedValue(); + if (select == null) + return; + targetM.addElement(select); + projectM.removeElement(select); + + } + }); + removebtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + String select = targetList.getSelectedValue(); + if (select == null) + return; + projectM.addElement(select); + targetM.removeElement(select); + + } + }); + + JButton addbtnAll = new JButton(">>"); + JButton removebtnAll = new JButton("<<"); + addbtnAll.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + Enumeration e = projectM.elements(); + Vector v = new Vector<>(); + while (e.hasMoreElements()) { + v.add(e.nextElement()); + } + for (int i = 0; i < v.size(); i++) { + targetM.addElement(v.get(i)); + } + projectM.removeAllElements(); + + } + }); + removebtnAll.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + Enumeration e = targetM.elements(); + Vector v = new Vector<>(); + while (e.hasMoreElements()) { + v.add(e.nextElement()); + } + for (int i = 0; i < v.size(); i++) { + projectM.addElement(v.get(i)); + } + targetM.removeAllElements(); + + } + }); + + if (list.size() > 0) + addbtn.setEnabled(false); + JPanel bpane = new JPanel(new PropertyLayout()); + bpane.add("1.1.center.center", addbtn); + bpane.add("2.1.center.center", addbtnAll); + bpane.add("3.1.center.center", removebtn); + bpane.add("4.1.center.center", removebtnAll); + jptopleft.add(BorderLayout.EAST, bpane); + +// final JTextField jt = new JTextField(30); +// +// jt.addKeyListener(new KeyAdapter() { +// public void keyReleased(KeyEvent ke) { +// char code = ke.getKeyChar(); +// if (code == KeyEvent.VK_ENTER) { +// System.out.println("ceshi س" + code + "=====" + KeyEvent.VK_ENTER); +// Vector pronewVector = listPro(jt.getText()); +// proList.setListData(pronewVector); +// } +// } +// +// }); +// jptopright.add("top.bind.center.top", jt); + jptopright.add("top.bind.center.top", proscrollPane); + + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(jptopleft); + splitPane.setRightComponent(jptopright); + + JPanel jp1 = new JPanel(new PropertyLayout()); + xmmc = new JTextField(50); + cdbm = new JTextField(50); + xmsyz = new JTextField(50); + JButton screenbtn = new JButton(""); + screenbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + +// ProjectLevelSecurityService service = ProjectLevelSecurityService.getService(session); +// System.out.println("user=============="+session.getUser().getUid()); +// System.out.println("session.getRole()=============="+session.getRole().getUid()); +// System.out.println("session.getGroup()=============="+session.getGroup().getUid()); +// UserGroupRoleInfo[] userGroupRoleInfos = new UserGroupRoleInfo[1]; +// userGroupRoleInfos[0] = new UserGroupRoleInfo(); +// userGroupRoleInfos[0].tcUser = session.getUser(); +// userGroupRoleInfos[0].tcRole = session.getRole(); +// userGroupRoleInfos[0].tcGroup = session.getGroup(); +// UserProjectsResponse userProjects2 = service.getUserProjects2(userGroupRoleInfos, true, true, true, true, true); +// TCComponent plainObject = userProjects2.serviceData.getPlainObject(0); +// System.out.println("plainObject==========="+plainObject.getUid()); + + String xmmString = xmmc.getText(); + String cdbmsString = cdbm.getText(); + String xmsyzString = xmsyz.getText(); + + ArrayList list1 = new ArrayList(); + ArrayList list2 = new ArrayList(); + + list1.add("ID"); + list2.add(user); + if (xmmString != null && !xmmString.isEmpty()) { + list1.add(""); + list2.add(xmmString); + } + + if (cdbmsString != null && !cdbmsString.isEmpty()) { + list1.add("Ŀе"); + list2.add(cdbmsString); + } + + if (xmsyzString != null && !xmsyzString.isEmpty()) { + list1.add("Ŀ"); + list2.add(xmsyzString); + } + + TCComponent[] searchLs = null; + try { + searchLs = session.search("__6ML_Om_SearchUserProjectsByProjectAttr", list1.toArray(new String[0]), + list2.toArray(new String[0])); + + Enumeration e = targetM.elements(); + Vector v = new Vector<>(); + while (e.hasMoreElements()) { + v.add(e.nextElement()); + } + + projectM.removeAllElements(); + ArrayList uidList = new ArrayList(); + if (searchLs.length > 0) { + Connection connection = DbPool.getConnection(); + String sql1 = "SELECT t_01.puid FROM PROLE t_01 WHERE t_01.prole_name in( 'Project Author','Project Administrator','Project Team Administrator' )"; + ArrayList list = new ArrayList(); + + try (PreparedStatement pstmt = connection.prepareStatement(sql1)) { + + ResultSet query1 = pstmt.executeQuery(); + while (query1.next()) { + list.add(query1.getString(1)); + } + } + + if (list.size() == 3) { + String sql2 = "SELECT DISTINCT t_01.puid FROM PTC_PROJECT t_01 , PPOM_MEMBER t_02 , PGROUPMEMBER t_03 , PPROJECTTEAM t_04 WHERE ( ( ( ( ( ( ( t_03.rroleu IN ('" + + list.get(0) + "', '" + list.get(1) + "', '" + list.get(2) + + "' ) AND ( t_02.ruseru = '" + uidUser + + "' ) ) AND ( t_03.pstatus = 0 ) ) AND ( t_04.puid = t_02.rgroupu ) ) AND ( t_01.rproject_teamu = t_04.puid ) ) AND ( t_01.pis_active = 1 ) ) AND ( t_01.pis_visible = 1 ) ) AND ( t_02.puid = t_03.puid ) )"; + System.out.println("sql2====================="+sql2); + + try (PreparedStatement pstmt = connection.prepareStatement(sql2)) { + + ResultSet query2 = pstmt.executeQuery(); + while (query2.next()) { + uidList.add(query2.getString(1)); + } + } + } + } + + + + for (int i = 0; i < searchLs.length; i++) { + String stringProperty = searchLs[i].getStringProperty("object_string"); + if(uidList.contains(searchLs[i].getUid())) { + map.put(stringProperty, searchLs[i]); + if (!v.contains(stringProperty)) + projectM.addElement(stringProperty); + } + + } + + int size = projectM.size(); + System.out.println("Ŀ======================="+size); + if(size <= 0) { + MessageBox.post(AssignProjectDialog.this, "δĿ", "", MessageBox.INFORMATION); + } + + + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + } + }); + +// xmmc.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent actionevent) { +// String text = xmmc.getText(); +// Enumeration e = targetM.elements(); +// Vector v = new Vector<>(); +// while(e.hasMoreElements()) { +// v.add(e.nextElement()); +// } +// projectM.removeAllElements(); +// for(String t : projs) { +// if((text.isEmpty()||t.contains(text)) && !v.contains(t)) +// projectM.addElement(t); +// } +// } +// }); + + jp1.add("1.1.center.center", new JLabel("Ŀ")); + jp1.add("1.2.center.center", xmmc); + jp1.add("1.3.center.center", screenbtn); + jp1.add("2.1.center.center", new JLabel("е")); + jp1.add("2.2.center.center", cdbm); + jp1.add("3.1.center.center", new JLabel("Ŀ")); + jp1.add("3.2.center.center", xmsyz); + + JPanel butPanel = new JPanel(new ButtonLayout()); + JButton okbtn = new JButton("ȷ"); + JButton yybtn = new JButton("Ӧ"); + JButton canceltn = new JButton("ȡ"); + butPanel.add(okbtn); + butPanel.add(yybtn); + butPanel.add(canceltn); + canceltn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + dispose(); + } + }); + + JPanel jpx = new JPanel(new VerticalLayout()); + jpx.add("top.bind.center.top", jp1); + jpx.add("top.bind.center.top", splitPane);// jptop + jpx.add("top.bind.center.top", butPanel); + yybtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + int count = 0; + StringBuffer sbInfo = new StringBuffer(); + sbInfo.append("ָɣڷȨûĿ" + lineSeparator); + try { + Enumeration e = targetM.elements(); + Vector v = new Vector<>(); + while (e.hasMoreElements()) { + v.add(e.nextElement()); + } + + if (v.size() == 0) { + MessageBox.post(AssignProjectDialog.this, "ѡҪָɵĿ", "ɹ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < targets.length; i++) { + for (int j = 0; j < v.size(); j++) { + TCComponent project = map.get(v.get(j)); + try { + tccomponentprojecttype.assignToProject((TCComponentProject) project, + (TCComponent) targets[i]); + + } catch (Exception e2) { + // TODO: handle exception + sbInfo.append(v.get(j) + lineSeparator); + count++; + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AssignProjectDialog.this, "" + TCUtil.getStackTrace(e), "", MessageBox.ERROR); + } + if (count == 0) { + MessageBox.post(AssignProjectDialog.this, "ָɣ", "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post(AssignProjectDialog.this, sbInfo.toString(), "ɹ", MessageBox.INFORMATION); + } + } + }); + + okbtn.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionevent) { + int count = 0; + StringBuffer sbInfo = new StringBuffer(); + sbInfo.append("ָɣڷȨûĿ" + lineSeparator); + try { + Enumeration e = targetM.elements(); + Vector v = new Vector<>(); + while (e.hasMoreElements()) { + v.add(e.nextElement()); + } + + if (v.size() == 0) { + MessageBox.post(AssignProjectDialog.this, "ѡҪָɵĿ", "ɹ", MessageBox.INFORMATION); + return; + } + + for (int i = 0; i < targets.length; i++) { + for (int j = 0; j < v.size(); j++) { + TCComponent project = map.get(v.get(j)); + try { + tccomponentprojecttype.assignToProject((TCComponentProject) project, + (TCComponent) targets[i]); + + } catch (Exception e2) { + // TODO: handle exception + sbInfo.append(v.get(j) + lineSeparator); + count++; + } + } + } + + } catch (Exception e) { + e.printStackTrace(); + MessageBox.post(AssignProjectDialog.this, "" + TCUtil.getStackTrace(e), "", MessageBox.ERROR); + } + if (count > 0) { + MessageBox.post(AssignProjectDialog.this, sbInfo.toString(), "ɹ", MessageBox.INFORMATION); + } + dispose(); + } + }); + + add(jpx); +// setResizable(false); + pack(); + centerToScreen(); + setVisible(true); + } + +} diff --git a/src/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler.java b/src/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler.java new file mode 100644 index 0000000..87973e2 --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/AssignProjectHandler.java @@ -0,0 +1,42 @@ +package cn.net.connor.ml.plm.gotoQMS; + +import javax.swing.SwingUtilities; + +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.TCSession; +import com.teamcenter.rac.util.MessageBox; + +public class AssignProjectHandler extends AbstractHandler +{ + + public Object execute(ExecutionEvent arg0) throws ExecutionException + { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + try { + final TCSession session = (TCSession) app.getSession(); + InterfaceAIFComponent[] pasteTargets = app.getTargetComponents(); + if(pasteTargets.length <= 0) { + MessageBox.post(AIFUtility.getActiveDesktop(), "ѡҪָɵĶ","", MessageBox.ERROR); + return null; + } + SwingUtilities.invokeLater(new Runnable() { + public void run() { + new AssignProjectDialog(session, pasteTargets); + } + }); + } + catch (Exception exception) + { + exception.printStackTrace(); + MessageBox.post(exception, true); + } + + return null; + } +} diff --git a/src/cn/net/connor/ml/plm/gotoQMS/CommonUtil.java b/src/cn/net/connor/ml/plm/gotoQMS/CommonUtil.java new file mode 100644 index 0000000..ab614a1 --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/CommonUtil.java @@ -0,0 +1,210 @@ +package cn.net.connor.ml.plm.gotoQMS; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Vector; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.log4j.Logger; + +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.TCUserService; + +@SuppressWarnings("deprecation") +public class CommonUtil { + + private static final Logger logger = Logger.getLogger(CommonUtil.class); + public static String tmpDir = System.getProperty("java.io.tmpdir"); + + public static String debug(StackTraceElement ste) { + return ste.getFileName() + "(" + ste.getLineNumber() + "):"; + } + + public static ListOfValuesInfo getLov(String lovName,TCSession session) { + TCComponentListOfValuesType lovType; + try { + lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lov = lovType.find(lovName); + if (lov.length > 0) + return lov[0].getListOfValues(); + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static TCComponentItem getSingleItem(String itemId,TCSession session) throws TCException { + TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("Item"); + TCComponentItem[] items = itemType.findItems(itemId); + if (items.length == 1) { + return items[0]; + } + return null; + } + + + public static void setByPass(boolean val) throws TCException { + TCUserService userservice = null; + if (userservice == null) { + userservice = ((TCSession) AIFUtility.getCurrentApplication().getSession()).getUserService(); + } + //lidy20181030޸Ŀ· +// Object[] obj = new Object[1]; +// obj[0] = "origin"; + Object[] obj = new Object[2]; + if (val) { +// userservice.call("YSR_set_bypass", obj); + obj[0] = "Set_ByPass"; + obj[1] = "true"; + String result = (String)userservice.call("YSR8UserService", obj); + System.out.println("setByPass:"+result); + } else { +// userservice.call("YSR_close_bypass", obj); + obj[0] = "Close_ByPass"; + obj[1] = "false"; + String result = (String)userservice.call("YSR8UserService", obj); + System.out.println("setByPass:"+result); + } + } + + /** + * ָָstringתΪvector + * + * @param msg + * Դַ + * @param sepStr + * ָ + * @return vector + */ + public static Vector split2Vector(String msg, String sepStr) { + Vector vt = new Vector(); + try { + String tmpStr = null; + int pos = -1; + if (msg == null || msg.trim().length() == 0) { + vt.addElement(""); + return vt; + } + while (true) { + pos = msg.indexOf(sepStr); + if (pos == -1) { + vt.addElement(msg); + break; + } else if (pos == 0) { + vt.addElement(""); + msg = msg.substring(sepStr.length()); + } else { + tmpStr = msg.substring(0, pos); + vt.addElement(tmpStr); + msg = msg.substring(pos + sepStr.length()); + } + if (msg.length() == 0) { + vt.addElement(""); + break; + } + } + } catch (RuntimeException e) { + e.printStackTrace(); + } + return vt; + } + + public static boolean isNumeric(String str) { + Pattern pattern = Pattern.compile("[0-9]*"); + Matcher isNum = pattern.matcher(str); + if (!isNum.matches()) { + return false; + } + return true; + } + + /** + * ȡַ + * + * @param src + * Դַ + * @return double + */ + public static double getFloatFromStr(String src) { + if (logger.isDebugEnabled()) { + logger.debug("getFloatFromStr(String) - start"); + logger.debug("getFloatFromStr(String) - src===" + src); + } + double d = 0d; + try { + if (src == null || src.length() == 0) { + logger.error("Դַ󣬲ȡΪͣ src===" + src); + return 0d; + } + src = src.trim(); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < src.length(); i++) { + if (src.charAt(i) == '.' || src.charAt(i) == '+' || src.charAt(i) == '-') { + sb.append(src.charAt(i)); + } else if (src.charAt(i) >= '0' && src.charAt(i) <= '9') { + sb.append(src.charAt(i)); + } + } + d = Double.parseDouble(sb.toString()); + } catch (NumberFormatException e) { + logger.error("getFloatFromStr(String)", e); + e.printStackTrace(); + } + if (logger.isDebugEnabled()) { + logger.debug("getFloatFromStr(String) - d==" + d); + logger.debug("getFloatFromStr(String) - end"); + } + return d; + } + + public static int getDaysBetween(String dtFormer, String dtLater) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + try { + return getDaysBetween2(sdf.parse(dtFormer), sdf.parse(dtLater)); + } catch (ParseException e) { + e.printStackTrace(); + } + return 0; + } + + public static int getDaysBetween2(java.util.Date date1, java.util.Date date2) { + GregorianCalendar former = (GregorianCalendar) GregorianCalendar.getInstance(); + GregorianCalendar latter = (GregorianCalendar) GregorianCalendar.getInstance(); + + former.setTime(date1); + former.set(Calendar.MILLISECOND, 0); + former.set(Calendar.SECOND, 0); + former.set(Calendar.MINUTE, 0); + former.set(Calendar.HOUR_OF_DAY, 0); + + latter.setTime(date2); + latter.set(Calendar.MILLISECOND, 0); + latter.set(Calendar.SECOND, 0); + latter.set(Calendar.MINUTE, 0); + latter.set(Calendar.HOUR_OF_DAY, 0); + + int iCounter = 0; + if (former.before(latter)) { + while (former.before(latter)) { + former.add(Calendar.DATE, 1); + iCounter++; + } + } else { + while (latter.before(former)) { + latter.add(Calendar.DATE, 1); + iCounter--; + } + } + return iCounter; + } +} diff --git a/src/cn/net/connor/ml/plm/gotoQMS/DbPool.java b/src/cn/net/connor/ml/plm/gotoQMS/DbPool.java new file mode 100644 index 0000000..73e0433 --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/DbPool.java @@ -0,0 +1,193 @@ +package cn.net.connor.ml.plm.gotoQMS; + +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", "2"); + 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 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); + System.out.println("返回操作的记录数目:" + i); + } 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 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/src/cn/net/connor/ml/plm/gotoQMS/GotoQMSHandler.java b/src/cn/net/connor/ml/plm/gotoQMS/GotoQMSHandler.java new file mode 100644 index 0000000..52b786a --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/GotoQMSHandler.java @@ -0,0 +1,133 @@ +package cn.net.connor.ml.plm.gotoQMS; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Properties; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.teamcenter.rac.aif.AIFDesktop; +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.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class GotoQMSHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent[] targets = app.getTargetComponents(); + TCSession session = (TCSession) app.getSession(); + if (targets == null || targets.length != 1 || !(targets[0] instanceof TCComponentItemRevision)) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ񵥸ĵ汾"); + return null; + } + try { + TCComponent target = (TCComponent) targets[0]; + // + + String state = "QMSӿ"; + TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(state, TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (taskTemplate == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "δҵģ壡"); + return null; + } + // һ ơģ塢Ŀ󡢸 + String name = target.getProperty("object_string"); + processType.create(state + "" + name, "", taskTemplate, new TCComponent[] { target }, new int[] { 1 }); + + String url = KUtil.getPrefVal((TCSession) app.getSession(), "Meling_QMS_url"); + if (url == null || url.length() < 1) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ[Meling_QMS_url]"); + return null; + } + // ȡtoken + String tokenUrl = "http://" + url + "/api/auth/gettoken?account=plm_test&password=plm123456"; + + // ־ + insertLog("sendToQMS", tokenUrl, "POST"); + + String tokenRes = HttpUtil.sendGet(tokenUrl); + JSONObject tokenJSON = JSON.parseObject(tokenRes); + + /// ֵд־ + insertLog("sendToQMS", tokenJSON.toString(), "RESULT"); + + if (tokenJSON.getInteger("errcode") != 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ȡQMSӿtokenʧܣ" + tokenJSON.get("errmsg")); + return null; + } + JSONObject dataObject = (JSONObject) tokenJSON.get("data"); + String token = (String) dataObject.get("access_token"); + + // uid + String uid = target.getUid(); + String jsonStr = "{\"bisnetcode\":\"PLMĵID\",\"data\":{\"DOCID\":\"" + uid + "\"}}"; + String postUrl = "http://" + url + "/api/qms/service?access_token=" + token; + + // ־ + insertLog("sendToQMS", jsonStr, "POST"); + + String result = HttpUtil.sendPost2(postUrl, jsonStr); + JSONObject resultJSON = JSON.parseObject(result); + if (resultJSON == null || resultJSON.getInteger("errcode") != 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "QMSӿڷʧܣ" + resultJSON.get("errmsg")); + return null; + } + + // ֵд־ + insertLog("sendToQMS", resultJSON.toString(), "RESULT"); + + KUtil.info(AIFDesktop.getActiveDesktop(), "QMSӿڷͳɹ"); + } catch (Exception e) { + KUtil.info(AIFDesktop.getActiveDesktop(), "QMSӿڷʧܣ\n" + e); + e.printStackTrace(); + } + + return null; + } + + public static void insertLog(String type, String json, String value) { + InputStream input = null; + try { + input = new BufferedInputStream(GotoQMSHandler.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) { + e.printStackTrace(); + } finally { + if (input != null) { + try { + input.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + DbPool.freeAll(); + } + } + +} diff --git a/src/cn/net/connor/ml/plm/gotoQMS/HttpUtil.java b/src/cn/net/connor/ml/plm/gotoQMS/HttpUtil.java new file mode 100644 index 0000000..f96325f --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/HttpUtil.java @@ -0,0 +1,201 @@ +package cn.net.connor.ml.plm.gotoQMS; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.net.URLConnection; +import java.util.List; +import java.util.Map; + +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; + +public class HttpUtil { + + public static String sendPost2(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; + } + + /** + * ָURLGET + * @param url URL + * @param param Ӧ name1=value1&name2=value2 ʽ + * @return URL ԶԴӦ + */ + public static String sendGet(String url, String param) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url + "/" + param; + URL realUrl = new URL(urlNameString); + // 򿪺URL֮ + URLConnection connection = realUrl.openConnection(); + // ͨõ + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // ʵʵ + connection.connect(); + // ȡӦͷֶ + Map> map = connection.getHeaderFields(); + // еӦͷֶ + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // BufferedReaderȡURLӦ + in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("GET쳣" + e); + e.printStackTrace(); + } + // ʹfinallyر + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + public static String sendGet(String url) { + String result = ""; + BufferedReader in = null; + try { + String urlNameString = url; + URL realUrl = new URL(urlNameString); + // 򿪺URL֮ + URLConnection connection = realUrl.openConnection(); + // ͨõ + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // ʵʵ + connection.connect(); + // ȡӦͷֶ + Map> map = connection.getHeaderFields(); + // еӦͷֶ + for (String key : map.keySet()) { + System.out.println(key + "--->" + map.get(key)); + } + // BufferedReaderȡURLӦ + in = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println("GET쳣" + e); + e.printStackTrace(); + } + // ʹfinallyر + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + /** + * ָ URL POST + * @param url URL + * @param param Ӧ name1=value1&name2=value2 ʽ + * @return ԶԴӦ + */ + public static String sendPost(String url, String param) { + PrintWriter out = null; + BufferedReader in = null; + String result = ""; + try { + URL realUrl = new URL(url); + // 򿪺URL֮ + URLConnection conn = realUrl.openConnection(); + // ͨõ + conn.setRequestProperty("accept", "*/*"); + conn.setRequestProperty("connection", "Keep-Alive"); + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + // POST + conn.setDoOutput(true); + conn.setDoInput(true); + // ȡURLConnectionӦ + out = new PrintWriter(conn.getOutputStream()); + // + out.print(param); + // flushĻ + out.flush(); + // BufferedReaderȡURLӦ + in = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + while ((line = in.readLine()) != null) { + result += line; + } + } catch (Exception e) { + System.out.println(" POST 쳣" + e); + e.printStackTrace(); + } + // ʹfinallyر + finally { + try { + if (out != null) { + out.close(); + } + if (in != null) { + in.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return result; + } + + public static void main(String[] args) { + String s = HttpUtil.sendGet("http://localhost:8762/testGet", "gordan"); + System.out.println(s); + + s = HttpUtil.sendPost("http://localhost:8762/testPost", "name=gordan"); + System.out.println(s); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/gotoQMS/TCUtil.java b/src/cn/net/connor/ml/plm/gotoQMS/TCUtil.java new file mode 100644 index 0000000..a953361 --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/TCUtil.java @@ -0,0 +1,1235 @@ +package cn.net.connor.ml.plm.gotoQMS; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.io.Reader; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.sql.Types; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Vector; + +import javax.imageio.ImageIO; + +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.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.TCComponentEnvelope; +import com.teamcenter.rac.kernel.TCComponentEnvelopeType; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCComponentProject; +import com.teamcenter.rac.kernel.TCComponentProjectType; +import com.teamcenter.rac.kernel.TCComponentPseudoFolder; +import com.teamcenter.rac.kernel.TCComponentQuery; +import com.teamcenter.rac.kernel.TCComponentQueryType; +import com.teamcenter.rac.kernel.TCComponentSchedule; +import com.teamcenter.rac.kernel.TCComponentTcFile; +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.TCTypeService; +import com.teamcenter.rac.util.MessageBox; + +public class TCUtil { + + /** + * getPreferenceHashMap:ϵͳֵ + * + * @param session + * tcsession + * @param scope + * + * @param pid + * ѡ + * @param @return + * 趨ļ + * @return HashMap + * @throws @since + * CodingExample Ver 1.1 + */ + public static String[] getPreference(TCSession session, int scope, String pid) { + String options[] = session.getPreferenceService().getStringValues(pid); + return options; + } + + public static String getPreference2(TCSession session, int scope, String pid) { + String option = session.getPreferenceService().getStringValue(pid); + return option; + } + + // String[] lov = (String[]) list.toArray(new String[list.size()]); + /** + * ð汾ı + * + * @param revision + * @return 汾 + * @throws TCException + */ + public static TCComponentForm getItemRevisionMasterForm(TCComponentItemRevision revision) throws TCException { + if (revision != null) { + AIFComponentContext[] contexts = revision.getChildren("IMAN_master_form_rev"); + if (contexts != null && contexts.length > 0) { + InterfaceAIFComponent component = contexts[0].getComponent(); + if (component instanceof TCComponentForm) { + return (TCComponentForm) component; + } + } + } + return null; + } + + public static TCComponentItemRevision getItemRevisionFromItem(TCComponentItem item, String rev) throws TCException { + if (item != null) { +// System.out.println("rev-----" + rev); + AIFComponentContext[] contexts = item.getChildren("revision_list"); + if (contexts != null && contexts.length > 0) { + for (int i = 0; i < contexts.length; i++) { + InterfaceAIFComponent component = contexts[i].getComponent(); + if (component instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) component; + if (revision.getProperty("item_revision_id").equals(rev)) { + return (TCComponentItemRevision) revision; + } + } + } + } + } + return null; + } + + public static String getSerialNo(TCSession session, String itemId, String objectType) { + try { + TCComponent[] comps = null; + if (objectType.equals("")) { + comps = TCUtil.query(session, " ID", new String[] { "ItemID" }, new String[] { itemId + "*" }); + } else { + comps = TCUtil.query(session, "...", new String[] { "ItemID", "Type" }, new String[] { itemId + "*", objectType }); + } + System.out.println("getSerialNo comps.len:" + (comps == null ? 0 : comps.length)); + if (comps.length > 0) { + Integer maxId = 0; + DecimalFormat df = new DecimalFormat("00"); + for (TCComponent comp : comps) { + String pid = comp.getProperty("item_id"); + System.out.println("pid:" + pid); + String pidSuffix = pid.substring(pid.length() - 2); + if (Integer.parseInt(pidSuffix) > maxId) { + maxId = Integer.parseInt(pidSuffix); + } + } + return df.format(maxId + 1); + } + } catch (TCException e) { + e.printStackTrace(); + } + return "01"; + } + + public static String getRevSeq(String rev) { + char[] revCh = rev.toUpperCase().toCharArray(); + Integer revI = Integer.valueOf(revCh[0]) - 64; + DecimalFormat df = new DecimalFormat("00"); + return df.format(revI); + } + + /** + * ݰ汾bomLine + * + * @param revision + * @return TCComponentBOMLine + * @throws TCException + */ + public static TCComponentBOMLine getBOMLine(TCSession session, TCComponentItemRevision revision) { + TCComponentBOMLine bomLine = null; + try { + TCComponentBOMWindowType bomWinType = (TCComponentBOMWindowType) session.getTypeComponent("BOMWindow"); + TCComponentBOMWindow window = bomWinType.create(null); + bomLine = window.setWindowTopLine(null, revision, null, null); + window.save(); + } catch (TCException e) { + e.printStackTrace(); + } + return bomLine; + } + + public static TCComponentBOMLine getBOMLineWithID(TCSession session, String itemID) { + TCComponentItem item = findItemByID(session, itemID); + TCComponentBOMLine bomLine = null; + if (item != null) { + try { + bomLine = getBOMLine(session, item.getLatestItemRevision()); + } catch (TCException e) { + e.printStackTrace(); + } + } + return bomLine; + } + + public static Object compareBOMLineQuantity(TCComponentBOMLine preBomLine, TCComponentBOMLine currentBomLine) { + double currentQuantity = totalBOMLineQuantity(currentBomLine); + double preQuantity = totalBOMLineQuantity(preBomLine); + System.out.println(preQuantity + ":" + currentQuantity); + if (currentQuantity == preQuantity) { + return true; + } else { + return new double[] { preQuantity, currentQuantity }; + } + } + + /** + * + * + * @param bomLine + * @return + */ + public static double totalBOMLineQuantity(TCComponentBOMLine bomLine) { + double count = 0; + try { + String itemID = bomLine.getProperty("bl_item_item_id"); + String install = bomLine.getProperty("YSR8_InstallP_bom"); + TCComponentBOMLine rootBomLine = bomLine; + while (rootBomLine.parent() != null) { + rootBomLine = rootBomLine.parent(); + } + count += loop(rootBomLine, itemID + install, true); + // System.out.println("ҪItem" + itemID + " Ŀǰ" + count); + } catch (TCException e) { + e.printStackTrace(); + } + return count; + } + + /** + * ѰһbomLinePSEгֵĴ + * + * @param bomLine + * @param itemID + * @param loopFlag + * ǷҪѰ + * @throws TCException + */ + private static double loop(TCComponentBOMLine bomLine, String itemID, Boolean loopFlag) throws TCException { + double count = 0; + AIFComponentContext[] context = bomLine.getChildren(); + String parentQuantity = bomLine.getProperty("bl_quantity"); + parentQuantity = parentQuantity.isEmpty() ? "1" : parentQuantity; + for (int i = 0; i < context.length; i++) { + TCComponentBOMLine children = (TCComponentBOMLine) context[i].getComponent(); + String childrenID = children.getProperty("bl_item_item_id"); + String install = bomLine.getProperty("YSR8_InstallP_bom"); + // System.out.println("ǰItem" + childrenID + install); + if ((childrenID + install).equals(itemID)) { + String quantity = children.getProperty("bl_quantity"); + quantity = quantity.isEmpty() ? "1" : quantity; + // count += Double.parseDouble(parentQuantity) * Double.parseDouble(quantity); + count += Double.parseDouble(quantity); + // System.out.println("ҪItem" + itemID + " BomLine" + quantity); + } else if (loopFlag) { + count += loop(children, itemID, loopFlag); + // System.out.println("ҪItem" + itemID + " ϼBomLine" + parentQuantity + "Ŀǰ" + count); + } + } + return count * Double.parseDouble(parentQuantity); + } + + public static void getBOMLineChildComps(TCComponentBOMLine pbomLine, Vector comps, Map map, Map mapItemId, + Set set) { + try { + String pitemId = pbomLine.getProperty("bl_item_item_id"); + AIFComponentContext[] context = pbomLine.getChildren(); + for (int i = 0; i < context.length; i++) { + TCComponentBOMLine bomLine = (TCComponentBOMLine) context[i].getComponent(); + String itemId = bomLine.getProperty("bl_item_item_id"); + String install = bomLine.getProperty("YSR8_InstallP_bom"); + if (!set.contains(itemId + install)) { + comps.add(bomLine); + set.add(itemId + install); + map.put(itemId + install, bomLine); + mapItemId.put(bomLine, pitemId); + // System.out.println(itemId + install + "-----" + bomLine); + } + getBOMLineChildComps(bomLine, comps, map, mapItemId, set); + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public static boolean compareBOMLineRevId(TCComponentBOMLine preBomLine, TCComponentBOMLine currentBomLine) { + try { + String currentRevId = currentBomLine.getItemRevision().getProperty("item_revision_id"); + String preRevId = preBomLine.getItemRevision().getProperty("item_revision_id"); + System.out.println(preRevId + ":" + currentRevId); + if (currentRevId.equals(preRevId)) { + return true; + } + } catch (TCException e) { + e.printStackTrace(); + } + return false; + } + + public static TCComponentItem createItem(TCSession session, String id, String name, String type) { + try { + TCTypeService service = session.getTypeService(); + System.out.println("id-----" + id + "-----name-----" + name + "-----type-----" + type); + TCComponentItemType itemType = (TCComponentItemType) service.getTypeComponent("Item"); + TCComponentItem newItem = itemType.create(id, null, type, name, "", null); + return newItem; + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static TCComponentDataset createDataset(TCSession session, File file, String datasetName) { + try { + String refType = null, objType = null, fileName = null; + fileName = file.getName().toLowerCase(); + if (fileName.endsWith("doc")) { + refType = "word"; + objType = "MSWord"; + } else if (fileName.endsWith("docx")) { + refType = "word"; + objType = "MSWordX"; + } else if (fileName.endsWith("xls")) { + refType = "excel"; + objType = "MSExcel"; + } else if (fileName.endsWith("xlsx")) { + refType = "excel"; + objType = "MSExcelX"; + } else if (fileName.endsWith("jpg")) { + refType = "JPEG_Reference"; + objType = "JPEG"; + } else if (fileName.endsWith("bmp")) { + refType = "Image"; + objType = "Bitmap"; + } else if (fileName.endsWith("gif")) { + refType = "GIF_Reference"; + objType = "GIF"; + } else if (fileName.endsWith("png")) { + refType = "Image"; + objType = "Image"; + } else if (fileName.endsWith("zip")) { + refType = "ZIPFILE"; + objType = "zip"; + } else if (fileName.endsWith("rar")) { + refType = "YSR8_WinRAR"; + objType = "YSR8_WinRAR"; + } + TCComponentDatasetType compType = (TCComponentDatasetType) session.getTypeService().getTypeComponent("Dataset"); + TCComponentDataset dataset = compType.create(datasetName, "description", objType); + dataset.setFiles(new String[] { file.getAbsolutePath() }, new String[] { refType }); + return dataset; + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static void updateFile(TCComponentDataset dataset, File file) { + try { + /* + * String refType = null, fileName = null; fileName = + * file.getName().toLowerCase(); if (fileName.endsWith("doc")) { refType = + * "word"; } else if (fileName.endsWith("docx")) { refType = "word"; } else if + * (fileName.endsWith("xls")) { refType = "excel"; } else if + * (fileName.endsWith("xlsx")) { refType = "excel"; } else if + * (fileName.endsWith("jpg")) { refType = "JPEG_Reference"; } else if + * (fileName.endsWith("bmp")) { refType = "Image"; } else if + * (fileName.endsWith("gif")) { refType = "GIF_Reference"; } else if + * (fileName.endsWith("png")) { refType = "Image"; } + */ + String[] refNames = dataset.getTCProperty("ref_names").getStringArrayValue(); + dataset.replaceFiles(new File[] { file }, new String[] { file.getName() }, new String[] { "" }, refNames); + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * ѯѯ + * + * @param session + * @param queryName + * @param aKey + * @param aVal + * @return + * @throws TCException + */ + public static TCComponent[] query(TCSession session, String queryName, String[] aKey, String[] aVal) throws TCException { + TCComponentQueryType imanQueryType = (TCComponentQueryType) session.getTypeComponent("ImanQuery"); + TCComponentQuery imancomponentquery = (TCComponentQuery) imanQueryType.find(queryName); + if (imancomponentquery == null) { + System.out.println("δҵѯ " + queryName + "!"); + return null; + } + aKey = session.getTextService().getTextValues(aKey); +// for (int i = 0; i < aKey.length; i++) { +// System.out.println(aKey[i] + "===============" + aVal[i]); +// } + TCComponentContextList componentContextList = imancomponentquery.getExecuteResultsList(aKey, aVal); + return componentContextList.toTCComponentArray(); + } + + /** + * Ϊѯ + * TCComponentѯ propertyո + */ + public static TCComponent[] TCsort(TCComponent[] TCComponent, String property) { + HashMap map = new HashMap<>(); + int count = TCComponent.length; + for(TCComponent Component : TCComponent) { + try { + map.put(Component, Component.getProperty(property)); + } catch (Exception e) { + e.printStackTrace(); + } + } + // ͨArrayList캯map.entrySet()תlist + List> list = new ArrayList>(map.entrySet()); + // ͨȽʵֱȽ + Collections.sort(list, new Comparator>() { + public int compare(Map.Entry mapping1, Map.Entry mapping2) { + return mapping1.getValue().compareTo(mapping2.getValue()); + } + }); + TCComponent = new TCComponent[count]; + int i=0; + for(Map.Entry mapping : list) { + TCComponent[i] = mapping.getKey(); + i++; + } + return TCComponent; + } + public static TCComponent[] TCFormsort(TCComponent[] TCComponent, String property, final boolean forward) { + HashMap map = new HashMap<>(); + int count = TCComponent.length; + for(TCComponent Component : TCComponent) { + try { + map.put(Component, TCUtil.getItemRevisionMasterForm((TCComponentItemRevision) Component).getProperty(property)); + } catch (Exception e) { + e.printStackTrace(); + } + } + // ͨArrayList캯map.entrySet()תlist + List> list = new ArrayList>(map.entrySet()); + // ͨȽʵֱȽ + Collections.sort(list, new Comparator>() { + public int compare(Map.Entry mapping1, Map.Entry mapping2) { + if(forward) + return mapping1.getValue().compareTo(mapping2.getValue()); + return mapping2.getValue().compareTo(mapping1.getValue()); + } + }); + TCComponent = new TCComponent[count]; + int i=0; + for(Map.Entry mapping : list) { + TCComponent[i] = mapping.getKey(); + i++; + } + return TCComponent; + } + + /** + * ͨItemIDȡTCComponentItem + * + * @param str_ItemID + * @return ѯItem + * @throws TCException + */ + @SuppressWarnings("deprecation") + public static TCComponentItem findItemByID(TCSession session, String itemID) { + try { + TCComponentItemType imancomponentitemtype = (TCComponentItemType) session.getTypeService().getTypeComponent("Item"); + return imancomponentitemtype.find(itemID); + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static TCComponentSchedule findScheduleByID(TCSession session, String itemID) { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + attrVec.add("item_id"); + valVec.add(itemID); + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] schedules; + try { + schedules = query(session, "Schedules...", attrs, vals); + } catch (TCException e) { + e.printStackTrace(); + return null; + } + if (schedules != null && schedules.length > 0) { +// System.out.println("schedules[0].getUid()-----" + schedules[0].getUid()); + return (TCComponentSchedule) schedules[0]; + } + + return null; + } + + public static TCComponentSchedule findScheduleByProjectID(TCSession session, String projectID) { + Vector attrVec = new Vector(); + Vector valVec = new Vector(); + attrVec.add("project_id"); + valVec.add(projectID); + String[] attrs = (String[]) attrVec.toArray(new String[attrVec.size()]); + String[] vals = (String[]) valVec.toArray(new String[attrVec.size()]); + TCComponent[] schedules; + try { + schedules = query(session, "Schedules...", attrs, vals); + } catch (TCException e) { + e.printStackTrace(); + return null; + } + if (schedules != null && schedules.length > 0) { +// System.out.println("schedules[0].getUid()-----" + schedules[0].getUid()); + return (TCComponentSchedule) schedules[0]; + } + + return null; + } + + public static TCComponent getChildComponent(TCSession session, TCComponent parent, String relType, String childType) { + TCComponent child = null; + try { + AIFComponentContext[] context = parent.getChildren(relType); + for (int i = 0; i < context.length; i++) { + TCComponent childPart = (TCComponent) context[i].getComponent(); + if (childPart.getProperty("object_type").equalsIgnoreCase(childType)) { + child = childPart; + break; + } + } + } catch (TCException e) { + e.printStackTrace(); + } + + return child; + } + + public static ArrayList getAllChildComponent(TCSession session, TCComponent parent, String relType, String childType) { + ArrayList childList = new ArrayList(); + try { + AIFComponentContext[] context = parent.getChildren(relType); + System.out.printf("getAllChildComponent.context.length========" + context.length); + for (int i = 0; i < context.length; i++) { + TCComponent childPart = (TCComponent) context[i].getComponent(); + System.out + .printf("getAllChildComponent.childPart========" + "========" + childPart.getUid() + childPart.getProperty("object_name") + "========" + childPart.getProperty("object_type")); + + if (childType.equals("")) { + childList.add(childPart); + } else if (childPart.getProperty("object_type").equalsIgnoreCase(childType)) { + childList.add(childPart); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + + return childList; + } + + public static TCComponentUser findUserById(TCSession session, String userId) { + try { + TCComponentUserType userType = (TCComponentUserType) session.getTypeComponent("User"); + TCComponentUser user = userType.find(userId); + return user; + } catch (TCException e) { + System.out.println("ϵͳûҵû" + userId); + } + return null; + } + + /** + * ͨobject_nameȡTCComponentDataset + * + * @throws TCException + */ + public static TCComponentDataset findDatasetByObjectName(TCSession session, String objectName) throws TCException { + TCComponentDatasetType datasetType = (TCComponentDatasetType) session.getTypeComponent("Dataset"); + return datasetType.find(objectName); + } + + public static TCComponentPseudoFolder getRevisionPseudoFolder(TCComponentItemRevision itemRev, String relation) { + TCComponentPseudoFolder realtionFolder = null; + try { + AIFComponentContext[] comps = itemRev.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); +// System.out.println("property_name:" + comp.getProperty("property_name")); + if ((comp instanceof TCComponentPseudoFolder)) { + if (comp.isTypeOf("PseudoFolder")) { + if (comp.getProperty("property_name").equalsIgnoreCase(relation)) { + realtionFolder = (TCComponentPseudoFolder) comp; + break; + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return realtionFolder; + } + + public static TCComponentItem getPseudoItem(TCComponentPseudoFolder pseudoFolder, String itemObjType, String itemObjName) { + TCComponentItem item = null; + try { + AIFComponentContext[] comps = pseudoFolder.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if ((comp instanceof TCComponentItem)) { + String objName = comp.getProperty("object_name"); + String objType = comp.getProperty("object_type"); + if (objType.equals(itemObjType) && objName.equals(itemObjName)) { + item = (TCComponentItem) comp; + break; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return item; + } + + // item_idȡαļµItem + public static TCComponentItem getPseudoItem(TCComponentPseudoFolder pseudoFolder, String item_id) { + TCComponentItem item = null; + try { + AIFComponentContext[] comps = pseudoFolder.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if (comp instanceof TCComponentItem) { + String objItem_id = comp.getProperty("item_id"); + if (objItem_id.equals(item_id)) { + item = (TCComponentItem) comp; + break; + } + } else if (comp instanceof TCComponentItemRevision) { + TCComponentItem compitem = ((TCComponentItemRevision) comp).getItem(); + String objItem_id = compitem.getProperty("item_id"); + if (objItem_id.equals(item_id)) { + item = (TCComponentItem) compitem; + break; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return item; + } + + // item_idȡαļµItem汾 + public static TCComponentItemRevision getPseudoItem2(TCComponentPseudoFolder pseudoFolder, String item_id) { + TCComponentItemRevision item = null; + try { + AIFComponentContext[] comps = pseudoFolder.getChildren(); + if (comps != null && comps.length > 0 && comps[0] != null) { + for (int i = 0; i < comps.length; i++) { + TCComponent comp = (TCComponent) comps[i].getComponent(); + if (comp instanceof TCComponentItem) { + String objItem_id = comp.getProperty("item_id"); + if (objItem_id.equals(item_id)) { + item = ((TCComponentItem) comp).getLatestItemRevision(); + break; + } + } else if (comp instanceof TCComponentItemRevision) { + TCComponentItem compitem = ((TCComponentItemRevision) comp).getItem(); + String objItem_id = compitem.getProperty("item_id"); + if (objItem_id.equals(item_id)) { + item = (TCComponentItemRevision) comp; + break; + } + } + } + } + } catch (TCException e) { + e.printStackTrace(); + } + return item; + } + + /** + * ݼĿ¼ + * + * @param dataset + * @param filePath + * · + * @return File [] + * @throws TCException + */ + public static File exportFileToDir(TCComponentDataset dataset, String filePath) { + File exportFile = null; + try { + TCComponentTcFile[] files = dataset.getTcFiles(); + if (files.length == 1) { + exportFile = files[0].getFile(filePath); + } + } catch (Exception e) { + e.printStackTrace(); + } + return exportFile; + } + + public static File exportFileToDir(TCComponentDataset dataset, String dir, String fileTitle) { + File exportFile = null; + try { + String fileExt; + TCComponentTcFile tcfiles[] = dataset.getTcFiles(); + if (tcfiles != null && tcfiles.length > 0) { + fileExt = tcfiles[0].getProperty("file_ext"); + + File file = new File(dir, fileTitle + "." + fileExt); + if (file.exists()) { + file.delete(); + } + + exportFile = tcfiles[0].getFile(dir, fileTitle + "." + fileExt); + } + } catch (TCException e) { + e.printStackTrace(); + } + return exportFile; + } + + /** + * жȡTXT + * + * @param txt + * @return + * @throws IOException + */ + public static String[] readTxt(File txt) throws IOException { + BufferedReader br = new BufferedReader(new FileReader(txt)); + List list = new ArrayList<>(); + String line = null; + while ((line = br.readLine()) != null) { + list.add(line); + } + br.close(); + return list.toArray(new String[list.size()]); + } + + /** + * ͨļչļ + * + * @param dataset + * @param extension + * @param rename + * @param export_path + * @return + * @throws TCException + */ + public static File exportFile(TCComponentDataset dataset, String extension, String rename, String export_path) throws TCException { + TCComponentTcFile tcFile = null; + for (TCComponentTcFile tc_file : dataset.getTcFiles()) { + if (extension.equalsIgnoreCase(tc_file.getProperty("file_ext"))) { + tcFile = tc_file; + break; + } + } + if (tcFile != null) { + File file = null; + try { + file = tcFile.getFile(export_path, rename); + } catch (TCException e) { + e.printStackTrace(); + return null; + } + return file; + } + return null; + } + + public static void saveFileToDataset(TCComponentDataset dataset, File file) { + try { + String refType = "excel"; + dataset.setFiles(new String[] { file.getAbsolutePath() }, new String[] { refType }); + } catch (TCException e) { + e.printStackTrace(); + } + } + + /** + * ͨproject_idȡTC_Project + */ + public static TCComponentProject findProjectByID(TCSession session, String projectID) { + TCComponentProject project = null; + try { + TCComponentProjectType projectType = (TCComponentProjectType) session.getTypeComponent("TC_Project"); + project = projectType.find(projectID); + } catch (TCException e) { + e.printStackTrace(); + } + return project; + } + + public static void sendMail(TCSession session, String subject, String message, TCComponent[] comp, TCComponentUser[] users) { + try { + TCComponentEnvelopeType envelopeType = (TCComponentEnvelopeType) session.getTypeComponent("Envelope"); + TCComponentEnvelope envelope = envelopeType.create(subject, message, "Envelop"); + + envelope.addReceivers(users); + envelope.addAttachments(comp); + envelope.send(); + } catch (TCException e) { + e.printStackTrace(); + } + } + + public static LinkedHashMap getlovValues(TCSession session, String lovName) { + try { + LinkedHashMap lovVal = new LinkedHashMap(); + TCComponentListOfValuesType lovType = (TCComponentListOfValuesType) session.getTypeComponent("ListOfValues"); + TCComponentListOfValues[] lovs = lovType.find(lovName); + if (lovs != null && lovs.length > 0) { + TCComponentListOfValues lov = lovs[0]; + ListOfValuesInfo lovInfo = lov.getListOfValues(); + String[] code = lovInfo.getStringListOfValues(); + String[] name = lovInfo.getLOVDisplayValues(); + if (code != null && name != null) { + for (int i = 0; i < code.length; i++) { + // System.out.printf("code[%d]=%s name[%d]=%s \n", i, code[i], i, name[i]); + lovVal.put(code[i], name[i]); + } + } + return lovVal; + } + } catch (TCException e) { + e.printStackTrace(); + } + return null; + } + + public static Connection getDBConn(TCSession session) { + Connection connection = null; + String loginInfo = getPreference2(session, TCPreferenceService.TC_preference_site, "YSR_db_host_logon"); + try { + Vector loginInfos = CommonUtil.split2Vector(loginInfo, "="); + if (loginInfo.equals("") || loginInfos.size() != 3) { + MessageBox.post("޷ȡݿϢ,鿴ѡYSR_db_host_logon0!", "", MessageBox.ERROR); + return null; + } + String dbUrl = loginInfos.get(0); + String userName = loginInfos.get(1); + String password = loginInfos.get(2); + + Class.forName("oracle.jdbc.OracleDriver"); + connection = DriverManager.getConnection("jdbc:oracle:thin:@" + dbUrl, userName, password); + connection.setAutoCommit(false); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + return null; + } catch (SQLException e) { + e.printStackTrace(); + return null; + } + return connection; + } + + public static Object getDBInfo(TCSession session, String sql) { + Connection connection = getDBConn(session); + return getDBInfoSub(connection, sql); + } + + public static Object getDBInfoSub(Connection connection, String sql) { + if (connection == null) { + MessageBox.post("޷ȡݿϢ鿴ݿ1", "", MessageBox.ERROR); + return null; + } + + Object value = null; + try { + Statement statement = connection.createStatement(); + ResultSet rs = statement.executeQuery(sql); + + String columnName = rs.getMetaData().getColumnName(1); + int columnType = rs.getMetaData().getColumnType(1); + + if (rs.next()) { + switch (columnType) { + case Types.VARCHAR: + value = rs.getString(columnName); + break; + case Types.NUMERIC: + value = rs.getInt(columnName); + break; + case Types.DATE: + Timestamp timestamp = rs.getTimestamp(columnName); + if (timestamp != null) { + value = new Date(timestamp.getTime()); + } + break; + case Types.TIMESTAMP: + value = rs.getTimestamp(columnName); + break; + case Types.CLOB: + try { + Clob clob = rs.getClob(columnName); + if (clob != null) { + Reader inStream = clob.getCharacterStream(); + char[] c = new char[(int) clob.length()]; + inStream.read(c); + value = new String(c); + inStream.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + break; + default: + value = ""; + break; + } + if (value == null) { + value = ""; + } + } + rs.close(); + statement.close(); + } catch (SQLException e1) { + e1.printStackTrace(); + return null; + } + return value; + } + + public static Vector getDBInfo2(TCSession session, String sql) { + Connection connection = getDBConn(session); + return getDBInfo2Sub(connection, sql); + } + + public static Vector getDBInfo2Sub(Connection connection, String sql) { + if (connection == null) { + MessageBox.post("޷ȡݿϢ鿴ݿ2", "", MessageBox.ERROR); + return null; + } + + Vector vecData = new Vector(); + try { + Statement statement = connection.createStatement(); + ResultSet rs = statement.executeQuery(sql); + + String columnName = rs.getMetaData().getColumnName(1); + int columnType = rs.getMetaData().getColumnType(1); + + while (rs.next()) { + Object value = null; + switch (columnType) { + case Types.VARCHAR: + value = rs.getString(columnName); + break; + case Types.NUMERIC: + value = rs.getInt(columnName); + break; + case Types.DATE: + Timestamp timestamp = rs.getTimestamp(columnName); + if (timestamp != null) { + value = new Date(timestamp.getTime()); + } + break; + case Types.TIMESTAMP: + value = rs.getTimestamp(columnName); + break; + case Types.CLOB: + try { + Clob clob = rs.getClob(columnName); + if (clob != null) { + Reader inStream = clob.getCharacterStream(); + char[] c = new char[(int) clob.length()]; + inStream.read(c); + value = new String(c); + inStream.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + break; + default: + value = ""; + break; + } + if (value == null) { + value = ""; + } + vecData.add(value); + } + rs.close(); + statement.close(); + } catch (SQLException e1) { + e1.printStackTrace(); + return null; + } + + return vecData; + } + + public static Vector> getDBInfo3(TCSession session, String sql) { + Connection connection = getDBConn(session); + return getDBInfo3Sub(connection, sql); + } + + public static Vector> getDBInfo3Sub(Connection connection, String sql) { + if (connection == null) { + MessageBox.post("޷ȡݿϢ鿴ݿ3", "", MessageBox.ERROR); + return null; + } + + Vector> vecData = new Vector>(); + try { + Statement statement = connection.createStatement(); + ResultSet rs = statement.executeQuery(sql); + + String[] columnNames = new String[rs.getMetaData().getColumnCount()]; + int[] columnTypes = new int[rs.getMetaData().getColumnCount()]; + + for (int i = 0; i < columnNames.length; i++) { + columnNames[i] = rs.getMetaData().getColumnName(i + 1); + columnTypes[i] = rs.getMetaData().getColumnType(i + 1); + } + + while (rs.next()) { + Hashtable dataTable = new Hashtable(); + + for (int i = 0; i < columnNames.length; i++) { + Object value = null; + switch (columnTypes[i]) { + case Types.VARCHAR: + value = rs.getString(columnNames[i]); + break; + case Types.NUMERIC: + value = rs.getInt(columnNames[i]); + break; + case Types.DATE: + Timestamp timestamp = rs.getTimestamp(columnNames[i]); + if (timestamp != null) { + value = new Date(timestamp.getTime()); + } + break; + case Types.TIMESTAMP: + value = rs.getTimestamp(columnNames[i]); + break; + case Types.CLOB: + try { + Clob clob = rs.getClob(columnNames[i]); + if (clob != null) { + Reader inStream = clob.getCharacterStream(); + char[] c = new char[(int) clob.length()]; + inStream.read(c); + value = new String(c); + inStream.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + break; + default: + value = ""; + break; + } + if (value == null) { + value = ""; + } + dataTable.put(columnNames[i], value); + } + vecData.add(dataTable); + } + rs.close(); + statement.close(); + } catch (SQLException e1) { + e1.printStackTrace(); + return null; + } + + return vecData; + } + + // ȡ顱PCID, PNAME + public static Vector> GetCls_Class(TCSession session, String PKLASSI) { + String sql = String.format("SELECT PCID, PNAME FROM psmlb0 WHERE PKLASSI = '%s'", PKLASSI); + return getDBInfo3(session, sql); + } + + // ȡ洢ࡱPID + public static Vector GetCls_Instance(TCSession session, String PCID) { + String sql = String.format("SELECT PID FROM picm0 WHERE PCID = '%s'", PCID); + return getDBInfo2(session, sql); + } + + // ȡ洢ࡱĸֶΣPSM01~PSM99ֵ + public static Vector> GetCls_InstanceInfo(TCSession session, String sql) { + return getDBInfo3(session, sql); + } + + // ȡ洢ࡱֶPSM01PSM02ֵ + public static LinkedHashMap GetCls_InstanceInfo2(TCSession session, String PCID) { + String sql = String.format("SELECT PSM01, PSM02 FROM picm0 WHERE PCID = '%s'", PCID); + Vector> vecData = getDBInfo3(session, sql); + if (vecData == null) { + return null; + } + LinkedHashMap lovVal = new LinkedHashMap(); + for (Iterator> iterator = vecData.iterator(); iterator.hasNext();) { + Hashtable hashtable = (Hashtable) iterator.next(); + lovVal.put(hashtable.get("PSM01").toString(), hashtable.get("PSM02").toString()); + } + return lovVal; + } + + public static ArrayList getNextScheduTaskItemID(TCSession session, String currScheduTaskUID) { + String sql = String.format("SELECT PSCHEDULETASK.PITEM_ID FROM PSCHEDULETASK, PIMANRELATION WHERE PSCHEDULETASK.PUID = PIMANRELATION.RPRIMARY_OBJECTU AND RSECONDARY_OBJECTU = '%s'", + currScheduTaskUID); + Vector res = getDBInfo2(session, sql); + if (res == null) { + return null; + } + ArrayList list = new ArrayList(); + for (Object object : res) { + list.add(object.toString()); + } + return list; + } + + public static File findTemplete(TCSession session, String templeteCfgName, String templeteName) { + File reportFile = null; + try { + String itemID = getPreference2(session, TCPreferenceService.TC_preference_site, templeteCfgName); + if (itemID == null || itemID.equals("")) { + MessageBox.post(AIFUtility.getActiveDesktop(), "ѡ" + templeteCfgName + "δ...", "ʾ", MessageBox.WARNING); + return null; + } + + TCComponentItem item = TCUtil.findItemByID(session, itemID); + if (item == null) { + MessageBox.post(AIFUtility.getActiveDesktop(), "δҵģItem...", "ʾ", MessageBox.WARNING); + return null; + } + TCComponentDataset dataset = (TCComponentDataset) item.getLatestItemRevision().getRelatedComponent("IMAN_specification"); + if (dataset == null) { + MessageBox.post(AIFUtility.getActiveDesktop(), "ûҵģݼ...", "ʾ", MessageBox.WARNING); + return null; + } + reportFile = exportFileToDir(dataset, System.getProperty("java.io.tmpdir"), templeteName);// + "_" + session.getUser().getUserId() + if (reportFile == null) { + MessageBox.post(AIFUtility.getActiveDesktop(), "ûпõģ...", "ʾ", MessageBox.WARNING); + return null; + } + } catch (TCException e) { + e.printStackTrace(); + } + System.out.println("reportFile:" + reportFile.getPath()); + return reportFile; + } + + /** + * + * @param source + * ԴͼƬ· + * @param formatName + * ҪתͼƬʽ + * @param result + * ĿͼƬ· convert("C:\\timg.jpg", "png", "C:\\time.png"); + */ + public static void convert(String source, String formatName, String result) { + java.awt.image.BufferedImage src=null; + File f=null; + try { + f = new File(source); + System.out.println(f.getAbsolutePath()); + // if(f.canRead()) { + src = ImageIO.read(f); + ImageIO.write(src, formatName, new File(result)); + // } + } catch (Exception e) { + e.printStackTrace(); + }finally { + if(src!=null) { + src.flush(); + src=null; + } + f.delete(); + } + } + + public static String getNumber(String str) { + if (null == str || str.length() <= 0) { + return "0"; + } + char[] charArray = str.toCharArray(); + //ȫַתchar + for (int i = 0; i < charArray.length; ++i) { + int charIntValue = (int) charArray[i]; + //תϵ,Ӧ±֮ƫ65248;ǿոĻ,ֱת + if (charIntValue >= 65281 && charIntValue <= 65374) { + charArray[i] = (char) (charIntValue - 65248); + } else if (charIntValue == 12288) { + charArray[i] = (char) 32; + } + } + return new String(charArray); + } + + public static boolean contains(String[] array, String str) { + for(String s : array) { +// System.out.println("contains:"+s+"="+str); + if(s.equals(str)) + return true; + } + return false; + } + + public static String getStackTrace(Exception e) { + StringBuilder rError = new StringBuilder(""+e.getMessage()); + for(StackTraceElement ste : e.getStackTrace()) { + rError.append("\n\t"+ste.toString()); + } + return rError.toString(); + } + +} diff --git a/src/cn/net/connor/ml/plm/gotoQMS/sql.properties b/src/cn/net/connor/ml/plm/gotoQMS/sql.properties new file mode 100644 index 0000000..8c21d90 --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/sql.properties @@ -0,0 +1,2 @@ +ML_WEBSERVICE_LOGINSERTSQL=INSERT INTO ML_WEBSERVICE_LOG 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/src/cn/net/connor/ml/plm/gotoQMS/sqlconn.properties b/src/cn/net/connor/ml/plm/gotoQMS/sqlconn.properties new file mode 100644 index 0000000..a9f980b --- /dev/null +++ b/src/cn/net/connor/ml/plm/gotoQMS/sqlconn.properties @@ -0,0 +1,4 @@ +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/src/cn/net/connor/ml/plm/implementRate/ImplementRateCommand.java b/src/cn/net/connor/ml/plm/implementRate/ImplementRateCommand.java new file mode 100644 index 0000000..5380b34 --- /dev/null +++ b/src/cn/net/connor/ml/plm/implementRate/ImplementRateCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.implementRate; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ImplementRateCommand extends KCommand { + + public ImplementRateCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ImplementRateDialog(app)); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/implementRate/ImplementRateDialog.java b/src/cn/net/connor/ml/plm/implementRate/ImplementRateDialog.java new file mode 100644 index 0000000..3df4e9d --- /dev/null +++ b/src/cn/net/connor/ml/plm/implementRate/ImplementRateDialog.java @@ -0,0 +1,149 @@ +package cn.net.connor.ml.plm.implementRate; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.DateButton; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.ml.plm.KUtil; + +@SuppressWarnings("serial") +public class ImplementRateDialog extends AbstractAIFDialog { + + private ImplementRateDialogController controller; + protected AbstractAIFApplication app; + public TCSession session; + private DateButton start; + private DateButton end; + protected JTextField field; + private JButton b_export; + private JButton b_query; + final static int QUERY = 1; + final static int EXPORT = 2; + protected String startDate; + protected String endDate; +// private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm"); + private SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy hh:mm:ss"); + protected JComboBox box; + + public ImplementRateDialog(AbstractAIFApplication app) { + super(false); + this.controller = new ImplementRateDialogController(this); + this.app = app; + this.session = (TCSession) app.getSession(); + + } + + @Override + public void run() { + try { + if (!controller.init()) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.error(this, "ʼʱ쳣\n" + e.getMessage()); + return; + } + initUI(); + addListeners(); + showDialog(); + } + + private void addListeners() { + this.b_query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (start.getDate() == null || end.getDate() == null) { + KUtil.info(ImplementRateDialog.this, "ڲΪգ"); + return; + } + startDate = sdf.format(start.getDate()); + endDate = sdf.format(end.getDate()); + // ֵǴڴڲ + System.out.println(start.getDate()); + System.out.println(end.getDate()); + if (start.getDate().compareTo(end.getDate()) > 0) { + KUtil.info(ImplementRateDialog.this, "ڲܴҲڣ"); + return; + } +// if (startDate.compareTo(endDate) > 0) { +// KUtil.info(ImplementRateDialog.this, "ڲܴҲڣ"); +// return; +// } + readData(QUERY); + } + }); + this.b_export.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + readData(EXPORT); + } + }); + } + + private void readData(int type) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + controller.readData(type); + } catch (Exception e) { + KUtil.error(ImplementRateDialog.this, "ʱ쳣\n" + e.getMessage()); + e.printStackTrace(); + } + } + }); + } + + private void initUI() { + this.setTitle(""); + this.setMinimumSize(new Dimension(600, 150)); + PropertyLayout layout = new PropertyLayout(); + layout.setLeftMargin(10); + this.setLayout(layout); + + JLabel label = new JLabel("ѡʱ䷶Χ"); + this.add("1.1.left.top", label); + start = new DateButton(new Date()); + this.add("1.2.left.top", start); + + JLabel label2 = new JLabel(" - "); + this.add("1.3.left.top", label2); + + end = new DateButton(new Date()); + this.add("1.4.left.top", end); + + JLabel label3 = new JLabel("۷ʽ"); + this.add("2.1.left.top", label3); + box = new JComboBox(new String[] { "", "", "" }); + this.add("2.2.left.top", box); + + b_query = new JButton("ѯ"); + this.add("2.3.left.top", b_query); + + JLabel label4 = new JLabel("ʣ"); + this.add("3.1.left.top", label4); + + field = new JTextField(10); + field.setHorizontalAlignment(JTextField.CENTER); + field.setEditable(false); + this.add("3.2.left.top", field); + + b_export = new JButton("Excel"); + this.add("3.3.RIGHT.bottom", b_export); + } +} diff --git a/src/cn/net/connor/ml/plm/implementRate/ImplementRateDialogController.java b/src/cn/net/connor/ml/plm/implementRate/ImplementRateDialogController.java new file mode 100644 index 0000000..10f573f --- /dev/null +++ b/src/cn/net/connor/ml/plm/implementRate/ImplementRateDialogController.java @@ -0,0 +1,226 @@ +package cn.net.connor.ml.plm.implementRate; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.List; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileSystemView; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentFolder; + +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.util.BigDecimalUtils; + +public class ImplementRateDialogController { + private static final String PREF_EXCEL_COLUMN = "Meling_Implement_Rate_Column"; + private ImplementRateDialog dialog; + private TCComponent target; + private List headers; + private List props; + private List values; + private String objectType; + + public ImplementRateDialogController(ImplementRateDialog implementRateDialog) { + this.dialog = implementRateDialog; + } + + public boolean init() throws Exception { + // ѡ + if (!initExcelColumn()) { + return false; + } + return true; + } + + public void readData(int type) throws Exception { + switch (type) { + case 1: + queryData(); + break; + case 2: + exportExcel(); + break; + default: + break; + } + } + + private void exportExcel() throws IOException { + if (values == null || values.size() < 1) { + KUtil.info(dialog, "ΪգȲѯݣ"); + return; + } + int rowCount = values.size(); + int columnCount = headers.size(); + File file = getFile(); + if (file == null) { + return; + } + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + + for (int i = 0; i < rowCount + 1; i++) { + Row row = sheet.createRow(i); + for (int j = 0; j < columnCount; j++) { + Cell cell = row.createCell(j); + if (i == 0) { + cell.setCellValue(headers.get(j)); + } else { + cell.setCellValue(values.get(i - 1)[j]); + } + } + } + + // һ + if (sheet.getRow(0) != null) { + int lastRowNo = sheet.getLastRowNum(); + sheet.shiftRows(0, lastRowNo, 1); + } + Row row = sheet.createRow(0); + for (int j = 0; j < columnCount; j++) { + Cell cell = row.createCell(j); + } + row.getCell(0).setCellValue("ʣ" + dialog.field.getText()); + // Ԫñͷʽ + CellStyle style = workBook.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + // ϲԪ񣺲ʼ, ֹ, ʼ, ֹ + CellRangeAddress cra = new CellRangeAddress(0, 0, 0, columnCount - 1); + sheet.addMergedRegion(cra); + row.getCell(0).setCellStyle(style); + + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + KUtil.info(dialog, "ɹ"); + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new XSSFWorkbook(); + workbook.createSheet("sheet1"); + return workbook; + } + + private File getFile() { + JFileChooser jf = new JFileChooser(); + String name = "ExcelName.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(dialog, ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(dialog, "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(dialog, "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private void queryData() throws Exception { + System.out.println(dialog.startDate); + System.out.println(dialog.endDate); + TCComponent[] searchs = null; + if (headers.contains("۷ʽ")) { + searchs = dialog.session.search(objectType + "ѯ", new String[] { "ʼʱ", "ʱ", "۷ʽ" }, + new String[] { dialog.startDate, dialog.endDate, dialog.box.getSelectedItem().toString() }); + } else { + searchs = dialog.session.search(objectType + "ѯ", new String[] { "ʼʱ", "ʱ" }, new String[] { dialog.startDate, dialog.endDate }); + } + int num1 = searchs.length; + if (searchs == null || num1 < 1) { + KUtil.info(dialog, "ѯΪգ"); + return; + } + int num2 = 0; + values = new ArrayList(); + for (TCComponent search : searchs) { + String value = search.getProperty("ml8_ItemTime"); + if (!value.trim().equals("")) { + num2++; + } + String[] properties = search.getProperties(props.toArray(new String[0])); + values.add(properties); + } + Double divide = BigDecimalUtils.divide(num2, num1); + System.out.println("[" + num2 + "/" + num1 + "]"); + NumberFormat nt = NumberFormat.getPercentInstance();// ȡʽ + nt.setMinimumFractionDigits(2);// ðٷȷ2λС + dialog.field.setText(nt.format(divide)); + } + + private boolean initExcelColumn() throws Exception { + target = (TCComponent) dialog.app.getTargetComponent(); + if (target == null || !(target instanceof TCComponentFolder && target.getType().startsWith("ML8"))) { + KUtil.info(dialog, "ѡƷߣ"); + return false; + } + String[] configs = KUtil.getPrefVals(dialog.session, PREF_EXCEL_COLUMN); + if (configs == null || configs.length < 1) { + throw new Exception("ѡ[" + PREF_EXCEL_COLUMN + "]δãϵԱ"); + } + String uid = target.getUid(); + for (String config : configs) { + String[] split = config.split("="); + if (split == null || split.length != 3) { + throw new Exception("ѡ[" + PREF_EXCEL_COLUMN + "]ϵԱ"); + } + if (split[0].equals(uid)) { + objectType = split[1]; + String[] columns = split[2].split(","); + if (columns == null || columns.length < 1) { + throw new Exception("ѡ[" + PREF_EXCEL_COLUMN + "]ϵԱ"); + } + headers = new ArrayList(); + props = new ArrayList(); + for (String column : columns) { + String[] names = column.split(":"); + if (names == null || names.length != 2) { + throw new Exception("ѡ[" + PREF_EXCEL_COLUMN + "]ϵԱ"); + } + headers.add(names[0]); + props.add(names[1]); + } + return true; + } + } + return false; + } +} diff --git a/src/cn/net/connor/ml/plm/k_locale.properties b/src/cn/net/connor/ml/plm/k_locale.properties new file mode 100644 index 0000000..ac8931f --- /dev/null +++ b/src/cn/net/connor/ml/plm/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/src/cn/net/connor/ml/plm/k_locale_zh_CN.properties b/src/cn/net/connor/ml/plm/k_locale_zh_CN.properties new file mode 100644 index 0000000..902d489 --- /dev/null +++ b/src/cn/net/connor/ml/plm/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/src/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseCommand.java b/src/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseCommand.java new file mode 100644 index 0000000..5b2dd9b --- /dev/null +++ b/src/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseCommand.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.melingKnowledgeBase; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class MelingKnowledgeBaseCommand extends KCommand { + + public MelingKnowledgeBaseCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new MelingKnowledgeBaseOperation(app, "֪ʶ")); + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseOperation.java b/src/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseOperation.java new file mode 100644 index 0000000..602a975 --- /dev/null +++ b/src/cn/net/connor/ml/plm/melingKnowledgeBase/MelingKnowledgeBaseOperation.java @@ -0,0 +1,35 @@ +package cn.net.connor.ml.plm.melingKnowledgeBase; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; + +import cn.net.connor.ml.plm.KOperation; +import cn.net.connor.ml.plm.KUtil; + +public class MelingKnowledgeBaseOperation extends KOperation { + public static final String PREF_KNOWLEDGEBASE = "Meling_KnowledgeBase_Puid"; + + public MelingKnowledgeBaseOperation(AbstractAIFApplication app, String opName) { + super(app, opName, "ִ..."); + } + + @Override + public boolean init() throws Exception { + String puid = KUtil.getPrefVal(session, PREF_KNOWLEDGEBASE); + if (puid == null || puid.length() < 1) { + throw new Exception("ѡ<" + PREF_KNOWLEDGEBASE + ">ô"); + } + TCComponent comp = session.stringToComponent(puid); + + 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 }); + + return true; + } + + @Override + public void execute() throws Exception { + } + +} diff --git a/src/cn/net/connor/ml/plm/melingSectrum/MelingSectrumCommand.java b/src/cn/net/connor/ml/plm/melingSectrum/MelingSectrumCommand.java new file mode 100644 index 0000000..2cef9e8 --- /dev/null +++ b/src/cn/net/connor/ml/plm/melingSectrum/MelingSectrumCommand.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.melingSectrum; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class MelingSectrumCommand extends KCommand { + + public MelingSectrumCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new MelingSectrumOperation(app, "")); + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/melingSectrum/MelingSectrumOperation.java b/src/cn/net/connor/ml/plm/melingSectrum/MelingSectrumOperation.java new file mode 100644 index 0000000..703fa83 --- /dev/null +++ b/src/cn/net/connor/ml/plm/melingSectrum/MelingSectrumOperation.java @@ -0,0 +1,35 @@ +package cn.net.connor.ml.plm.melingSectrum; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; + +import cn.net.connor.ml.plm.KOperation; +import cn.net.connor.ml.plm.KUtil; + +public class MelingSectrumOperation extends KOperation { + public static final String PREF_SECTRUM = "Meling_Sectrum_Puid"; + + public MelingSectrumOperation(AbstractAIFApplication app, String opName) { + super(app, opName, "ִ..."); + } + + @Override + public boolean init() throws Exception { + String puid = KUtil.getPrefVal(session, PREF_SECTRUM); + if (puid == null || puid.length() < 1) { + throw new Exception("ѡ<" + PREF_SECTRUM + ">ô"); + } + TCComponent comp = session.stringToComponent(puid); + + 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 }); + + return true; + } + + @Override + public void execute() throws Exception { + } + +} diff --git a/src/cn/net/connor/ml/plm/modelImport/ModelImportCommand.java b/src/cn/net/connor/ml/plm/modelImport/ModelImportCommand.java new file mode 100644 index 0000000..3e54bc9 --- /dev/null +++ b/src/cn/net/connor/ml/plm/modelImport/ModelImportCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.modelImport; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ModelImportCommand extends KCommand{ + + public ModelImportCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ModelImportOperation(app, "ͺŵ")); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/modelImport/ModelImportOperation.java b/src/cn/net/connor/ml/plm/modelImport/ModelImportOperation.java new file mode 100644 index 0000000..9ebebd1 --- /dev/null +++ b/src/cn/net/connor/ml/plm/modelImport/ModelImportOperation.java @@ -0,0 +1,383 @@ +package cn.net.connor.ml.plm.modelImport; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.dom4j.Document; +import org.dom4j.Element; +import org.dom4j.io.SAXReader; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; + +import cn.net.connor.ml.plm.KOperation; +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.beans.ImportBean; +import cn.net.connor.ml.plm.util.FileUtil; + +public class ModelImportOperation extends KOperation { + private static final SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// ڸʽ + public static final String IMPORT_CONFIG = "Meling_Import_Config_Path"; + private ImportBean bean1; + private ArrayList tcList; + private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + + public ModelImportOperation(AbstractAIFApplication app, String opName) { + super(app, opName, "ִ..."); + } + + @Override + public boolean init() throws Exception { +// BasicConfigurator.configure(); + + // XMLݼpuid + String puid = KUtil.getPrefVal(session, IMPORT_CONFIG); + if (puid == null || puid.length() < 1) { + throw new Exception("ѡ[" + IMPORT_CONFIG + "]δãϵԱ"); + } + TCComponent datasetComp = session.stringToComponent(puid); + if (datasetComp == null || !(datasetComp instanceof TCComponentDataset)) { + throw new Exception("ѡ[" + IMPORT_CONFIG + "]õpuidδҵݼϵԱ"); + } + TCComponentDataset dataset = (TCComponentDataset) datasetComp; + String[] fileNames = dataset.getFileNames(""); + int len = fileNames.length; + if (len == 0) { + throw new Exception(String.format("ѡ <%s>, ݼ <%s> ûļ", IMPORT_CONFIG, dataset)); + } + if (len > 1) { + throw new Exception(String.format("ѡ <%s>, ݼ <%s> жļ", IMPORT_CONFIG, dataset)); + } + File configFile = dataset.getFile("", fileNames[0], System.getenv("TEMP")); + System.out.println("ģļ" + configFile.getAbsolutePath()); + SAXReader saxReader = new SAXReader(); + Document doc = saxReader.read(configFile); + configFile.delete(); + ImportBean bean1 = null; + try { + bean1 = readSetting(doc); + } catch (Exception e) { + throw new Exception("ȡļʱ쳣\n" + e.getMessage()); + } + if (bean1 != null) { + this.bean1 = bean1; + } else { + throw new Exception("ȡļʱ쳣\n" + "òƷ쳣ļ"); + } + return true; + } + + @SuppressWarnings("unchecked") + private ImportBean readSetting(Document doc) throws Exception { + ImportBean bean1 = null; + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null || !(target instanceof TCComponentFolder)) { + throw new Exception("ѡƷļе룡"); + } + String uid = target.getUid(); + Element imports = doc.getRootElement();// ڵimports + Iterator iterator1 = imports.elementIterator(); + while (iterator1.hasNext()) { + Element targetNode = iterator1.next();// ӽڵtargetNode + String puid = targetNode.attributeValue("puid");// ӽڵpuidֵ + if (!puid.equals(uid)) { + continue; + } + Iterator iterator2 = targetNode.elementIterator(); + ArrayList toList = new ArrayList<>(); + String type2 = ""; + ArrayList> list3 = null; + while (iterator2.hasNext()) { + Element node = iterator2.next(); + if ("to".equals(node.getName())) { + String type1 = node.attributeValue("type"); + String relation = node.attributeValue("relation"); + String[] strs = { type1, relation }; + toList.add(strs); + } else if ("object".equals(node.getName())) { + type2 = node.attributeValue("type"); + Iterator iterator3 = node.elementIterator(); + list3 = new ArrayList<>(); + while (iterator3.hasNext()) { + ArrayList list4 = new ArrayList(); + Element propNode = iterator3.next(); + String from = propNode.attributeValue("from"); + String name = propNode.attributeValue("name"); + String add = propNode.attributeValue("add"); + String required = propNode.attributeValue("required"); + list4.add(from); + list4.add(name); + list4.add(add); + list4.add(required); + list3.add(list4); + } + } + } + bean1 = new ImportBean(puid, toList, type2, list3); + } + return bean1; + } + + @Override + public void execute() throws Exception { + KUtil.setByPass(true); + int count = 0; + try { + File file = KUtil.chooseFile(this.getCurrentDesktop()); + if (file == null || !file.exists()) { + KUtil.setByPass(false); + return; + } + Workbook workbook = KUtil.getWorkbook(file); + Sheet sheet = workbook.getSheetAt(0); + int cellcount = sheet.getRow(0).getLastCellNum();// һУΪֶεУжٸԪ + int rowcount = KUtil.findRealRows(sheet, 0); + ArrayList toList = bean1.getToList(); + String type = bean1.getType(); + ArrayList> list = bean1.getList(); + int toSize = toList.size(); + System.out.println(">>> ļ..."); + // һļǷ淶 + StringBuilder toNULL = new StringBuilder("ȡļ쳣ϵͳвڣ\r\n"); + StringBuilder propNULL = new StringBuilder("ȡļ쳣ԱҲΪգ\r\n"); + System.out.println(">>> У" + rowcount + ",У" + cellcount); + boolean isNoType = false; + for (int i = 1; i < rowcount + 1; i++) { + TCComponent temp = session.stringToComponent(bean1.getPuid());// ʱ + Row row = sheet.getRow(i); + if (null != row) { + for (int j = 0; j < cellcount; j++) { + Cell cell = row.getCell(j); + String cellValue = KUtil.getCellValue(cell); + if (j < toSize) { + boolean flag = true; + // compsϵͳеĶ + TCComponent[] comps = KUtil.getComponentsByItemType(temp, toList.get(j)[0], toList.get(j)[1]); + if (comps == null || comps.length < 1) { + isNoType = true; + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", + df.format(new Date()) + " ѡûӦ㼶\n쳣λã" + (i + 1) + "", true, "utf-8"); + continue; + } + for (TCComponent comp : comps) { + String name = comp.getProperty("object_name"); + if (name.equals(cellValue)) { + temp = comp; + flag = false; + break; + } + } + // 㼶ϵͳδҵش + if (flag) { + toNULL.append("" + (i + 1) + "У" + (j + 1) + "У\r\n"); + } + } + for (int k = 0; k < list.size(); k++) { + String add = list.get(k).get(2); + String required = list.get(k).get(3); + if (Integer.valueOf(add) == j) { + if (required.equals("TRUE") && cellValue.trim().equals("")) { + propNULL.append("" + (i + 1) + "У" + (j + 1) + "У\r\n"); + } + } + } + } + } + } + File f = new File("C:\\PLM\\־" + sdf.format(new Date()) + ".log"); + if (toNULL.toString().contains("") && propNULL.toString().contains("")) { + KUtil.setByPass(false); + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", df.format(new Date()) + " " + toNULL.toString() + propNULL, true, + "utf-8"); + KUtil.error(getCurrentDesktop(), "̴쳣,鿴־ļ\nC:\\PLM\\־" + sdf.format(new Date()) + ".log"); + openErrorFile(f); + return; + } else if (toNULL.toString().contains("") && !propNULL.toString().contains("")) { + KUtil.setByPass(false); + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", df.format(new Date()) + " " + toNULL.toString(), true, "utf-8"); + KUtil.error(getCurrentDesktop(), "̴쳣,鿴־ļ\nC:\\PLM\\־" + sdf.format(new Date()) + ".log"); + openErrorFile(f); + return; + } else if (!toNULL.toString().contains("") && propNULL.toString().contains("")) { + KUtil.setByPass(false); + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", df.format(new Date()) + " " + propNULL.toString(), true, "utf-8"); + KUtil.error(getCurrentDesktop(), "̴쳣,鿴־ļ\nC:\\PLM\\־" + sdf.format(new Date()) + ".log"); + openErrorFile(f); + return; + } + if (isNoType) { + KUtil.setByPass(false); + KUtil.error(getCurrentDesktop(), "̴쳣,鿴־ļ\nC:\\PLM\\־" + sdf.format(new Date()) + ".log"); + openErrorFile(f); + return; + } + System.out.println(">>> ļʼͺŵ..."); + // ڶ鵼ݶ + boolean isMultiple = false; + count = 0; + tcList = new ArrayList<>(); + for (int i = 1; i < rowcount + 1; i++) { + TCComponent temp = session.stringToComponent(bean1.getPuid());// ʱ + TCComponentItemType itemType = null; + TCComponentItem item = null; + Row row = sheet.getRow(i); + if (null != row) { + for (int j = 0; j < cellcount; j++) { + Cell cell = row.getCell(j); + String cellValue = KUtil.getCellValue(cell); + if (j < toSize) { + TCComponent[] comps = KUtil.getComponentsByItemType(temp, toList.get(j)[0], toList.get(j)[1]); + for (TCComponent comp : comps) { + String name = comp.getProperty("object_name"); + if (name.equals(cellValue)) { + temp = comp; + break; + } + } + } + // + if (itemType == null) { + itemType = (TCComponentItemType) session.getTypeComponent(type); + item = itemType.create(itemType.getNewID(), itemType.getNewRev(null), type, "temp", null, null); + } + // + for (int k = 0; k < list.size(); k++) { + String from = list.get(k).get(0); + String name = list.get(k).get(1); + String add = list.get(k).get(2); + if (Integer.valueOf(add) == j) { + if (from.equals("ITEM")) { + try { + if (item.getTCProperty(name).getPropertyType() == TCProperty.PROP_date) { + if (cellValue.length() != 8) { + System.out.println("cell=" + cell.getStringCellValue()); + System.out.println("cellValue=" + cellValue + ",length=" + cellValue.length()); + item.delete(); + throw new Exception(" " + (i + 1) + "У" + (j + 1) + "쳣ڳȲΪ8λ"); + } + Integer y = Integer.valueOf(cellValue.substring(0, 4)); + Integer m = Integer.valueOf(cellValue.substring(4, 6)) - 1; + Integer d = Integer.valueOf(cellValue.substring(6, 8)); + Calendar calendar = Calendar.getInstance(); + calendar.set(y, m, d); + Date date = calendar.getTime(); + item.setDateProperty(name, date); + } else { + item.setProperty(name, cellValue); + } + } catch (TCException e) { + // 쳣 + isMultiple = true; + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", + df.format(new Date()) + " " + (i + 1) + "У" + (j + 1) + "쳣" + e.toString(), true, "utf-8"); + e.printStackTrace(); + } + } + } + } + } + // check name + if (type.equals("ML8_ProModelRef") ) { + String name = item.getProperty("ml8_Box") + "_" + item.getProperty("ml8_ProductStructure") + "_" + + item.getProperty("ml8_ProductModel") + item.getProperty("ml8_EnergyDemand") + "_" + "Ŀ"; + TCComponent[] search = session.search("...", new String[] { "", "" }, new String[] { name, type }); + if (search.length > 1) { + isMultiple = true; + item.delete(); + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", df.format(new Date()) + " " + (i + 1) + "ظֹͣ룡", + true, "utf-8"); + break; + } else { + tcList.add(item); + temp.add("contents", item); + count++; + } + } else if(type.equals("ML8_ProModelWas")) { + String name = item.getProperty("ml8_ProductStructure") + "_" + item.getProperty("ml8_ProductModel") + "Ŀ"; + TCComponent[] search = session.search("...", new String[] { "", "" }, new String[] { name, type }); + if (search.length > 1) { + isMultiple = true; + item.delete(); + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", df.format(new Date()) + " " + (i + 1) + "ظֹͣ룡", + true, "utf-8"); + break; + } else { + tcList.add(item); + temp.add("contents", item); + count++; + } + + }else { + TCComponent[] search = session.search("...", new String[] { "", "" }, + new String[] { item.getProperty("object_name"), type }); + if (search.length > 1) { + isMultiple = true; + item.delete(); + FileUtil.writeLog("C:\\PLM\\־" + sdf.format(new Date()) + ".log", df.format(new Date()) + " " + (i + 1) + "ظֹͣ룡", + true, "utf-8"); + break; + } else { + temp.add("contents", item); + count++; + } + } + } + } + // + if (isMultiple) { + if (tcList.size() > 0) { + for (TCComponent tc : tcList) { + AIFComponentContext[] ref = tc.whereReferenced(); + TCComponent refCom = (TCComponent) ref[0].getComponent(); + refCom.remove("contents", tc); + tc.delete(); + } + } + KUtil.setByPass(false); + + KUtil.error(getCurrentDesktop(), "̴쳣,鿴־ļ\nC:\\PLM\\־" + sdf.format(new Date()) + ".log"); + + openErrorFile(f); + return; + } + KUtil.setByPass(false); + } catch (NumberFormatException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (TCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + KUtil.info(getCurrentDesktop(), "ͺŵɹ..." + count + ""); + } + + private void openErrorFile(File f) { + if (f.exists()) { + try { + Runtime.getRuntime().exec("explorer /e,/select," + f.getAbsolutePath()); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/src/cn/net/connor/ml/plm/planningPanel/AddUserDialog.java b/src/cn/net/connor/ml/plm/planningPanel/AddUserDialog.java new file mode 100644 index 0000000..c45aa27 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/AddUserDialog.java @@ -0,0 +1,280 @@ +package cn.net.connor.ml.plm.planningPanel; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +import javax.swing.ImageIcon; +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.JTree; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.beans.TMomUserBean; +import cn.net.connor.ml.plm.util.TCGroupDialogTree; + +@SuppressWarnings({ "serial", "unused" }) +public class AddUserDialog extends AbstractAIFDialog { + + private JPanel panel; + private JPanel panel3; + private JLabel lable; + private JLabel searchLable; + private JTextField searchField; + private JButton searchButton; + private JTree userTree; + private DefaultMutableTreeNode node; + private DefaultTreeModel m_model; + private String value; + private List nameList = new ArrayList(); + TCGroupDialogTree treeDialog; + private PlanningPanelDialog dialog; + + public AddUserDialog(PlanningPanelDialog planningPanelDialog) { + super(planningPanelDialog, true); + this.dialog = planningPanelDialog; + initUI(); + } + + @Override + public void run() { + initUI(); + showDialog(); + } + + public void initUI() { + System.out.println("ʼ"); + this.setTitle("ѡû"); + this.setPreferredSize(new Dimension(400, 300)); + + this.lable = new JLabel("1"); + + this.panel = new JPanel(new BorderLayout()); + this.panel3 = new JPanel(new FlowLayout()); + + this.searchLable = new JLabel("2"); + this.searchField = new JTextField(20); + + this.searchButton = new JButton("ѯû"); + this.searchButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + if (value != null && !value.equals(searchField.getText())) { + nameList.clear(); + value = searchField.getText(); + } else { + value = searchField.getText(); + } + DefaultMutableTreeNode node = searchNode(searchField.getText(), nameList); + if (node != null) { + TCComponent user = ((TMomUserBean) node.getUserObject()).getUser(); + try { + nameList.add(user.getStringProperty("user_id")); + } catch (TCException e) { + e.printStackTrace(); + } + TreeNode[] nodes = m_model.getPathToRoot(node); + TreePath path = new TreePath(nodes); + userTree.scrollPathToVisible(path); + userTree.setSelectionPath(path); + } else { + MessageBox.post("δҵԱ", "", MessageBox.ERROR); + nameList.clear(); + } + } + }); + + if (treeDialog == null) { + treeDialog = new TCGroupDialogTree(); + } + if (this.userTree == null) { + + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + try { + TCComponentGroupType type = ((TCComponentGroupType) session.getTypeComponent("Group")); + // meling froup-------------------------------- + String groupName = session.getPreferenceService().getStringValue("Meling_Group_Name"); + TCComponentGroup group = type.find(groupName); + TMomUserBean bean = new TMomUserBean(group, null); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + getUsers(node1, group, null); + this.node = node1; + m_model = new DefaultTreeModel(node); + userTree = new JTree(m_model); + userTree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + okAction(); + } + } + }); + userTree.setRowHeight(20); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) userTree.getCellRenderer(); + cellRenderer.setLeafIcon(new ImageIcon("icons\\person_16.png")); + cellRenderer.setOpenIcon(new ImageIcon("icons\\role_16.png")); + cellRenderer.setClosedIcon(new ImageIcon("icons\\group_16.png")); + + } catch (TCException e) { + e.printStackTrace(); + } + } + panel3.add(searchField); + panel3.add(searchButton); + panel.add(panel3, BorderLayout.SOUTH); + panel.add(new JScrollPane(this.userTree), BorderLayout.CENTER); + this.add(panel, "Center"); + } + + public void getUsers(DefaultMutableTreeNode node, TCComponent comp, TCComponent parent) { + try { + if (comp instanceof TCComponentGroup) { + TCComponent[] comps = ((TCComponentGroup) comp).getRolesAndGroups(); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + node.add(node1); + getUsers(node1, comps[i], comp); + } + } else if (comp instanceof TCComponentRole) { + TCComponent[] comps = ((TCComponentRole) comp).getUsers((TCComponentGroup) parent); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + node.add(node1); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + // ӵĽڵ + @SuppressWarnings("rawtypes") + public DefaultMutableTreeNode searchNode(String nodeStr, List nameList) { + DefaultMutableTreeNode node = null; + Enumeration e = this.node.breadthFirstEnumeration(); + while (e.hasMoreElements()) { + node = (DefaultMutableTreeNode) e.nextElement(); + if (node.getUserObject() instanceof TMomUserBean) { + TCComponent user = ((TMomUserBean) node.getUserObject()).getUser(); + try { + String userName = user.getStringProperty("user_name"); + String userId = user.getStringProperty("user_id"); + if (userName != null) { + if ((userName.indexOf(nodeStr) >= 0 || userId.indexOf(nodeStr) >= 0) && !nameList.contains(userId)) { + return node; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + return null; + } + + public void okAction() { + Object selectObj = userTree.getLastSelectedPathComponent(); + if (selectObj instanceof DefaultMutableTreeNode) { + Object userObj = ((DefaultMutableTreeNode) selectObj).getUserObject(); + if (userObj instanceof TMomUserBean) { + if (((TMomUserBean) userObj).getUser() instanceof TCComponentUser) { + try { + TCComponentUser user = (TCComponentUser) ((TMomUserBean) userObj).getUser(); + TCAccessControlService aclService = dialog.session.getTCAccessControlService(); + DefaultTableModel model = dialog.tableModel; + JTable table = dialog.table; + System.out.println(dialog.table.getSelectedRows().length + "=" + dialog.table.getSelectedRows()[0]); + TCComponent comp = null; + KUtil.setByPass(true); + for (int i : dialog.table.getSelectedRows()) { + String uid = (String) model.getValueAt(i, table.getColumnCount() - 1); + comp = dialog.session.stringToComponent(uid); + aclService.grantPrivilege(comp, user, "READ"); + aclService.grantPrivilege(comp, user, "WRITE"); + comp.setProperty("ml8_ProjectManagement1", user.getProperty("object_string")); + } + dispose(); + ProgressBarThread thread = new ProgressBarThread("Ȩ", "Ȩ...", this); + try { + thread.start(); + String state = "ĿȨ΢֪ͨ"; + TCComponentProcessType processType = (TCComponentProcessType) dialog.session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) dialog.session + .getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(state, TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (taskTemplate == null) { + KUtil.info(this, "δҵģ壡"); + return; + } + // һ ơģ塢Ŀ󡢸 + String name = comp.getProperty("object_string"); + processType.create(state + "" + name, "", taskTemplate, new TCComponent[] { comp }, new int[] { 1 }); + // رս + thread.setBool(true); + MessageBox.post("û[" + user.getUserName() + "]дȨ޳ɹ\n" + "" + name + "[" + state + "]ɹ", "", + MessageBox.INFORMATION); + disposeDialog(); + } catch (Exception e) { + KUtil.setByPass(false); + // رս + thread.setBool(true); + e.printStackTrace(); + KUtil.error(this, "̷쳣\n" + e.getMessage()); + } + + } catch (Exception e1) { + KUtil.setByPass(false); + MessageBox.post(e1.toString(), "", MessageBox.ERROR); + e1.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + } + + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + } + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/Constant.java b/src/cn/net/connor/ml/plm/planningPanel/Constant.java new file mode 100644 index 0000000..e6b59b2 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/Constant.java @@ -0,0 +1,7 @@ +package cn.net.connor.ml.plm.planningPanel; + +public class Constant { + public static final String ASC = "1"; + public static final String DESC = "-1"; + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/MultiColumnTableRowSorter.java b/src/cn/net/connor/ml/plm/planningPanel/MultiColumnTableRowSorter.java new file mode 100644 index 0000000..2c48170 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/MultiColumnTableRowSorter.java @@ -0,0 +1,53 @@ +package cn.net.connor.ml.plm.planningPanel; + +import javax.swing.*; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import java.util.ArrayList; +import java.util.List; + +public class MultiColumnTableRowSorter extends TableRowSorter { + public MultiColumnTableRowSorter(M model) { + super(model); + } + + @Override + public void toggleSortOrder(int column) {// л˳ + setMaxSortKeys(4); + checkColumn(column); + if (isSortable(column)) { + List keys = new ArrayList(getSortKeys()); + SortKey sortKey; + int sortIndex; + for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) { + if (keys.get(sortIndex).getColumn() == column) { + break; + } + } + if (sortIndex == -1) { + // Key doesn't exist + sortKey = new SortKey(column, SortOrder.ASCENDING);// + keys.add(sortKey); + } else { + SortKey key = keys.get(sortIndex); + if (key.getSortOrder() == SortOrder.ASCENDING) {// + key = new SortKey(key.getColumn(), SortOrder.DESCENDING);// ½ + keys.set(sortIndex, key); + } else if (key.getSortOrder() == SortOrder.DESCENDING) {// ½ + keys.remove(sortIndex); + } + } + + if (keys.size() > getMaxSortKeys()) { + keys = keys.subList(getMaxSortKeys(), keys.size()); + } + setSortKeys(keys); + } + } + + private void checkColumn(int column) { + if (column < 0 || column >= getModelWrapper().getColumnCount()) { + throw new IndexOutOfBoundsException("column beyond range of TableModel"); + } + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/MutilColumnTableCellHeaderRenderer.java b/src/cn/net/connor/ml/plm/planningPanel/MutilColumnTableCellHeaderRenderer.java new file mode 100644 index 0000000..84b668d --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/MutilColumnTableCellHeaderRenderer.java @@ -0,0 +1,93 @@ +package cn.net.connor.ml.plm.planningPanel; + +import sun.swing.DefaultLookup; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.plaf.UIResource; +import javax.swing.table.DefaultTableCellRenderer; + +import cn.net.connor.ml.plm.planningPanel.sortTable.Constant; +import cn.net.connor.ml.plm.planningPanel.sortTable.SorterColumnGroupUtil; + +import java.awt.*; +import java.io.Serializable; +import java.util.List; + +public class MutilColumnTableCellHeaderRenderer extends DefaultTableCellRenderer implements UIResource { + + public MutilColumnTableCellHeaderRenderer() { + this.setHorizontalAlignment(0); + } + + public void setHorizontalTextPosition(int textPosition) { + super.setHorizontalTextPosition(textPosition); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + this.setText(value == null ? "" : value.toString()); + Border var13 = null; + if (hasFocus) { + var13 = DefaultLookup.getBorder(this, this.ui, "TableHeader.focusCellBorder"); + } + + if (var13 == null) { + var13 = DefaultLookup.getBorder(this, this.ui, "TableHeader.cellBorder"); + } + + this.setBorder(var13); + + String sortColumnName = ""; + sortColumnName = table.getColumnName(column); + if (sortColumnName.equals(SorterColumnGroupUtil.getColumn1())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn1Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn1Asc())) { + this.setText(this.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn2())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn2Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn2Asc())) { + this.setText(this.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn3())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn3Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn3Asc())) { + this.setText(this.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn4())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn4Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn4Asc())) { + this.setText(this.getText() + ""); + } + } + return this; + } + + public static int getColumnSortOrderNum(JTable table) { + return 0; + } + + public static SortOrder getColumnSortOrder(JTable table, int columnIndex) { + SortOrder sortOrder = null; + if (table != null && table.getRowSorter() != null) { + List sortKeys = table.getRowSorter().getSortKeys(); + columnIndex = table.convertColumnIndexToModel(columnIndex); + if (sortKeys.size() > 0) { + for (Object sortKey : sortKeys) { + if (columnIndex == ((RowSorter.SortKey) sortKey).getColumn()) { + sortOrder = ((RowSorter.SortKey) sortKey).getSortOrder(); + break; + } + } + } + return sortOrder; + } else { + return sortOrder; + } + } + +} diff --git a/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelCommand.java b/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelCommand.java new file mode 100644 index 0000000..f4c0c5b --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelCommand.java @@ -0,0 +1,14 @@ +package cn.net.connor.ml.plm.planningPanel; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class PlanningPanelCommand extends KCommand { + + public PlanningPanelCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new PlanningPanelDialog(app)); + + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog.java b/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog.java new file mode 100644 index 0000000..0731409 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialog.java @@ -0,0 +1,288 @@ +package cn.net.connor.ml.plm.planningPanel; + +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.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JSplitPane; +import javax.swing.JTable; +import javax.swing.ScrollPaneConstants; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableModel; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.planningPanel.sortTable.SorterColumnGroupUtil; +import cn.net.connor.ml.plm.util.ProgressBar; +import cn.net.connor.ml.plm.util.TableUtil3; + +@SuppressWarnings("serial") +public class PlanningPanelDialog extends AbstractAIFDialog { + private PlanningPanelDialogController controller; + protected TCSession session; + protected AbstractAIFApplication app; + private JButton b_query; + private JButton b_accredit; + private JButton b_export; + private JButton b_showColumn; + private JButton b_editRow; + private JButton b_delRow; + protected JTable table; + protected DefaultTableModel tableModel; + protected List columnList; + protected Set allColumns; + protected Set nowColumns; + final static int QUERY = 1; + final static int DELETE = 2; + final static int EXPORT = 3; + final static int EDITROW = 4; + + public PlanningPanelDialog(AbstractAIFApplication app) { + super(false); + this.controller = new PlanningPanelDialogController(this); + this.session = (TCSession) app.getSession(); + this.app = app; + } + + @Override + public void run() { + try { + if (!controller.init()) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.error(this, "ʼʱ쳣\n" + e.getMessage()); + return; + } + initUI(); + addListeners(); + showDialog(); + } + + private void addListeners() { + this.b_query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + readData(QUERY); + } + }); + this.b_showColumn.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + new Planning_ShowColumnDialog(PlanningPanelDialog.this).run(); + } + }); + this.b_delRow.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (table.getSelectedRows().length == 0) { + KUtil.info(PlanningPanelDialog.this, "ѡнɾ"); + return; + } + int yesOrNo = JOptionPane.showConfirmDialog(AIFDesktop.getActiveDesktop(), "ȷɾж", "ʾ", JOptionPane.YES_NO_OPTION); + if (yesOrNo != 0) { + return; + } + readData(DELETE); + } + }); + this.b_export.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + readData(EXPORT); + } + }); + this.b_editRow.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (table.getSelectedRows().length == 0 || table.getSelectedRows().length > 1) { + KUtil.info(PlanningPanelDialog.this, "ѡнб༭,ܶѡ"); + return; + } + readData(EDITROW); + } + }); + this.b_accredit.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (table.getSelectedRowCount() > 0) { + new AddUserDialog(PlanningPanelDialog.this).run(); + } else { + KUtil.info(PlanningPanelDialog.this, "ѡȨ"); + } + } + }); + } + + private void readData(int type) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + setCompEnabled(false); + ProgressBar pb = new ProgressBar(PlanningPanelDialog.this, new Dimension(250, 50), true); + try { + controller.readData(pb, type); + pb.disposeDialog(); + } catch (Exception e) { + pb.disposeDialog(); + KUtil.error(PlanningPanelDialog.this, "ʱ쳣\n" + e.getMessage()); + e.printStackTrace(); + } + setCompEnabled(true); + } + }); + } + + protected void setCompEnabled(boolean b) { + b_accredit.setEnabled(b); + b_delRow.setEnabled(b); + b_editRow.setEnabled(b); + b_export.setEnabled(b); + b_query.setEnabled(b); + b_showColumn.setEnabled(b); + table.setEnabled(b); + } + + private void initUI() { + this.setTitle("滮ٿ"); + Dimension dim = new Dimension(950, 600); + this.setPreferredSize(new Dimension(1000, 600)); + this.setMinimumSize(dim); + this.setLayout(new BorderLayout(20, 5)); + Component leftPanel = initSearchPanel(); + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.add(BorderLayout.NORTH, initMenuPanel()); + rightPanel.add(BorderLayout.CENTER, initTablePanel()); + + JSplitPane splitPane = new JSplitPane(); + splitPane.setOneTouchExpandable(true);// ÷ָʾͷ + splitPane.setContinuousLayout(true);// ͷػͼ + splitPane.setLeftComponent(leftPanel); + splitPane.setRightComponent(rightPanel); + this.add(BorderLayout.CENTER, splitPane); + } + + private Component initSearchPanel() { + JPanel panel = new JPanel(new PropertyLayout(10, 5)); + int i = 1; + for (JComponent label : controller.compMap.keySet()) { + JComponent comp = controller.compMap.get(label); + panel.add(i + ".1.left.top", label); + panel.add(i + ".2.left.top", comp); + i++; + } + JScrollPane jsp = new JScrollPane(panel); + jsp.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + return jsp; + } + + private Component initTablePanel() { + tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + allColumns = controller.columnMap.keySet(); + nowColumns = new HashSet<>(Arrays.asList(controller.defaultColumns)); + System.out.println(allColumns); + tableModel.setDataVector(null, allColumns.toArray(new String[] {})); + table = new JTable(tableModel); + // Ĭʾ + setShowColumns(Arrays.asList(controller.defaultColumns)); + table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // ˮƽʾ +// table.setAutoCreateRowSorter(true);// + + // ԼSorter + MultiColumnTableRowSorter tableRowSorter = new MultiColumnTableRowSorter<>(table.getModel()); + table.setRowSorter(tableRowSorter); + + // ԼıͷRender + table.getTableHeader().setDefaultRenderer(new MutilColumnTableCellHeaderRenderer()); + + // ͷӼ + table.getTableHeader().addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent evt) { + if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 1) { // жҼ˼ + int selectedColumn = table.getTableHeader().columnAtPoint(evt.getPoint());// õеcolumn0ʼ + String sortColumn = tableModel.getColumnName(selectedColumn);// + SorterColumnGroupUtil.setColumn(sortColumn);// УSorterColumnGroupUtilάеĹ + } + } + + }); + + JScrollPane scroll = new JScrollPane(table); + return scroll; + } + + protected void setShowColumns(List list) { + try { + // ʼ + for (int i = 0; i < tableModel.getColumnCount(); i++) { + TableUtil3.showTableColumn(table, Integer.valueOf(i)); + } + + // δõ + for (String columnNum : allColumns) { + if (!list.contains(columnNum)) { + TableUtil3.hideTableColumn(table, columnNum); + } + } + columnList = list; + } catch (Exception e) { + KUtil.error(this, "ʾʱ쳣\n" + e.getMessage()); + e.printStackTrace(); + } + } + + private Component initMenuPanel() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5)); + b_query = new JButton("ѯ"); + b_accredit = new JButton("ĿȨ"); + b_showColumn = new JButton("ʾ"); + b_editRow = new JButton("༭"); + b_delRow = new JButton("ɾ"); + b_export = new JButton("Excel"); + Dimension dim = new Dimension(120, 25); + b_query.setPreferredSize(dim); + b_accredit.setPreferredSize(dim); + b_showColumn.setPreferredSize(dim); + b_editRow.setPreferredSize(dim); + b_delRow.setPreferredSize(dim); + b_export.setPreferredSize(dim); + panel.add(b_query); + panel.add(b_accredit); + panel.add(b_showColumn); + panel.add(b_editRow); + panel.add(b_delRow); + panel.add(b_export); + + return panel; + } + +} diff --git a/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialogController.java b/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialogController.java new file mode 100644 index 0000000..afcb4d6 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/PlanningPanelDialogController.java @@ -0,0 +1,533 @@ +package cn.net.connor.ml.plm.planningPanel; + +import java.awt.Dimension; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import javax.swing.JComponent; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.commands.editproperties.EditPropertiesCommand; +import com.teamcenter.rac.kernel.ListOfValuesInfo; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentDataset; +import com.teamcenter.rac.kernel.TCComponentFolder; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCComponentItemType; +import com.teamcenter.rac.kernel.TCComponentListOfValues; +import com.teamcenter.rac.kernel.TCComponentListOfValuesType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.ui.common.RACUIUtil; +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.teamcenter.soa.client.model.LovValue; + +import cn.net.connor.ml.plm.KUtil; +import cn.net.connor.ml.plm.beans.LOVBean; +import cn.net.connor.ml.plm.beans.ObjectFactory; +import cn.net.connor.ml.plm.beans.Property; +import cn.net.connor.ml.plm.beans.Search; +import cn.net.connor.ml.plm.beans.Searchs; +import cn.net.connor.ml.plm.util.JAutoCompleteComboBox; +import cn.net.connor.ml.plm.util.JProTextField; +import cn.net.connor.ml.plm.util.JaxbUtil; +import cn.net.connor.ml.plm.util.ProgressBar; + +public class PlanningPanelDialogController { + private static final String PREF_PUID = "Meling_Planning_Config_Path"; + private static final String PREF_COLUMNS = "Meling_Planning_AllColumns"; + private static final String PREF_DEFAULT_COLUMNS = "Meling_Planning_DefaultColumns"; + private PlanningPanelDialog dialog; + private TCComponent target; + private Search search; + protected Map compMap; + protected Map columnMap; + protected String[] defaultColumns; + + public PlanningPanelDialogController(PlanningPanelDialog planningPanelDialog) { + this.dialog = planningPanelDialog; + } + + public boolean init() throws Exception { + // 1ѡȡļ + if (!initPrefConfig()) { + return false; + } + // 2ļͨsearchȡؼ + if (!initComps()) { + return false; + } + // 3 + if (!initAllColumns()) { + return false; + } + // 4Ĭ + if (!initDefaultColumns()) { + return false; + } + + return true; + } + + private boolean initDefaultColumns() throws Exception { + String[] config_columns = KUtil.getPrefVals(dialog.session, PREF_DEFAULT_COLUMNS); + if (config_columns == null || config_columns.length < 1) { + throw new Exception("ѡ[" + PREF_DEFAULT_COLUMNS + "]δãϵԱ"); + } + String objectType = search.getObjectType(); + for (String config_column : config_columns) { + String[] config = config_column.split("="); + if (config == null || config.length != 2) { + throw new Exception("ѡ[" + PREF_DEFAULT_COLUMNS + "]ϵԱ"); + } + if (objectType.equals(config[0])) { + defaultColumns = config[1].split(","); + if (defaultColumns == null || defaultColumns.length < 1) { + throw new Exception("ѡ[" + PREF_DEFAULT_COLUMNS + "]δãϵԱ"); + } + return true; + } + } + return false; + } + + private boolean initAllColumns() throws Exception { + String[] config_columns = KUtil.getPrefVals(dialog.session, PREF_COLUMNS); + if (config_columns == null || config_columns.length < 1) { + throw new Exception("ѡ[" + PREF_COLUMNS + "]δãϵԱ"); + } + String objectType = search.getObjectType(); + for (String config_column : config_columns) { + String[] config = config_column.split("="); + if (config == null || config.length != 2) { + throw new Exception("ѡ[" + PREF_COLUMNS + "]ϵԱ"); + } + if (objectType.equals(config[0])) { + String[] columns = config[1].split(","); + if (columns == null || columns.length < 1) { + throw new Exception("ѡ[" + PREF_COLUMNS + "]δãϵԱ"); + } + + columnMap = new LinkedHashMap(); + for (String column : columns) { + String[] names = column.split(":"); + if (names == null || names.length != 2) { + throw new Exception("ѡ[" + PREF_COLUMNS + "]ϵԱ"); + } + columnMap.put(names[0], names[1]); + } + columnMap.put("uid", ""); + return true; + } + } + return false; + } + + private boolean initComps() throws Exception { + List propList = search.getProperty(); + if (propList == null || propList.size() < 1) { + throw new Exception("ȡļʱ쳣\n" + "ûҵã"); + } + compMap = new LinkedHashMap(); + Dimension dim1 = new Dimension(90, 25); + Dimension dim2 = new Dimension(100, 25); + for (Property property : propList) { + String displayName = property.getDisplayName(); + JLabel label = new JLabel(displayName); + label.setPreferredSize(dim1); + JComponent comp = null; + boolean isLov = property.isIsLov(); + String propertyType = property.getPropertyType(); + String realName = property.getRealName(); + String lovName = property.getLovName(); + if (isLov) { + if (propertyType.toUpperCase().equals("STRING")) { + comp = new JAutoCompleteComboBox(getDynamicLOV(lovName)); + } else if (propertyType.toUpperCase().equals("DATE")) { + + } + } else { + comp = new JProTextField(); + ((JProTextField) comp).setRealName(realName); + } + comp.setPreferredSize(dim2); + compMap.put(label, comp); + } + if (compMap == null || compMap.size() < 1) { + return false; + } + return true; + } + + private boolean initPrefConfig() throws Exception { + target = (TCComponent) dialog.app.getTargetComponent(); + if (target == null || !target.getType().equals("ML8_ProLine")) { + KUtil.info(dialog, "ѡƷߣ"); + return false; + } + + // XMLݼpuid + String puid = KUtil.getPrefVal(dialog.session, PREF_PUID); + if (puid == null || puid.length() < 1) { + throw new Exception("ѡ[" + PREF_PUID + "]δãϵԱ"); + } + TCComponent datasetComp = dialog.session.stringToComponent(puid); + if (datasetComp == null || !(datasetComp instanceof TCComponentDataset)) { + throw new Exception("ѡ[" + PREF_PUID + "]õpuidδҵݼϵԱ"); + } + TCComponentDataset dataset = (TCComponentDataset) datasetComp; + +// dataset.setFiles(new String[] { "c:\xxx.txt" }, new String[] { "Text" }); + + String[] fileNames = dataset.getFileNames(""); + int len = fileNames.length; + if (len == 0) { + throw new Exception(String.format("ѡ <%s>, ݼ <%s> ûļ", PREF_PUID, dataset)); + } + if (len > 1) { + throw new Exception(String.format("ѡ <%s>, ݼ <%s> жļ", PREF_PUID, dataset)); + } + File configFile = dataset.getFile("", fileNames[0], System.getenv("TEMP")); + System.out.println("ģļ" + configFile.getAbsolutePath()); + + Searchs searchs = (Searchs) JaxbUtil.unmarshaller(ObjectFactory.class, configFile.getAbsolutePath()); + configFile.delete(); + if (searchs == null) { + throw new Exception("ȡļʱ쳣\n" + "ļΪգ"); + } + search = getConfigBean(searchs); + if (search == null) { + throw new Exception("ȡļʱ쳣\n" + "ûҵӦã"); + } + return true; + } + + private Search getConfigBean(Searchs searchs) { + List searchList = searchs.getSearch(); + for (Search search : searchList) { + String uid = target.getUid(); + if (search.getPuid().equals(uid)) { + return search; + } + } + return null; + } + + public static LOVBean[] getDynamicLOV(String s) throws Exception { + TCComponentListOfValues lov = null; + List beans = new ArrayList<>(); + beans.add(new LOVBean("", "")); + lov = TCComponentListOfValuesType.findLOVByName(s); + try { + if (lov != null) { + 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 = 500;//ԭֵΪ100 20240809 ܿ + filter.maxResults = 500;//ԭֵΪ100 20240809 ܿ + + input.lov = lov; + input.filterData = filter; + LOVSearchResults result = lovService.getInitialLOVValues(input); + for (LOVValueRow row : result.lovValues) { + Map map = row.propDisplayValues; + Map realmap = row.propInternalValues; + + for (String key : map.keySet()) { + LOVBean bean = new LOVBean(); + bean.setDisplayName(map.get(key)[0]); + bean.setRealName(realmap.get(key)[0]); + beans.add(bean); + } + } + } else { + ListOfValuesInfo info = lov.getListOfValues(); + info.getLOVDisplayValues(); + List lovValueList = info.getValues(); + for (LovValue lovV : lovValueList) { + LOVBean bean = new LOVBean(); + bean.setDisplayName(lovV.getDisplayValue()); + bean.setRealName(lovV.getStringValue()); + beans.add(bean); + } + } + } else { + throw new Exception("ϵͳûҵlov:[" + s + "]"); + } + } catch (TCException e) { + e.printStackTrace(); + } + return beans.toArray(new LOVBean[beans.size()]); + } + + public void readData(ProgressBar pb, int type) throws Exception { + switch (type) { + case 1: + queryData(pb); + break; + + case 2: + deleteData(); + break; + + case 3: + exportExcel(pb); + break; + case 4: + editRow(); + break; + default: + break; + } + } + + private void editRow() throws TCException { + DefaultTableModel model = (DefaultTableModel) dialog.table.getModel(); // ñģ + int[] selectedRows = dialog.table.getSelectedRows(); + Object uid = model.getValueAt(selectedRows[0], model.getColumnCount() - 1); + TCComponent comp = dialog.session.stringToComponent((String) uid); + new EditPropertiesCommand(comp, dialog); + } + + private void exportExcel(ProgressBar pb) throws Exception { + TableModel model = dialog.table.getModel(); + int rowCount = model.getRowCount(); + if (rowCount == 0) { + KUtil.info(dialog, "Ϊգ"); + return; + } + File file = getFile(); + if (file == null) { + return; + } + pb.showDialog(); + pb.setText("ڵ..."); + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + + TableColumnModel columnModel = dialog.table.getColumnModel(); + List columnIndex = new ArrayList(); + for (String column : dialog.columnList) { + columnIndex.add(columnModel.getColumnIndex(column)); + } + for (int i = 0; i < rowCount + 1; i++) { + Row row = sheet.createRow(i); + for (int j = 0; j < columnIndex.size(); j++) { + Cell cell = row.createCell(j); + if (i == 0) { + cell.setCellValue(dialog.columnList.get(j)); + } else { + cell.setCellValue((String) model.getValueAt(i - 1, columnIndex.get(j))); + } + } + } + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + KUtil.info(dialog, "ɹ"); + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new XSSFWorkbook(); + workbook.createSheet("sheet1"); + return workbook; + } + + private File getFile() { + JFileChooser jf = new JFileChooser(); + String name = "ExcelName.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(dialog, ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(dialog, "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(dialog, "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private void deleteData() { + DefaultTableModel model = (DefaultTableModel) dialog.table.getModel(); // ñģ + int[] selectedRows = dialog.table.getSelectedRows(); + for (int i : selectedRows) { + Object uid = model.getValueAt(i, model.getColumnCount() - 1); + try { + TCComponent comp = dialog.session.stringToComponent((String) uid); + AIFComponentContext[] refs = comp.whereReferenced(); + if (refs == null || refs.length > 1) { + throw new Exception("öжã"); + } + TCComponentFolder folder = (TCComponentFolder) refs[0].getComponent(); + folder.remove("contents", comp); + comp.delete(); + model.removeRow(i); + } catch (Exception e) { + KUtil.info(dialog, "ɾʧܣ\n" + e); + e.printStackTrace(); + } + } + dialog.table.setModel(model); + } + + private void queryData(ProgressBar pb) throws Exception { + pb.showDialog(); + pb.setText("ѯ..."); + + List nameList = new ArrayList(); + List valueList = new ArrayList(); + for (JLabel label : compMap.keySet()) { + JComponent comp = compMap.get(label); + if (comp instanceof JProTextField) { + JProTextField text = (JProTextField) comp; + String value = text.getText().trim(); + if (!value.equals("")) { + nameList.add(label.getText()); + valueList.add(value); + } + } else if (comp instanceof JAutoCompleteComboBox) { + JAutoCompleteComboBox box = (JAutoCompleteComboBox) comp; + String value = box.getSelectedItem().toString().trim(); + if (!value.equals("")) { + nameList.add(label.getText()); + valueList.add(value); + } + } else { + throw new Exception(label.getText() + "޷"); + } + } + if (nameList.size() > 0) { + TCComponent[] resultSet = dialog.session.search(search.getObjectType() + "ѯ", nameList.toArray(new String[] {}), + valueList.toArray(new String[] {})); + if (resultSet != null && resultSet.length > 0) { + // ݵ + dialog.tableModel.setRowCount(0); + KUtil.setByPass(true); + try { + System.out.println("·"); + for (TCComponent component : resultSet) { + try { + TCComponentItem componentItem = (TCComponentItem) component; + componentItem.lock(); + componentItem.unlock(); + componentItem.refresh(); + ArrayList list = new ArrayList<>(); + for (String prop : columnMap.values()) { + if (prop.equals("ml8_ACompressor")) { + TCComponent[] related = component.getRelatedComponents("ML8_ProductPaperRelation"); + if (related == null || related.length == 0 || !(related[0] instanceof TCComponentItem)) { + list.add(""); + } else { + TCComponentItem item = (TCComponentItem) related[0]; + TCComponentItemRevision rev = item.getLatestItemRevision(); + list.add(rev.getProperty(prop)); + } + } else if (prop.equals("ml8_Remark") || prop.equals("ml8_Remark2")) { + TCComponent[] related = component.getRelatedComponents("ML8_ProductRelation"); + if (related == null || related.length == 0 || !(related[0] instanceof TCComponentItem)) { + list.add(""); + } else { + TCComponentItem item = (TCComponentItem) related[0]; + TCComponentItemRevision rev = item.getLatestItemRevision(); + list.add(rev.getProperty(prop)); + } + } else if (prop.equals("ml8_WbsNo") || prop.equals("ml8_ProductCode")) { + TCComponent[] forms = component.getRelatedComponents("ML8_ProjectRelation"); + if (forms == null || forms.length == 0) { + list.add(""); + } else { + list.add(forms[0].getProperty(prop)); + } + } else if (prop.equals("ml8_Remark")) { + TCComponent[] related = component.getRelatedComponents("ML8_ProductRelation"); + if (related == null || related.length == 0 || !(related[0] instanceof TCComponentItem)) { + list.add(""); + } else { + TCComponentItem item = (TCComponentItem) related[0]; + TCComponentItemRevision rev = item.getLatestItemRevision(); + list.add(rev.getProperty(prop)); + } + } else { + String property = component.getProperty(prop) == null ? "" : component.getProperty(prop); + list.add(property); + } + } + list.remove(list.size() - 1); + list.add(component.getUid()); + dialog.tableModel.addRow(list.toArray(new String[0])); + +// String[] properties = component.getProperties(columnMap.values().toArray(new String[0])); +// properties[properties.length - 1] = component.getUid(); +// dialog.tableModel.addRow(properties); + } catch (TCException e) { + System.out.println("****error***>" + component + "=" + columnMap.values().toArray(new String[0])); + e.printStackTrace(); + } + } +// dialog.FitTableColumns(dialog.table); + dialog.table.revalidate(); + dialog.table.repaint(); + KUtil.setByPass(false); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + } else { + KUtil.info(dialog, "Ҳ"); + } + } else { + // ûƣʾѯ׼ + throw new Exception("δѯ"); + } + } +} diff --git a/src/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog.java b/src/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog.java new file mode 100644 index 0000000..b787fd9 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/Planning_ShowColumnDialog.java @@ -0,0 +1,165 @@ +package cn.net.connor.ml.plm.planningPanel; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Collections; +import java.util.HashSet; + +import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.border.TitledBorder; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.util.ButtonLayout; +import com.teamcenter.rac.util.HorizontalLayout; +import com.teamcenter.rac.util.SplitPane; + +@SuppressWarnings("serial") +public class Planning_ShowColumnDialog extends AbstractAIFDialog { + private JButton b_ok; + private JButton b_cancel; + private PlanningPanelDialog dialog; + private JList leftList; + private JList rightList; + private DefaultListModel leftModel; + private DefaultListModel rightModel; + private JButton add; + private JButton remove; + + public Planning_ShowColumnDialog(PlanningPanelDialog planningPanelDialog) { + super(planningPanelDialog, true); + this.dialog = planningPanelDialog; + } + + @Override + public void run() { + initUI(); + addListeners(); + dialog.setCompEnabled(false); + showDialog(); + } + + @Override + public void dispose() { + super.dispose(); + dialog.setCompEnabled(true); + } + + private void addListeners() { + this.b_cancel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + } + }); + this.b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + dispose(); + dialog.nowColumns = new HashSet<>(Collections.list(rightModel.elements())); + dialog.setShowColumns(Collections.list(rightModel.elements())); +// dialog.FitTableColumns(dialog.table); +// dialog.table.revalidate(); +// dialog.table.repaint(); + } + }); + add.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + Integer row = leftList.getSelectedIndex(); + if (row != null && row >= 0) { + String select = leftModel.getElementAt(row); + leftModel.removeElementAt(row); + rightModel.addElement(select); + } + } + }); + remove.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + Integer row = rightList.getSelectedIndex(); + if (row != null && row >= 0) { + String select = rightModel.getElementAt(row); + rightModel.removeElementAt(row); + leftModel.addElement(select); + } + } + }); + } + + private void initUI() { + this.setTitle("༭"); + this.setPreferredSize(new Dimension(500, 300)); + this.setLayout(new BorderLayout()); + this.add(initPanel(), "Center"); + this.add(initButton(), "South"); + } + + private Component initButton() { + JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 5, 5)); + b_ok = new JButton("ȷ"); + b_cancel = new JButton("ȡ"); + panel.add(b_ok); + panel.add(b_cancel); + return panel; + } + + private Component initPanel() { + JPanel panel1 = new JPanel(new BorderLayout()); + panel1.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "ѡ")); + leftModel = new DefaultListModel<>(); + for (String showColumn : dialog.allColumns) { + if (!dialog.nowColumns.contains(showColumn)) { + leftModel.addElement(showColumn); + } + } + leftList = new JList<>(leftModel); + panel1.add(new JScrollPane(this.leftList), "Center"); + + JPanel panel2 = new JPanel(new ButtonLayout(2)); + add = createButton(">", ""); + remove = createButton("<", "Ƴ"); + panel2.add(add); + panel2.add(remove); + + JPanel rightPanel = new JPanel(new BorderLayout()); + rightPanel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "ǰ")); + rightModel = new DefaultListModel<>(); + for (String showColumn : dialog.nowColumns) { + rightModel.addElement(showColumn); + } + rightList = new JList<>(rightModel); + rightPanel.add(new JScrollPane(this.rightList), "Center"); + + JPanel leftPanel = new JPanel(new HorizontalLayout(3, 3, 3, 3, 3)); + leftPanel.add("unbound.bind", panel1); + leftPanel.add("right.bind.center.center", panel2); + + SplitPane panel = new SplitPane(0); +// panel.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "༭")); + panel.setLeftComponent(leftPanel); + panel.setRightComponent(rightPanel); + panel.setDividerLocation(0.5D); + return panel; + } + + private JButton createButton(String paramString1, String paramString2) { + JButton localJButton = new JButton(paramString1); + localJButton.setMargin(new Insets(0, 0, 0, 0)); + localJButton.setFocusPainted(false); + localJButton.setEnabled(true); + localJButton.setToolTipText(paramString2); + return localJButton; + } +} diff --git a/src/cn/net/connor/ml/plm/planningPanel/ProgressBar.java b/src/cn/net/connor/ml/plm/planningPanel/ProgressBar.java new file mode 100644 index 0000000..1cb2764 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/ProgressBar.java @@ -0,0 +1,144 @@ +package cn.net.connor.ml.plm.planningPanel; + +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, AbstractAIFDialog dialog) { + super(dialog); + 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; + } + + }); + setLocationRelativeTo(null); + 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/src/cn/net/connor/ml/plm/planningPanel/ProgressBarThread.java b/src/cn/net/connor/ml/plm/planningPanel/ProgressBarThread.java new file mode 100644 index 0000000..eb04a11 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/ProgressBarThread.java @@ -0,0 +1,31 @@ +package cn.net.connor.ml.plm.planningPanel; + +import com.teamcenter.rac.aif.AbstractAIFDialog; + +// Referenced classes of package com.teamcenter.rac.importflex: +// ProgressBar + +public class ProgressBarThread extends Thread { + + public ProgressBarThread(String title, String showLable, AbstractAIFDialog dialog) { + this.title = title; + bar = new ProgressBar(showLable, dialog); + } + + public void run() { + bar.setTitle(title); + // óʼ + bar.initUI(); + } + + /* + * ýʾͲʾ + */ + public void setBool(boolean bool) { + bar.setBool(true); + } + + private ProgressBar bar; + + private String title; +} diff --git a/src/cn/net/connor/ml/plm/planningPanel/SorterColumnGroupUtil.java b/src/cn/net/connor/ml/plm/planningPanel/SorterColumnGroupUtil.java new file mode 100644 index 0000000..8ee3ae5 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/SorterColumnGroupUtil.java @@ -0,0 +1,120 @@ +package cn.net.connor.ml.plm.planningPanel; + +import cn.net.connor.ml.plm.planningPanel.sortTable.Constant; + +public class SorterColumnGroupUtil { + + private static String[][] sorterArray = new String[4][2];// + + public static String getColumn1() {// õһ + return sorterArray[0][0]; + } + + public static String getColumn2() {// õڶ + return sorterArray[1][0]; + } + + public static String getColumn3() {// õ + return sorterArray[2][0]; + } + + public static String getColumn4() {// õ + return sorterArray[3][0]; + } + + public static String getColumn1Asc() {// õһ + return sorterArray[0][1]; + } + + public static String getColumn2Asc() {// õڶ + return sorterArray[1][1]; + } + + public static String getColumn3Asc() {// õ + return sorterArray[2][1]; + } + + public static String getColumn4Asc() {// õ + return sorterArray[3][1]; + } + + // + public static void setColumn(String columnName) { + if (columnName != null) {// һΪnull򽫸ΪһĬ + if (sorterArray[0][0] == null) { + sorterArray[0][0] = columnName; + sorterArray[0][1] = Constant.ASC; + } else if (sorterArray[1][0] == null && !sorterArray[0][0].equals(columnName)) {// еһҵڶΪnull򽫸ΪڶĬ + sorterArray[1][0] = columnName; + sorterArray[1][1] = Constant.ASC; + } else if (sorterArray[2][0] == null && !sorterArray[0][0].equals(columnName) && !sorterArray[1][0].equals(columnName)) {// еһ͵ڶҵڶΪnull򽫸ΪڶĬ + sorterArray[2][0] = columnName; + sorterArray[2][1] = Constant.ASC; + } else if (sorterArray[3][0] == null && !sorterArray[0][0].equals(columnName) && !sorterArray[1][0].equals(columnName) + && !sorterArray[2][0].equals(columnName)) {// еһ͵ڶ͵ҵΪnull򽫸ΪĬ + sorterArray[3][0] = columnName; + sorterArray[3][1] = Constant.ASC; + } else { + if (columnName.equals(sorterArray[0][0])) {// ڵһ򽲵һ + if (Constant.ASC.equals(sorterArray[0][1])) { + sorterArray[0][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[0][1])) {// һΪȥһ򣬶һıΪ + sorterArray[0][0] = sorterArray[1][0]; + sorterArray[0][1] = sorterArray[1][1]; + + sorterArray[1][0] = sorterArray[2][0]; + sorterArray[1][1] = sorterArray[2][1]; + + sorterArray[2][0] = sorterArray[3][0]; + sorterArray[2][1] = sorterArray[3][1]; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else if (columnName.equals(sorterArray[1][0])) {// ڶ ͬ + if (Constant.ASC.equals(sorterArray[1][1])) { + sorterArray[1][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[1][1])) {// ڶΪȥڶıΪ + sorterArray[1][0] = sorterArray[2][0]; + sorterArray[1][1] = sorterArray[2][1]; + + sorterArray[2][0] = sorterArray[3][0]; + sorterArray[2][1] = sorterArray[3][1]; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else if (columnName.equals(sorterArray[2][0])) {// + if (Constant.ASC.equals(sorterArray[2][1])) { + sorterArray[2][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[2][1])) {// ΪȥıΪ + sorterArray[2][0] = sorterArray[3][0]; + sorterArray[2][1] = sorterArray[3][1]; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else if (columnName.equals(sorterArray[3][0])) {// + if (Constant.ASC.equals(sorterArray[3][1])) { + sorterArray[3][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[3][1])) {// ΪȥΪ + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else {// + sorterArray[0][0] = columnName; + sorterArray[0][1] = Constant.ASC; + + sorterArray[1][0] = null; + sorterArray[1][1] = null; + + sorterArray[2][0] = null; + sorterArray[2][1] = null; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } + } + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/Constant.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/Constant.java new file mode 100644 index 0000000..17fc9b9 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/Constant.java @@ -0,0 +1,7 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +public class Constant { + public static final String ASC = "1"; + public static final String DESC = "-1"; + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/SorterColumnGroupUtil.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/SorterColumnGroupUtil.java new file mode 100644 index 0000000..02bbc31 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/SorterColumnGroupUtil.java @@ -0,0 +1,118 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +public class SorterColumnGroupUtil { + + private static String[][] sorterArray = new String[4][2];// + + public static String getColumn1() {// õһ + return sorterArray[0][0]; + } + + public static String getColumn2() {// õڶ + return sorterArray[1][0]; + } + + public static String getColumn3() {// õ + return sorterArray[2][0]; + } + + public static String getColumn4() {// õ + return sorterArray[3][0]; + } + + public static String getColumn1Asc() {// õһ + return sorterArray[0][1]; + } + + public static String getColumn2Asc() {// õڶ + return sorterArray[1][1]; + } + + public static String getColumn3Asc() {// õ + return sorterArray[2][1]; + } + + public static String getColumn4Asc() {// õ + return sorterArray[3][1]; + } + + // + public static void setColumn(String columnName) { + if (columnName != null) {// һΪnull򽫸ΪһĬ + if (sorterArray[0][0] == null) { + sorterArray[0][0] = columnName; + sorterArray[0][1] = Constant.ASC; + } else if (sorterArray[1][0] == null && !sorterArray[0][0].equals(columnName)) {// еһҵڶΪnull򽫸ΪڶĬ + sorterArray[1][0] = columnName; + sorterArray[1][1] = Constant.ASC; + } else if (sorterArray[2][0] == null && !sorterArray[0][0].equals(columnName) && !sorterArray[1][0].equals(columnName)) {// еһ͵ڶҵڶΪnull򽫸ΪڶĬ + sorterArray[2][0] = columnName; + sorterArray[2][1] = Constant.ASC; + } else if (sorterArray[3][0] == null && !sorterArray[0][0].equals(columnName) && !sorterArray[1][0].equals(columnName) + && !sorterArray[2][0].equals(columnName)) {// еһ͵ڶ͵ҵΪnull򽫸ΪĬ + sorterArray[3][0] = columnName; + sorterArray[3][1] = Constant.ASC; + } else { + if (columnName.equals(sorterArray[0][0])) {// ڵһ򽲵һ + if (Constant.ASC.equals(sorterArray[0][1])) { + sorterArray[0][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[0][1])) {// һΪȥһ򣬶һıΪ + sorterArray[0][0] = sorterArray[1][0]; + sorterArray[0][1] = sorterArray[1][1]; + + sorterArray[1][0] = sorterArray[2][0]; + sorterArray[1][1] = sorterArray[2][1]; + + sorterArray[2][0] = sorterArray[3][0]; + sorterArray[2][1] = sorterArray[3][1]; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else if (columnName.equals(sorterArray[1][0])) {// ڶ ͬ + if (Constant.ASC.equals(sorterArray[1][1])) { + sorterArray[1][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[1][1])) {// ڶΪȥڶıΪ + sorterArray[1][0] = sorterArray[2][0]; + sorterArray[1][1] = sorterArray[2][1]; + + sorterArray[2][0] = sorterArray[3][0]; + sorterArray[2][1] = sorterArray[3][1]; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else if (columnName.equals(sorterArray[2][0])) {// + if (Constant.ASC.equals(sorterArray[2][1])) { + sorterArray[2][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[2][1])) {// ΪȥıΪ + sorterArray[2][0] = sorterArray[3][0]; + sorterArray[2][1] = sorterArray[3][1]; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else if (columnName.equals(sorterArray[3][0])) {// + if (Constant.ASC.equals(sorterArray[3][1])) { + sorterArray[3][1] = Constant.DESC; + } else if (Constant.DESC.equals(sorterArray[3][1])) {// ΪȥΪ + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } else {// + sorterArray[0][0] = columnName; + sorterArray[0][1] = Constant.ASC; + + sorterArray[1][0] = null; + sorterArray[1][1] = null; + + sorterArray[2][0] = null; + sorterArray[2][1] = null; + + sorterArray[3][0] = null; + sorterArray[3][1] = null; + } + } + } + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/SorterUtil.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/SorterUtil.java new file mode 100644 index 0000000..ef5196c --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/SorterUtil.java @@ -0,0 +1,328 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +import java.lang.reflect.Method; +import java.text.Collator; + +import org.apache.commons.lang.StringUtils; + +public class SorterUtil { + + public static int compare(Object o1, Object o2) { + Object o1sorterColumn1 = getFieldByReflect(o1, SorterColumnGroupUtil.getColumn1()); // õo1 ĵһ + Object o1sorterColumn2 = getFieldByReflect(o1, SorterColumnGroupUtil.getColumn2()); // õo1 ĵڶ + Object o1sorterColumn3 = getFieldByReflect(o1, SorterColumnGroupUtil.getColumn3()); // õo1 ĵ + Object o2sorterColumn1 = getFieldByReflect(o2, SorterColumnGroupUtil.getColumn1()); // õo2 ĵһ + Object o2sorterColumn2 = getFieldByReflect(o2, SorterColumnGroupUtil.getColumn2()); // õo2 ĵڶ + Object o2sorterColumn3 = getFieldByReflect(o2, SorterColumnGroupUtil.getColumn3()); // õo2 ĵ + Object sorterColumnAsc1 = SorterColumnGroupUtil.getColumn1Asc();// һ + Object sorterColumnAsc2 = SorterColumnGroupUtil.getColumn2Asc();// ڶ + Object sorterColumnAsc3 = SorterColumnGroupUtil.getColumn3Asc();// + if (sorterColumnAsc1 != null) {// ж 1 + if (Constant.ASC.equals(sorterColumnAsc1)) {// 1 + if (sorterColumnAsc2 != null) {// ж 2 + if (Constant.ASC.equals(sorterColumnAsc2)) {// 2 + if (sorterColumnAsc3 != null) {// ж3 + if (Constant.ASC.equals(sorterColumnAsc3)) {// 3 + return compareAsc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareAsc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareAsc(o1sorterColumn3, o2sorterColumn3) + : compareAsc(o1sorterColumn2, o2sorterColumn2)) + : compareAsc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } else if (Constant.DESC.equals(sorterColumnAsc3)) {// 3 + return compareAsc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareAsc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareDesc(o1sorterColumn3, o2sorterColumn3) + : compareAsc(o1sorterColumn2, o2sorterColumn2)) + : compareAsc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } + } else {// 3 + return compareAsc(o1sorterColumn1, o2sorterColumn1) == 0 ? (compareAsc(o1sorterColumn2, o2sorterColumn2)) + : compareAsc(o1sorterColumn1, o2sorterColumn1);// 1 2 + } + } else if (Constant.DESC.equals(sorterColumnAsc2)) {// 2 + if (sorterColumnAsc3 != null) {// ж3 + if (Constant.ASC.equals(sorterColumnAsc3)) {// 3 + return compareAsc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareDesc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareAsc(o1sorterColumn3, o2sorterColumn3) + : compareDesc(o1sorterColumn2, o2sorterColumn2)) + : compareAsc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } else if (Constant.DESC.equals(sorterColumnAsc3)) {// 3 + return compareAsc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareDesc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareDesc(o1sorterColumn3, o2sorterColumn3) + : compareDesc(o1sorterColumn2, o2sorterColumn2)) + : compareAsc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } + } else {// 3 + return compareAsc(o1sorterColumn1, o2sorterColumn1) == 0 ? compareDesc(o1sorterColumn2, o2sorterColumn2) + : compareAsc(o1sorterColumn1, o2sorterColumn1);// 1 2 + } + } + } else {// 2 + return compareAsc(o1sorterColumn1, o2sorterColumn1);// 1 + } + } else if (Constant.DESC.equals(sorterColumnAsc1)) {// 1 + if (sorterColumnAsc2 != null) {// ж 2 + if (Constant.ASC.equals(sorterColumnAsc2)) {// 2 + if (sorterColumnAsc3 != null) {// ж3 + if (Constant.ASC.equals(sorterColumnAsc3)) {// 3 + return compareDesc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareAsc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareAsc(o1sorterColumn3, o2sorterColumn3) + : compareAsc(o1sorterColumn2, o2sorterColumn2)) + : compareDesc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } else if (Constant.DESC.equals(sorterColumnAsc3)) {// 3 + return compareDesc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareAsc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareDesc(o1sorterColumn3, o2sorterColumn3) + : compareAsc(o1sorterColumn2, o2sorterColumn2)) + : compareDesc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } + } else {// 3 + return compareDesc(o1sorterColumn1, o2sorterColumn1) == 0 ? compareAsc(o1sorterColumn2, o2sorterColumn2) + : compareDesc(o1sorterColumn1, o2sorterColumn1);// 1 2 + } + } else if (Constant.DESC.equals(sorterColumnAsc2)) {// 2 + if (sorterColumnAsc3 != null) {// ж3 + if (Constant.ASC.equals(sorterColumnAsc3)) {// 3 + return compareDesc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareDesc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareAsc(o1sorterColumn3, o2sorterColumn3) + : compareDesc(o1sorterColumn2, o2sorterColumn2)) + : compareDesc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } else if (Constant.DESC.equals(sorterColumnAsc3)) {// 3 + return compareDesc(o1sorterColumn1, o2sorterColumn1) == 0 + ? (compareDesc(o1sorterColumn2, o2sorterColumn2) == 0 ? compareDesc(o1sorterColumn3, o2sorterColumn3) + : compareDesc(o1sorterColumn2, o2sorterColumn2)) + : compareDesc(o1sorterColumn1, o2sorterColumn1);// 1 2 3 + } + } else {// 3 + return compareDesc(o1sorterColumn1, o2sorterColumn1) == 0 ? compareDesc(o1sorterColumn2, o2sorterColumn2) + : compareDesc(o1sorterColumn1, o2sorterColumn1);// 1 2 + } + } + } else {// 2 + return compareDesc(o1sorterColumn1, o2sorterColumn1);// 1 + } + } + } else {// 1 + return 0; + } + return 0; + } + + /** + * ԶѰҺʵѡ + * @param o1 + * @param o2 + * @return + */ + public static int compareAsc(Object o1, Object o2) { + if (o1 instanceof String) { // ַ + return compareAsc((String) o1, (String) o2); + } else if (o1 instanceof Integer) { // Integer + return compareAsc((Integer) o1, (Integer) o2); + } else if (o1 instanceof Long) { // Long + return compareAsc((Long) o1, (Long) o2); + } else { + System.err.println("δҵʵıȽ"); // Ҳ + return 0; + } + } + + /** + * ԶѰҺʵĽѡ + * @param o1 + * @param o2 + * @return + */ + public static int compareDesc(Object o1, Object o2) { + if (o1 instanceof String) { // ַ + return compareDesc((String) o1, (String) o2); + } else if (o1 instanceof Integer) { // Integer + return compareDesc((Integer) o1, (Integer) o2); + } else if (o1 instanceof Long) { // Integer + return compareDesc((Long) o1, (Long) o2); + } else { + System.err.println("δҵʵıȽ"); // Ҳ + return 1; + } + } + + /** + * Ƚַ + * @param s1 + * @param s2 + * @return + */ + public static int compareAscs(String s1, String s2) { + int result = 0; + if (StringUtils.isBlank(s1)) { + result = 1; + } else if (StringUtils.isBlank(s2)) { + result = -1; + } else { + result = s1.compareTo(s2); + } + return result; + } + + /** + * Ƚַ + * @param s1 + * @param s2 + * @return + */ + public static int compareDescs(String s1, String s2) { + int result = 0; + if (StringUtils.isBlank(s1)) { + result = 1; + } else if (StringUtils.isBlank(s2)) { + result = -1; + } else { + result = s2.compareTo(s1); + } + return result; + } + + /** + * Ƚֵ + * @param s1 + * @param s2 + * @return + */ + public static int compareAsc(Integer s1, Integer s2) { + int result = 0; + if (s1 <= 0) { + result = 1; + } else if (s2 <= 0) { + result = -1; + } else { + result = s1.compareTo(s2); + } + return result; + } + + /** + * Ƚֵ + * @param s1 + * @param s2 + * @return + */ + public static int compareDesc(Long s1, Long s2) { + int result = 0; + if (s1 <= 0) { + result = 1; + } else if (s2 <= 0) { + result = -1; + } else { + result = s2.compareTo(s1); + } + return result; + } + + /** + * Ƚֵ + * @param s1 + * @param s2 + * @return + */ + public static int compareAsc(Long s1, Long s2) { + int result = 0; + if (s1 <= 0) { + result = 1; + } else if (s2 <= 0) { + result = -1; + } else { + result = s1.compareTo(s2); + } + return result; + } + + /** + * Ƚֵ + * @param s1 + * @param s2 + * @return + */ + public static int compareDesc(Integer s1, Integer s2) { + int result = 0; + if (s1 <= 0) { + result = 1; + } else if (s2 <= 0) { + result = -1; + } else { + result = s2.compareTo(s1); + } + return result; + } + + /** + * get + * @param field + * @return + */ + public static String field2MethodName(String field) { + StringBuffer method = null; + if (StringUtils.isNotBlank(field)) { + method = new StringBuffer(); + method.append("get"); + method.append(field.substring(0, 1).toUpperCase()); + method.append(field.substring(1)); + return method.toString(); + } else + return null; + } + + /** + * ͨԵõֵʹ÷ķʽֻҪset&getͨø + * @param o + * @param field + * @return + */ + public static Object getFieldByReflect(Object o, String field) { + Object oo = null; + Class clazz = o.getClass(); + String methodName = field2MethodName(field); + if (clazz != null && methodName != null) { + try { + Method method = clazz.getMethod(methodName); + oo = method.invoke(o); + } catch (Exception e) { + e.printStackTrace(); + } + } + return oo; + } + + /** + * ȽϺַ + * @param s1 + * @param s2 + * @return + */ + public static int compareAsc(String s1, String s2) { + int result = 0; + if (StringUtils.isBlank(s1)) { + result = 1; + } else if (StringUtils.isBlank(s2)) { + result = -1; + } else { + result = Collator.getInstance(java.util.Locale.CHINA).compare(s1, s2); + } + return result; + } + + /** + * ȽϺַ + * @param s1 + * @param s2 + * @return + */ + public static int compareDesc(String s1, String s2) { + int result = 0; + if (StringUtils.isBlank(s1)) { + result = 1; + } else if (StringUtils.isBlank(s2)) { + result = -1; + } else { + result = -Collator.getInstance(java.util.Locale.CHINA).compare(s1, s2); + } + return result; + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableHeaderButton.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableHeaderButton.java new file mode 100644 index 0000000..9d4b910 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableHeaderButton.java @@ -0,0 +1,22 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.SwingConstants; + +public class TableHeaderButton extends JButton{ + + public TableHeaderButton(){ + setRolloverEnabled(true); + setRequestFocusEnabled(false); + setBorder(BorderFactory.createRaisedBevelBorder()); + setOpaque(true); + setContentAreaFilled(false); + setFocusable(false); + setHorizontalAlignment(JLabel.CENTER); + setHorizontalTextPosition(SwingConstants.LEFT); + setIconTextGap(5); + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table.java new file mode 100644 index 0000000..e52a3ce --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Table.java @@ -0,0 +1,164 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +import java.awt.Component; +import java.awt.Font; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.JTableHeader; + +public class TableOrder3Table { + + private TableOrder3TableMode tabelMode; + private JTable order3Table; + private List userList; + private TableOrderSorter tableOrderSorterUtil; + + public JTable initUI() { + getData(); + tabelMode = new TableOrder3TableMode(userList);// ȡmodel + order3Table = new JTable(); + order3Table.setModel(tabelMode);// model + addHeaderEvent();// ӶԱͷ¼ + setSorterIconToTableHeader(order3Table.getTableHeader());// ӱͷͼ + return order3Table; + } + + /** + * ӶԱͷ¼ + */ + public void addHeaderEvent() { + order3Table.getTableHeader().addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent evt) { + if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 1) { // жҼ˼ + int selectedColumn = order3Table.getTableHeader().columnAtPoint(evt.getPoint());// õеcolumn0ʼ + String sortColumn = tabelMode.getColumnObjectName(selectedColumn);// + SorterColumnGroupUtil.setColumn(sortColumn);// УSorterColumnGroupUtilάеĹ + userSort();// + } + } + }); + } + + /** + * Ϊͷͼ + * @param tableHeader + */ + @SuppressWarnings("serial") + public void setSorterIconToTableHeader(JTableHeader tableHeader) { + tableHeader.setDefaultRenderer(new DefaultTableCellRenderer() {// tableheaderȾ + +// private Font TABLE_FONT = new Font("", Font.PLAIN, 15); + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + JButton btn = new TableHeaderButton();// JideTool.newJideButton(); + btn.setText(value == null ? "" : value.toString()); + String sortColumnName = ""; + sortColumnName = tabelMode.getColumnObjectName(column); + if (sortColumnName.equals(SorterColumnGroupUtil.getColumn1())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn1Asc())) { + btn.setText(btn.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn1Asc())) { + btn.setText(btn.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn2())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn2Asc())) { + btn.setText(btn.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn2Asc())) { + btn.setText(btn.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn3())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn3Asc())) { + btn.setText(btn.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn3Asc())) { + btn.setText(btn.getText() + ""); + } + } + return btn; + } + }); + } + + /** + * Էװ˻iconĹ,Ĭ + */ + public static ImageIcon getIconResource(String iconName) { + return new ImageIcon("icon/" + iconName); + } + + /** + * + */ + public void userSort() { + Collections.sort(tabelMode.getList(), getOrderTableSorter());// ҪݼԶഫCollections + order3Table.updateUI(); + } + + /** + * ӿ + * @return + */ + public TableOrderSorter getOrderTableSorter() { + if (tableOrderSorterUtil == null) { + tableOrderSorterUtil = new TableOrderSorter(); + } + return tableOrderSorterUtil; + } + + /** + * ñʽ + */ + public void setStyle() { + order3Table.getColumnModel().getColumn(2).setPreferredWidth(10); + order3Table.setRowHeight(25); + } + + /** + * ӶԱݵ¼ + */ + public void addEvent() { + order3Table.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(MouseEvent e) {// 굥ʱӦ + // õѡееֵ + int r = order3Table.getSelectedRow(); + int c = order3Table.getSelectedColumn(); + // õѡеĵԪֵжַ + Object value = order3Table.getValueAt(r, c); + String info = r + "" + c + "ֵ : " + value.toString(); + javax.swing.JOptionPane.showMessageDialog(null, info); + } + }); + } + + /** + * ȡģ + */ + public void getData() { + userList = new ArrayList(); + User user1 = new User(1, "Ԫ˧", "", 18, "ddd", "eee"); + User user2 = new User(11, "˧˧", "bbb", 18, "drdfrt", "aba"); + User user3 = new User(10, "˧", "dsd", 18, "dnca", "aba"); + User user4 = new User(2, "", "sdf", 18, "wer", "aba"); + User user5 = new User(3, "Сħ", "abc", 18, "gm", "aba"); + User user6 = new User(5, "NN", "sd", 20, "dsz", "aba"); + User user7 = new User(21, "", "ddd", 21, "nhd", "aba"); + User user8 = new User(22, "", "bbb", 22, "dhsa", "aba"); + userList.add(user1); + userList.add(user2); + userList.add(user3); + userList.add(user4); + userList.add(user5); + userList.add(user6); + userList.add(user7); + userList.add(user8); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3TableMode.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3TableMode.java new file mode 100644 index 0000000..375709b --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3TableMode.java @@ -0,0 +1,119 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +import java.util.List; + +import javax.swing.event.TableModelListener; +import javax.swing.table.TableModel; + +public class TableOrder3TableMode implements TableModel { + + private List userList; + + public TableOrder3TableMode(List userList) { + this.userList = userList; + } + + @Override + public Class getColumnClass(int columnIndex) { + return String.class; + } + + @Override + public int getColumnCount() { + + return 6; + } + + @Override + public int getRowCount() { + return userList.size(); + } + + @Override + public String getColumnName(int columnIndex) { + if (columnIndex == 0) + return "id"; + if (columnIndex == 1) + return "û"; + if (columnIndex == 2) + return ""; + if (columnIndex == 3) + return ""; + if (columnIndex == 4) + return ""; + if (columnIndex == 5) + return "ַ"; + else + return null; + + } + + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + User user = userList.get(rowIndex); + if (columnIndex == 0) + return user.getId(); + if (columnIndex == 1) + return user.getUserName(); + if (columnIndex == 2) + return user.getUserPassword(); + if (columnIndex == 3) + return user.getAge(); + if (columnIndex == 4) + return user.getEmail(); + if (columnIndex == 5) + return user.getAddress(); + return null; + } + + /** + * Ա༭༭갴enterԶø÷ + */ + @Override + public void setValueAt(Object aValue, int rowIndex, int columnIndex) { + String s = "Change at: " + rowIndex + "--- " + columnIndex + " newValue: " + aValue; + System.out.println(s); + + } + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + if (columnIndex == 0) + return false; + return true; + } + + @Override + public void removeTableModelListener(TableModelListener l) { + // TODO Auto-generated method stub + + } + + @Override + public void addTableModelListener(TableModelListener l) { + // TODO Auto-generated method stub + + } + + public List getList() { + return this.userList; + } + + public String getColumnObjectName(int columnIndex) { + if (columnIndex == 0) + return User.ID; + if (columnIndex == 1) + return User.USERNAME; + if (columnIndex == 2) + return User.USERPASSWORD; + if (columnIndex == 3) + return User.AGE; + if (columnIndex == 4) + return User.EMAIL; + if (columnIndex == 5) + return User.ADDRESS; + else + return null; + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test.java new file mode 100644 index 0000000..2c50c12 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrder3Test.java @@ -0,0 +1,55 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +import java.awt.Dimension; +import java.awt.Toolkit; + +import javax.swing.JFrame; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.WindowConstants; + +public class TableOrder3Test { +// private static int width = 600; +// private static int height = 600; + + public static void main(String[] args) { + displayTable(); + + } + + public static void displayTable() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + // ó + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); + } catch (Exception localException1) { + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (Exception localException2) { + localException2.printStackTrace(); + } + } + + JFrame tableFrame = new JFrame(""); + + TableOrder3Table order3Talbe = new TableOrder3Table(); + + tableFrame.setContentPane(new JScrollPane(order3Talbe.initUI())); + + Toolkit kit = Toolkit.getDefaultToolkit();// ôڳ + Dimension dim = kit.getScreenSize();// õǰĻ +// tableFrame.setLocation(((int)dim.getWidth()-width)/2, +// (int)(dim.getHeight()-height)/2);//frameϵƫʾλ +// tableFrame.setLocationRelativeTo(null); + tableFrame.setSize(dim);// ĻС +// tableFrame.setSize(200, 200);//ĻС + tableFrame.setResizable(true);// ǷɵС + tableFrame.setVisible(true);// Ƿʾ + tableFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);// ִ֮ĸ + tableFrame.setAlwaysOnTop(true); + } + }); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrderSorter.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrderSorter.java new file mode 100644 index 0000000..15372d8 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/TableOrderSorter.java @@ -0,0 +1,11 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +import java.util.Comparator; + +public class TableOrderSorter implements Comparator { + + @Override + public int compare(User o1, User o2) { + return SorterUtil.compare(o1, o2); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable/User.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable/User.java new file mode 100644 index 0000000..92ed430 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable/User.java @@ -0,0 +1,85 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable; + +import java.io.Serializable; + +public class User implements Serializable{ + + @Override + public String toString() { + StringBuffer bf = new StringBuffer(); + bf.append("User[:"); + bf.append("userName:"+userName); + bf.append("\nuserPassword:"+userPassword); + bf.append("\nage:"+age+"]"); + return bf.toString(); + } + + private static final long serialVersionUID = 2764373816508835680L; + private Integer id; + private String userName; + private String userPassword; + private int age; + private String email; + private String address; + + + + public User(Integer id, String userName, String userPassword, int age, + String email, String address) { + super(); + this.id = id; + this.userName = userName; + this.userPassword = userPassword; + this.age = age; + this.email = email; + this.address = address; + } + public User() { + super(); + // TODO Auto-generated constructor stub + } + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public String getUserName() { + return userName; + } + public void setUserName(String userName) { + this.userName = userName; + } + public String getUserPassword() { + return userPassword; + } + public void setUserPassword(String userPassword) { + this.userPassword = userPassword; + } + public int getAge() { + return age; + } + public void setAge(int age) { + this.age = age; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + public String getAddress() { + return address; + } + public void setAddress(String address) { + this.address = address; + } + + public final static String ID = "id"; + public final static String USERNAME = "userName"; + public final static String USERPASSWORD = "userPassword"; + public final static String AGE = "age"; + public final static String EMAIL= "email"; + public final static String ADDRESS = "address"; + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable2/MultiColumnTableRowSorter.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable2/MultiColumnTableRowSorter.java new file mode 100644 index 0000000..b4de26e --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable2/MultiColumnTableRowSorter.java @@ -0,0 +1,53 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable2; + +import javax.swing.*; +import javax.swing.table.TableModel; +import javax.swing.table.TableRowSorter; +import java.util.ArrayList; +import java.util.List; + +public class MultiColumnTableRowSorter extends TableRowSorter { + public MultiColumnTableRowSorter(M model) { + super(model); + } + + @Override + public void toggleSortOrder(int column) {// л˳ + setMaxSortKeys(4); + checkColumn(column); + if (isSortable(column)) { + List keys = new ArrayList(getSortKeys()); + SortKey sortKey; + int sortIndex; + for (sortIndex = keys.size() - 1; sortIndex >= 0; sortIndex--) { + if (keys.get(sortIndex).getColumn() == column) { + break; + } + } + if (sortIndex == -1) { + // Key doesn't exist + sortKey = new SortKey(column, SortOrder.ASCENDING);// + keys.add(sortKey); + } else { + SortKey key = keys.get(sortIndex); + if (key.getSortOrder() == SortOrder.ASCENDING) {// + key = new SortKey(key.getColumn(), SortOrder.DESCENDING);// ½ + keys.set(sortIndex, key); + } else if (key.getSortOrder() == SortOrder.DESCENDING) {// ½ + keys.remove(sortIndex); + } + } + + if (keys.size() > getMaxSortKeys()) { + keys = keys.subList(getMaxSortKeys(), keys.size()); + } + setSortKeys(keys); + } + } + + private void checkColumn(int column) { + if (column < 0 || column >= getModelWrapper().getColumnCount()) { + throw new IndexOutOfBoundsException("column beyond range of TableModel"); + } + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable2/MutilColumnTableCellHeaderRenderer.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable2/MutilColumnTableCellHeaderRenderer.java new file mode 100644 index 0000000..574b315 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable2/MutilColumnTableCellHeaderRenderer.java @@ -0,0 +1,93 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable2; + +import sun.swing.DefaultLookup; + +import javax.swing.*; +import javax.swing.border.Border; +import javax.swing.plaf.UIResource; +import javax.swing.table.DefaultTableCellRenderer; + +import cn.net.connor.ml.plm.planningPanel.sortTable.Constant; +import cn.net.connor.ml.plm.planningPanel.sortTable.SorterColumnGroupUtil; + +import java.awt.*; +import java.io.Serializable; +import java.util.List; + +public class MutilColumnTableCellHeaderRenderer extends DefaultTableCellRenderer implements UIResource { + + public MutilColumnTableCellHeaderRenderer() { + this.setHorizontalAlignment(0); + } + + public void setHorizontalTextPosition(int textPosition) { + super.setHorizontalTextPosition(textPosition); + } + + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + this.setText(value == null ? "" : value.toString()); + Border var13 = null; + if (hasFocus) { + var13 = DefaultLookup.getBorder(this, this.ui, "TableHeader.focusCellBorder"); + } + + if (var13 == null) { + var13 = DefaultLookup.getBorder(this, this.ui, "TableHeader.cellBorder"); + } + + this.setBorder(var13); + + String sortColumnName = ""; + sortColumnName = table.getColumnName(column); + if (sortColumnName.equals(SorterColumnGroupUtil.getColumn1())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn1Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn1Asc())) { + this.setText(this.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn2())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn2Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn2Asc())) { + this.setText(this.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn3())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn3Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn3Asc())) { + this.setText(this.getText() + ""); + } + } else if (sortColumnName.equals(SorterColumnGroupUtil.getColumn4())) { + if (Constant.ASC.equals(SorterColumnGroupUtil.getColumn4Asc())) { + this.setText(this.getText() + ""); + } else if (Constant.DESC.equals(SorterColumnGroupUtil.getColumn4Asc())) { + this.setText(this.getText() + ""); + } + } + return this; + } + + public static int getColumnSortOrderNum(JTable table) { + return 0; + } + + public static SortOrder getColumnSortOrder(JTable table, int columnIndex) { + SortOrder sortOrder = null; + if (table != null && table.getRowSorter() != null) { + List sortKeys = table.getRowSorter().getSortKeys(); + columnIndex = table.convertColumnIndexToModel(columnIndex); + if (sortKeys.size() > 0) { + for (Object sortKey : sortKeys) { + if (columnIndex == ((RowSorter.SortKey) sortKey).getColumn()) { + sortOrder = ((RowSorter.SortKey) sortKey).getSortOrder(); + break; + } + } + } + return sortOrder; + } else { + return sortOrder; + } + } + +} diff --git a/src/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo.java b/src/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo.java new file mode 100644 index 0000000..31ebcf9 --- /dev/null +++ b/src/cn/net/connor/ml/plm/planningPanel/sortTable2/TableSortDemo.java @@ -0,0 +1,114 @@ +package cn.net.connor.ml.plm.planningPanel.sortTable2; + +import javax.swing.*; +import javax.swing.table.*; + +import cn.net.connor.ml.plm.planningPanel.sortTable.SorterColumnGroupUtil; + +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +public class TableSortDemo extends JPanel { + public TableSortDemo() { + super(new GridLayout(1, 0)); + + JTable table = new JTable(new AbstractTableModel() { + private String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" }; + private Object[][] data = { { "Kathy", "Smith", "Snowboarding", new Integer(10), new Boolean(false) }, + { "John", "Doe", "Rowing", new Integer(3), new Boolean(true) }, + { "Sue", "White", "Knitting", new Integer(2), new Boolean(false) }, + { "Kathy", "White", "Speed reading", new Integer(20), new Boolean(true) }, + { "Joe", "Brown", "Pool", new Integer(10), new Boolean(true) } }; + + public int getColumnCount() { + return columnNames.length; + } + + public int getRowCount() { + return data.length; + } + + public String getColumnName(int col) { + return columnNames[col]; + } + + public Object getValueAt(int row, int col) { + return data[row][col]; + } + + public Class getColumnClass(int c) { + return getValueAt(0, c).getClass(); + } + }); + table.setPreferredScrollableViewportSize(new Dimension(500, 70)); + table.setFillsViewportHeight(true); + + // ԼSorter + MultiColumnTableRowSorter tableRowSorter = new MultiColumnTableRowSorter<>(table.getModel()); + table.setRowSorter(tableRowSorter); + + // ԼıͷRender + table.getTableHeader().setDefaultRenderer(new MutilColumnTableCellHeaderRenderer()); + + // ͷӼ + table.getTableHeader().addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent evt) { + if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 1) { // жҼ˼ + int selectedColumn = table.getTableHeader().columnAtPoint(evt.getPoint());// õеcolumn0ʼ + String sortColumn = table.getModel().getColumnName(selectedColumn);// + SorterColumnGroupUtil.setColumn(sortColumn);// УSorterColumnGroupUtilάеĹ + } + } + + }); + + // üеϢ + table.getTableHeader().addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() % 2 == 1 && SwingUtilities.isLeftMouseButton(e)) { + JTableHeader header = table.getTableHeader(); + RowSorter sorter; + if ((sorter = table.getRowSorter()) != null) { + int columnIndex = header.columnAtPoint(e.getPoint()); + if (columnIndex != -1) { + for (Object key : sorter.getSortKeys()) { + RowSorter.SortKey sortKey = (RowSorter.SortKey) key; + +// System.out.print(sortKey.getColumn() + ":" + table.getColumnName(columnIndex) + " | "); + } +// System.out.println(""); + } + } + } + } + }); + + JScrollPane scrollPane = new JScrollPane(table); + add(scrollPane); + } + + private static void createAndShowGUI() { + JFrame frame = new JFrame("TableSortDemo"); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + TableSortDemo newContentPane = new TableSortDemo(); + newContentPane.setOpaque(true); // content panes must be opaque + frame.setContentPane(newContentPane); + + frame.pack(); + frame.setVisible(true); + frame.setAlwaysOnTop(true); + } + + public static void main(String[] args) { + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog.java b/src/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog.java new file mode 100644 index 0000000..612b131 --- /dev/null +++ b/src/cn/net/connor/ml/plm/projectSchedule/ChooseUserDialog.java @@ -0,0 +1,241 @@ +package cn.net.connor.ml.plm.projectSchedule; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; + +import javax.swing.ImageIcon; +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.JTree; +import javax.swing.table.DefaultTableModel; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeModel; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; + +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCAccessControlService; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCComponentUser; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.beans.TMomUserBean; +import cn.net.connor.ml.plm.util.TCGroupDialogTree; + +public class ChooseUserDialog extends AbstractAIFDialog { + + private JPanel panel; + private JPanel panel3; + private JLabel lable; + private JLabel searchLable; + private JTextField searchField; + private JButton searchButton; + private JTree userTree; + private DefaultMutableTreeNode node; + private DefaultTreeModel m_model; + private String value; + private List nameList = new ArrayList(); + TCGroupDialogTree treeDialog; + private ProjectScheduleDialog dialog; + private JButton clearButton; + + public ChooseUserDialog(ProjectScheduleDialog planningPanelDialog) { + super(planningPanelDialog, true); + this.dialog = planningPanelDialog; + initUI(); + } + + @Override + public void run() { + initUI(); + showDialog(); + } + + public void initUI() { + System.out.println("ʼ"); + this.setTitle("ѡû"); + this.setPreferredSize(new Dimension(600, 300)); + + this.lable = new JLabel("1"); + + this.panel = new JPanel(new BorderLayout()); + this.panel3 = new JPanel(new FlowLayout()); + + this.searchLable = new JLabel("2"); + this.searchField = new JTextField(20); + + this.searchButton = new JButton("ѯû"); + this.searchButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + // TODO Auto-generated method stub + if (value != null && !value.equals(searchField.getText())) { + nameList.clear(); + value = searchField.getText(); + } else { + value = searchField.getText(); + } + DefaultMutableTreeNode node = searchNode(searchField.getText(), nameList); + if (node != null) { + TCComponent user = ((TMomUserBean) node.getUserObject()).getUser(); + try { + nameList.add(user.getStringProperty("user_id")); + } catch (TCException e) { + e.printStackTrace(); + } + TreeNode[] nodes = m_model.getPathToRoot(node); + TreePath path = new TreePath(nodes); + userTree.scrollPathToVisible(path); + userTree.setSelectionPath(path); + } else { + MessageBox.post("δҵԱ", "", MessageBox.ERROR); + nameList.clear(); + } + } + }); + this.clearButton = new JButton("û"); + this.clearButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent actionevent) { + dialog.projectManager.setText(""); + } + }); + + if (treeDialog == null) { + treeDialog = new TCGroupDialogTree(); + } + if (this.userTree == null) { + + TCSession session = (TCSession) AIFUtility.getCurrentApplication().getSession(); + try { + TCComponentGroupType type = ((TCComponentGroupType) session.getTypeComponent("Group")); + // meling froup-------------------------------- + String groupName = session.getPreferenceService().getStringValue("Meling_Group_Name"); + TCComponentGroup group = type.find(groupName); + TMomUserBean bean = new TMomUserBean(group, null); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + getUsers(node1, group, null); + this.node = node1; + m_model = new DefaultTreeModel(node); + userTree = new JTree(m_model); + userTree.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent mouseevent) { + if (mouseevent.getClickCount() == 2) { + okAction(); + } + } + }); + userTree.setRowHeight(20); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) userTree.getCellRenderer(); + cellRenderer.setLeafIcon(new ImageIcon("icons\\person_16.png")); + cellRenderer.setOpenIcon(new ImageIcon("icons\\role_16.png")); + cellRenderer.setClosedIcon(new ImageIcon("icons\\group_16.png")); + + } catch (TCException e) { + e.printStackTrace(); + } + } + panel3.add(searchField); + panel3.add(searchButton); + panel3.add(clearButton); + panel.add(panel3, BorderLayout.SOUTH); + panel.add(new JScrollPane(this.userTree), BorderLayout.CENTER); + this.add(panel, "Center"); + } + + public void getUsers(DefaultMutableTreeNode node, TCComponent comp, TCComponent parent) { + try { + if (comp instanceof TCComponentGroup) { + TCComponent[] comps = ((TCComponentGroup) comp).getRolesAndGroups(); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + node.add(node1); + getUsers(node1, comps[i], comp); + } + } else if (comp instanceof TCComponentRole) { + TCComponent[] comps = ((TCComponentRole) comp).getUsers((TCComponentGroup) parent); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + node.add(node1); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + // ӵĽڵ + public DefaultMutableTreeNode searchNode(String nodeStr, List nameList) { + DefaultMutableTreeNode node = null; + Enumeration e = this.node.breadthFirstEnumeration(); + while (e.hasMoreElements()) { + node = (DefaultMutableTreeNode) e.nextElement(); + if (node.getUserObject() instanceof TMomUserBean) { + TCComponent user = ((TMomUserBean) node.getUserObject()).getUser(); + try { + String userName = user.getStringProperty("user_name"); + String userId = user.getStringProperty("user_id"); + if (userName != null) { + if ((userName.indexOf(nodeStr) >= 0 || userId.indexOf(nodeStr) >= 0) && !nameList.contains(userId)) { + return node; + } + } + } catch (TCException e1) { + e1.printStackTrace(); + } + } + } + return null; + } + + public void okAction() { + Object selectObj = userTree.getLastSelectedPathComponent(); + if (selectObj instanceof DefaultMutableTreeNode) { + Object userObj = ((DefaultMutableTreeNode) selectObj).getUserObject(); + if (userObj instanceof TMomUserBean) { + if (((TMomUserBean) userObj).getUser() instanceof TCComponentUser) { + try { + TCComponentUser user = (TCComponentUser) ((TMomUserBean) userObj).getUser(); + dialog.projectManager.setText(user.getProperty("user_name")); +// dialog.projectManager.setText(user.getProperty("object_string")); + dispose(); + } catch (Exception e1) { + MessageBox.post(e1.toString(), "", MessageBox.ERROR); + e1.printStackTrace(); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + } + + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + } + } else { + MessageBox.post("ѡԱ", "", MessageBox.ERROR); + } + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleCommand.java b/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleCommand.java new file mode 100644 index 0000000..63bc24a --- /dev/null +++ b/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.projectSchedule; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class ProjectScheduleCommand extends KCommand { + + public ProjectScheduleCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new ProjectScheduleDialog(app)); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog.java b/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog.java new file mode 100644 index 0000000..1574b49 --- /dev/null +++ b/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialog.java @@ -0,0 +1,202 @@ +package cn.net.connor.ml.plm.projectSchedule; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Set; + +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; + +import org.jfree.chart.ChartPanel; +import org.jfree.data.general.DefaultPieDataset; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.stylesheet.PropertyDateComponent; +import com.teamcenter.rac.util.PropertyLayout; +import com.yujianbo.swing.SwingService; + +import cn.net.connor.ml.plm.KUtil; + +@SuppressWarnings("serial") +public class ProjectScheduleDialog extends AbstractAIFDialog { + protected TCSession session; + @SuppressWarnings("unused") + private AbstractAIFApplication app; + private ProjectScheduleDialogController controller; + protected DefaultTableModel tableModel; + protected JTable table; + private Set columns; + private JButton query; + private JButton export; + protected JComboBox dept; + protected PropertyDateComponent startDate1; + protected PropertyDateComponent startDate2; + protected PropertyDateComponent finishDate1; + protected PropertyDateComponent finishDate2; + protected DefaultPieDataset dataset; + protected JButton projectManager; + final static int QUERY = 1; + final static int EXPORT = 2; + + public ProjectScheduleDialog(AbstractAIFApplication app) { + super(false); + this.controller = new ProjectScheduleDialogController(this); + this.session = (TCSession) app.getSession(); + this.app = app; + } + + @Override + public void run() { + try { + if (!controller.init()) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.error(this, "ʼʱ쳣\n" + e.getMessage()); + return; + } + initUI(); + addListeners(); + showDialog(); + } + + protected void setCompEnabled(boolean b) { + query.setEnabled(b); + export.setEnabled(b); + table.setEnabled(b); + } + + private void readData(int type) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + setCompEnabled(false); + try { + controller.readData(type); + } catch (Exception e) { + KUtil.error(ProjectScheduleDialog.this, "ʱ쳣\n" + e.getMessage()); + e.printStackTrace(); + } + setCompEnabled(true); + } + }); + } + + private void addListeners() { + this.query.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + readData(QUERY); + } + }); + this.export.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + readData(EXPORT); + } + }); + this.projectManager.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + new ChooseUserDialog(ProjectScheduleDialog.this).run(); + } + }); + } + + private void initUI() { + this.setTitle("ͳĿ"); + this.setPreferredSize(new Dimension(1200, 400)); + this.setLayout(new BorderLayout(20, 5)); + this.add(BorderLayout.WEST, initSearchPanel()); + this.add(BorderLayout.CENTER, initTablePanel()); + this.add(BorderLayout.EAST, initFanChart()); + } + + // ͼ + private Component initFanChart() { + dataset = new DefaultPieDataset(); +// dataset.setValue("", 100); +// dataset.setValue("", 100); +// dataset.setValue("Ԥ", 200); + ChartPanel chartPanel = SwingService.chart.getChartPie(2, dataset, "0.00%", 400, 200, "ͼ", 12, 10, 10); + return chartPanel; + } + + // + private Component initTablePanel() { + tableModel = new DefaultTableModel() { + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + }; + columns = controller.columnMap.keySet(); + System.out.println("" + columns.size()); + tableModel.setDataVector(null, columns.toArray(new String[] {})); + table = new JTable(tableModel); + + JScrollPane scroll = new JScrollPane(table); + return scroll; + } + + // ѯ + private Component initSearchPanel() { + JPanel panel = new JPanel(new PropertyLayout()); + JLabel label1 = new JLabel("Ŀеţ"); + dept = new JComboBox<>(KUtil.getDynamicLOV("ML8_PrjDepartment_LOV")); + JLabel label = new JLabel("Ŀ"); + projectManager = new JButton("ѡĿ"); + + JLabel label2 = new JLabel("ʼʱڣ"); + startDate1 = new PropertyDateComponent(); + JLabel label22 = new JLabel("ʼʱڣ"); + startDate2 = new PropertyDateComponent(); + JLabel label3 = new JLabel("ʱڣ"); + finishDate1 = new PropertyDateComponent(); + JLabel label33 = new JLabel("ʱڣ"); + finishDate2 = new PropertyDateComponent(); + dept.setPreferredSize(startDate2.getPreferredSize()); + projectManager.setPreferredSize(startDate2.getPreferredSize()); + query = new JButton("ѯʱ"); + export = new JButton(""); + query.setPreferredSize(new Dimension(100, 25)); + export.setPreferredSize(new Dimension(100, 25)); + + panel.add("1.1.left.top", label1); + panel.add("1.2.left.top", dept); + + panel.add("2.1.left.top", label); + panel.add("2.2.left.top", projectManager); + + panel.add("3.1.left.top", label2); + panel.add("3.2.left.top", startDate1); + panel.add("4.1.left.top", label22); + panel.add("4.2.left.top", startDate2); + + panel.add("5.1.left.top", label3); + panel.add("5.2.left.top", finishDate1); + panel.add("6.1.left.top", label33); + panel.add("6.2.left.top", finishDate2); + + panel.add("7.1.right.top", query); + panel.add("8.1.right.top", export); + + return panel; + } + +} diff --git a/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController.java b/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController.java new file mode 100644 index 0000000..b9e7e39 --- /dev/null +++ b/src/cn/net/connor/ml/plm/projectSchedule/ProjectScheduleDialogController.java @@ -0,0 +1,341 @@ +package cn.net.connor.ml.plm.projectSchedule; + +import java.awt.Color; +import java.awt.Component; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.JTable; +import javax.swing.filechooser.FileSystemView; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableModel; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.jfree.data.general.DefaultPieDataset; + +import com.teamcenter.rac.kernel.TCComponent; + +import cn.net.connor.ml.plm.KUtil; + +public class ProjectScheduleDialogController { + private static final String PREF_COLUMNS = "Meling_Project_Schedule_Columns"; + private ProjectScheduleDialog dialog; + protected LinkedHashMap columnMap; + private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-M-dd HH:mm:ss"); + + public ProjectScheduleDialogController(ProjectScheduleDialog projectScheduleDialog) { + this.dialog = projectScheduleDialog; + } + + public boolean init() throws Exception { + String[] config_columns = KUtil.getPrefVals(dialog.session, PREF_COLUMNS); + if (config_columns == null || config_columns.length < 1) { + throw new Exception("ѡ[" + PREF_COLUMNS + "]δãϵԱ"); + } + columnMap = new LinkedHashMap(); + for (String config_column : config_columns) { + String[] display_real = config_column.split("="); + if (display_real.length != 2) { + throw new Exception("ѡ[" + PREF_COLUMNS + "]ϵԱ"); + } + columnMap.put(display_real[0], display_real[1]); + } + return true; + } + + public void readData(int type) { + switch (type) { + case 1: + queryData(); + break; + case 2: + exportExcel(); + break; + default: + break; + } + } + + private File getFile() { + JFileChooser jf = new JFileChooser(); + String name = "ExcelName.xlsx"; + jf.setDialogTitle("ļ" + name + "..."); + FileSystemView fileSystemView = FileSystemView.getFileSystemView(); + String homePath = fileSystemView.getHomeDirectory().getPath(); + jf.setCurrentDirectory(new File(homePath)); + jf.setSelectedFile(new File(name)); + boolean flag = false; + do { + int showOpenDialog = jf.showDialog(dialog, ""); + if (showOpenDialog == JFileChooser.APPROVE_OPTION) { + File file = new File(jf.getSelectedFile().getAbsolutePath()); + if (file.exists()) { + if (!file.getName().endsWith(".xlsx")) { + KUtil.info(dialog, "ʧܣļҪ\".xlsx\"β"); + return null; + } + int yesOrNo = JOptionPane.showConfirmDialog(dialog, "ļѴڣҪ", "ļ", JOptionPane.YES_NO_OPTION); + if (yesOrNo == 0) { + // 0 + return file; + } else { + // 1 + flag = true; + } + } else { + return file; + } + } else { + return null; + } + } while (flag); + return null; + } + + private Workbook getworkbook() throws IOException { + Workbook workbook = new XSSFWorkbook(); + workbook.createSheet("sheet1"); + return workbook; + } + + private void exportExcel() { + TableModel model = dialog.table.getModel(); + int rowCount = model.getRowCount(); + int columnCount = model.getColumnCount(); + if (rowCount == 0) { + KUtil.info(dialog, "Ϊգ"); + return; + } + File file = getFile(); + if (file == null) { + return; + } + try { + Workbook workBook = getworkbook(); + Sheet sheet = workBook.getSheetAt(0); + + for (int i = 0; i < rowCount + 1; i++) { + Row row = sheet.createRow(i); + for (int j = 0; j < columnCount; j++) { + Cell cell = row.createCell(j); + if (i == 0) { + cell.setCellValue(dialog.table.getColumnName(j)); + } else { + cell.setCellValue((String) model.getValueAt(i - 1, j)); + } + } + } + FileOutputStream fileOutputStream = new FileOutputStream(file); + workBook.write(fileOutputStream); + fileOutputStream.close(); + } catch (Exception e) { + e.printStackTrace(); + KUtil.info(dialog, "ʧ\n" + e); + return; + } + KUtil.info(dialog, "ɹ"); + } + + @SuppressWarnings("deprecation") + private void queryData() { + ArrayList list1 = new ArrayList<>(); + ArrayList list2 = new ArrayList<>(); + if (!dialog.dept.getSelectedItem().toString().equals("")) { + list2.add(dialog.dept.getSelectedItem().toString()); + list1.add("Ŀе"); + } + if (!dialog.projectManager.getText().trim().equals("") && !dialog.projectManager.getText().trim().equals("ѡĿ")) { + list2.add(dialog.projectManager.getText().trim()); + list1.add("Ŀ"); + } + if (dialog.startDate1.getDateString() != null && !dialog.startDate1.getDateString().equals("")) { +// list2.add(dialog.startDate1.getDateString()); + list2.add(sdf.format(dialog.startDate1.getDate())); + list1.add("ʼ"); + } + if (dialog.startDate2.getDateString() != null && !dialog.startDate2.getDateString().equals("")) { +// list2.add(dialog.startDate2.getDateString()); + list2.add(sdf.format(dialog.startDate2.getDate())); + list1.add("ʼ"); + } + if (dialog.finishDate1.getDateString() != null && !dialog.finishDate1.getDateString().equals("")) { +// list2.add(dialog.finishDate1.getDateString()); + list2.add(sdf.format(dialog.finishDate1.getDate())); + list1.add(""); + } + if (dialog.finishDate2.getDateString() != null && !dialog.finishDate2.getDateString().equals("")) { +// list2.add(dialog.finishDate2.getDateString()); + list2.add(sdf.format(dialog.finishDate2.getDate())); + list1.add(""); + } + if (list1.size() < 1) { + KUtil.info(dialog, "δѯ"); + return; + } + { + list2.add("FALSE"); + list1.add("ǻ"); + + list2.add("FALSE"); + list1.add("ʱģ"); + } + try { + KUtil.setByPass(true); + System.out.println("ǰѯƣʱѯ"); + System.out.println("ǰѯ" + list1.toString()); + System.out.println("ǰѯֵ" + list2.toString()); + System.out.println(" > ִвѯ..."); + TCComponent[] searchs = dialog.session.search("ʱѯ", list1.toArray(new String[] {}), list2.toArray(new String[] {})); + if (searchs == null || searchs.length < 1) { + KUtil.info(dialog, "Ҳ"); + return; + } + // ݵ + dialog.tableModel.setRowCount(0); + HashMap states = new HashMap<>(); + ArrayList colors = new ArrayList<>(); + for (TCComponent component : searchs) { + Collection values = columnMap.values(); + ArrayList list = new ArrayList<>(); + Color color = null; + for (String realName : values) { + String value = ""; + if (realName.startsWith("pro.")) { + TCComponent project = component.getRelatedComponent("project_list"); + String[] strs = realName.split("\\."); + if (project != null) { + if (strs[1].equals("owning_user")) { + TCComponent user = project.getRelatedComponent(strs[1]); + value = user.getProperty("user_name"); + } else { + value = project.getProperty(strs[1]); + } + } + } else { + value = component.getProperty(realName); + } + list.add(value); + if (realName.equals("finish_date")) { + value = component.getProperty(realName); + Date valueDate = sdf.parse(value); + if (valueDate.before(new Date())) {// ɫ + color = new Color(254, 132, 161); + } else if (differentDays(new Date(), valueDate) <= 14 && differentDays(new Date(), valueDate) > 0) {// Ԥ ɫ + color = new Color(255, 255, 0); + } else {// ɫ + color = new Color(0, 255, 0); + } + } + } + dialog.tableModel.addRow(list.toArray(new String[] {})); + colors.add(color); + // ¼ͼ״̬ +// String state = component.getProperty("fnd0state"); + String state = component.getProperty("fnd0status"); + if (!state.equals("")) { + if (states.containsKey(state)) { + Integer integer = states.get(state); + states.put(state, ++integer); + } else { + states.put(state, 1); + } + } + } + setColor(dialog.table, colors.toArray(new Color[] {})); + dialog.dataset.clear(); + for (String key : states.keySet()) { + dialog.dataset.setValue(key, states.get(key)); + } + dialog.table.revalidate(); + dialog.table.repaint(); + } catch (Exception e) { + KUtil.setByPass(false); + e.printStackTrace(); + KUtil.info(dialog, "ѯ쳣\n" + e); + }finally { + KUtil.setByPass(false); + } + } + + /** + * 򵥷װһ· + * @param table + * @param color ɫб + */ + public static void setColor(JTable table, Color[] color) { + try { + DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer() { + // дgetTableCellRendererComponent + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, + int column) { + // ##################### Ҫ޸ĵIJ + setForeground(Color.black); + setBackground(color[row]); + // ###################### + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } + }; + // ÿеÿһԪ + int columnCount = table.getColumnCount(); + for (int i = 0; i < columnCount; i++) { + table.getColumn(table.getColumnName(i)).setCellRenderer(dtcr); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * date2date1 + * @param date1 + * @param date2 + * @return + */ + public static int differentDays(Date date1, Date date2) { + Calendar cal1 = Calendar.getInstance(); + cal1.setTime(date1); + + Calendar cal2 = Calendar.getInstance(); + cal2.setTime(date2); + int day1 = cal1.get(Calendar.DAY_OF_YEAR); + int day2 = cal2.get(Calendar.DAY_OF_YEAR); + + int year1 = cal1.get(Calendar.YEAR); + int year2 = cal2.get(Calendar.YEAR); + if (year1 != year2) // ͬһ + { + int timeDistance = 0; + for (int i = year1; i < year2; i++) { + if (i % 4 == 0 && i % 100 != 0 || i % 400 == 0) // + { + timeDistance += 366; + } else // + { + timeDistance += 365; + } + } + + return timeDistance + (day2 - day1); + } else // ͬһ + { + return day2 - day1; + } + } +} diff --git a/src/cn/net/connor/ml/plm/refreshRev/RefreshRevAction.java b/src/cn/net/connor/ml/plm/refreshRev/RefreshRevAction.java new file mode 100644 index 0000000..a656141 --- /dev/null +++ b/src/cn/net/connor/ml/plm/refreshRev/RefreshRevAction.java @@ -0,0 +1,61 @@ +package cn.net.connor.ml.plm.refreshRev; + +import java.awt.Frame; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.common.actions.AbstractAIFAction; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.util.MessageBox; + +public class RefreshRevAction extends AbstractAIFAction { + private AbstractAIFApplication application; + + public RefreshRevAction(AbstractAIFApplication application, Frame frame, String param) { + super(application, frame, param); + this.application = application; + } + + @Override + public void run() { + InterfaceAIFComponent[] targetComponents = application.getTargetComponents(); + if (targetComponents.length <= 0) { + MessageBox.post("δѡκζ","title",MessageBox.ERROR); + return; + } + + try { + for (int i = 0; i < targetComponents.length; i++) { + InterfaceAIFComponent selectComponent = targetComponents[i]; + if (selectComponent instanceof TCComponentItemRevision) { + TCComponentItemRevision revision = (TCComponentItemRevision) selectComponent; + String type = revision.getStringProperty("object_type"); + if ("ML8_ApplicationRevision".equals(type)) { + //TODO ˢµǰ汾 + revision.refresh(); + System.out.println(revision.getStringProperty("object_string")+"汾ˢɣ"); + TCComponent[] referenceListPropertys = revision.getReferenceListProperty("ML8_ProjectRelation"); + for (int j = 0; j < referenceListPropertys.length; j++) { + String referenceType = referenceListPropertys[j].getStringProperty("object_type"); + if ("ML8_ProjectForm".equals(referenceType)) { + TCComponentForm form = (TCComponentForm)referenceListPropertys[j]; + //TODO ˢµǰ + form.refresh(); + System.out.println(form.getStringProperty("object_string")+"ˢɣ"); + } + } + }else { + MessageBox.post("ѡĿƷ汾ʹF4ˢ£","title",MessageBox.ERROR); + } + } + } + + } catch (TCException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/cn/net/connor/ml/plm/refreshRev/RefreshRevHandler.java b/src/cn/net/connor/ml/plm/refreshRev/RefreshRevHandler.java new file mode 100644 index 0000000..1f3a261 --- /dev/null +++ b/src/cn/net/connor/ml/plm/refreshRev/RefreshRevHandler.java @@ -0,0 +1,22 @@ +package cn.net.connor.ml.plm.refreshRev; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; + +public class RefreshRevHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + System.out.println("F4ˢ²"); + AbstractAIFApplication application = AIFUtility.getCurrentApplication(); + RefreshRevAction action = new RefreshRevAction(application, null, null); + + new Thread(action).start(); + return null; + } + +} diff --git a/src/cn/net/connor/ml/plm/saveAs/G4MDialog.java b/src/cn/net/connor/ml/plm/saveAs/G4MDialog.java new file mode 100644 index 0000000..9df88ff --- /dev/null +++ b/src/cn/net/connor/ml/plm/saveAs/G4MDialog.java @@ -0,0 +1,214 @@ +package cn.net.connor.ml.plm.saveAs; + +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.List; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Text; + +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.common.tree.G4MTreeNode; +import com.teamcenter.rac.classification.icm.ICMApplication; +import com.teamcenter.rac.kernel.TCComponentForm; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSHierarchyNodeDescriptor; +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; + TCComponentForm form; + TCSession session; + private Text nameText; + private String name; + private String classId; + private SaveAsDialog dialog; + + public G4MDialog(String expandClass, Text nameText, List revList, TCSession session) { +// super(AIFDesktop.getActiveDesktop(), true); + this.expandClass = expandClass; + this.revList = revList; + this.session = session; + this.nameText = nameText; + try { + this.app = new ICMApplication(); + this.m_context = new MyG4MContext(app, "k0"); + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + } + + public G4MDialog(SaveAsDialog saveAsDialog) { + super(saveAsDialog, true); + this.dialog = saveAsDialog; + try { + this.app = new ICMApplication(); + this.m_context = new MyG4MContext(app, "k0"); + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + } + + @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(); + } + this.add(BorderLayout.SOUTH, initBtnPanel()); + addListeners(); + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + private void addListeners() { + b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + G4MTreeNode selectNode = m_context.getTree().getSelectedNode(); + int childCount = selectNode.getChildCount(); + if (childCount == 0) { + ICSHierarchyNodeDescriptor ics = selectNode.getICSDescriptor(); + name = ics.getName(); + classId = ics.getId(); + dialog.text.setText(name); + dialog.text.setToolTipText(classId); + disposeDialog(); + return; + } + + 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; + System.out.println(" ico.getClassId()=====" + ico.getClassId()); + + TCComponentItemRevision rev = (TCComponentItemRevision) ico.getClassifiedObject(); + revList.add(rev); + MessageBox.post("ͼֽóɹ", "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("ѡݲICO", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡݲICO"); + return; + } + } + }); + b_cel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { +// disposeDialog(); + dispose(); + } + }); + } + + 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/src/cn/net/connor/ml/plm/saveAs/SaveAsCommand.java b/src/cn/net/connor/ml/plm/saveAs/SaveAsCommand.java new file mode 100644 index 0000000..60cb258 --- /dev/null +++ b/src/cn/net/connor/ml/plm/saveAs/SaveAsCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.saveAs; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class SaveAsCommand extends KCommand { + + public SaveAsCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new SaveAsDialog(app)); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/saveAs/SaveAsDialog.java b/src/cn/net/connor/ml/plm/saveAs/SaveAsDialog.java new file mode 100644 index 0000000..b92c5c2 --- /dev/null +++ b/src/cn/net/connor/ml/plm/saveAs/SaveAsDialog.java @@ -0,0 +1,248 @@ +package cn.net.connor.ml.plm.saveAs; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JTextField; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCAccessControlService; +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.TCSession; +import com.teamcenter.rac.kernel.TCTypeService; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.ml.plm.KUtil; + +public class SaveAsDialog extends AbstractAIFDialog { + + /** + * + */ + private static final long serialVersionUID = 1L; + private AbstractAIFApplication app; + private JButton query; + private JTextField id; + private TCSession session; + private JComboBox box; + private JButton close; + private JButton finish; + private JButton choose; + protected JTextField text; + private TCComponentItem target; + + public SaveAsDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + try { + if (!init()) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.error(this, "ʼʱ쳣\n" + e.getMessage()); + return; + } + initUI(); + addListeners(); + showDialog(); + } + + private void addListeners() { + this.query.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + String idid = id.getText().trim(); + System.out.println("id=" + idid); + if (idid.equals("")) { + KUtil.info(SaveAsDialog.this, "ĵΪգ"); + return; + } + try { + TCComponent[] result = session.search("ĵ汾ѯ", new String[] { "ĵ" }, new String[] { idid }); + if (result == null || result.length < 1) { + KUtil.info(SaveAsDialog.this, "ѯΪգ"); + return; + } + box.removeAllItems(); + for (TCComponent rev : result) { + box.addItem(rev); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + }); + this.choose.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + new G4MDialog(SaveAsDialog.this).run(); + } + }); + this.finish.addActionListener(new ActionListener() { + @SuppressWarnings("deprecation") + @Override + public void actionPerformed(ActionEvent e) { + TCComponent rev = (TCComponent) box.getSelectedItem(); + String name = text.getText().trim(); + String classId = text.getToolTipText(); + if (rev == null || name.equals("")) { + KUtil.info(SaveAsDialog.this, "[ĵ][ĵ]Ϊգ"); + return; + } + try { + TCComponent form = rev.getRelatedComponent("ML8_ProjectRelation"); + if (form == null) { + KUtil.info(SaveAsDialog.this, "ѡûĿ޷棡"); + return; + } + System.out.println(text.getToolTipText()); +// TCComponent[] views = rev.getRelatedComponents("view"); + TCComponentItemType itemtype = (TCComponentItemType) session.getTypeComponent("Item"); + int n = 1; + String id = rev.getProperty("item_id"), newId = id + "." + n; + TCComponentItem[] items = itemtype.findItems(newId); + while(items!=null && items.length>0) { + n++; + newId = id + "." + n; + items = itemtype.findItems(newId); + } +// if (views == null || views.length < 1) { +// } else { +// for (TCComponent tcComponent : views) { +// String tempId = tcComponent.getProperty("item_id"); +// newId = newId.compareTo(tempId) > 0 ? newId : tempId; +// } +// char c = newId.charAt(newId.length() - 1); +// Integer i = Character.getNumericValue(c); +// i++; +// newId = newId.substring(0, newId.length() - 1) + i; +// } + TCComponentItemRevision targetRev = target.getLatestItemRevision(); + boolean canWrite = checkAccessPrivilige(session.getUser(), rev, "WRITE"); + boolean isReleased = true; + TCComponent[]release_list = rev.getTCProperty("release_status_list").getReferenceValueArray(); + if(release_list==null||release_list.length==0)isReleased = false; + StringBuilder sb = new StringBuilder(); + TCComponentItem newItem = targetRev.saveAsItem(newId, "A", name, "", true, null); + TCComponentItemRevision newItemRev = newItem.getLatestItemRevision(); + TCComponent[] forms = newItemRev.getRelatedComponents("ML8_ProjectRelation"); + if (forms != null && forms.length > 0) { + newItemRev.remove("ML8_ProjectRelation", forms); + } + newItemRev.add("ML8_ProjectRelation", form); + System.out.println("classId=" + classId); + newItemRev.setProperty("ml8_ClassificationStr", classId); + if(canWrite&&!isReleased){ + + TCTypeService service = session.getTypeService(); + TCComponentBOMWindowType winType = (TCComponentBOMWindowType) service.getTypeComponent("BOMWindow"); + TCComponentBOMWindow view = winType.create(null); + TCComponentItemRevision topRev = (TCComponentItemRevision) rev; + TCComponentBOMLine line = view.setWindowTopLine(topRev.getItem(), topRev, null, null);// Ѱ汾bomline +// KUtil.setByPass(true); + view.lock(); + line.lock(); + line.add(newItem, newItemRev, null, false, ""); + line.save(); + line.unlock(); + view.save(); + view.unlock(); + view.close(); + sb.append(newItemRev.getStringProperty("item_id")+"浽"+line+""); +// KUtil.setByPass(false); + }else { +// KUtil.setByPass(true); + session.getUser().getNewStuffFolder().add("contents", newItem); +// KUtil.setByPass(false); + sb.append(newItemRev.getStringProperty("item_id")+"浽NewStuffFolder"); + if(!canWrite)sb.append(",ûдȨ"); + if(isReleased)sb.append(",ѷ"); + } + disposeDialog(); + KUtil.info(SaveAsDialog.this, "ɹ"+sb.toString()+"!"); + } catch (TCException e1) { + e1.printStackTrace(); + KUtil.info(SaveAsDialog.this, "ʧ\n" + e1); + } + } + }); + this.close.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + /** + * checkAccessPrivilige:ûԸComponentǷȨ + * @param @return 趨ļ + * @return String + * @throws + * @since CodingExampleVer 1.1 + */ + private boolean checkAccessPrivilige(TCComponentUser user, TCComponent comp, String accessName) throws TCException { + TCAccessControlService accessService = ((TCSession) session).getTCAccessControlService(); + boolean returnboolean = accessService.checkUsersPrivilege(user, comp, accessName); + return returnboolean; + } + + private void initUI() { + this.setTitle("ĵΪ"); + PropertyLayout layout = new PropertyLayout(); + layout.setLeftMargin(6); + this.setLayout(layout); + this.setMinimumSize(new Dimension(400, 100)); + + this.add("1.1.left.top", new JLabel("ĵ룺")); + id = new JTextField(); + id.setPreferredSize(new Dimension(100, 25)); + this.add("1.2.left.top", id); + query = new JButton("ѯ"); + this.add("1.3.left.top", query); + box = new JComboBox<>(); + box.setPreferredSize(new Dimension(150, 25)); + this.add("1.4.left.top", box); + + this.add("2.1.left.top", new JLabel("ĵƣ")); + text = new JTextField(); + text.setEditable(false); + text.setPreferredSize(new Dimension(100, 25)); + this.add("2.2.left.top", text); + choose = new JButton("ѡ"); + this.add("2.3.left.top", choose); + + finish = new JButton(""); + this.add("3.1.right.top", finish); + close = new JButton("ر"); + this.add("3.2.right.top", close); + + } + + private boolean init() { + target = (TCComponentItem) app.getTargetComponent(); + if (target != null) { + return true; + } + return false; + } + +} diff --git a/src/cn/net/connor/ml/plm/tcm/TCM01Command.java b/src/cn/net/connor/ml/plm/tcm/TCM01Command.java new file mode 100644 index 0000000..ca4c078 --- /dev/null +++ b/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/src/cn/net/connor/ml/plm/tcm/TCM01Operation.java b/src/cn/net/connor/ml/plm/tcm/TCM01Operation.java new file mode 100644 index 0000000..6d39977 --- /dev/null +++ b/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/src/cn/net/connor/ml/plm/test/BigDecimalUtils.java b/src/cn/net/connor/ml/plm/test/BigDecimalUtils.java new file mode 100644 index 0000000..10a7347 --- /dev/null +++ b/src/cn/net/connor/ml/plm/test/BigDecimalUtils.java @@ -0,0 +1,144 @@ +package cn.net.connor.ml.plm.test; + +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(); + } + + /** + * ȽϴС С0v1 < v2 0v1 > v2 0v1 = 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/src/cn/net/connor/ml/plm/test/CheckHandler.java b/src/cn/net/connor/ml/plm/test/CheckHandler.java new file mode 100644 index 0000000..379462e --- /dev/null +++ b/src/cn/net/connor/ml/plm/test/CheckHandler.java @@ -0,0 +1,65 @@ +package cn.net.connor.ml.plm.test; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; + +import cn.net.connor.ml.plm.KUtil; + +public class CheckHandler extends AbstractHandler { + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + InterfaceAIFComponent[] targets = app.getTargetComponents(); + if (targets == null || targets.length != 2) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡ2ļУ"); + return null; + } + try { + TCComponent target1 = null;// + TCComponent target2 = null;// + if (targets[0].getProperty("object_name").equals("1")) { + target1 = (TCComponent) targets[0]; + target2 = (TCComponent) targets[1]; + } else if (targets[1].getProperty("object_name").equals("1")) { + target1 = (TCComponent) targets[1]; + target2 = (TCComponent) targets[0]; + } + TCComponent[] comps = target1.getRelatedComponents("contents"); + TCComponent[] forms = target2.getRelatedComponents("contents"); + KUtil.setByPass(true); + for (TCComponent comp : comps) { + TCComponentItem item = (TCComponentItem) comp; + TCComponentItemRevision rev = item.getLatestItemRevision(); + String name1 = rev.getProperty("object_name"); + System.out.println(">>> ǰ" + name1); + for (TCComponent form : forms) { + String name2 = form.getProperty("object_name"); + if (name1.equals(name2)) { + System.out.println(" *** " + name1 + "ƥ䵽" + name2); + rev.add("ML8_ProjectRelation", form); + break; + } + } + } + KUtil.setByPass(false); + } catch (Exception e) { + KUtil.setByPass(false); + e.printStackTrace(); + }finally { + KUtil.setByPass(false); + } + + return null; + } + +} diff --git a/src/cn/net/connor/ml/plm/test/ScreenShotTest.java b/src/cn/net/connor/ml/plm/test/ScreenShotTest.java new file mode 100644 index 0000000..b5ad255 --- /dev/null +++ b/src/cn/net/connor/ml/plm/test/ScreenShotTest.java @@ -0,0 +1,230 @@ +package cn.net.connor.ml.plm.test; + +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.ImageIcon; +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 cn.net.connor.ml.plm.exportExcel.ExportExcel3Operation; + +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 (AWTException e) { + e.printStackTrace(); + } catch (IOException 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 ToolsWindow tools = null; + + public ScreenShotWindow() throws AWTException, IOException { + // ȡĻߴ + 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ֹwidthheight0 + g.setColor(Color.BLUE); + g.drawRect(x - 1, y - 1, width + 1, height + 1); + // 11˷ֹͼƬο򸲸ǵ + 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 { + System.out.println("Width=" + saveImage.getWidth() + ",Height=" + saveImage.getHeight()); + JFileChooser jfc = new JFileChooser(); + jfc.setDialogTitle(""); + + // ļû˿ѡļ + FileNameExtensionFilter filter = new FileNameExtensionFilter("JPG", "jpg"); + 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 + ".jpg"); + jfc.setSelectedFile(defaultFile); + + int flag = jfc.showSaveDialog(this); + if (flag == JFileChooser.APPROVE_OPTION) { + File file = jfc.getSelectedFile(); + String path = file.getPath(); + // ļ׺û׺벻ȷĺ׺ + if (!(path.endsWith(".jpg") || path.endsWith(".JPG"))) { + path += ".jpg"; + } + // дļ + ImageIO.write(saveImage, "jpg", new File(path)); + System.exit(0); + } + } +} + +/** +* +*/ +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) { + try { + parent.saveImage(); + } catch (IOException e1) { + e1.printStackTrace(); + } + } + }); + toolBar.add(saveButton); + + // رհť + JButton closeButton = new JButton("close"); + closeButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }); + toolBar.add(closeButton); + + this.add(toolBar, BorderLayout.NORTH); + } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/updateDesignName/G4MDialog.java b/src/cn/net/connor/ml/plm/updateDesignName/G4MDialog.java new file mode 100644 index 0000000..9e05264 --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateDesignName/G4MDialog.java @@ -0,0 +1,283 @@ +package cn.net.connor.ml.plm.updateDesignName; + +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.List; + +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Text; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +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.common.tree.G4MTreeNode; +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.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.kernel.ics.ICSHierarchyNodeDescriptor; +import com.teamcenter.rac.util.MessageBox; + +import cn.net.connor.ml.plm.KUtil; + +@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; + TCComponentForm form; + TCSession session; + private Text nameText; + private String name; + private String classId; + private AbstractAIFApplication app2; + private TCComponent target; +// private TCComponentItemRevision revision; + + public G4MDialog(String expandClass, Text nameText, List revList, TCSession session) { +// super(AIFDesktop.getActiveDesktop(), true); + this.expandClass = expandClass; + this.revList = revList; + this.session = session; + this.nameText = nameText; + try { + this.app = new ICMApplication(); + this.m_context = new MyG4MContext(app, "k0"); + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + } + + public G4MDialog(AbstractAIFApplication app2) { + super(false); + this.app2 = app2; + this.session = (TCSession) app2.getSession(); + target = (TCComponent) app2.getTargetComponent(); + if (!init()) { + KUtil.info(AIFUtility.getActiveDesktop(), "飺\n1.[]Ҫ͵ǰûͬ\n2.汾ܷҲУ"); + return; + } + try { + this.app = new ICMApplication(); + this.m_context = new MyG4MContext(app, "k0"); + } catch (Exception e) { + e.printStackTrace(); + } + initUI(); + showDialog(); + } + + private boolean init() { + try { + if (target instanceof TCComponentItem) { + TCComponent[] revs = target.getRelatedComponents("revision_list"); + TCComponent[] relateds = revs[0].getRelatedComponents("release_status_list"); + TCComponent[] related2s = revs[0].getRelatedComponents("process_stage_list"); + if (relateds == null || relateds.length == 0) { + + } else { + return false; + } + if (related2s == null || related2s.length == 0) { + + } else { + return false; + } + } + String name1 = target.getRelatedComponent("owning_user").getProperty("user_name"); + System.out.println(name1); + System.out.println(session.getUser().getUserName()); + if (!session.getUser().getUserName().equals(name1)) { + return false; + } + } catch (TCException e) { + e.printStackTrace(); + } + return true; + } + + @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(); + } + this.add(BorderLayout.SOUTH, initBtnPanel()); + addListeners(); + } + + public String getClassId() { + return classId; + } + + public void setClassId(String classId) { + this.classId = classId; + } + + private void addListeners() { + b_ok.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + G4MTreeNode selectNode = m_context.getTree().getSelectedNode(); + int childCount = selectNode.getChildCount(); + if (childCount == 0) { + ICSHierarchyNodeDescriptor ics = selectNode.getICSDescriptor(); + name = ics.getName(); + classId = ics.getId(); + + try { +// if (!target.getProperty("object_name").equals("װ")) { +// disposeDialog(); +// KUtil.info(G4MDialog.this, "[װ]Ʋ޸"); +// return; +// } + KUtil.setPropValue(session, "object_name", name, target); + if (target instanceof TCComponentItemRevision) { + System.out.println(target.getType()); + target.setProperty("ml8_ClassificationStr", classId); + TCComponentItem item = ((TCComponentItemRevision) target).getItem(); + KUtil.setPropValue(session, "object_name", name, item); + } else { + System.out.println(target.getType()); + TCComponentItemRevision rev = ((TCComponentItem) target).getLatestItemRevision(); + KUtil.setPropValue(session, "object_name", name, rev); + rev.setProperty("ml8_ClassificationStr", classId); + } + target.refresh(); + KUtil.info(G4MDialog.this, "޸ijɹ" + name); + } catch (Exception e1) { + e1.printStackTrace(); + } +// dialog.text.setText(name); +// dialog.text.setToolTipText(classId); + disposeDialog(); + return; + } + + 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; + System.out.println(" ico.getClassId()=====" + ico.getClassId()); + + TCComponentItemRevision rev = (TCComponentItemRevision) ico.getClassifiedObject(); + revList.add(rev); + MessageBox.post("ͼֽóɹ", "ɹ", MessageBox.INFORMATION); + } else { + MessageBox.post("ѡݲICO", "", MessageBox.INFORMATION); + // KUtil.info(G4MDialog.this, "ѡݲICO"); + return; + } + } + }); + b_cel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { +// disposeDialog(); + dispose(); + } + }); + } + + 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/src/cn/net/connor/ml/plm/updateDesignName/UpdateDesignNameCommand.java b/src/cn/net/connor/ml/plm/updateDesignName/UpdateDesignNameCommand.java new file mode 100644 index 0000000..758896d --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateDesignName/UpdateDesignNameCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.updateDesignName; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class UpdateDesignNameCommand extends KCommand { + + public UpdateDesignNameCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new G4MDialog(app)); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/updateDesignProperty/UpdateDesignPropertyHandler.java b/src/cn/net/connor/ml/plm/updateDesignProperty/UpdateDesignPropertyHandler.java new file mode 100644 index 0000000..cf35e52 --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateDesignProperty/UpdateDesignPropertyHandler.java @@ -0,0 +1,110 @@ +package cn.net.connor.ml.plm.updateDesignProperty; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aif.kernel.AIFComponentContext; +import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentItem; +import com.teamcenter.rac.kernel.TCComponentItemRevision; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateDesignPropertyHandler extends AbstractHandler { + + private TCComponent father; + private TCComponent form; + private StringBuilder errorInfo = new StringBuilder(); + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target == null || !target.getType().equals("ML8_DesignRevision")) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡư汾"); + return null; + } + TCComponentItemRevision rev = (TCComponentItemRevision) target; + try { + TCComponentItem item = rev.getItem(); + int count = item.getWhereReferencedCount(); + if (count == 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ĵùϵ"); + return null; + } + AIFComponentContext[] refs = item.whereReferenced(); + for (AIFComponentContext ref : refs) { + InterfaceAIFComponent component = ref.getComponent(); + if (component.getType().startsWith("ML8_TecModel") || component.getType().startsWith("ML8_ProModel")) { + father = (TCComponent) component; + break; + } + } + if (father == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ĵùϵ"); + return null; + } + System.out.println(father.getProperty("object_string")); + form = father.getRelatedComponent("ML8_ProjectRelation"); + if (form == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ûб"); + return null; + } + findAllChilds(rev); + if (errorInfo.length() > 0) { + KUtil.info(AIFDesktop.getActiveDesktop(), errorInfo.toString()); + } else { + KUtil.info(AIFDesktop.getActiveDesktop(), "ͬɣ"); + } + } catch (TCException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + private void findAllChilds(TCComponent rev) { + try { + TCComponent[] state = rev.getRelatedComponents("release_status_list"); + if (state.length == 0) { + setProps(rev); + } else { + return; + } + TCComponent[] childs = rev.getRelatedComponents("view"); + if (childs != null && childs.length > 0) { + for (TCComponent child : childs) { + TCComponentItemRevision latestItemRevision = ((TCComponentItem) child).getLatestItemRevision(); + findAllChilds(latestItemRevision); + } + } + } catch (TCException e) { + e.printStackTrace(); + KUtil.info(AIFDesktop.getActiveDesktop(), "[" + rev.toString() + "]ͬ\n" + e); + } + + } + + private void setProps(TCComponent rev) { + try { + TCComponent[] forms = rev.getRelatedComponents("ML8_ProjectRelation"); + if (forms != null && forms.length > 0) { +// KUtil.info(AIFDesktop.getActiveDesktop(), "[" + rev.toString() + "]Ѵڱͬö"); + errorInfo.append("[" + rev.toString() + "]Ѵڱö\n"); + return; + } + rev.add("ML8_ProjectRelation", form); + } catch (TCException e) { + e.printStackTrace(); + KUtil.info(AIFDesktop.getActiveDesktop(), "[" + rev.toString() + "]ͬ\n" + e); + } + } +} diff --git a/src/cn/net/connor/ml/plm/updateDocState/UpdateDocStateCommand.java b/src/cn/net/connor/ml/plm/updateDocState/UpdateDocStateCommand.java new file mode 100644 index 0000000..fee3e4e --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateDocState/UpdateDocStateCommand.java @@ -0,0 +1,13 @@ +package cn.net.connor.ml.plm.updateDocState; + +import com.teamcenter.rac.aif.AbstractAIFApplication; + +import cn.net.connor.ml.plm.KCommand; + +public class UpdateDocStateCommand extends KCommand { + + public UpdateDocStateCommand(AbstractAIFApplication app, String commandId, String actionInfo) { + super(app, commandId, actionInfo); + this.setRunnable(new UpdateDocStateDialog(app)); + } +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog.java b/src/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog.java new file mode 100644 index 0000000..c946547 --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateDocState/UpdateDocStateDialog.java @@ -0,0 +1,161 @@ +package cn.net.connor.ml.plm.updateDocState; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.TitledBorder; + +import com.teamcenter.rac.aif.AbstractAIFApplication; +import com.teamcenter.rac.aif.AbstractAIFDialog; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentICO; +import com.teamcenter.rac.kernel.TCComponentProcessType; +import com.teamcenter.rac.kernel.TCComponentTaskTemplate; +import com.teamcenter.rac.kernel.TCComponentTaskTemplateType; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; +import com.teamcenter.rac.util.PropertyLayout; + +import cn.net.connor.ml.plm.KUtil; + +@SuppressWarnings("serial") +public class UpdateDocStateDialog extends AbstractAIFDialog { + + private static final String PREF_STATE = "Meling_Doc_State"; + private AbstractAIFApplication app; + private TCComponent target; + @SuppressWarnings("rawtypes") + private JComboBox box; + private JButton okButton; + private JButton cancelButton; + private TCSession session; + private String[] processs; + + public UpdateDocStateDialog(AbstractAIFApplication app) { + super(false); + this.app = app; + this.session = (TCSession) app.getSession(); + } + + @Override + public void run() { + try { + if (!init()) { + return; + } + } catch (Exception e) { + e.printStackTrace(); + KUtil.error(this, "ʼʱ쳣\n" + e.getMessage()); + return; + } + initUI(); + addListeners(); + showDialog(); + } + + private void addListeners() { + this.okButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String state = box.getSelectedItem().toString(); + updateState(state); + } + }); + this.cancelButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + disposeDialog(); + } + }); + } + + protected void updateState(String state) { + try { + TCComponentProcessType processType = (TCComponentProcessType) session.getTypeComponent("Job"); + TCComponentTaskTemplateType taskTemplateType = (TCComponentTaskTemplateType) session.getTypeComponent("EPMTaskTemplate"); + TCComponentTaskTemplate taskTemplate = taskTemplateType.find(state, TCComponentTaskTemplate.PROCESS_TEMPLATE_TYPE); + if (taskTemplate == null) { + KUtil.info(this, "δҵģ壡"); + return; + } + // һ ơģ塢Ŀ󡢸 + String name = target.getProperty("object_string"); + processType.create(state + "" + name, "", taskTemplate, new TCComponent[] { target }, new int[] { 1 }); + KUtil.info(this, "" + name + "[" + state + "]ɹ"); + disposeDialog(); + } catch (TCException e) { + e.printStackTrace(); + KUtil.error(this, "̷쳣\n" + e.getMessage()); + } + } + + private void initUI() { + this.setTitle("ѡ"); + this.setMinimumSize(new Dimension(300, 150)); + this.add(BorderLayout.CENTER, initPanel()); + } + + private Component initPanel() { + JPanel panel = new JPanel(new PropertyLayout(10, 5)); + panel.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.black), "״̬")); + panel.add("1.1.left.top", new JLabel("״̬")); + box = new JComboBox<>(processs); + box.setPreferredSize(new Dimension(100, 25)); + panel.add("1.2.left.top", box); + okButton = new JButton("ȷ"); + cancelButton = new JButton("ȡ"); + panel.add("2.1.left.top", okButton); + panel.add("2.2.left.top", cancelButton); + return panel; + } + + private boolean init() throws Exception { + try { + TCComponentICO ico = (TCComponentICO) app.getTargetComponent(); + target = ico.getClassifiedObject(); + if (target == null || !target.getType().equals("ML8_PatentDocRevision")) { + KUtil.info(this, "ڷѡרĵ汾"); + return false; + } + } catch (Exception e) { + KUtil.info(this, "ڷѡרĵ汾"); + e.printStackTrace(); + return false; + } + String patentType = target.getProperty("ml8_PatentType"); + String[] docStates = KUtil.getPrefVals(session, PREF_STATE); + if (docStates == null || docStates.length < 1) { + KUtil.info(this, "ѡ[" + PREF_STATE + "]δãϵԱ"); + return false; + } + for (String docState : docStates) { + String[] states = docState.split("="); + if (states.length != 2) { + KUtil.info(this, "ѡ[" + PREF_STATE + "]ϵԱ"); + return false; + } + if (states[0].equals(patentType)) { + processs = states[1].split(","); + if (processs == null || processs.length < 1) { + KUtil.info(this, "ѡ[" + PREF_STATE + "]ϵԱ"); + return false; + } + break; + } + } + if (processs == null) { + KUtil.info(this, "ѡ[" + PREF_STATE + "]û[ml8_PatentType]ϵԱ"); + return false; + } + return true; + } +} diff --git a/src/cn/net/connor/ml/plm/updateUser/ShowSearchDialog.java b/src/cn/net/connor/ml/plm/updateUser/ShowSearchDialog.java new file mode 100644 index 0000000..05ead50 --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateUser/ShowSearchDialog.java @@ -0,0 +1,234 @@ +package cn.net.connor.ml.plm.updateUser; + +import java.util.List; + +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.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.Dialog; +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 com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.util.MessageBox; + +public class ShowSearchDialog extends Dialog { + protected Shell shell; + private Object result; + private Table table; + private Text name; + private Button query; + private Button ok; + private Button cancel; + private TableItem item; + private CheckboxTableViewer checkboxTableViewer; + + public ShowSearchDialog(Shell parent, int style) { + super(parent, style); + } + + public Object open() { + createContents(); + addListeners(); + shell.open(); + shell.layout(); + Display display = getParent().getDisplay(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) { + display.sleep(); + } + } + return result; + } + + private void addListeners() { + table.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent arg0) { + int index = table.getSelectionIndex(); + TableItem[] items = table.getItems(); + for (int i = 0; i < items.length; i++) { + if (index == i) { + items[i].setChecked(true); + } else { + items[i].setChecked(false); + } + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + + } + }); + query.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + String nameStr = name.getText().trim(); +// String deptStr = dept.getText().trim(); + if (nameStr.equals("")) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "δѯ", "", MessageBox.INFORMATION); + return; + } + String json = "{\"infotype\":\"ԱϢ\",\"infocode\":\"" + nameStr + "\",\"infoname\":\"ȡ\"}"; + String url = "http://mlapp.meiling.com/mlwebapi/plm/getinfo"; + String result = sendPost2(url, json); + if (result != null) { + System.out.println(result); + addTable(result); + } else { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯΪգ", "", MessageBox.INFORMATION); + } + + } + }); + ok.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (table.getSelectionCount() != 1) { + System.out.println("ѡݣ"); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѡݣ", "", MessageBox.INFORMATION); + return; + } + TableItem tableItem = table.getSelection()[0]; + String str = tableItem.getText(1) + "(" + tableItem.getText(0) + ")"; + System.out.println(str); + result = str; + shell.dispose(); + } + }); + cancel.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { +// if (name.getText().trim().equals("")) { + shell.dispose(); +// } + } + }); + } + + protected void addTable(String result) { + table.setItemCount(0); + JSONObject json = JSON.parseObject(result); + JSONArray list = json.getJSONArray("list"); + List userList = JSON.parseObject(list.toJSONString(), new TypeReference>() { + }); + if (userList != null && userList.size() > 0) { + for (UserList user : userList) { + item = new TableItem(table, SWT.NONE); + item.setText(new String[] { user.getCode(), user.getName(), user.getDep() }); + } + } + // ²ֱ + for (int i = 0; i < 3; i++) { + table.getColumn(i).pack(); + } + } + + public static String sendPost2(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; + } + + private void createContents() { + shell = new Shell(getParent(), getStyle()); + shell.setSize(550, 250); + shell.setText("ѯ"); + shell.setBounds(100, 100, 550, 250); + 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); + + 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); + } +// item = new TableItem(table, SWT.NONE); +// item.setText(new String[] { "111", "ly1", "222" }); +// item = new TableItem(table, SWT.NONE); +// item.setText(new String[] { "aaaa", "ly2", "sssss" }); + // ²ֱ + for (int i = 0; i < tableHeader.length; i++) { + table.getColumn(i).pack(); + } + } +} diff --git a/src/cn/net/connor/ml/plm/updateUser/UpdateUserHandler.java b/src/cn/net/connor/ml/plm/updateUser/UpdateUserHandler.java new file mode 100644 index 0000000..2895a94 --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateUser/UpdateUserHandler.java @@ -0,0 +1,80 @@ +package cn.net.connor.ml.plm.updateUser; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.swt.SWT; + +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.aif.AbstractAIFUIApplication; +import com.teamcenter.rac.aifrcp.AIFUtility; +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCProperty; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.KUtil; + +public class UpdateUserHandler extends AbstractHandler { + + private String[] props; + + @Override + public Object execute(ExecutionEvent arg0) throws ExecutionException { + AbstractAIFUIApplication app = AIFUtility.getCurrentApplication(); + TCComponent target = (TCComponent) app.getTargetComponent(); + if (target != null) { + try { + props = null; + String[] types = KUtil.getPrefVals((TCSession) app.getSession(), "Meling_UpdateUser"); + if (types == null || types.length < 1) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡôϵϵͳԱ"); + return null; + } + for (String config : types) { + String[] splits = config.split("="); + if (splits.length != 2) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡôϵϵͳԱ"); + return null; + } + String type = splits[0]; + if (target.getType().equals(type)) { + props = splits[1].split(","); + if (props == null || props.length < 1) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡôϵϵͳԱ"); + return null; + } + for (String prop : props) { + TCProperty tcProperty = target.getTCProperty(prop); + if (tcProperty == null) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ûҵ[" + prop + "]"); + return null; + } + } + } + } + if (props == null || props.length < 1) { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡôϵϵͳԱ"); + return null; + } + + ShowSearchDialog dialog = new ShowSearchDialog(AIFDesktop.getActiveDesktop().getShell(), SWT.SHELL_TRIM); + Object resault = dialog.open(); + if (resault != null) { + System.out.println("resault = " + resault); + for (String prop : props) { + target.setProperty(prop, resault == null ? "" : resault + ""); + } +// target.setProperty("ml8_Proposer", resault == null ? "" : resault + ""); + } + } catch (Exception e) { + KUtil.info(AIFDesktop.getActiveDesktop(), e.toString()); + e.printStackTrace(); + } + } else { + KUtil.info(AIFDesktop.getActiveDesktop(), "ѡж"); + return null; + } + return null; + } +} diff --git a/src/cn/net/connor/ml/plm/updateUser/UserList.java b/src/cn/net/connor/ml/plm/updateUser/UserList.java new file mode 100644 index 0000000..4a12af6 --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateUser/UserList.java @@ -0,0 +1,32 @@ +package cn.net.connor.ml.plm.updateUser; + +public class UserList { + private String code; + private String name; + private String dep; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDep() { + return dep; + } + + public void setDep(String dep) { + this.dep = dep; + } + +} diff --git a/src/cn/net/connor/ml/plm/updateUser/test6.java b/src/cn/net/connor/ml/plm/updateUser/test6.java new file mode 100644 index 0000000..baf282f --- /dev/null +++ b/src/cn/net/connor/ml/plm/updateUser/test6.java @@ -0,0 +1,239 @@ +package cn.net.connor.ml.plm.updateUser; + +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +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.Table; +import org.eclipse.swt.widgets.TableColumn; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.swt.widgets.Text; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; +import com.teamcenter.rac.aif.AIFDesktop; +import com.teamcenter.rac.util.MessageBox; + +import java.util.List; + +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.eclipse.jface.viewers.CheckboxTableViewer; + +public class test6 { + + protected Shell shell; + private Table table; + private Text name; + private Button query; + private Button ok; + private Button cancel; + private TableItem item; + private CheckboxTableViewer checkboxTableViewer; + protected Object result; + + public static void main(String[] args) { + try { + test6 window = new test6(); + window.open(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + 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) { + int index = table.getSelectionIndex(); + TableItem[] items = table.getItems(); + for (int i = 0; i < items.length; i++) { + if (index == i) { + items[i].setChecked(true); + } else { + items[i].setChecked(false); + } + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + + } + }); + query.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + String nameStr = name.getText().trim(); +// String deptStr = dept.getText().trim(); + if (nameStr.equals("")) { + MessageBox.post(AIFDesktop.getActiveDesktop(), "δѯ", "", MessageBox.INFORMATION); + return; + } + String json = "{\"infotype\":\"ԱϢ\",\"infocode\":\"" + nameStr + "\",\"infoname\":\"ȡ\"}"; + String url = "http://mlapp.meiling.com/mlwebapi/plm/getinfo"; + String result = sendPost2(url, json); + if (result != null) { + System.out.println(result); + addTable(result); + } else { + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѯΪգ", "", MessageBox.INFORMATION); + } + + } + }); + ok.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + if (table.getSelectionCount() != 1) { + System.out.println("ѡݣ"); + MessageBox.post(AIFDesktop.getActiveDesktop(), "ѡݣ", "", MessageBox.INFORMATION); + return; + } + TableItem tableItem = table.getSelection()[0]; + String str = tableItem.getText(1) + "(" + tableItem.getText(0) + ")"; + System.out.println(str); + result = str; + shell.dispose(); + } + }); + cancel.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { +// if (name.getText().trim().equals("")) { + shell.dispose(); +// } + } + }); + } + + protected void addTable(String result) { + table.setItemCount(0); + JSONObject json = JSON.parseObject(result); + JSONArray list = json.getJSONArray("list"); + List userList = JSON.parseObject(list.toJSONString(), new TypeReference>() { + }); + if (userList != null && userList.size() > 0) { + for (UserList user : userList) { + item = new TableItem(table, SWT.NONE); + item.setText(new String[] { user.getCode(), user.getName(), user.getDep() }); + } + } + // ²ֱ + for (int i = 0; i < 3; i++) { + table.getColumn(i).pack(); + } + } + + public static String sendPost2(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; + } + + private void createContents() { + shell = new Shell(); + shell.setSize(550, 250); + 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); + + 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); + } +// item = new TableItem(table, SWT.NONE); +// item.setText(new String[] { "111", "ly1", "222" }); +// item = new TableItem(table, SWT.NONE); +// item.setText(new String[] { "aaaa", "ly2", "sssss" }); + // ²ֱ + for (int i = 0; i < tableHeader.length; i++) { + table.getColumn(i).pack(); + } + } +} diff --git a/src/cn/net/connor/ml/plm/util/BigDecimalUtils.java b/src/cn/net/connor/ml/plm/util/BigDecimalUtils.java new file mode 100644 index 0000000..4198d7a --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/BigDecimalUtils.java @@ -0,0 +1,143 @@ +package cn.net.connor.ml.plm.util; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.text.DecimalFormat; +import java.text.NumberFormat; + +@SuppressWarnings("deprecation") +public class BigDecimalUtils { + + public static final int MONEY_POINT = 2; // ұλС + + /** + * ʽ + * + * @param v + * @param point + * Сλ + * @return double + */ + 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 + */ + 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(); + } + + /** + * ȽϴС С0v1 < v2 0v1 > v2 0v1 = 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/src/cn/net/connor/ml/plm/util/FileUtil.java b/src/cn/net/connor/ml/plm/util/FileUtil.java new file mode 100644 index 0000000..2074f47 --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/FileUtil.java @@ -0,0 +1,235 @@ +package cn.net.connor.ml.plm.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +/** + * @author chenhuan001 + * + */ +public class FileUtil { + String newline = "\r\n";// windows + + /** + * дļ,ĩβԶ\r\n + * utf-8 ׷ + * @param path + * @param str + */ + public static void writeLog(String path, String str) { + try { + File file = new File(path); + if (!file.exists()) { + String temp = path.substring(0, path.lastIndexOf("\\")); + File file1 = new File(temp); + if (!file1.exists()) { + file1.mkdirs(); + } + file.createNewFile(); + } + FileOutputStream out = new FileOutputStream(file); // trueʾ׷ + StringBuffer sb = new StringBuffer(); + sb.append(str + "\r\n"); + out.write(sb.toString().getBytes("utf-8"));// + out.close(); + } catch (IOException ex) { + System.out.println(ex.getStackTrace()); + } + } + + /** + * дļ,ĩβԶ\r\n + * @param path + * @param str + */ + public static void writeLog(String path, String str, boolean is_append, String encode) { + try { + File file = new File(path); + if (!file.exists()) { + String temp = path.substring(0, path.lastIndexOf("\\")); + File file1 = new File(temp); + if (!file1.exists()) { + file1.mkdirs(); + } + file.createNewFile(); + } + FileOutputStream out = new FileOutputStream(file, is_append); // trueʾ׷ + StringBuffer sb = new StringBuffer(); + sb.append(str + "\r\n"); + out.write(sb.toString().getBytes(encode));// + out.close(); + } catch (IOException ex) { + System.out.println(ex.getStackTrace()); + } + } + + /** + * ļstringŻأ\r\n + * @param path + * @return + */ + @SuppressWarnings("resource") + public static String readLogByString(String path) { + StringBuffer sb = new StringBuffer(); + String tempstr = null; + try { + File file = new File(path); + if (!file.exists()) + throw new FileNotFoundException(); + FileInputStream fis = new FileInputStream(file); + BufferedReader br = new BufferedReader(new InputStreamReader(fis, "utf-8")); + while ((tempstr = br.readLine()) != null) { + sb.append(tempstr + "\r\n"); + } + } catch (IOException ex) { + System.out.println(ex.getStackTrace()); + } + return sb.toString(); + } + + /** + * + * ļstringŻأ\r\n + * @param path + * @return + */ + @SuppressWarnings("resource") + public static String readLogByStringAndEncode(String path, String encode) { + StringBuffer sb = new StringBuffer(); + String tempstr = null; + try { + File file = new File(path); + if (!file.exists()) + throw new FileNotFoundException(); + FileInputStream fis = new FileInputStream(file); + BufferedReader br = new BufferedReader(new InputStreamReader(fis, encode)); + while ((tempstr = br.readLine()) != null) { + sb.append(tempstr + "\r\n"); + } + } catch (IOException ex) { + System.out.println(ex.getStackTrace()); + } + return sb.toString(); + } + + /** + * жȡļlistʽ + * @param path + * @return + */ + @SuppressWarnings("resource") + public static List readLogByList(String path) { + List lines = new ArrayList(); + String tempstr = null; + try { + File file = new File(path); + if (!file.exists()) { + throw new FileNotFoundException(); + } + FileInputStream fis = new FileInputStream(file); + BufferedReader br = new BufferedReader(new InputStreamReader(fis, "utf-8")); + while ((tempstr = br.readLine()) != null) { + lines.add(tempstr.toString()); + } + } catch (IOException ex) { + System.out.println(ex.getStackTrace()); + } + return lines; + } + + /** + * Ŀ¼ + * @param dir_path + */ + public static void mkDir(String dir_path) { + File myFolderPath = new File(dir_path); + try { + if (!myFolderPath.exists()) { + myFolderPath.mkdir(); + } + } catch (Exception e) { + System.out.println("½Ŀ¼"); + e.printStackTrace(); + } + } + + /** + * ļ + * @param file_path + */ + public static void createNewFile(String file_path) { + File myFilePath = new File(file_path); + try { + if (!myFilePath.exists()) { + myFilePath.createNewFile(); + } + } catch (Exception e) { + System.out.println("½ļ"); + e.printStackTrace(); + } + } + + /** + * ݹɾļĿ¼ + * @param file_path + */ + public static void deleteEveryThing(String file_path) { + try { + File file = new File(file_path); + if (!file.exists()) { + return; + } + if (file.isFile()) { + file.delete(); + } else { + File[] files = file.listFiles(); + for (int i = 0; i < files.length; i++) { + String root = files[i].getAbsolutePath();// õļļеľ· + deleteEveryThing(root); + } + file.delete(); + } + } catch (Exception e) { + System.out.println("ɾļʧ"); + } + } + + /** + * õһļļ + */ + public static List getAllFileNameInFold(String fold_path) { + List file_paths = new ArrayList(); + + LinkedList folderList = new LinkedList(); + folderList.add(fold_path); + while (folderList.size() > 0) { + File file = new File(folderList.peekLast()); + folderList.removeLast(); + File[] files = file.listFiles(); + ArrayList fileList = new ArrayList(); + for (int i = 0; i < files.length; i++) { + if (files[i].isDirectory()) { + folderList.add(files[i].getPath()); + } else { + fileList.add(files[i]); + } + } + for (File f : fileList) { + file_paths.add(f.getAbsoluteFile().getPath()); + } + } + return file_paths; + } + +// public static void main(String[] args) { +// } + +} \ No newline at end of file diff --git a/src/cn/net/connor/ml/plm/util/JAutoCompleteComboBox.java b/src/cn/net/connor/ml/plm/util/JAutoCompleteComboBox.java new file mode 100644 index 0000000..bb145d6 --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/JAutoCompleteComboBox.java @@ -0,0 +1,160 @@ +package cn.net.connor.ml.plm.util; + +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.List; +import java.util.Vector; + +import javax.swing.ComboBoxModel; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JTextField; + +@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/src/cn/net/connor/ml/plm/util/JProTextField.java b/src/cn/net/connor/ml/plm/util/JProTextField.java new file mode 100644 index 0000000..48d541c --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/JProTextField.java @@ -0,0 +1,16 @@ +package cn.net.connor.ml.plm.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/src/cn/net/connor/ml/plm/util/JaxbUtil.java b/src/cn/net/connor/ml/plm/util/JaxbUtil.java new file mode 100644 index 0000000..099f416 --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/JaxbUtil.java @@ -0,0 +1,68 @@ +package cn.net.connor.ml.plm.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 = XMLConstants.W3C_XML_SCHEMA_NS_URI; + 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/src/cn/net/connor/ml/plm/util/MultiComboBox.java b/src/cn/net/connor/ml/plm/util/MultiComboBox.java new file mode 100644 index 0000000..5936caa --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/MultiComboBox.java @@ -0,0 +1,198 @@ +package cn.net.connor.ml.plm.util; + +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.LayoutManager; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.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/src/cn/net/connor/ml/plm/util/MultiPopup.java b/src/cn/net/connor/ml/plm/util/MultiPopup.java new file mode 100644 index 0000000..d3f8743 --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/MultiPopup.java @@ -0,0 +1,190 @@ +package cn.net.connor.ml.plm.util; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.List; + + + +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; + +public class MultiPopup extends JPopupMenu { + + private List listeners = new ArrayList(); + + private Object[] values; + + private Object[] defaultValues; + + private List checkBoxList = new ArrayList(); + + private JButton commitButton ; + + private JButton cancelButton; + + public static final String COMMIT_EVENT = "commit"; + + public static final String CANCEL_EVENT = "cancel"; + + public MultiPopup(Object[] value , Object[] defaultValue) { + super(); + values = value; + defaultValues = defaultValue; + initComponent(); + } + + public void addActionListener(ActionListener listener) { + if (!listeners.contains(listener)) + listeners.add(listener); + } + + public void removeActionListener(ActionListener listener) { + if (listeners.contains(listener)) + listeners.remove(listener); + } + + private void initComponent() { + + JPanel checkboxPane = new JPanel(); + + JPanel buttonPane = new JPanel(); + + this.setLayout(new BorderLayout()); + + + for(Object v : values){ + JCheckBox temp = new JCheckBox(v.toString() , selected(v)); + checkBoxList.add(temp); + } + + if(checkBoxList.get(0).getText().equals("Selected All")) + checkBoxList.get(0).addItemListener(new ItemListener() + { + public void itemStateChanged(ItemEvent e) + { + System.out.println("ѡ״̬ "+checkBoxList.get(0).isSelected()); + if(checkBoxList.get(0).isSelected())//Select All ѡ + { + //Ƿѡ鹵ûоѡ + for(int i=1; i< checkBoxList.size();i++) + { + if(!checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(true); + } + } + else + { + for(int i=1; i< checkBoxList.size();i++) + { + if(checkBoxList.get(i).isSelected()) + checkBoxList.get(i).setSelected(false); + } + } + } + }); + + + + checkboxPane.setLayout(new GridLayout(checkBoxList.size() , 1 ,3, 3)); + for(JCheckBox box : checkBoxList){ + checkboxPane.add(box); + } + + commitButton = new JButton("ok"); + + commitButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + commit(); + } + + }); + + cancelButton = new JButton("cancel"); + + cancelButton.addActionListener(new ActionListener(){ + + public void actionPerformed(ActionEvent e) { + cancel(); + } + + }); + + buttonPane.add(commitButton); + + buttonPane.add(cancelButton); + + this.add(checkboxPane , BorderLayout.CENTER); + + this.add(buttonPane , BorderLayout.SOUTH); + + + } + + private boolean selected(Object v) { + for(Object dv : defaultValues){ + if( dv .equals(v) ){ + return true; + } + } + return false; + } + + protected void fireActionPerformed(ActionEvent e) { + for (ActionListener l : listeners) { + l.actionPerformed(e); + } + } + + public Object[] getSelectedValues(){ + List selectedValues = new ArrayList(); + + if(checkBoxList.get(0).getText().equals("Selected All")) + { + if(checkBoxList.get(0).isSelected()) + { + for(int i = 1 ; i < checkBoxList.size() ; i++) + { + selectedValues.add(values[i]); + } + } + else + { + for(int i = 1 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + } + }else + for(int i = 0 ; i < checkBoxList.size() ; i++){ + + if(checkBoxList.get(i).isSelected()) + selectedValues.add(values[i]); + } + + + return selectedValues.toArray(new Object[selectedValues.size()]); + } + + public void setDefaultValue(Object[] defaultValue) { + defaultValues = defaultValue; + + } + + public void commit(){ + fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); + } + + public void cancel(){ + fireActionPerformed(new ActionEvent(this, 0, CANCEL_EVENT)); + } + +} diff --git a/src/cn/net/connor/ml/plm/util/ProgressBar.java b/src/cn/net/connor/ml/plm/util/ProgressBar.java new file mode 100644 index 0000000..cc57850 --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/ProgressBar.java @@ -0,0 +1,130 @@ +package cn.net.connor.ml.plm.util; + +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/src/cn/net/connor/ml/plm/util/TCGroupDialogTree.java b/src/cn/net/connor/ml/plm/util/TCGroupDialogTree.java new file mode 100644 index 0000000..a9985ba --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/TCGroupDialogTree.java @@ -0,0 +1,65 @@ +package cn.net.connor.ml.plm.util; + +import javax.swing.ImageIcon; +import javax.swing.JTree; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; + +import com.teamcenter.rac.kernel.TCComponent; +import com.teamcenter.rac.kernel.TCComponentGroup; +import com.teamcenter.rac.kernel.TCComponentGroupType; +import com.teamcenter.rac.kernel.TCComponentRole; +import com.teamcenter.rac.kernel.TCException; +import com.teamcenter.rac.kernel.TCSession; + +import cn.net.connor.ml.plm.beans.TMomUserBean; + +public class TCGroupDialogTree { + + public void getUsers(DefaultMutableTreeNode node, TCComponent comp, TCComponent parent) { + try { + if (comp instanceof TCComponentGroup) { + TCComponent[] comps = ((TCComponentGroup) comp).getRolesAndGroups(); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + node.add(node1); + getUsers(node1, comps[i], comp); + } + } else if (comp instanceof TCComponentRole) { + TCComponent[] comps = ((TCComponentRole) comp).getUsers((TCComponentGroup) parent); + for (int i = 0; i < comps.length; i++) { + TMomUserBean bean = new TMomUserBean(comps[i], comp); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + node.add(node1); + } + } + } catch (TCException e) { + e.printStackTrace(); + } + } + + public JTree getTcOrgTree(TCSession session, String goupFullName) { + JTree tree = new JTree(); + + try { + TCComponentGroupType type = ((TCComponentGroupType) session.getTypeComponent("Group")); + TCComponentGroup group = type.find("NBTM"); + TMomUserBean bean = new TMomUserBean(group, null); + DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(bean); + getUsers(node1, group, null); + tree = new JTree(node1); + tree.setRowHeight(20); + DefaultTreeCellRenderer cellRenderer = (DefaultTreeCellRenderer) tree.getCellRenderer(); + cellRenderer.setLeafIcon(new ImageIcon("icons\\person_16.png")); + cellRenderer.setOpenIcon(new ImageIcon("icons\\role_16.png")); + cellRenderer.setClosedIcon(new ImageIcon("icons\\group_16.png")); + + } catch (TCException e) { + e.printStackTrace(); + } + + return tree; + } + +} diff --git a/src/cn/net/connor/ml/plm/util/TableUtil3.java b/src/cn/net/connor/ml/plm/util/TableUtil3.java new file mode 100644 index 0000000..ef31c23 --- /dev/null +++ b/src/cn/net/connor/ml/plm/util/TableUtil3.java @@ -0,0 +1,59 @@ +package cn.net.connor.ml.plm.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 = 100; + TableColumnModel columns = table.getColumnModel(); + TableColumn column_id_data = columns.getColumn(column); + + column_id_data.setMaxWidth(width + 200); + column_id_data.setPreferredWidth(width); +// column_id_data.setMinWidth(width); + + TableColumn column_id_header = table.getTableHeader().getColumnModel().getColumn(column); + column_id_header.setMaxWidth(width + 200); + column_id_header.setPreferredWidth(width); +// column_id_header.setMinWidth(width); + } +} \ No newline at end of file diff --git a/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties b/src/com/teamcenter/rac/stylesheet/stylesheet_user.properties new file mode 100644 index 0000000..bfc2b8e --- /dev/null +++ b/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=cn.net.connor.ml.plm.AssignProductName.AssignPropertyTextField \ No newline at end of file diff --git a/src/plm.properties b/src/plm.properties new file mode 100644 index 0000000..c999966 --- /dev/null +++ b/src/plm.properties @@ -0,0 +1,10 @@ +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 +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 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 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, T5.puid AS rev_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, T5.puid AS rev_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 +EXCEL5.SQL= WITH TEMP AS(SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 and (not exists(select * from PRELEASE_STATUS_LIST where puid =T5.puid) or exists (select * from PRELEASE_STATUS_LIST where puid=T5.puid and pvalu_0 in(select puid from PRELEASESTATUS where pname not like 'ML8_Replaced' )))UNION ALL SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 and (not exists(select * from PRELEASE_STATUS_LIST where puid =T5.puid) or exists (select * from PRELEASE_STATUS_LIST where puid=T5.puid and pvalu_0 in(select puid from PRELEASESTATUS where pname not like 'ML8_Replaced' )))) SELECT DISTINCT * FROM TEMP +EXCEL6.SQL=WITH TEMP AS( SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 INNER JOIN PRELEASE_STATUS_LIST T6 ON T4.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid AND T7.pname not like 'ML8_Replaced' UNION ALL SELECT T5.ritems_tagu AS parent_uid, T5.puid AS rev_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 INNER JOIN PRELEASE_STATUS_LIST T6 ON T4.puid = T6.puid INNER JOIN PRELEASESTATUS T7 ON T6.pvalu_0 = T7.puid AND T7.pname not like 'ML8_Replaced') SELECT DISTINCT * FROM TEMP +#ͼԭɿӦĸ߶ +#ͼx/y (HEIGHT=WIDTH*y/x) +IMAGE.WIDTH=1 +IMAGE.HEIGHT=1 \ No newline at end of file diff --git a/src/sql.properties b/src/sql.properties new file mode 100644 index 0000000..8c21d90 --- /dev/null +++ b/src/sql.properties @@ -0,0 +1,2 @@ +ML_WEBSERVICE_LOGINSERTSQL=INSERT INTO ML_WEBSERVICE_LOG 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/src/sqlconn.properties b/src/sqlconn.properties new file mode 100644 index 0000000..f3204cf --- /dev/null +++ b/src/sqlconn.properties @@ -0,0 +1,4 @@ +DBDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver +Connection=jdbc:sqlserver://10.18.1.106:1433; DatabaseName=TC +User=infodba +Password=Plm_8023